summaryrefslogtreecommitdiffstats
path: root/web/gui/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-08 07:31:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-08 07:31:03 +0000
commit50485bedfd9818165aa1d039d0abe95a559134b7 (patch)
tree79c7b08f67edcfb0c936e7a22931653b91189b9f /web/gui/src
parentReleasing debian version 1.11.1+dfsg-7. (diff)
downloadnetdata-50485bedfd9818165aa1d039d0abe95a559134b7.tar.xz
netdata-50485bedfd9818165aa1d039d0abe95a559134b7.zip
Merging upstream version 1.12.0.
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/charting/dygraph.js4
-rw-r--r--web/gui/src/dashboard.js/common.js4
-rw-r--r--web/gui/src/dashboard.js/main.js3
-rw-r--r--web/gui/src/dashboard.js/options.js4
-rw-r--r--web/gui/src/dashboard.js/prologue.js.inc3
-rw-r--r--web/gui/src/dashboard.js/registry.js47
-rw-r--r--web/gui/src/dashboard.js/themes.js2
-rw-r--r--web/gui/src/dashboard.js/units-conversion.js45
-rw-r--r--web/gui/src/dashboard.js/utils.js2
-rw-r--r--web/gui/src/dashboard.js/xss.js2
13 files changed, 341 insertions, 18 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 00000000..6688bbcc
--- /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 00000000..30789e4e
--- /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 00000000..2d89a22a
--- /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/charting/dygraph.js b/web/gui/src/dashboard.js/charting/dygraph.js
index 62cb466f..a60af18b 100644
--- a/web/gui/src/dashboard.js/charting/dygraph.js
+++ b/web/gui/src/dashboard.js/charting/dygraph.js
@@ -1,5 +1,9 @@
// dygraph
+// Codacy declarations
+/* global smoothPlotter */
+/* global Dygraph */
+
NETDATA.dygraph = {
smooth: false
};
diff --git a/web/gui/src/dashboard.js/common.js b/web/gui/src/dashboard.js/common.js
index aa9d4bac..4a97babe 100644
--- a/web/gui/src/dashboard.js/common.js
+++ b/web/gui/src/dashboard.js/common.js
@@ -56,7 +56,7 @@ NETDATA.commonMin = {
// for (let i in t) {
// if (t.hasOwnProperty(i) && t[i] < m) m = t[i];
// }
- for (const ti of Object.values(t)) {
+ for (var ti of Object.values(t)) {
if (ti < m) {
m = ti;
}
@@ -120,7 +120,7 @@ NETDATA.commonMax = {
// for (let i in t) {
// if (t.hasOwnProperty(i) && t[i] > m) m = t[i];
// }
- for (const ti of Object.values(t)) {
+ for (var ti of Object.values(t)) {
if (ti > m) {
m = ti;
}
diff --git a/web/gui/src/dashboard.js/main.js b/web/gui/src/dashboard.js/main.js
index 3d8cc3b7..1d050d61 100644
--- a/web/gui/src/dashboard.js/main.js
+++ b/web/gui/src/dashboard.js/main.js
@@ -1,6 +1,9 @@
// *** src/dashboard.js/main.js
+// Codacy declarations
+/* global clipboard */
+
if (NETDATA.options.debug.main_loop) {
console.log('welcome to NETDATA');
}
diff --git a/web/gui/src/dashboard.js/options.js b/web/gui/src/dashboard.js/options.js
index 653740a8..68132e7b 100644
--- a/web/gui/src/dashboard.js/options.js
+++ b/web/gui/src/dashboard.js/options.js
@@ -18,7 +18,7 @@ if (typeof netdataIcons === 'object') {
// if (NETDATA.icons.hasOwnProperty(icon) && typeof(netdataIcons[icon]) === 'string')
// NETDATA.icons[icon] = netdataIcons[icon];
// }
- for (const icon of Object.keys(NETDATA.icons)) {
+ for (var icon of Object.keys(NETDATA.icons)) {
if (typeof(netdataIcons[icon]) === 'string') {
NETDATA.icons[icon] = netdataIcons[icon]
}
@@ -38,7 +38,7 @@ if (typeof netdataShowAlarms === 'undefined') {
}
if (typeof netdataRegistryAfterMs !== 'number' || netdataRegistryAfterMs < 0) {
- netdataRegistryAfterMs = 1500;
+ netdataRegistryAfterMs = 0; // 1500;
}
if (typeof netdataRegistry === 'undefined') {
diff --git a/web/gui/src/dashboard.js/prologue.js.inc b/web/gui/src/dashboard.js/prologue.js.inc
index ae9201bc..afa1f0e0 100644
--- a/web/gui/src/dashboard.js/prologue.js.inc
+++ b/web/gui/src/dashboard.js/prologue.js.inc
@@ -77,7 +77,8 @@
// ----------------------------------------------------------------------------
// global namespace
-const NETDATA = window.NETDATA || {};
+// Should stay var!
+var NETDATA = window.NETDATA || {};
(function(window, document, $, undefined) {
diff --git a/web/gui/src/dashboard.js/registry.js b/web/gui/src/dashboard.js/registry.js
index b9d91291..77a822b7 100644
--- a/web/gui/src/dashboard.js/registry.js
+++ b/web/gui/src/dashboard.js/registry.js
@@ -3,6 +3,8 @@
NETDATA.registry = {
server: null, // the netdata registry server
+ isCloudEnabled: false,// is netdata.cloud functionality enabled?
+ cloudBaseURL: null, // the netdata cloud base url
person_guid: null, // the unique ID of this browser / user
machine_guid: null, // the unique ID the netdata server that served dashboard.js
hostname: 'unknown', // the hostname of the netdata server that served dashboard.js
@@ -10,8 +12,17 @@ NETDATA.registry = {
machines_array: null, // the user's other URLs in an array
person_urls: null,
+ MASKED_DATA: "***",
+
+ isUsingGlobalRegistry: function() {
+ return NETDATA.registry.server == "https://registry.my-netdata.io";
+ },
+
+ isRegistryEnabled: function() {
+ return !(NETDATA.registry.isUsingGlobalRegistry() || isSignedIn())
+ },
+
parsePersonUrls: function (person_urls) {
- // console.log(person_urls);
NETDATA.registry.person_urls = person_urls;
if (person_urls) {
@@ -64,13 +75,21 @@ NETDATA.registry = {
NETDATA.registry.hello(NETDATA.serverDefault, function (data) {
if (data) {
NETDATA.registry.server = data.registry;
+ if (data.cloud_base_url != "") {
+ NETDATA.registry.isCloudEnabled = true;
+ NETDATA.registry.cloudBaseURL = data.cloud_base_url;
+ } else {
+ NETDATA.registry.isCloudEnabled = false;
+ NETDATA.registry.cloudBaseURL = "";
+ }
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});
+ }
NETDATA.registry.access(2, function (person_urls) {
NETDATA.registry.parsePersonUrls(person_urls);
-
- });
+ });
}
});
},
@@ -113,13 +132,25 @@ NETDATA.registry = {
},
access: function (max_redirects, callback) {
+ let name = NETDATA.registry.MASKED_DATA;
+ let url = NETDATA.registry.MASKED_DATA;
+
+ if (!NETDATA.registry.isUsingGlobalRegistry()) {
+ // If the user is using a private registry keep sending identifiable
+ // data.
+ name = NETDATA.registry.hostname;
+ url = NETDATA.serverDefault;
+ }
+
+ console.log("ACCESS", name, url);
+
// send ACCESS to a netdata registry:
// 1. it lets it know we are accessing a netdata server (its machine GUID and its URL)
// 2. it responds with a list of netdata servers we know
// the registry identifies us using a cookie it sets the first time we access it
// the registry may respond with a redirect URL to send us to another registry
$.ajax({
- url: NETDATA.registry.server + '/api/v1/registry?action=access&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault), // + '&visible_url=' + encodeURIComponent(document.location),
+ url: NETDATA.registry.server + '/api/v1/registry?action=access&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(name) + '&url=' + encodeURIComponent(url), // + '&visible_url=' + encodeURIComponent(document.location),
async: true,
cache: false,
headers: {
@@ -151,14 +182,14 @@ NETDATA.registry = {
return callback(null);
}
}
- }
- else {
+ } else {
if (typeof data.person_guid === 'string') {
NETDATA.registry.person_guid = data.person_guid;
}
if (typeof callback === 'function') {
- return callback(data.urls);
+ const urls = data.urls.filter((u) => u[1] !== NETDATA.registry.MASKED_DATA);
+ return callback(urls);
}
}
})
diff --git a/web/gui/src/dashboard.js/themes.js b/web/gui/src/dashboard.js/themes.js
index a83a1dd3..aafe1576 100644
--- a/web/gui/src/dashboard.js/themes.js
+++ b/web/gui/src/dashboard.js/themes.js
@@ -1,3 +1,5 @@
+// Codacy declarations
+/* global netdataTheme */
NETDATA.themes = {
white: {
diff --git a/web/gui/src/dashboard.js/units-conversion.js b/web/gui/src/dashboard.js/units-conversion.js
index e4eba57f..26b84034 100644
--- a/web/gui/src/dashboard.js/units-conversion.js
+++ b/web/gui/src/dashboard.js/units-conversion.js
@@ -39,6 +39,21 @@ NETDATA.unitsConversion = {
'GB/s': 1024 * 1024,
'TB/s': 1024 * 1024 * 1024
},
+ 'KiB/s': {
+ 'B/s': 1 / 1024,
+ 'KiB/s': 1,
+ 'MiB/s': 1024,
+ 'GiB/s': 1024 * 1024,
+ 'TiB/s': 1024 * 1024 * 1024
+ },
+ 'B': {
+ 'B': 1,
+ 'KiB': 1024,
+ 'MiB': 1024 * 1024,
+ 'GiB': 1024 * 1024 * 1024,
+ 'TiB': 1024 * 1024 * 1024 * 1024,
+ 'PiB': 1024 * 1024 * 1024 * 1024 * 1024
+ },
'KB': {
'B': 1 / 1024,
'KB': 1,
@@ -46,6 +61,13 @@ NETDATA.unitsConversion = {
'GB': 1024 * 1024,
'TB': 1024 * 1024 * 1024
},
+ 'KiB': {
+ 'B': 1 / 1024,
+ 'KiB': 1,
+ 'MiB': 1024,
+ 'GiB': 1024 * 1024,
+ 'TiB': 1024 * 1024 * 1024
+ },
'MB': {
'B': 1 / (1024 * 1024),
'KB': 1 / 1024,
@@ -54,6 +76,14 @@ NETDATA.unitsConversion = {
'TB': 1024 * 1024,
'PB': 1024 * 1024 * 1024
},
+ 'MiB': {
+ 'B': 1 / (1024 * 1024),
+ 'KiB': 1 / 1024,
+ 'MiB': 1,
+ 'GiB': 1024,
+ 'TiB': 1024 * 1024,
+ 'PiB': 1024 * 1024 * 1024
+ },
'GB': {
'B': 1 / (1024 * 1024 * 1024),
'KB': 1 / (1024 * 1024),
@@ -62,6 +92,15 @@ NETDATA.unitsConversion = {
'TB': 1024,
'PB': 1024 * 1024,
'EB': 1024 * 1024 * 1024
+ },
+ 'GiB': {
+ 'B': 1 / (1024 * 1024 * 1024),
+ 'KiB': 1 / (1024 * 1024),
+ 'MiB': 1 / 1024,
+ 'GiB': 1,
+ 'TiB': 1024,
+ 'PiB': 1024 * 1024,
+ 'EiB': 1024 * 1024 * 1024
}
/*
'milliseconds': {
@@ -261,7 +300,7 @@ NETDATA.unitsConversion = {
// }
// }
const sunit = this.scalableUnits[units];
- for (const x of Object.keys(sunit)) {
+ for (var x of Object.keys(sunit)) {
let m = sunit[x];
if (m <= max && m > tdivider) {
tunits = x;
@@ -297,7 +336,7 @@ NETDATA.unitsConversion = {
// find the max divider of all charts
let common_units = t[uuid];
- for (const x in t) {
+ for (var x in t) {
if (t.hasOwnProperty(x) && t[x].divider > common_units.divider) {
common_units = t[x];
}
@@ -364,7 +403,7 @@ NETDATA.unitsConversion = {
} else if (typeof this.convertibleUnits[units] !== 'undefined') {
// units that can be converted
if (desired_units === 'auto') {
- for (const x in this.convertibleUnits[units]) {
+ for (var x in this.convertibleUnits[units]) {
if (this.convertibleUnits[units].hasOwnProperty(x)) {
if (this.convertibleUnits[units][x].check(max)) {
//console.log('DEBUG: ' + uuid.toString() + ' converting ' + units.toString() + ' to: ' + x.toString());
diff --git a/web/gui/src/dashboard.js/utils.js b/web/gui/src/dashboard.js/utils.js
index 2d658dcc..8014aaf1 100644
--- a/web/gui/src/dashboard.js/utils.js
+++ b/web/gui/src/dashboard.js/utils.js
@@ -75,7 +75,7 @@ NETDATA.seconds4human = function (seconds, options) {
if (typeof options !== 'object') {
options = defaultOptions;
} else {
- for (const x in defaultOptions) {
+ for (var x in defaultOptions) {
if (typeof options[x] !== 'string') {
options[x] = defaultOptions[x];
}
diff --git a/web/gui/src/dashboard.js/xss.js b/web/gui/src/dashboard.js/xss.js
index 3f9cd1ac..fa66f34d 100644
--- a/web/gui/src/dashboard.js/xss.js
+++ b/web/gui/src/dashboard.js/xss.js
@@ -42,7 +42,7 @@ NETDATA.xss = {
} else {
// console.log('checking object "' + name + '"');
- for (const i in obj) {
+ for (var i in obj) {
if (obj.hasOwnProperty(i) === false) {
continue;
}