@cryptotaxi247 / netdata-1 / commits / d5dfb7000

dashboard.js code cleanup and jslint fixes

Costa Tsaousis (ktsaou) committed Feb 4, 2017 at 19:28 UTC d5dfb70006bac471402a3754c75bd98206f2cf75
2 files changed +213 -248
web/dashboard.js
+212 -247
@@ -1,35 +1,54 @@
1 +// ----------------------------------------------------------------------------
2 // You can set the following variables before loading this script:
2 -//
3 -// var netdataNoDygraphs = true; // do not use dygraph
4 -// var netdataNoSparklines = true; // do not use sparkline
5 -// var netdataNoPeitys = true; // do not use peity
6 -// var netdataNoGoogleCharts = true; // do not use google
7 -// var netdataNoMorris = true; // do not use morris
8 -// var netdataNoEasyPieChart = true; // do not use easy pie chart
9 -// var netdataNoGauge = true; // do not use gauge.js
10 -// var netdataNoD3 = true; // do not use D3
11 -// var netdataNoC3 = true; // do not use C3
12 -// var netdataNoBootstrap = true; // do not load bootstrap
13 -// var netdataDontStart = true; // do not start the thread to process the charts
14 -// var netdataErrorCallback = null; // Callback function that will be invoked upon error
15 -// var netdataRegistry = true; // Update the registry (default disabled)
16 -// var netdataRegistryCallback = null; // Callback function that will be invoked with one param,
17 -// the URLs from the registry
18 -// var netdataShowHelp = false; // enable/disable help (default enabled)
19 -// var netdataShowAlarms = true; // enable/disable alarms checks and notifications (default disabled)
20 -//
21 -// var netdataRegistryAfterMs = 1500 // the time to consult to registry on startup
22 -//
23 -// var netdataCallback = null; // a function to call when netdata is ready
24 -// // netdata will be running while this is called (call NETDATA.pause to stop it)
25 -// var netdataPrepCallback = null; // a callback to be called before netdata does anything else
26 -//
27 -// You can also set the default netdata server, using the following.
28 -// When this variable is not set, we assume the page is hosted on your
29 -// netdata server already.
30 -// var netdataServer = "http://yourhost:19999"; // set your NetData server
3
4 +/*global netdataNoDygraphs *//* boolean, disable dygraph charts
5 + * (default: false) */
6 +/*global netdataNoSparklines *//* boolean, disable sparkline charts
7 + * (default: false) */
8 +/*global netdataNoPeitys *//* boolean, disable peity charts
9 + * (default: false) */
10 +/*global netdataNoGoogleCharts *//* boolean, disable google charts
11 + * (default: false) */
12 +/*global netdataNoMorris *//* boolean, disable morris charts
13 + * (default: false) */
14 +/*global netdataNoEasyPieChart *//* boolean, disable easypiechart charts
15 + * (default: false) */
16 +/*global netdataNoGauge *//* boolean, disable gauge.js charts
17 + * (default: false) */
18 +/*global netdataNoD3 *//* boolean, disable d3 charts
19 + * (default: false) */
20 +/*global netdataNoC3 *//* boolean, disable c3 charts
21 + * (default: false) */
22 +/*global netdataNoBootstrap *//* boolean, disable bootstrap - disables help too
23 + * (default: false) */
24 +/*global netdataDontStart *//* boolean, do not start the thread to process the charts
25 + * (default: false) */
26 +/*global netdataErrorCallback *//* function, callback to be called when the dashboard encounters an error
27 + * (default: null) */
28 +/*global netdataRegistry *//* boolean, use the netdata registry
29 + * (default: false) */
30 +/*global netdataNoRegistry *//* boolean, included only for compatibility with existing custom dashboard
31 + * (obsolete - do not use this any more) */
32 +/*global netdataRegistryCallback *//* function, callback that will be invoked with one param: the URLs from the registry
33 + * (default: null) */
34 +/*global netdataShowHelp *//* boolean, disable charts help
35 + * (default: true) */
36 +/*global netdataShowAlarms *//* boolean, enable alarms checks and notifications
37 + * (default: false) */
38 +/*global netdataRegistryAfterMs *//* ms, delay registry use at started
39 + * (default: 1500) */
40 +/*global netdataCallback *//* function, callback to be called when netdata is ready to start
41 + * (default: null)
42 + * netdata will be running while this is called
43 + * (call NETDATA.pause to stop it) */
44 +/*global netdataPrepCallback *//* function, callback to be called before netdata does anything else
45 + * (default: null) */
46 +/*global netdataServer *//* string, the URL of the netdata server to use
47 + * (default: the URL the page is hosted at) */
48 +
49 +// ----------------------------------------------------------------------------
50 // global namespace
51 +
52 var NETDATA = window.NETDATA || {};
53
54 (function(window, document) {
@@ -741,7 +760,7 @@ var NETDATA = window.NETDATA || {};
760 // find the common min
761 var m = min;
762 for(var i in t)
744 - if(t[i] < m) m = t[i];
763 + if(t.hasOwnProperty(i) && t[i] < m) m = t[i];
764
765 //state.log('commonMin ' + state.__commonMin + ' updated: ' + m);
766 this.latest[name] = m;
@@ -796,7 +815,7 @@ var NETDATA = window.NETDATA || {};
815 // find the common max
816 var m = max;
817 for(var i in t)
799 - if(t[i] > m) m = t[i];
818 + if(t.hasOwnProperty(i) && t[i] > m) m = t[i];
819
820 //state.log('commonMax ' + state.__commonMax + ' updated: ' + m);
821 this.latest[name] = m;
@@ -946,14 +965,12 @@ var NETDATA = window.NETDATA || {};
965 // is the given state the master of the global
966 // pan and zoom sync?
967 isMaster: function(state) {
949 - if(this.master === state) return true;
950 - return false;
968 + return (this.master === state);
969 },
970
971 // are we currently have a global pan and zoom sync?
972 isActive: function() {
955 - if(this.master !== null && this.force_before_ms !== null && this.force_after_ms !== null && this.seq !== 0) return true;
956 - return false;
973 + return (this.master !== null && this.force_before_ms !== null && this.force_after_ms !== null && this.seq !== 0);
974 },
975
976 // check if a chart, other than the master
@@ -965,10 +982,7 @@ var NETDATA = window.NETDATA || {};
982 //if(state.needsRecreation())
983 // return true;
984
968 - if(state.tm.pan_and_zoom_seq === this.seq)
969 - return false;
970 -
971 - return true;
985 + return (!(state.tm.pan_and_zoom_seq === this.seq));
986 }
987 };
988
@@ -978,18 +992,14 @@ var NETDATA = window.NETDATA || {};
992 // FIXME
993 // move color assignment to dimensions, here
994
981 - dimensionStatus = function(parent, label, name_div, value_div, color) {
995 + var dimensionStatus = function(parent, label, name_div, value_div, color) {
996 this.enabled = false;
997 this.parent = parent;
998 this.label = label;
999 this.name_div = null;
1000 this.value_div = null;
1001 this.color = NETDATA.themes.current.foreground;
988 -
989 - if(parent.unselected_count === 0)
990 - this.selected = true;
991 - else
992 - this.selected = false;
1002 + this.selected = (parent.unselected_count === 0);
1003
1004 this.setOptions(name_div, value_div, color);
1005 };
@@ -1094,7 +1104,7 @@ var NETDATA = window.NETDATA || {};
1104
1105 // ----------------------------------------------------------------------------------------------------------------
1106
1097 - dimensionsVisibility = function(state) {
1107 + var dimensionsVisibility = function(state) {
1108 this.state = state;
1109 this.len = 0;
1110 this.dimensions = {};
@@ -1149,7 +1159,7 @@ var NETDATA = window.NETDATA || {};
1159 };
1160
1161 dimensionsVisibility.prototype.selected2BooleanArray = function(array) {
1152 - var ret = new Array();
1162 + var ret = [];
1163 this.selected_count = 0;
1164 this.unselected_count = 0;
1165
@@ -1203,7 +1213,7 @@ var NETDATA = window.NETDATA || {};
1213 // ----------------------------------------------------------------------------------------------------------------
1214 // Our state object, where all per-chart values are stored
1215
1206 - chartState = function(element) {
1216 + var chartState = function(element) {
1217 var self = $(element);
1218 this.element = element;
1219
@@ -1577,10 +1587,7 @@ var NETDATA = window.NETDATA || {};
1587 };
1588
1589 var isHidden = function() {
1580 - if(typeof that.___chartIsHidden___ !== 'undefined')
1581 - return true;
1582 -
1583 - return false;
1590 + return (typeof that.___chartIsHidden___ !== 'undefined');
1591 };
1592
1593 // hide the chart, when it is not visible - called from isVisible()
@@ -1632,10 +1639,7 @@ var NETDATA = window.NETDATA || {};
1639 };
1640
1641 var canBeRendered = function() {
1635 - if(isHidden() === true || that.isVisible(true) === false)
1636 - return false;
1637 -
1638 - return true;
1642 + return (isHidden() === false && that.isVisible(true) === true);
1643 };
1644
1645 // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
@@ -1846,7 +1850,7 @@ var NETDATA = window.NETDATA || {};
1850 document.ontouchend =
1851 this.element_legend_childs.resize_handler.onmouseup =
1852 this.element_legend_childs.resize_handler.ontouchend =
1849 - function(e) {
1853 + function() {
1854 // remove all the hooks
1855 document.onmouseup =
1856 document.onmousemove =
@@ -1921,10 +1925,7 @@ var NETDATA = window.NETDATA || {};
1925 if(NETDATA.options.current.sync_selection === false)
1926 return false;
1927
1924 - if(NETDATA.globalSelectionSync.dont_sync_before > Date.now())
1925 - return false;
1926 -
1927 - return true;
1928 + return (!(NETDATA.globalSelectionSync.dont_sync_before > Date.now()));
1929 };
1930
1931 this.globalSelectionSyncIsMaster = function() {
@@ -1959,7 +1960,7 @@ var NETDATA = window.NETDATA || {};
1960 var targets = NETDATA.options.targets;
1961 var len = targets.length;
1962 while(len--) {
1962 - st = targets[len];
1963 + var st = targets[len];
1964
1965 if(st === this) {
1966 if(this.debug === true)
@@ -1978,14 +1979,11 @@ var NETDATA = window.NETDATA || {};
1979
1980 // can the chart participate to the global selection sync as a slave?
1981 this.globalSelectionSyncIsEligible = function() {
1981 - if(this.enabled === true
1982 + return (this.enabled === true
1983 && this.library !== null
1984 && typeof this.library.setSelection === 'function'
1985 && this.isVisible() === true
1985 - && this.chart_created === true)
1986 - return true;
1987 -
1988 - return false;
1986 + && this.chart_created === true);
1987 };
1988
1989 // this chart becomes a slave of the global selection sync
@@ -2044,13 +2042,10 @@ var NETDATA = window.NETDATA || {};
2042 };
2043
2044 this.setSelection = function(t) {
2047 - if(typeof this.library.setSelection === 'function') {
2048 - if(this.library.setSelection(this, t) === true)
2049 - this.selected = true;
2050 - else
2051 - this.selected = false;
2052 - }
2053 - else this.selected = true;
2045 + if(typeof this.library.setSelection === 'function')
2046 + this.selected = (this.library.setSelection(this, t) === true);
2047 + else
2048 + this.selected = true;
2049
2050 if(this.selected === true && this.debug === true)
2051 this.log('selection set to ' + t.toString());
@@ -2060,13 +2055,10 @@ var NETDATA = window.NETDATA || {};
2055
2056 this.clearSelection = function() {
2057 if(this.selected === true) {
2063 - if(typeof this.library.clearSelection === 'function') {
2064 - if(this.library.clearSelection(this) === true)
2065 - this.selected = false;
2066 - else
2067 - this.selected = true;
2068 - }
2069 - else this.selected = false;
2058 + if(typeof this.library.clearSelection === 'function')
2059 + this.selected = (!(this.library.clearSelection(this) === true));
2060 + else
2061 + this.selected = false;
2062
2063 if(this.selected === false && this.debug === true)
2064 this.log('selection cleared');
@@ -2079,9 +2071,7 @@ var NETDATA = window.NETDATA || {};
2071
2072 // find if a timestamp (ms) is shown in the current chart
2073 this.timeIsVisible = function(t) {
2082 - if(t >= this.data_after && t <= this.data_before)
2083 - return true;
2084 - return false;
2074 + return (t >= this.data_after && t <= this.data_before);
2075 };
2076
2077 this.calculateRowForTime = function(t) {
@@ -2340,7 +2330,7 @@ var NETDATA = window.NETDATA || {};
2330 this.__legendSetTimeString(this.chart.name);
2331
2332 if(this.element_legend_childs.title_units)
2343 - this.__legendSetUnitsString(' ')
2333 + this.__legendSetUnitsString(' ');
2334
2335 if(this.data && this.element_legend_childs.series !== null) {
2336 var labels = this.data.dimension_names;
@@ -2422,8 +2412,8 @@ var NETDATA = window.NETDATA || {};
2412 this.chartColors = function() {
2413 if(this.colors !== null) return this.colors;
2414
2425 - this.colors = new Array();
2426 - this.colors_available = new Array();
2415 + this.colors = [];
2416 + this.colors_available = [];
2417
2418 // add the standard colors
2419 var len = NETDATA.themes.current.colors.length;
@@ -2548,7 +2538,7 @@ var NETDATA = window.NETDATA || {};
2538 + state.chart.chart_type
2539 + '" style="background-color: '
2540 + 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + NETDATA.options.current['color_fill_opacity_' + state.chart.chart_type] + ')'
2551 - + '"><tr class="netdata-legend-name-tr"><td class="netdata-legend-name-td"></td></tr></table>'
2541 + + '"><tr class="netdata-legend-name-tr"><td class="netdata-legend-name-td"></td></tr></table>';
2542
2543 var text = document.createTextNode(' ' + name);
2544 label.name.appendChild(text);
@@ -2821,7 +2811,7 @@ var NETDATA = window.NETDATA || {};
2811 }
2812 }
2813 else {
2824 - var tmp = new Array();
2814 + var tmp = [];
2815 keys = Object.keys(this.chart.dimensions);
2816 for(i = 0, len = keys.length; i < len ;i++) {
2817 dim = keys[i];
@@ -3604,10 +3594,10 @@ var NETDATA = window.NETDATA || {};
3594
3595 // ----------------------------------------------------------------------------------------------------------------
3596
3607 - // this is purely sequencial charts refresher
3597 + // this is purely sequential charts refresher
3598 // it is meant to be autonomous
3599 NETDATA.chartRefresherNoParallel = function(index) {
3610 - if(NETDATA.options.debug.mail_loop === true)
3600 + if(NETDATA.options.debug.main_loop === true)
3601 console.log('NETDATA.chartRefresherNoParallel(' + index + ')');
3602
3603 if(NETDATA.options.updated_dom === true) {
@@ -3650,41 +3640,11 @@ var NETDATA = window.NETDATA || {};
3640 }
3641 };
3642
3653 - // this is part of the parallel refresher
3654 - // its cause is to refresh sequencially all the charts
3655 - // that depend on chart library initialization
3656 - // it will call the parallel refresher back
3657 - // as soon as it sees a chart that its chart library
3658 - // is initialized
3659 - NETDATA.chartRefresher_uninitialized = function() {
3660 - if(NETDATA.options.updated_dom === true) {
3661 - // the dom has been updated
3662 - // get the dom parts again
3663 - NETDATA.parseDom(NETDATA.chartRefresher);
3664 - return;
3665 - }
3666 -
3667 - if(NETDATA.options.sequencial.length === 0)
3668 - NETDATA.chartRefresher();
3669 - else {
3670 - var state = NETDATA.options.sequencial.pop();
3671 - if(state.library.initialized === true)
3672 - NETDATA.chartRefresher();
3673 - else
3674 - state.autoRefresh(NETDATA.chartRefresher_uninitialized);
3675 - }
3676 - };
3677 -
3643 NETDATA.chartRefresherWaitTime = function() {
3644 return NETDATA.options.current.idle_parallel_loops;
3645 };
3646
3647 // the default refresher
3683 - // it will create 2 sets of charts:
3684 - // - the ones that can be refreshed in parallel
3685 - // - the ones that depend on something else
3686 - // the first set will be executed in parallel
3687 - // the second will be given to NETDATA.chartRefresher_uninitialized()
3648 NETDATA.chartRefresher = function() {
3649 // console.log('auto-refresher...');
3650
@@ -3717,7 +3677,7 @@ var NETDATA = window.NETDATA || {};
3677 return;
3678 }
3679
3720 - var parallel = new Array();
3680 + var parallel = [];
3681 var targets = NETDATA.options.targets;
3682 var len = targets.length;
3683 var state;
@@ -3764,7 +3724,7 @@ var NETDATA = window.NETDATA || {};
3724 if(NETDATA.options.debug.main_loop === true)
3725 console.log('DOM updated - there are ' + targets.length + ' charts on page.');
3726
3767 - NETDATA.options.targets = new Array();
3727 + NETDATA.options.targets = [];
3728 var len = targets.length;
3729 while(len--) {
3730 // the initialization will take care of sizing
@@ -3810,12 +3770,14 @@ var NETDATA = window.NETDATA || {};
3770 $('a[data-toggle="tab"]').on('shown.bs.tab', NETDATA.onscroll);
3771
3772 // bootstrap modal switching
3813 - $('.modal').on('hidden.bs.modal', NETDATA.onscroll);
3814 - $('.modal').on('shown.bs.modal', NETDATA.onscroll);
3773 + var $modal = $('.modal');
3774 + $modal.on('hidden.bs.modal', NETDATA.onscroll);
3775 + $modal.on('shown.bs.modal', NETDATA.onscroll);
3776
3777 // bootstrap collapse switching
3817 - $('.collapse').on('hidden.bs.collapse', NETDATA.onscroll);
3818 - $('.collapse').on('shown.bs.collapse', NETDATA.onscroll);
3778 + var $collapse = $('.collapse');
3779 + $collapse.on('hidden.bs.collapse', NETDATA.onscroll);
3780 + $collapse.on('shown.bs.collapse', NETDATA.onscroll);
3781
3782 NETDATA.parseDom(NETDATA.chartRefresher);
3783
@@ -4075,7 +4037,7 @@ var NETDATA = window.NETDATA || {};
4037 return true;
4038 };
4039
4078 - NETDATA.dygraphClearSelection = function(state, t) {
4040 + NETDATA.dygraphClearSelection = function(state) {
4041 if(typeof state.dygraph_instance !== 'undefined') {
4042 state.dygraph_instance.clearSelection();
4043 }
@@ -4226,13 +4188,13 @@ var NETDATA = window.NETDATA || {};
4188 if(chart_type === 'stacked' && data.dimensions === 1) chart_type = 'area';
4189 chart_type = self.data('dygraph-type') || chart_type;
4190
4229 - var smooth = (chart_type === 'line' && !NETDATA.chartLibraries.dygraph.isSparkline(state))?true:false;
4191 + var smooth = (chart_type === 'line' && !NETDATA.chartLibraries.dygraph.isSparkline(state));
4192 smooth = self.data('dygraph-smooth') || smooth;
4193
4194 if(NETDATA.dygraph.smooth === false)
4195 smooth = false;
4196
4235 - var strokeWidth = (chart_type === 'stacked')?0.1:((smooth)?1.5:0.7)
4197 + var strokeWidth = (chart_type === 'stacked')?0.1:((smooth)?1.5:0.7);
4198 var highlightCircleSize = (NETDATA.chartLibraries.dygraph.isSparkline(state))?3:4;
4199
4200 state.dygraph_options = {
@@ -4258,7 +4220,7 @@ var NETDATA = window.NETDATA || {};
4220 showLabelsOnHighlight: self.data('dygraph-showlabelsonhighlight') || true,
4221 hideOverlayOnMouseOut: self.data('dygraph-hideoverlayonmouseout') || true,
4222
4261 - includeZero: self.data('dygraph-includezero') || ((chart_type === 'stacked')? true : false),
4223 + includeZero: self.data('dygraph-includezero') || (chart_type === 'stacked'),
4224 xRangePad: self.data('dygraph-xrangepad') || 0,
4225 yRangePad: self.data('dygraph-yrangepad') || 1,
4226
@@ -4291,9 +4253,9 @@ var NETDATA = window.NETDATA || {};
4253 strokeBorderColor: self.data('dygraph-strokebordercolor') || NETDATA.themes.current.background,
4254 strokeBorderWidth: self.data('dygraph-strokeborderwidth') || (chart_type === 'stacked')?0.0:0.0,
4255
4294 - fillGraph: self.data('dygraph-fillgraph') || ((chart_type === 'area' || chart_type === 'stacked')?true:false),
4256 + fillGraph: self.data('dygraph-fillgraph') || (chart_type === 'area' || chart_type === 'stacked'),
4257 fillAlpha: self.data('dygraph-fillalpha') || ((chart_type === 'stacked')?NETDATA.options.current.color_fill_opacity_stacked:NETDATA.options.current.color_fill_opacity_area),
4296 - stackedGraph: self.data('dygraph-stackedgraph') || ((chart_type === 'stacked')?true:false),
4258 + stackedGraph: self.data('dygraph-stackedgraph') || (chart_type === 'stacked'),
4259 stackedGraphNaNFill: self.data('dygraph-stackedgraphnanfill') || 'none',
4260
4261 drawAxis: self.data('dygraph-drawaxis') || true,
@@ -4322,9 +4284,11 @@ var NETDATA = window.NETDATA || {};
4284 pixelsPerLabel: 50,
4285 ticker: Dygraph.dateTicker,
4286 axisLabelFormatter: function (d, gran) {
4287 + void(gran);
4288 return NETDATA.zeropad(d.getHours()) + ":" + NETDATA.zeropad(d.getMinutes()) + ":" + NETDATA.zeropad(d.getSeconds());
4289 },
4290 valueFormatter: function (ms) {
4291 + void(ms);
4292 //var d = new Date(ms);
4293 //return d.toLocaleDateString() + ' ' + d.toLocaleTimeString();
4294
@@ -4381,6 +4345,8 @@ var NETDATA = window.NETDATA || {};
4345 }
4346 },
4347 zoomCallback: function(minDate, maxDate, yRanges) {
4348 + void(yRanges);
4349 +
4350 if(NETDATA.options.debug.dygraph === true)
4351 state.log('dygraphZoomCallback()');
4352
@@ -4394,6 +4360,8 @@ var NETDATA = window.NETDATA || {};
4360 state.updateChartPanOrZoom(minDate, maxDate);
4361 },
4362 highlightCallback: function(event, x, points, row, seriesName) {
4363 + void(seriesName);
4364 +
4365 if(NETDATA.options.debug.dygraph === true || state.debug === true)
4366 state.log('dygraphHighlightCallback()');
4367
@@ -4413,6 +4381,8 @@ var NETDATA = window.NETDATA || {};
4381 // state.dygraph_instance.plugins_[0].plugin.legend_div_.style.zIndex = 10000;
4382 },
4383 unhighlightCallback: function(event) {
4384 + void(event);
4385 +
4386 if(NETDATA.options.debug.dygraph === true || state.debug === true)
4387 state.log('dygraphUnhighlightCallback()');
4388
@@ -4496,17 +4466,26 @@ var NETDATA = window.NETDATA || {};
4466 }
4467 },
4468 click: function(event, dygraph, context) {
4469 + void(dygraph);
4470 + void(context);
4471 +
4472 if(NETDATA.options.debug.dygraph === true || state.debug === true)
4473 state.log('interactionModel.click()');
4474
4475 event.preventDefault();
4476 },
4477 dblclick: function(event, dygraph, context) {
4478 + void(event);
4479 + void(dygraph);
4480 + void(context);
4481 +
4482 if(NETDATA.options.debug.dygraph === true || state.debug === true)
4483 state.log('interactionModel.dblclick()');
4484 NETDATA.resetAllCharts(state);
4485 },
4486 wheel: function(event, dygraph, context) {
4487 + void(context);
4488 +
4489 if(NETDATA.options.debug.dygraph === true || state.debug === true)
4490 state.log('interactionModel.wheel()');
4491
@@ -5618,7 +5597,7 @@ var NETDATA = window.NETDATA || {};
5597 colorStop: stopColor, // just experiment with them
5598 strokeColor: strokeColor, // to see which ones work best for you
5599 limitMax: true,
5621 - generateGradient: (generateGradient === true)?true:false,
5600 + generateGradient: (generateGradient === true),
5601 gradientType: 0
5602 };
5603
@@ -5629,13 +5608,13 @@ var NETDATA = window.NETDATA || {};
5608 // data-gauge-gradient-percent-color-50="#999900"
5609 // data-gauge-gradient-percent-color-100="#000000"
5610
5632 - options.percentColors = new Array();
5611 + options.percentColors = [];
5612 var len = generateGradient.length;
5613 while(len--) {
5614 var pcent = generateGradient[len];
5615 var color = self.data('gauge-gradient-percent-color-' + pcent.toString()) || false;
5616 if(color !== false) {
5638 - var a = new Array();
5617 + var a = [];
5618 a[0] = pcent / 100;
5619 a[1] = color;
5620 options.percentColors.unshift(a);
@@ -5746,31 +5725,21 @@ var NETDATA = window.NETDATA || {};
5725 toolboxPanAndZoom: NETDATA.dygraphToolboxPanAndZoom,
5726 initialized: false,
5727 enabled: true,
5749 - format: function(state) { return 'json'; },
5750 - options: function(state) { return 'ms|flip'; },
5728 + format: function(state) { void(state); return 'json'; },
5729 + options: function(state) { void(state); return 'ms|flip'; },
5730 legend: function(state) {
5752 - if(this.isSparkline(state) === false)
5753 - return 'right-side';
5754 - else
5755 - return null;
5731 + return (this.isSparkline(state) === false)?'right-side':null;
5732 },
5757 - autoresize: function(state) { return true; },
5758 - max_updates_to_recreate: function(state) { return 5000; },
5759 - track_colors: function(state) { return true; },
5733 + autoresize: function(state) { void(state); return true; },
5734 + max_updates_to_recreate: function(state) { void(state); return 5000; },
5735 + track_colors: function(state) { void(state); return true; },
5736 pixels_per_point: function(state) {
5761 - if(this.isSparkline(state) === false)
5762 - return 3;
5763 - else
5764 - return 2;
5737 + return (this.isSparkline(state) === false)?3:2;
5738 },
5766 -
5739 isSparkline: function(state) {
5740 if(typeof state.dygraph_sparkline === 'undefined') {
5741 var t = $(state.element).data('dygraph-theme');
5770 - if(t === 'sparkline')
5771 - state.dygraph_sparkline = true;
5772 - else
5773 - state.dygraph_sparkline = false;
5742 + state.dygraph_sparkline = (t === 'sparkline');
5743 }
5744 return state.dygraph_sparkline;
5745 }
@@ -5780,126 +5749,126 @@ var NETDATA = window.NETDATA || {};
5749 create: NETDATA.sparklineChartCreate,
5750 update: NETDATA.sparklineChartUpdate,
5751 resize: null,
5783 - setSelection: undefined, // function(state, t) { return true; },
5784 - clearSelection: undefined, // function(state) { return true; },
5752 + setSelection: undefined, // function(state, t) { void(state); return true; },
5753 + clearSelection: undefined, // function(state) { void(state); return true; },
5754 toolboxPanAndZoom: null,
5755 initialized: false,
5756 enabled: true,
5788 - format: function(state) { return 'array'; },
5789 - options: function(state) { return 'flip|abs'; },
5790 - legend: function(state) { return null; },
5791 - autoresize: function(state) { return false; },
5792 - max_updates_to_recreate: function(state) { return 5000; },
5793 - track_colors: function(state) { return false; },
5794 - pixels_per_point: function(state) { return 3; }
5757 + format: function(state) { void(state); return 'array'; },
5758 + options: function(state) { void(state); return 'flip|abs'; },
5759 + legend: function(state) { void(state); return null; },
5760 + autoresize: function(state) { void(state); return false; },
5761 + max_updates_to_recreate: function(state) { void(state); return 5000; },
5762 + track_colors: function(state) { void(state); return false; },
5763 + pixels_per_point: function(state) { void(state); return 3; }
5764 },
5765 "peity": {
5766 initialize: NETDATA.peityInitialize,
5767 create: NETDATA.peityChartCreate,
5768 update: NETDATA.peityChartUpdate,
5769 resize: null,
5801 - setSelection: undefined, // function(state, t) { return true; },
5802 - clearSelection: undefined, // function(state) { return true; },
5770 + setSelection: undefined, // function(state, t) { void(state); return true; },
5771 + clearSelection: undefined, // function(state) { void(state); return true; },
5772 toolboxPanAndZoom: null,
5773 initialized: false,
5774 enabled: true,
5806 - format: function(state) { return 'ssvcomma'; },
5807 - options: function(state) { return 'null2zero|flip|abs'; },
5808 - legend: function(state) { return null; },
5809 - autoresize: function(state) { return false; },
5810 - max_updates_to_recreate: function(state) { return 5000; },
5811 - track_colors: function(state) { return false; },
5812 - pixels_per_point: function(state) { return 3; }
5775 + format: function(state) { void(state); return 'ssvcomma'; },
5776 + options: function(state) { void(state); return 'null2zero|flip|abs'; },
5777 + legend: function(state) { void(state); return null; },
5778 + autoresize: function(state) { void(state); return false; },
5779 + max_updates_to_recreate: function(state) { void(state); return 5000; },
5780 + track_colors: function(state) { void(state); return false; },
5781 + pixels_per_point: function(state) { void(state); return 3; }
5782 },
5783 "morris": {
5784 initialize: NETDATA.morrisInitialize,
5785 create: NETDATA.morrisChartCreate,
5786 update: NETDATA.morrisChartUpdate,
5787 resize: null,
5819 - setSelection: undefined, // function(state, t) { return true; },
5820 - clearSelection: undefined, // function(state) { return true; },
5788 + setSelection: undefined, // function(state, t) { void(state); return true; },
5789 + clearSelection: undefined, // function(state) { void(state); return true; },
5790 toolboxPanAndZoom: null,
5791 initialized: false,
5792 enabled: true,
5824 - format: function(state) { return 'json'; },
5825 - options: function(state) { return 'objectrows|ms'; },
5826 - legend: function(state) { return null; },
5827 - autoresize: function(state) { return false; },
5828 - max_updates_to_recreate: function(state) { return 50; },
5829 - track_colors: function(state) { return false; },
5830 - pixels_per_point: function(state) { return 15; }
5793 + format: function(state) { void(state); return 'json'; },
5794 + options: function(state) { void(state); return 'objectrows|ms'; },
5795 + legend: function(state) { void(state); return null; },
5796 + autoresize: function(state) { void(state); return false; },
5797 + max_updates_to_recreate: function(state) { void(state); return 50; },
5798 + track_colors: function(state) { void(state); return false; },
5799 + pixels_per_point: function(state) { void(state); return 15; }
5800 },
5801 "google": {
5802 initialize: NETDATA.googleInitialize,
5803 create: NETDATA.googleChartCreate,
5804 update: NETDATA.googleChartUpdate,
5805 resize: null,
5837 - setSelection: undefined, //function(state, t) { return true; },
5838 - clearSelection: undefined, //function(state) { return true; },
5806 + setSelection: undefined, //function(state, t) { void(state); return true; },
5807 + clearSelection: undefined, //function(state) { void(state); return true; },
5808 toolboxPanAndZoom: null,
5809 initialized: false,
5810 enabled: true,
5842 - format: function(state) { return 'datatable'; },
5843 - options: function(state) { return ''; },
5844 - legend: function(state) { return null; },
5845 - autoresize: function(state) { return false; },
5846 - max_updates_to_recreate: function(state) { return 300; },
5847 - track_colors: function(state) { return false; },
5848 - pixels_per_point: function(state) { return 4; }
5811 + format: function(state) { void(state); return 'datatable'; },
5812 + options: function(state) { void(state); return ''; },
5813 + legend: function(state) { void(state); return null; },
5814 + autoresize: function(state) { void(state); return false; },
5815 + max_updates_to_recreate: function(state) { void(state); return 300; },
5816 + track_colors: function(state) { void(state); return false; },
5817 + pixels_per_point: function(state) { void(state); return 4; }
5818 },
5819 "raphael": {
5820 initialize: NETDATA.raphaelInitialize,
5821 create: NETDATA.raphaelChartCreate,
5822 update: NETDATA.raphaelChartUpdate,
5823 resize: null,
5855 - setSelection: undefined, // function(state, t) { return true; },
5856 - clearSelection: undefined, // function(state) { return true; },
5824 + setSelection: undefined, // function(state, t) { void(state); return true; },
5825 + clearSelection: undefined, // function(state) { void(state); return true; },
5826 toolboxPanAndZoom: null,
5827 initialized: false,
5828 enabled: true,
5860 - format: function(state) { return 'json'; },
5861 - options: function(state) { return ''; },
5862 - legend: function(state) { return null; },
5863 - autoresize: function(state) { return false; },
5864 - max_updates_to_recreate: function(state) { return 5000; },
5865 - track_colors: function(state) { return false; },
5866 - pixels_per_point: function(state) { return 3; }
5829 + format: function(state) { void(state); return 'json'; },
5830 + options: function(state) { void(state); return ''; },
5831 + legend: function(state) { void(state); return null; },
5832 + autoresize: function(state) { void(state); return false; },
5833 + max_updates_to_recreate: function(state) { void(state); return 5000; },
5834 + track_colors: function(state) { void(state); return false; },
5835 + pixels_per_point: function(state) { void(state); return 3; }
5836 },
5837 "c3": {
5838 initialize: NETDATA.c3Initialize,
5839 create: NETDATA.c3ChartCreate,
5840 update: NETDATA.c3ChartUpdate,
5841 resize: null,
5873 - setSelection: undefined, // function(state, t) { return true; },
5874 - clearSelection: undefined, // function(state) { return true; },
5842 + setSelection: undefined, // function(state, t) { void(state); return true; },
5843 + clearSelection: undefined, // function(state) { void(state); return true; },
5844 toolboxPanAndZoom: null,
5845 initialized: false,
5846 enabled: true,
5878 - format: function(state) { return 'csvjsonarray'; },
5879 - options: function(state) { return 'milliseconds'; },
5880 - legend: function(state) { return null; },
5881 - autoresize: function(state) { return false; },
5882 - max_updates_to_recreate: function(state) { return 5000; },
5883 - track_colors: function(state) { return false; },
5884 - pixels_per_point: function(state) { return 15; }
5847 + format: function(state) { void(state); return 'csvjsonarray'; },
5848 + options: function(state) { void(state); return 'milliseconds'; },
5849 + legend: function(state) { void(state); return null; },
5850 + autoresize: function(state) { void(state); return false; },
5851 + max_updates_to_recreate: function(state) { void(state); return 5000; },
5852 + track_colors: function(state) { void(state); return false; },
5853 + pixels_per_point: function(state) { void(state); return 15; }
5854 },
5855 "d3": {
5856 initialize: NETDATA.d3Initialize,
5857 create: NETDATA.d3ChartCreate,
5858 update: NETDATA.d3ChartUpdate,
5859 resize: null,
5891 - setSelection: undefined, // function(state, t) { return true; },
5892 - clearSelection: undefined, // function(state) { return true; },
5860 + setSelection: undefined, // function(state, t) { void(state); return true; },
5861 + clearSelection: undefined, // function(state) { void(state); return true; },
5862 toolboxPanAndZoom: null,
5863 initialized: false,
5864 enabled: true,
5896 - format: function(state) { return 'json'; },
5897 - options: function(state) { return ''; },
5898 - legend: function(state) { return null; },
5899 - autoresize: function(state) { return false; },
5900 - max_updates_to_recreate: function(state) { return 5000; },
5901 - track_colors: function(state) { return false; },
5902 - pixels_per_point: function(state) { return 3; }
5865 + format: function(state) { void(state); return 'json'; },
5866 + options: function(state) { void(state); return ''; },
5867 + legend: function(state) { void(state); return null; },
5868 + autoresize: function(state) { void(state); return false; },
5869 + max_updates_to_recreate: function(state) { void(state); return 5000; },
5870 + track_colors: function(state) { void(state); return false; },
5871 + pixels_per_point: function(state) { void(state); return 3; }
5872 },
5873 "easypiechart": {
5874 initialize: NETDATA.easypiechartInitialize,
@@ -5911,13 +5880,13 @@ var NETDATA = window.NETDATA || {};
5880 toolboxPanAndZoom: null,
5881 initialized: false,
5882 enabled: true,
5914 - format: function(state) { return 'array'; },
5915 - options: function(state) { return 'absolute'; },
5916 - legend: function(state) { return null; },
5917 - autoresize: function(state) { return false; },
5918 - max_updates_to_recreate: function(state) { return 5000; },
5919 - track_colors: function(state) { return true; },
5920 - pixels_per_point: function(state) { return 3; },
5883 + format: function(state) { void(state); return 'array'; },
5884 + options: function(state) { void(state); return 'absolute'; },
5885 + legend: function(state) { void(state); return null; },
5886 + autoresize: function(state) { void(state); return false; },
5887 + max_updates_to_recreate: function(state) { void(state); return 5000; },
5888 + track_colors: function(state) { void(state); return true; },
5889 + pixels_per_point: function(state) { void(state); return 3; },
5890 aspect_ratio: 100
5891 },
5892 "gauge": {
@@ -5930,13 +5899,13 @@ var NETDATA = window.NETDATA || {};
5899 toolboxPanAndZoom: null,
5900 initialized: false,
5901 enabled: true,
5933 - format: function(state) { return 'array'; },
5934 - options: function(state) { return 'absolute'; },
5935 - legend: function(state) { return null; },
5936 - autoresize: function(state) { return false; },
5937 - max_updates_to_recreate: function(state) { return 5000; },
5938 - track_colors: function(state) { return true; },
5939 - pixels_per_point: function(state) { return 3; },
5902 + format: function(state) { void(state); return 'array'; },
5903 + options: function(state) { void(state); return 'absolute'; },
5904 + legend: function(state) { void(state); return null; },
5905 + autoresize: function(state) { void(state); return false; },
5906 + max_updates_to_recreate: function(state) { void(state); return 5000; },
5907 + track_colors: function(state) { void(state); return true; },
5908 + pixels_per_point: function(state) { void(state); return 3; },
5909 aspect_ratio: 70
5910 }
5911 };
@@ -5962,10 +5931,7 @@ var NETDATA = window.NETDATA || {};
5931 if(typeof $().emulateTransitionEnd === 'function')
5932 return true;
5933 else {
5965 - if(typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap)
5966 - return true;
5967 - else
5968 - return false;
5934 + return (typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap);
5935 }
5936 }
5937 },
@@ -5979,10 +5945,7 @@ var NETDATA = window.NETDATA || {};
5945 {
5946 url: NETDATA.themes.current.bootstrap_css,
5947 isAlreadyLoaded: function() {
5982 - if(typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap)
5983 - return true;
5984 - else
5985 - return false;
5948 + return (typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap);
5949 }
5950 },
5951 {
@@ -6034,7 +5997,7 @@ var NETDATA = window.NETDATA || {};
5997
5998 if(async === false)
5999 NETDATA.loadRequiredJs(++index, callback);
6037 - })
6000 + });
6001
6002 if(async === true)
6003 NETDATA.loadRequiredJs(++index, callback);
@@ -6074,7 +6037,7 @@ var NETDATA = window.NETDATA || {};
6037 last_notification_id: 0, // the id of the last alarm_log we have raised an alarm for
6038 first_notification_id: 0, // the id of the first alarm_log entry for this session
6039 // this is used to prevent CLEAR notifications for past events
6077 - // notifications_shown: new Array(),
6040 + // notifications_shown: [],
6041
6042 server: null, // the server to connect to for fetching alarms
6043 current: null, // the list of raised alarms - updated in the background
@@ -6088,16 +6051,18 @@ var NETDATA = window.NETDATA || {};
6051 return;
6052 }
6053
6091 - var value = entry.value;
6054 + var value_string = entry.value_string;
6055 +
6056 if(NETDATA.alarms.current !== null) {
6057 + // get the current value_string
6058 var t = NETDATA.alarms.current.alarms[entry.chart + '.' + entry.name];
6059 if(typeof t !== 'undefined' && entry.status === t.status)
6095 - value = t.value;
6060 + value_string = t.value_string;
6061 }
6062
6063 var name = entry.name.replace(/_/g, ' ');
6064 var status = entry.status.toLowerCase();
6100 - var title = name + ' = ' + entry.value_string.toString();
6065 + var title = name + ' = ' + value_string.toString();
6066 var tag = entry.alarm_id;
6067 var icon = 'images/seo-performance-128.png';
6068 var interaction = false;
@@ -6130,7 +6095,7 @@ var NETDATA = window.NETDATA || {};
6095 // console.log('alarm' + entry.unique_id + ' is CLEAR but has no_clear_notification flag');
6096 return;
6097 }
6133 - title = name + ' back to normal (' + entry.value_string.toString() + ')';
6098 + title = name + ' back to normal (' + value_string.toString() + ')';
6099 icon = 'images/check-mark-2-128-green.png'
6100 interaction = false;
6101 break;
@@ -6403,7 +6368,7 @@ var NETDATA = window.NETDATA || {};
6368
6369 if(person_urls) {
6370 NETDATA.registry.machines = {};
6406 - NETDATA.registry.machines_array = new Array();
6371 + NETDATA.registry.machines_array = [];
6372
6373 var now = Date.now();
6374 var apu = person_urls;
@@ -6418,7 +6383,7 @@ var NETDATA = window.NETDATA || {};
6383 last_t: apu[i][2],
6384 accesses: apu[i][3],
6385 name: apu[i][4],
6421 - alternate_urls: new Array()
6386 + alternate_urls: []
6387 };
6388 obj.alternate_urls.push(apu[i][1]);
6389
web/index.html
+1 -1
@@ -3312,4 +3312,4 @@
3312 </div>
3313 </body>
3314 </html>
3315 -<script type="text/javascript" src="dashboard.js?v20170204-1"></script>
3315 +<script type="text/javascript" src="dashboard.js?v20170204-2"></script>