diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:19:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-11-07 12:20:17 +0000 |
commit | a64a253794ac64cb40befee54db53bde17dd0d49 (patch) | |
tree | c1024acc5f6e508814b944d99f112259bb28b1be /web/gui/dashboard.js | |
parent | New upstream version 1.10.0+dfsg (diff) | |
download | netdata-a64a253794ac64cb40befee54db53bde17dd0d49.tar.xz netdata-a64a253794ac64cb40befee54db53bde17dd0d49.zip |
New upstream version 1.11.0+dfsgupstream/1.11.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | web/gui/dashboard.js (renamed from web/dashboard.js) | 139 |
1 files changed, 97 insertions, 42 deletions
diff --git a/web/dashboard.js b/web/gui/dashboard.js index 607c9d1ac..16fbf88d0 100644 --- a/web/dashboard.js +++ b/web/gui/dashboard.js @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-3.0-or-later // ---------------------------------------------------------------------------- // You can set the following variables before loading this script: @@ -23,6 +24,10 @@ * (default: false) */ /*global netdataNoBootstrap *//* boolean, disable bootstrap - disables help too * (default: false) */ +/*global netdataNoFontAwesome *//* boolean, disable fontawesome (do not load it) + * (default: false) */ +/*global netdataIcons *//* object, overwrite netdata fontawesome icons + * (default: null) */ /*global netdataDontStart *//* boolean, do not start the thread to process the charts * (default: false) */ /*global netdataErrorCallback *//* function, callback to be called when the dashboard encounters an error @@ -70,6 +75,14 @@ var NETDATA = window.NETDATA || {}; (function(window, document, $, undefined) { + + NETDATA.encodeURIComponent = function(s) { + if(typeof(s) === 'string') + return encodeURIComponent(s); + + return s; + }; + // ------------------------------------------------------------------------ // compatibility fixes @@ -113,7 +126,7 @@ var NETDATA = window.NETDATA || {}; .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') - .replace(/'/g, '#27;'); + .replace(/'/g, '''); }, object: function(name, obj, ignore_regex) { @@ -208,7 +221,7 @@ var NETDATA = window.NETDATA || {}; NETDATA.serverDefault = netdataServer; else { var s = NETDATA._scriptSource(); - if(s) NETDATA.serverDefault = s.replace(/\/dashboard.js(\?.*)*$/g, ""); + if(s) NETDATA.serverDefault = s.replace(/\/dashboard.js(\?.*)?$/g, ""); else { console.log('WARNING: Cannot detect the URL of the netdata server.'); NETDATA.serverDefault = null; @@ -338,6 +351,27 @@ var NETDATA = window.NETDATA || {}; // (blue) (red) (orange) (green) (pink) (brown) (purple) (yellow) (gray) //NETDATA.colors = [ '#5DA5DA', '#F15854', '#FAA43A', '#60BD68', '#F17CB0', '#B2912F', '#B276B2', '#DECF3F', '#4D4D4D' ]; + NETDATA.icons = { + left: '<i class="fas fa-backward"></i>', + reset: '<i class="fas fa-play"></i>', + right: '<i class="fas fa-forward"></i>', + zoomIn: '<i class="fas fa-plus"></i>', + zoomOut: '<i class="fas fa-minus"></i>', + resize: '<i class="fas fa-sort"></i>', + lineChart: '<i class="fas fa-chart-line"></i>', + areaChart: '<i class="fas fa-chart-area"></i>', + noChart: '<i class="fas fa-chart-area"></i>', + loading: '<i class="fas fa-sync-alt"></i>', + noData: '<i class="fas fa-exclamation-triangle"></i>' + }; + + if(typeof netdataIcons === 'object') { + for(var icon in NETDATA.icons) { + if(NETDATA.icons.hasOwnProperty(icon) && typeof(netdataIcons[icon]) === 'string') + NETDATA.icons[icon] = netdataIcons[icon]; + } + } + if(typeof netdataSnapshotData === 'undefined') netdataSnapshotData = null; @@ -537,7 +571,7 @@ var NETDATA = window.NETDATA || {}; focus: false, visibility: false, chart_data_url: false, - chart_errors: true, // FIXME: remember to set it to false before merging + chart_errors: false, // remember to set it to false before merging chart_timing: false, chart_calls: false, libraries: false, @@ -1758,7 +1792,7 @@ var NETDATA = window.NETDATA || {}; // ---------------------------------------------------------------------------------------------------------------- // dimensions selection - // FIXME + // TODO // move color assignment to dimensions, here var dimensionStatus = function(parent, label, name_div, value_div, color) { @@ -2054,8 +2088,8 @@ var NETDATA = window.NETDATA || {}; return this.xAxisFormat.format(d); }; - var d = new Date(); - var t = this.dateFormat.format(d) + ' ' + this.timeFormat.format(d) + ' ' + this.xAxisFormat.format(d); + //var d = new Date(); + //var t = this.dateFormat.format(d) + ' ' + this.timeFormat.format(d) + ' ' + this.xAxisFormat.format(d); ret = true; } @@ -2094,6 +2128,16 @@ var NETDATA = window.NETDATA || {}; }, scalableUnits: { + 'packets/s': { + 'pps': 1, + 'Kpps': 1000, + 'Mpps': 1000000 + }, + 'pps': { + 'pps': 1, + 'Kpps': 1000, + 'Mpps': 1000000 + }, 'kilobits/s': { 'bits/s': 1 / 1000, 'kilobits/s': 1, @@ -2176,7 +2220,7 @@ var NETDATA = window.NETDATA || {}; 'milliseconds': { check: function (max) { return NETDATA.options.current.seconds_as_time && max < 1000; }, convert: function(milliseconds) { - tms = Math.round(milliseconds * 10); + var tms = Math.round(milliseconds * 10); milliseconds = Math.floor(tms / 10); tms -= milliseconds * 10; @@ -2368,7 +2412,7 @@ var NETDATA = window.NETDATA || {}; } return value / tdivider; - } + }; } else { // the caller did not give data-common-units @@ -2891,7 +2935,7 @@ var NETDATA = window.NETDATA || {}; that.force_update_every *= 1000; // the dimensions requested by the user - that.dimensions = NETDATA.dataAttribute(that.element, 'dimensions', null); + that.dimensions = NETDATA.encodeURIComponent(NETDATA.dataAttribute(that.element, 'dimensions', null)); that.title = NETDATA.dataAttribute(that.element, 'title', null); // the title of the chart that.units = NETDATA.dataAttribute(that.element, 'units', null); // the units of the chart dimensions @@ -2899,8 +2943,11 @@ var NETDATA = window.NETDATA || {}; that.units_current = that.units; that.units_common = NETDATA.dataAttribute(that.element, 'common-units', null); - that.append_options = NETDATA.dataAttribute(that.element, 'append-options', null); // additional options to pass to netdata - that.override_options = NETDATA.dataAttribute(that.element, 'override-options', null); // override options to pass to netdata + // additional options to pass to netdata + that.append_options = NETDATA.encodeURIComponent(NETDATA.dataAttribute(that.element, 'append-options', null)); + + // override options to pass to netdata + that.override_options = NETDATA.encodeURIComponent(NETDATA.dataAttribute(that.element, 'override-options', null)); that.debug = NETDATA.dataAttributeBoolean(that.element, 'debug', false); @@ -3045,7 +3092,7 @@ var NETDATA = window.NETDATA || {}; var invisibleSearchableText = function() { return '<span style="position:absolute; opacity: 0; width: 0px;">' + that.id + '</span>'; - } + }; /* init() private * initialize state variables @@ -3119,19 +3166,19 @@ var NETDATA = window.NETDATA || {}; var icon; if(that.chart !== null) { if(that.chart.chart_type === 'line') - icon = '<i class="fas fa-chart-line"></i>'; + icon = NETDATA.icons.lineChart; else - icon = '<i class="fas fa-chart-area"></i>'; + icon = NETDATA.icons.areaChart; } else - icon = '<i class="fas fa-chart-area"></i>'; + icon = NETDATA.icons.noChart; showMessageIcon(icon + ' netdata' + invisibleSearchableText()); }; var showLoading = function() { if(that.chart_created === false) { - showMessageIcon('<i class="fas fa-sync-alt"></i> netdata'); + showMessageIcon(NETDATA.icons.loading + ' netdata'); return true; } return false; @@ -3532,7 +3579,7 @@ var NETDATA = window.NETDATA || {}; var noDataToShow = function() { - showMessageIcon('<i class="fas fa-exclamation-triangle"></i> empty'); + showMessageIcon(NETDATA.icons.noData + ' empty'); that.legendUpdateDOM(); that.tm.last_autorefreshed = Date.now(); // that.data_update_every = 30 * 1000; @@ -4043,10 +4090,7 @@ var NETDATA = window.NETDATA || {}; if(typeof label === 'undefined') continue; if(typeof this.element_legend_childs.series[label] === 'undefined') continue; - if(show_undefined) - this.legendSetLabelValue(label, null); - else - this.legendSetLabelValue(label, this.data.view_latest_values[i]); + this.legendSetLabelValue(label, this.data.view_latest_values[i]); } }; @@ -4115,9 +4159,12 @@ var NETDATA = window.NETDATA || {}; if (typeof this.chart.plugin === 'string' && this.chart.plugin !== '') { str = this.chart.plugin; - if (typeof this.chart.module === 'string' && this.chart.module !== '') { - str += '/' + this.chart.module; - } + + if(str.endsWith(".plugin")) + str = str.substring(0, str.length - 7); + + if (typeof this.chart.module === 'string' && this.chart.module !== '') + str += ':' + this.chart.module; if (withContext && context !== '') str += ', ' + context; @@ -4315,7 +4362,7 @@ var NETDATA = window.NETDATA || {}; this.element.appendChild(this.element_legend_childs.toolbox); this.element_legend_childs.toolbox_left.className += ' netdata-legend-toolbox-button'; - this.element_legend_childs.toolbox_left.innerHTML = '<i class="fas fa-backward"></i>'; + this.element_legend_childs.toolbox_left.innerHTML = NETDATA.icons.left; this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_left); this.element_legend_childs.toolbox_left.onclick = function(e) { e.preventDefault(); @@ -4340,7 +4387,7 @@ var NETDATA = window.NETDATA || {}; this.element_legend_childs.toolbox_reset.className += ' netdata-legend-toolbox-button'; - this.element_legend_childs.toolbox_reset.innerHTML = '<i class="fas fa-play"></i>'; + this.element_legend_childs.toolbox_reset.innerHTML = NETDATA.icons.reset; this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_reset); this.element_legend_childs.toolbox_reset.onclick = function(e) { e.preventDefault(); @@ -4359,7 +4406,7 @@ var NETDATA = window.NETDATA || {}; }); this.element_legend_childs.toolbox_right.className += ' netdata-legend-toolbox-button'; - this.element_legend_childs.toolbox_right.innerHTML = '<i class="fas fa-forward"></i>'; + this.element_legend_childs.toolbox_right.innerHTML = NETDATA.icons.right; this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_right); this.element_legend_childs.toolbox_right.onclick = function(e) { e.preventDefault(); @@ -4383,7 +4430,7 @@ var NETDATA = window.NETDATA || {}; this.element_legend_childs.toolbox_zoomin.className += ' netdata-legend-toolbox-button'; - this.element_legend_childs.toolbox_zoomin.innerHTML = '<i class="fas fa-plus"></i>'; + this.element_legend_childs.toolbox_zoomin.innerHTML = NETDATA.icons.zoomIn; this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomin); this.element_legend_childs.toolbox_zoomin.onclick = function(e) { e.preventDefault(); @@ -4405,7 +4452,7 @@ var NETDATA = window.NETDATA || {}; }); this.element_legend_childs.toolbox_zoomout.className += ' netdata-legend-toolbox-button'; - this.element_legend_childs.toolbox_zoomout.innerHTML = '<i class="fas fa-minus"></i>'; + this.element_legend_childs.toolbox_zoomout.innerHTML = NETDATA.icons.zoomOut; this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomout); this.element_legend_childs.toolbox_zoomout.onclick = function(e) { e.preventDefault(); @@ -4441,7 +4488,7 @@ var NETDATA = window.NETDATA || {}; this.element_legend_childs.resize_handler = document.createElement('div'); this.element_legend_childs.resize_handler.className += " netdata-legend-resize-handler"; - this.element_legend_childs.resize_handler.innerHTML = '<i class="fas fa-sort"></i>'; + this.element_legend_childs.resize_handler.innerHTML = NETDATA.icons.resize; this.element.appendChild(this.element_legend_childs.resize_handler); if (NETDATA.options.current.show_help === true) $(this.element_legend_childs.resize_handler).popover({ @@ -4653,12 +4700,12 @@ var NETDATA = window.NETDATA || {}; ret = this.library.options(this); if(this.append_options !== null) - ret += '|' + this.append_options.toString(); + ret += '%7C' + this.append_options.toString(); - ret += '|jsonwrap'; + ret += '%7C' + 'jsonwrap'; if(NETDATA.options.current.eliminate_zero_dimensions === true) - ret += '|nonzero'; + ret += '%7C' + 'nonzero'; return ret; }; @@ -4846,7 +4893,7 @@ var NETDATA = window.NETDATA || {}; this.__redraw_on_unhide = true; if(this.debug === true) - this.log("drawn while not visible") + this.log("drawn while not visible"); } if(this.selected === true) @@ -6312,6 +6359,7 @@ var NETDATA = window.NETDATA || {}; :false; state.tmp.dygraph_include_zero = NETDATA.dataAttribute(state.element, 'dygraph-includezero', (state.tmp.dygraph_chart_type === 'stacked')); + var drawAxis = NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawaxis', true); state.tmp.dygraph_options = { colors: NETDATA.dataAttribute(state.element, 'dygraph-colors', state.chartColors()), @@ -6375,7 +6423,7 @@ var NETDATA = window.NETDATA || {}; ), stackedGraph: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraph', (state.tmp.dygraph_chart_type === 'stacked')), stackedGraphNaNFill: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraphnanfill', 'none'), - drawAxis: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawaxis', true), + drawAxis: drawAxis, axisLabelFontSize: NETDATA.dataAttribute(state.element, 'dygraph-axislabelfontsize', 10), axisLineColor: NETDATA.dataAttribute(state.element, 'dygraph-axislinecolor', NETDATA.themes.current.axis), axisLineWidth: NETDATA.dataAttribute(state.element, 'dygraph-axislinewidth', 1.0), @@ -6399,6 +6447,7 @@ var NETDATA = window.NETDATA || {}; pixelsPerLabel: NETDATA.dataAttribute(state.element, 'dygraph-xpixelsperlabel', 50), ticker: Dygraph.dateTicker, axisLabelWidth: NETDATA.dataAttribute(state.element, 'dygraph-xaxislabelwidth', 60), + drawAxis: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawxaxis', drawAxis), axisLabelFormatter: function (d, gran) { void(gran); return NETDATA.dateTime.xAxisTimeString(d); @@ -6408,6 +6457,7 @@ var NETDATA = window.NETDATA || {}; logscale: (NETDATA.chartLibraries.dygraph.isLogScale(state) === true)?true:undefined, pixelsPerLabel: NETDATA.dataAttribute(state.element, 'dygraph-ypixelsperlabel', 15), axisLabelWidth: NETDATA.dataAttribute(state.element, 'dygraph-yaxislabelwidth', 50), + drawAxis: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawyaxis', drawAxis), axisLabelFormatter: function (y) { // unfortunately, we have to call this every single time @@ -6985,6 +7035,8 @@ var NETDATA = window.NETDATA || {}; state.tmp.dygraph_options.labelsSeparateLines = true; state.tmp.dygraph_options.rightGap = 0; state.tmp.dygraph_options.yRangePad = 1; + state.tmp.dygraph_options.axes.x.drawAxis = false; + state.tmp.dygraph_options.axes.y.drawAxis = false; } if(smooth === true) { @@ -8430,7 +8482,7 @@ var NETDATA = window.NETDATA || {}; enabled: true, xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), format: function(state) { void(state); return 'json'; }, - options: function(state) { return 'ms|flip' + (this.isLogScale(state)?'|abs':'').toString(); }, + options: function(state) { return 'ms' + '%7C' + 'flip' + (this.isLogScale(state)?('%7C' + 'abs'):'').toString(); }, legend: function(state) { return (this.isSparkline(state) === false && NETDATA.dataAttributeBoolean(state.element, 'legend', true) === true) ? 'right-side' : null; }, @@ -8475,7 +8527,7 @@ var NETDATA = window.NETDATA || {}; enabled: true, xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), format: function(state) { void(state); return 'array'; }, - options: function(state) { void(state); return 'flip|abs'; }, + options: function(state) { void(state); return 'flip' + '%7C' + 'abs'; }, legend: function(state) { void(state); return null; }, autoresize: function(state) { void(state); return false; }, max_updates_to_recreate: function(state) { void(state); return 5000; }, @@ -8495,7 +8547,7 @@ var NETDATA = window.NETDATA || {}; enabled: true, xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), format: function(state) { void(state); return 'ssvcomma'; }, - options: function(state) { void(state); return 'null2zero|flip|abs'; }, + options: function(state) { void(state); return 'null2zero' + '%7C' + 'flip' + '%7C' + 'abs'; }, legend: function(state) { void(state); return null; }, autoresize: function(state) { void(state); return false; }, max_updates_to_recreate: function(state) { void(state); return 5000; }, @@ -8515,7 +8567,7 @@ var NETDATA = window.NETDATA || {}; enabled: true, xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), format: function(state) { void(state); return 'json'; }, - options: function(state) { void(state); return 'objectrows|ms'; }, + options: function(state) { void(state); return 'objectrows' + '%7C' + 'ms'; }, legend: function(state) { void(state); return null; }, autoresize: function(state) { void(state); return false; }, max_updates_to_recreate: function(state) { void(state); return 50; }, @@ -8595,7 +8647,7 @@ var NETDATA = window.NETDATA || {}; enabled: true, xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), format: function(state) { void(state); return 'json'; }, - options: function(state) { void(state); return 'objectrows|ms'; }, + options: function(state) { void(state); return 'objectrows' + '%7C' + 'ms'; }, legend: function(state) { void(state); return null; }, autoresize: function(state) { void(state); return false; }, max_updates_to_recreate: function(state) { void(state); return 5000; }, @@ -8695,7 +8747,9 @@ var NETDATA = window.NETDATA || {}; { url: NETDATA.serverStatic + 'lib/fontawesome-all-5.0.1.min.js', async: true, - isAlreadyLoaded: function() { return false; } + isAlreadyLoaded: function() { + return (typeof netdataNoFontAwesome !== 'undefined' && netdataNoFontAwesome === true); + } }, { url: NETDATA.serverStatic + 'lib/perfect-scrollbar-0.6.15.min.js', @@ -8927,7 +8981,8 @@ var NETDATA = window.NETDATA || {}; /* // cleanup old notifications with the same alarm_id as this one - // FIXME: it does not seem to work on any web browser! + // it does not seem to work on any web browser - so notifications cannot be removed + var len = NETDATA.alarms.notifications_shown.length; while(len--) { var n = NETDATA.alarms.notifications_shown[len]; |