summaryrefslogtreecommitdiffstats
path: root/web/gui/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-04-17 17:57:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-04-17 17:57:35 +0000
commit3b95e5be69c199a2a195c57aba12d88c242225ac (patch)
tree137b72ffaefe7f34bf21e975ccc9cc9ec0474564 /web/gui/src
parentAdding upstream version 1.13.0. (diff)
downloadnetdata-3b95e5be69c199a2a195c57aba12d88c242225ac.tar.xz
netdata-3b95e5be69c199a2a195c57aba12d88c242225ac.zip
Adding upstream version 1.14.0~rc0.upstream/1.14.0_rc0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/gui/src')
-rw-r--r--web/gui/src/dashboard.js/charting/_c3.js114
-rw-r--r--web/gui/src/dashboard.js/charting/_morris.js81
-rw-r--r--web/gui/src/dashboard.js/charting/_raphael.js48
-rw-r--r--web/gui/src/dashboard.js/registry.js14
4 files changed, 254 insertions, 3 deletions
diff --git a/web/gui/src/dashboard.js/charting/_c3.js b/web/gui/src/dashboard.js/charting/_c3.js
new file mode 100644
index 000000000..6688bbcce
--- /dev/null
+++ b/web/gui/src/dashboard.js/charting/_c3.js
@@ -0,0 +1,114 @@
+
+// DEPRECATED: will be removed!
+
+// c3
+
+NETDATA.c3Initialize = function(callback) {
+ if (typeof netdataNoC3 === 'undefined' || !netdataNoC3) {
+
+ // C3 requires D3
+ if (!NETDATA.chartLibraries.d3.initialized) {
+ if (NETDATA.chartLibraries.d3.enabled) {
+ NETDATA.d3Initialize(function() {
+ NETDATA.c3Initialize(callback);
+ });
+ } else {
+ NETDATA.chartLibraries.c3.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+ } else {
+ NETDATA._loadCSS(NETDATA.c3_css);
+
+ $.ajax({
+ url: NETDATA.c3_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('c3', NETDATA.c3_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.c3.enabled = false;
+ NETDATA.error(100, NETDATA.c3_js);
+ })
+ .always(function() {
+ if (typeof callback === "function")
+ return callback();
+ });
+ }
+ } else {
+ NETDATA.chartLibraries.c3.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+};
+
+NETDATA.c3ChartUpdate = function(state, data) {
+ state.c3_instance.destroy();
+ return NETDATA.c3ChartCreate(state, data);
+
+ //state.c3_instance.load({
+ // rows: data.result,
+ // unload: true
+ //});
+
+ //return true;
+};
+
+NETDATA.c3ChartCreate = function(state, data) {
+
+ state.element_chart.id = 'c3-' + state.uuid;
+ // console.log('id = ' + state.element_chart.id);
+
+ state.c3_instance = c3.generate({
+ bindto: '#' + state.element_chart.id,
+ size: {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ },
+ color: {
+ pattern: state.chartColors()
+ },
+ data: {
+ x: 'time',
+ rows: data.result,
+ type: (state.chart.chart_type === 'line')?'spline':'area-spline'
+ },
+ axis: {
+ x: {
+ type: 'timeseries',
+ tick: {
+ format: function(x) {
+ return NETDATA.dateTime.xAxisTimeString(x);
+ }
+ }
+ }
+ },
+ grid: {
+ x: {
+ show: true
+ },
+ y: {
+ show: true
+ }
+ },
+ point: {
+ show: false
+ },
+ line: {
+ connectNull: false
+ },
+ transition: {
+ duration: 0
+ },
+ interaction: {
+ enabled: true
+ }
+ });
+
+ // console.log(state.c3_instance);
+
+ return true;
+};
diff --git a/web/gui/src/dashboard.js/charting/_morris.js b/web/gui/src/dashboard.js/charting/_morris.js
new file mode 100644
index 000000000..30789e4e2
--- /dev/null
+++ b/web/gui/src/dashboard.js/charting/_morris.js
@@ -0,0 +1,81 @@
+
+// DEPRECATED: will be removed!
+
+// morris
+
+NETDATA.morrisInitialize = function(callback) {
+ if (typeof netdataNoMorris === 'undefined' || !netdataNoMorris) {
+
+ // morris requires raphael
+ if (!NETDATA.chartLibraries.raphael.initialized) {
+ if (NETDATA.chartLibraries.raphael.enabled) {
+ NETDATA.raphaelInitialize(function() {
+ NETDATA.morrisInitialize(callback);
+ });
+ } else {
+ NETDATA.chartLibraries.morris.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+ } else {
+ NETDATA._loadCSS(NETDATA.morris_css);
+
+ $.ajax({
+ url: NETDATA.morris_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('morris', NETDATA.morris_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.morris.enabled = false;
+ NETDATA.error(100, NETDATA.morris_js);
+ })
+ .always(function() {
+ if (typeof callback === "function")
+ return callback();
+ });
+ }
+ } else {
+ NETDATA.chartLibraries.morris.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+};
+
+NETDATA.morrisChartUpdate = function(state, data) {
+ state.morris_instance.setData(data.result.data);
+ return true;
+};
+
+NETDATA.morrisChartCreate = function(state, data) {
+
+ state.morris_options = {
+ element: state.element_chart.id,
+ data: data.result.data,
+ xkey: 'time',
+ ykeys: data.dimension_names,
+ labels: data.dimension_names,
+ lineWidth: 2,
+ pointSize: 3,
+ smooth: true,
+ hideHover: 'auto',
+ parseTime: true,
+ continuousLine: false,
+ behaveLikeLine: false
+ };
+
+ if (state.chart.chart_type === 'line')
+ state.morris_instance = new Morris.Line(state.morris_options);
+
+ else if (state.chart.chart_type === 'area') {
+ state.morris_options.behaveLikeLine = true;
+ state.morris_instance = new Morris.Area(state.morris_options);
+ }
+ else // stacked
+ state.morris_instance = new Morris.Area(state.morris_options);
+
+ return true;
+};
diff --git a/web/gui/src/dashboard.js/charting/_raphael.js b/web/gui/src/dashboard.js/charting/_raphael.js
new file mode 100644
index 000000000..2d89a22a8
--- /dev/null
+++ b/web/gui/src/dashboard.js/charting/_raphael.js
@@ -0,0 +1,48 @@
+
+// DEPRECATED: will be removed!
+
+// raphael
+
+NETDATA.raphaelInitialize = function(callback) {
+ if (typeof netdataStopRaphael === 'undefined' || !netdataStopRaphael) {
+ $.ajax({
+ url: NETDATA.raphael_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('raphael', NETDATA.raphael_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.raphael.enabled = false;
+ NETDATA.error(100, NETDATA.raphael_js);
+ })
+ .always(function() {
+ if (typeof callback === "function")
+ return callback();
+ });
+ } else {
+ NETDATA.chartLibraries.raphael.enabled = false;
+ if (typeof callback === "function")
+ return callback();
+ }
+};
+
+NETDATA.raphaelChartUpdate = function(state, data) {
+ $(state.element_chart).raphael(data.result, {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ });
+
+ return false;
+};
+
+NETDATA.raphaelChartCreate = function(state, data) {
+ $(state.element_chart).raphael(data.result, {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ });
+
+ return false;
+};
diff --git a/web/gui/src/dashboard.js/registry.js b/web/gui/src/dashboard.js/registry.js
index 7894eaa21..090ef52fd 100644
--- a/web/gui/src/dashboard.js/registry.js
+++ b/web/gui/src/dashboard.js/registry.js
@@ -11,7 +11,7 @@ NETDATA.registry = {
machines: null, // the user's other URLs
machines_array: null, // the user's other URLs in an array
person_urls: null,
-
+ anonymous_statistics_checked: false,
MASKED_DATA: "***",
isUsingGlobalRegistry: function() {
@@ -84,8 +84,16 @@ NETDATA.registry = {
}
NETDATA.registry.machine_guid = data.machine_guid;
NETDATA.registry.hostname = data.hostname;
- if (dataLayer) {
- if (data.anonymous_statistics) dataLayer.push({"anonymous_statistics" : "true", "machine_guid" : data.machine_guid});
+ if (!NETDATA.registry.anonymous_statistics_checked) {
+ NETDATA.registry.anonymous_statistics_checked=true;
+ if (data.anonymous_statistics) {
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=false;j.src=
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
+ })(window,document,'script','dataLayer','GTM-N6CBMJD');
+ dataLayer.push({"anonymous_statistics" : "true", "machine_guid" : data.machine_guid});
+ }
}
NETDATA.registry.access(2, function (person_urls) {
NETDATA.registry.parsePersonUrls(person_urls);