diff options
| author | Paul Donald | 2026-02-15 06:51:05 +0000 |
|---|---|---|
| committer | Paul Donald | 2026-02-16 00:42:57 +0000 |
| commit | 2bebe21493c23cf4d61311e85a1e3cbd6275f1c3 (patch) | |
| tree | 2949901984f83a1cc8470add534080d0e1251e5b | |
| parent | c567bfc2a8914e944d8e9e0f914099edb2243674 (diff) | |
| download | luci-2bebe21493c23cf4d61311e85a1e3cbd6275f1c3.tar.gz | |
luci-app-statistics: js linting fixes / ES6 treatment
Fix errors
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
79 files changed, 525 insertions, 533 deletions
diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool.js index 0e8414ff2f..5231194a19 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool.js @@ -17,9 +17,9 @@ function subst(str, val) { }); } -var i18n = L.Class.singleton({ - title: function(host, plugin, pinst, dtype, dinst, user_title) { - var title = user_title || 'p=%s/pi=%s/dt=%s/di=%s'.format( +const i18n = L.Class.singleton({ + title(host, plugin, pinst, dtype, dinst, user_title) { + const title = user_title || 'p=%s/pi=%s/dt=%s/di=%s'.format( plugin, pinst || '(nil)', dtype || '(nil)', @@ -35,8 +35,8 @@ var i18n = L.Class.singleton({ }); }, - label: function(host, plugin, pinst, dtype, dinst, user_label) { - var label = user_label || 'dt=%s/%di=%s'.format( + label(host, plugin, pinst, dtype, dinst, user_label) { + const label = user_label || 'dt=%s/%di=%s'.format( dtype || '(nil)', dinst || '(nil)' ); @@ -50,8 +50,8 @@ var i18n = L.Class.singleton({ }); }, - ds: function(host, source) { - var label = source.title || 'dt=%s/di=%s/ds=%s'.format( + ds(host, source) { + const label = source.title || 'dt=%s/di=%s/ds=%s'.format( source.type || '(nil)', source.instance || '(nil)', source.ds || '(nil)' @@ -66,8 +66,8 @@ var i18n = L.Class.singleton({ } }); -var colors = L.Class.singleton({ - fromString: function(s) { +const colors = L.Class.singleton({ + fromString(s) { if (typeof(s) != 'string' || !s.match(/^[0-9a-fA-F]{6}$/)) return null; @@ -78,15 +78,15 @@ var colors = L.Class.singleton({ ]; }, - asString: function(c) { + asString(c) { if (!Array.isArray(c) || c.length != 3) return null; return '%02x%02x%02x'.format(c[0], c[1], c[2]); }, - defined: function(i) { - var t = [ + defined(i) { + const t = [ [230, 25, 75], [245, 130, 48], [255, 225, 25], @@ -100,22 +100,22 @@ var colors = L.Class.singleton({ return this.asString(t[i % t.length]); }, - random: function() { - var r = random.get(255), - g = random.get(255), - min = 0, max = 255; + random() { + const r = random.get(255); + const g = random.get(255); + let min = 0, max = 255; if (r + g < 255) min = 255 - r - g; else max = 511 - r - g; - var b = min + Math.floor(random.get() * (max - min)); + const b = min + Math.floor(random.get() * (max - min)); return [ r, g, b ]; }, - faded: function(fg, bg, alpha) { + faded(fg, bg, alpha) { fg = this.fromString(fg) || (this.asString(fg) ? fg : null); bg = this.fromString(bg) || (this.asString(bg) ? bg : [255, 255, 255]); alpha = !isNaN(alpha) ? +alpha : 0.25; @@ -131,23 +131,20 @@ var colors = L.Class.singleton({ } }); -var rrdtree = {}, - graphdefs = {}; +const rrdtree = {}; +const graphdefs = {}; return baseclass.extend({ - __init__: function() { + __init__() { this.opts = {}; }, - load: function() { + load() { return Promise.all([ L.resolveDefault(fs.list('/www' + L.resource('statistics/rrdtool/definitions')), []), fs.trimmed('/proc/sys/kernel/hostname'), uci.load('luci_statistics') - ]).then(L.bind(function(data) { - var definitions = data[0], - hostname = data[1]; - + ]).then(L.bind(function([definitions, hostname]) { this.opts.host = uci.get('luci_statistics', 'collectd', 'Hostname') || hostname; this.opts.timespan = uci.get('luci_statistics', 'rrdtool', 'default_timespan') || 3600; this.opts.width = uci.get('luci_statistics', 'rrdtool', 'image_width') || 600; @@ -156,14 +153,14 @@ return baseclass.extend({ this.opts.rrasingle = (uci.get('luci_statistics', 'collectd_rrdtool', 'RRASingle') == '1'); this.opts.rramax = (uci.get('luci_statistics', 'collectd_rrdtool', 'RRAMax') == '1'); - graphdefs = {}; + const graphdefs = {}; - var tasks = [ this.scan() ]; + const tasks = [ this.scan() ]; - for (var i = 0; i < definitions.length; i++) { - var m = definitions[i].name.match(/^(.+)\.js$/); + for (let def of definitions) { + const m = def.name.match(/^(.+)\.js$/); - if (definitions[i].type != 'file' || m == null) + if (def.type != 'file' || m == null) continue; tasks.push(L.require('statistics.rrdtool.definitions.' + m[1]).then(L.bind(function(name, def) { @@ -175,30 +172,30 @@ return baseclass.extend({ }, this)); }, - ls: function() { - var dir = this.opts.rrdpath; + ls() { + const dir = this.opts.rrdpath; return L.resolveDefault(fs.list(dir), []).then(function(entries) { - var tasks = []; + const tasks = []; - for (var i = 0; i < entries.length; i++) { - if (entries[i].type != 'directory') + for (let entr of entries) { + if (entr.type != 'directory') continue; - tasks.push(L.resolveDefault(fs.list(dir + '/' + entries[i].name), []).then(L.bind(function(entries) { - var tasks = []; + tasks.push(L.resolveDefault(fs.list(dir + '/' + entr.name), []).then(L.bind(function(entries) { + const tasks = []; - for (var j = 0; j < entries.length; j++) { - if (entries[j].type != 'directory') + for (let dir of entries) { + if (dir.type != 'directory') continue; - tasks.push(L.resolveDefault(fs.list(dir + '/' + this.name + '/' + entries[j].name), []).then(L.bind(function(entries) { + tasks.push(L.resolveDefault(fs.list(dir + '/' + this.name + '/' + dir.name), []).then(L.bind(function(entries) { return Object.assign(this, { entries: entries.filter(function(e) { return e.type == 'file' && e.name.match(/\.rrd$/); }) }); - }, entries[j]))); + }, dir))); } return Promise.all(tasks).then(L.bind(function(entries) { @@ -206,42 +203,42 @@ return baseclass.extend({ entries: entries }); }, this)); - }, entries[i]))); + }, entr))); } return Promise.all(tasks); }); }, - scan: function() { + scan() { return this.ls().then(L.bind(function(entries) { - rrdtree = {}; + const rrdtree = {}; - for (var i = 0; i < entries.length; i++) { - var hostInstance = entries[i].name; + for (let entr of entries) { + const hostInstance = entr.name; rrdtree[hostInstance] = rrdtree[hostInstance] || {}; - for (var j = 0; j < entries[i].entries.length; j++) { - var m = entries[i].entries[j].name.match(/^([^-]+)(?:-(.+))?$/); + for (let jentr of entr.entries) { + const m = jentr.name.match(/^([^-]+)(?:-(.+))?$/); if (!m) continue; - var pluginName = m[1], - pluginInstance = m[2] || ''; + const pluginName = m[1]; + const pluginInstance = m[2] || ''; rrdtree[hostInstance][pluginName] = rrdtree[hostInstance][pluginName] || {}; rrdtree[hostInstance][pluginName][pluginInstance] = rrdtree[hostInstance][pluginName][pluginInstance] || {}; - for (var k = 0; k < entries[i].entries[j].entries.length; k++) { - var m = entries[i].entries[j].entries[k].name.match(/^([^-]+)(?:-(.+))?\.rrd$/); + for (let kentr of jentr.entries) { + const m = kentr.name.match(/^([^-]+)(?:-(.+))?\.rrd$/); if (!m) continue; - var dataType = m[1], - dataInstance = m[2] || ''; + const dataType = m[1]; + const dataInstance = m[2] || ''; rrdtree[hostInstance][pluginName][pluginInstance][dataType] = rrdtree[hostInstance][pluginName][pluginInstance][dataType] || []; rrdtree[hostInstance][pluginName][pluginInstance][dataType].push(dataInstance); @@ -251,18 +248,18 @@ return baseclass.extend({ }, this)); }, - hostInstances: function() { + hostInstances() { return Object.keys(rrdtree).sort(); }, - pluginNames: function(hostInstance) { + pluginNames(hostInstance) { return Object.keys(rrdtree[hostInstance] || {}).sort(); }, - pluginInstances: function(hostInstance, pluginName) { + pluginInstances(hostInstance, pluginName) { return Object.keys((rrdtree[hostInstance] || {})[pluginName] || {}).sort(function(a, b) { - var x = a.match(/^(\d+)\b/), - y = b.match(/^(\d+)\b/); + const x = a.match(/^(\d+)\b/); + const y = b.match(/^(\d+)\b/); if (!x != !y) return !x - !y; @@ -273,40 +270,40 @@ return baseclass.extend({ }); }, - dataTypes: function(hostInstance, pluginName, pluginInstance) { + dataTypes(hostInstance, pluginName, pluginInstance) { return Object.keys(((rrdtree[hostInstance] || {})[pluginName] || {})[pluginInstance] || {}).sort(); }, - dataInstances: function(hostInstance, pluginName, pluginInstance, dataType) { + dataInstances(hostInstance, pluginName, pluginInstance, dataType) { return ((((rrdtree[hostInstance] || {})[pluginName] || {})[pluginInstance] || {})[dataType] || []).sort(); }, - pluginTitle: function(pluginName) { - var def = graphdefs[pluginName]; + pluginTitle(pluginName) { + const def = graphdefs[pluginName]; return (def ? def.title : null) || pluginName; }, - hasDefinition: function(pluginName) { + hasDefinition(pluginName) { return (graphdefs[pluginName] != null); }, - hasInstanceDetails: function(hostInstance, pluginName, pluginInstance) { - var def = graphdefs[pluginName]; + hasInstanceDetails(hostInstance, pluginName, pluginInstance) { + const def = graphdefs[pluginName]; if (!def || typeof(def.rrdargs) != 'function') return false; - var optlist = this._forcelol(def.rrdargs(this, hostInstance, pluginName, pluginInstance, null, false)); + const optlist = this._forcelol(def.rrdargs(this, hostInstance, pluginName, pluginInstance, null, false)); - for (var i = 0; i < optlist.length; i++) - if (optlist[i].detail) + for (let opt of optlist) + if (opt.detail) return true; return false; }, - _mkpath: function(host, plugin, plugin_instance, dtype, data_instance) { - var path = host + '/' + plugin; + _mkpath(host, plugin, plugin_instance, dtype, data_instance) { + let path = host + '/' + plugin; if (plugin_instance != null && plugin_instance != '') path += '-' + plugin_instance; @@ -319,19 +316,19 @@ return baseclass.extend({ return path; }, - mkrrdpath: function(/* ... */) { + mkrrdpath(/* ... */) { return '%s/%s.rrd'.format( this.opts.rrdpath, this._mkpath.apply(this, arguments) ).replace(/[\\:]/g, '\\$&'); }, - _forcelol: function(list) { + _forcelol(list) { return L.isObject(list[0]) ? list : [ list ]; }, - _rrdtool: function(def, rrd, timespan, width, height, cache) { - var cmdline = [ + _rrdtool(def, rrd, timespan, width, height, cache) { + const cmdline = [ 'graph', '-', '-a', 'PNG', '-s', 'NOW-%s'.format(timespan || this.opts.timespan), '-e', 'NOW-15', @@ -339,8 +336,8 @@ return baseclass.extend({ '-h', height || this.opts.height ]; - for (var i = 0; i < def.length; i++) { - var opt = String(def[i]); + for (let d of def) { + let opt = String(d); if (rrd) opt = opt.replace(/\{file\}/g, rrd); @@ -349,7 +346,7 @@ return baseclass.extend({ } if (L.isObject(cache)) { - var key = sfh(cmdline.join('\0')); + const key = sfh(cmdline.join('\0')); if (!cache.hasOwnProperty(key)) cache[key] = fs.exec_direct('/usr/bin/rrdtool', cmdline, 'blob', true); @@ -360,24 +357,24 @@ return baseclass.extend({ return fs.exec_direct('/usr/bin/rrdtool', cmdline, 'blob', true); }, - _generic: function(opts, host, plugin, plugin_instance, dtype, index) { - var defs = [], - gopts = this.opts, - _args = [], - _sources = [], - _stack_neg = [], - _stack_pos = [], - _longest_name = 0, - _has_totals = false; + _generic(opts, host, plugin, plugin_instance, dtype, index) { + const defs = []; + const gopts = this.opts; + let _args = []; + let _sources = []; + let _stack_neg = []; + let _stack_pos = []; + let _longest_name = 0; + let _has_totals = false; /* use the plugin+instance+type as seed for the prng to ensure the same pseudo-random color sequence for each render */ random.seed(sfh([plugin, plugin_instance || '', dtype || ''].join('.'))); function __def(source) { - var inst = source.sname, - rrd = source.rrd, - ds = source.ds || 'value'; + const inst = source.sname; + const rrd = source.rrd; + const ds = source.ds || 'value'; _args.push( 'DEF:%s_avg_raw=%s:%s:AVERAGE'.format(inst, rrd, ds), @@ -398,7 +395,7 @@ return baseclass.extend({ } function __cdef(source) { - var prev; + let prev; if (source.flip) prev = _stack_neg[_stack_neg.length - 1]; @@ -470,7 +467,7 @@ return baseclass.extend({ /* local helper: create line and area statements */ function __line(source) { - var line_color, area_color, legend, variable; + let line_color, area_color, legend, variable; /* find colors: try source, then opts.colors; fall back to random color */ if (typeof(source.color) == 'string') { @@ -508,8 +505,8 @@ return baseclass.extend({ /* local helper: create gprint statements */ function __gprint(source) { - var numfmt = opts.number_format || '%6.1lf', - totfmt = opts.totals_format || '%5.1lf%s'; + const numfmt = opts.number_format || '%6.1lf'; + const totfmt = opts.totals_format || '%5.1lf%s'; /* don't include MIN if rrasingle is enabled */ if (!gopts.rrasingle) @@ -535,7 +532,7 @@ return baseclass.extend({ */ /* find data types */ - var data_types = dtype ? [ dtype ] : (opts.data.types || []); + const data_types = dtype ? [ dtype ] : (opts.data.types || []); if (!(dtype || opts.data.types)) { if (L.isObject(opts.data.instances)) @@ -546,45 +543,45 @@ return baseclass.extend({ } /* iterate over data types */ - for (var i = 0; i < data_types.length; i++) { + for (let dt of data_types) { /* find instances */ - var data_instances; + let data_instances; if (!opts.per_instance) { - if (L.isObject(opts.data.instances) && Array.isArray(opts.data.instances[data_types[i]])) - data_instances = opts.data.instances[data_types[i]]; + if (L.isObject(opts.data.instances) && Array.isArray(opts.data.instances[dt])) + data_instances = opts.data.instances[dt]; else - data_instances = this.dataInstances(host, plugin, plugin_instance, data_types[i]); + data_instances = this.dataInstances(host, plugin, plugin_instance, dt); } if (!Array.isArray(data_instances) || data_instances.length == 0) data_instances = [ '' ]; /* iterate over data instances */ - for (var j = 0; j < data_instances.length; j++) { + for (let di of data_instances) { /* construct combined data type / instance name */ - var dname = data_types[i]; + let dname = dt; - if (data_instances[j].length) - dname += '_' + data_instances[j]; + if (di.length) + dname += '_' + di; /* find sources */ - var data_sources = [ 'value' ]; + let data_sources = [ 'value' ]; if (L.isObject(opts.data.sources)) { if (Array.isArray(opts.data.sources[dname])) data_sources = opts.data.sources[dname]; - else if (Array.isArray(opts.data.sources[data_types[i]])) - data_sources = opts.data.sources[data_types[i]]; + else if (Array.isArray(opts.data.sources[dt])) + data_sources = opts.data.sources[dt]; } /* iterate over data sources */ - for (var k = 0; k < data_sources.length; k++) { - var dsname = data_types[i] + '_' + data_instances[j].replace(/\W/g, '_') + '_' + data_sources[k], - altname = data_types[i] + '__' + data_sources[k]; + for (let ds of data_sources) { + const dsname = dt + '_' + di.replace(/\W/g, '_') + '_' + ds; + const altname = dt + '__' + ds; /* find datasource options */ - var dopts = {}; + let dopts = {}; if (L.isObject(opts.data.options)) { if (L.isObject(opts.data.options[dsname])) @@ -593,13 +590,13 @@ return baseclass.extend({ dopts = opts.data.options[altname]; else if (L.isObject(opts.data.options[dname])) dopts = opts.data.options[dname]; - else if (L.isObject(opts.data.options[data_types[i]])) - dopts = opts.data.options[data_types[i]]; + else if (L.isObject(opts.data.options[dt])) + dopts = opts.data.options[dt]; } /* store values */ - var source = { - rrd: dopts.rrd || this.mkrrdpath(host, plugin, plugin_instance, data_types[i], data_instances[j]), + const source = { + rrd: dopts.rrd || this.mkrrdpath(host, plugin, plugin_instance, dt, di), color: dopts.color || colors.asString(colors.random()), flip: dopts.flip || false, total: dopts.total || false, @@ -608,12 +605,12 @@ return baseclass.extend({ noarea: dopts.noarea || false, noavg: dopts.noavg || false, title: dopts.title || null, - weight: dopts.weight || (dopts.negweight ? -+data_instances[j] : null) || (dopts.posweight ? +data_instances[j] : null) || null, - ds: data_sources[k], - type: data_types[i], - instance: data_instances[j], + weight: dopts.weight || (dopts.negweight ? -+di : null) || (dopts.posweight ? +di : null) || null, + ds: ds, + type: dt, + instance: di, index: _sources.length + 1, - sname: String(_sources.length + 1) + data_types[i] + sname: String(_sources.length + 1) + dt }; _sources.push(source); @@ -637,17 +634,17 @@ return baseclass.extend({ /* if per_instance is enabled then find all instances from the first datasource in diagram */ /* if per_instance is disabled then use an empty pseudo instance and use model provided values */ - var instances = [ '' ]; + let instances = [ '' ]; if (opts.per_instance) instances = this.dataInstances(host, plugin, plugin_instance, _sources[0].type); /* iterate over instances */ - for (var i = 0; i < instances.length; i++) { + for (let inst of instances) { /* store title and vlabel */ _args.push( - '-t', i18n.title(host, plugin, plugin_instance, _sources[0].type, instances[i], opts.title), - '-v', i18n.label(host, plugin, plugin_instance, _sources[0].type, instances[i], opts.vlabel) + '-t', i18n.title(host, plugin, plugin_instance, _sources[0].type, inst, opts.title), + '-v', i18n.label(host, plugin, plugin_instance, _sources[0].type, inst, opts.vlabel) ); if (opts.y_max) @@ -667,44 +664,44 @@ return baseclass.extend({ /* store additional rrd options */ if (Array.isArray(opts.rrdopts)) - for (var j = 0; j < opts.rrdopts.length; j++) - _args.push(String(opts.rrdopts[j])); + for (let opt of opts.rrdopts) + _args.push(String(opt)); /* sort sources */ _sources.sort(function(a, b) { - var x = a.weight || a.index || 0, - y = b.weight || b.index || 0; + const x = a.weight || a.index || 0; + const y = b.weight || b.index || 0; return +x - +y; }); /* define colors in order */ if (opts.ordercolor) - for (var j = 0; j < _sources.length; j++) + for (let j = 0; j < _sources.length; j++) _sources[j].color = colors.defined(j); /* create DEF statements for each instance */ - for (var j = 0; j < _sources.length; j++) { + for (let src of _sources) { /* fixup properties for per instance mode... */ if (opts.per_instance) { - _sources[j].instance = instances[i]; - _sources[j].rrd = this.mkrrdpath(host, plugin, plugin_instance, _sources[j].type, instances[i]); + src.instance = inst; + src.rrd = this.mkrrdpath(host, plugin, plugin_instance, src.type, inst); } - __def(_sources[j]); + __def(src); } /* create CDEF required for calculating totals */ __cdef_totals(); /* create CDEF statements for each instance in reversed order */ - for (var j = _sources.length - 1; j >= 0; j--) + for (let j = _sources.length - 1; j >= 0; j--) __cdef(_sources[j]); /* create LINE1, AREA and GPRINT statements for each instance */ - for (var j = 0; j < _sources.length; j++) { - __line(_sources[j]); - __gprint(_sources[j]); + for (let src of _sources) { + __line(src); + __gprint(src); } /* push arg stack to definition list */ @@ -719,28 +716,28 @@ return baseclass.extend({ return defs; }, - render: function(plugin, plugin_instance, is_index, hostname, timespan, width, height, cache) { - var pngs = []; + render(plugin, plugin_instance, is_index, hostname, timespan, width, height, cache) { + const pngs = []; /* check for a whole graph handler */ - var def = graphdefs[plugin]; + const def = graphdefs[plugin]; if (def && typeof(def.rrdargs) == 'function') { /* temporary image matrix */ - var _images = []; + const _images = []; /* get diagram definitions */ - var optlist = this._forcelol(def.rrdargs(this, hostname, plugin, plugin_instance, null, is_index)); - for (var i = 0; i < optlist.length; i++) { - var opt = optlist[i]; + const optlist = this._forcelol(def.rrdargs(this, hostname, plugin, plugin_instance, null, is_index)); + for (let i = 0; i < optlist.length; i++) { + const opt = optlist[i]; if (!is_index || !opt.detail) { _images[i] = []; /* get diagram definition instances */ - var diagrams = this._generic(opt, hostname, plugin, plugin_instance, null, i); + const diagrams = this._generic(opt, hostname, plugin, plugin_instance, null, i); /* render all diagrams */ - for (var j = 0; j < diagrams.length; j++) { + for (let j = 0; j < diagrams.length; j++) { /* exec */ _images[i][j] = this._rrdtool(diagrams[j], null, timespan, width, height, cache); } @@ -748,8 +745,8 @@ return baseclass.extend({ } /* remember images - XXX: fixme (will cause probs with asymmetric data) */ - for (var y = 0; y < _images[0].length; y++) - for (var x = 0; x < _images.length; x++) + for (let y = 0; y < _images[0].length; y++) + for (let x = 0; x < _images.length; x++) pngs.push(_images[x][y]); } diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/apcups.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/apcups.js index c03e38cf57..2a5204904e 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/apcups.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/apcups.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('APC UPS'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var rv = []; + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const rv = []; /* * Types and instances supported by APC UPS @@ -15,15 +15,15 @@ return baseclass.extend({ * e.g. ups_inst['voltage'] -> [ 'input', 'battery' ] */ - var ups_types = graph.dataTypes(host, plugin, plugin_instance), - ups_inst = {}; + const ups_types = graph.dataTypes(host, plugin, plugin_instance); + const ups_inst = {}; - for (var i = 0; i < ups_types.length; i++) - ups_inst[ups_types[i]] = graph.dataInstances(host, plugin, plugin_instance, ups_types[i]); + for (let upst of ups_types) + ups_inst[upst] = graph.dataInstances(host, plugin, plugin_instance, upst); /* Check if hash table or array is empty or nil-filled */ function empty(t) { - for (var k in t) + for (let k in t) if (t[k] != null) return false; @@ -34,12 +34,12 @@ return baseclass.extend({ /* supported and available to the plugin and UPS. */ function add_supported(t, defs) { - var def_inst = defs['data']['instances']; + const def_inst = defs['data']['instances']; if (L.isObject(def_inst)) { - for (var k in def_inst) { + for (let k in def_inst) { if (ups_types.filter(function(t) { return t == k }).length) { - for (var i = def_inst[k].length - 1; i >= 0; i--) + for (let i = def_inst[k].length - 1; i >= 0; i--) if (!ups_inst[k].filter(function(n) { return n == def_inst[k][i] }).length) def_inst[k].splice(i, 1); @@ -62,7 +62,7 @@ return baseclass.extend({ /* Graph definitions for APC UPS measurements MUST use only 'instances': */ /* e.g. instances = { voltage = { "input", "output" } } */ - var voltagesdc = { + const voltagesdc = { title: "%H: Voltages on APC UPS - Battery", vlabel: "Volts DC", alt_autoscale: true, @@ -78,7 +78,7 @@ return baseclass.extend({ }; add_supported(rv, voltagesdc); - var voltagesac = { + const voltagesac = { title: "%H: Voltages on APC UPS - AC", vlabel: "Volts AC", alt_autoscale: true, @@ -95,7 +95,7 @@ return baseclass.extend({ }; add_supported(rv, voltagesac); - var percentload = { + const percentload = { title: "%H: Load on APC UPS ", vlabel: "Percent", y_min: "0", @@ -112,7 +112,7 @@ return baseclass.extend({ }; add_supported(rv, percentload); - var charge_percent = { + const charge_percent = { title: "%H: Battery charge on APC UPS ", vlabel: "Percent", y_min: "0", @@ -129,7 +129,7 @@ return baseclass.extend({ }; add_supported(rv, charge_percent); - var temperature = { + const temperature = { title: "%H: Battery temperature on APC UPS ", vlabel: "\u00b0C", number_format: "%5.1lf\u00b0C", @@ -143,7 +143,7 @@ return baseclass.extend({ }; add_supported(rv, temperature); - var timeleft = { + const timeleft = { title: "%H: Time left on APC UPS ", vlabel: "Minutes", number_format: "%.1lfm", @@ -158,7 +158,7 @@ return baseclass.extend({ }; add_supported(rv, timeleft); - var frequency = { + const frequency = { title: "%H: Incoming line frequency on APC UPS ", vlabel: "Hz", number_format: "%5.0lfhz", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/chrony.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/chrony.js index 4730adfbd8..2064c7d300 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/chrony.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/chrony.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('Chrony'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var offset = { + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const offset = { title: "%H: Chrony - time offset", vlabel: "Time offset (ms)", number_format: "%9.3lf ms", @@ -32,7 +32,7 @@ return baseclass.extend({ } }; - var stratum = { + const stratum = { title: "%H: Chrony - clock stratum", vlabel: "Clock stratum", number_format: "%3.1lf%S", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/conntrack.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/conntrack.js index 35951dffba..1f757cf599 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/conntrack.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/conntrack.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Conntrack'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var entries = { + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const entries = { title: "%H: Conntrack entries", vlabel: "Count", number_format: "%5.0lf", @@ -28,7 +28,7 @@ return baseclass.extend({ } }; - var percent = { + const percent = { title: "%H: Conntrack usage", vlabel: "Percent", number_format: "%5.1lf%%", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/contextswitch.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/contextswitch.js index 8dc3cc75fb..ef6f0a81dc 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/contextswitch.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/contextswitch.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Context Switches'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: Context switches", alt_autoscale: true, diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpu.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpu.js index bbd0e47642..8f27a69dcb 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpu.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpu.js @@ -7,18 +7,18 @@ return baseclass.extend({ title: _('Processor'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var p = []; + rrdargs(graph, host, plugin, plugin_instance, dtype) { + let p = []; - var title = "%H: Processor usage"; + let title = "%H: Processor usage"; if (plugin_instance != '') title = "%H: Processor usage on core #%pi"; - var show_idle = uci.get("luci_statistics", "collectd_cpu", "ShowIdle") == "1" ? true : false; + const show_idle = uci.get("luci_statistics", "collectd_cpu", "ShowIdle") == "1" ? true : false; if (uci.get("luci_statistics", "collectd_cpu", "ReportByState") == "1") { - var cpu = { + const cpu = { title: title, y_min: "0", alt_autoscale_max: true, @@ -74,7 +74,7 @@ return baseclass.extend({ } }; - var percent = { + const percent = { title: title, y_min: "0", y_max: "2", @@ -131,12 +131,12 @@ return baseclass.extend({ } }; - var types = graph.dataTypes(host, plugin, plugin_instance); + const types = graph.dataTypes(host, plugin, plugin_instance); - for (var i = 0; i < types.length; i++) - if (types[i] == 'cpu') + for (let type of types) + if (type == 'cpu') p.push(cpu); - else if (types[i] == 'percent') + else if (type == 'percent') p.push(percent); } else { diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpufreq.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpufreq.js index a2cc1309e7..98ddf71a38 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpufreq.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/cpufreq.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('CPU Frequency'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var cpufreq = { + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const cpufreq = { title: "%H: Processor frequency - core %pi", alt_autoscale: true, vlabel: "Frequency (Hz)", @@ -22,7 +22,7 @@ return baseclass.extend({ }; if (uci.get("luci_statistics", "collectd_cpufreq", "ExtraItems")) { - var transitions = { + const transitions = { detail: true, title: "%H: Frequency transitions - core %pi", alt_autoscale: true, @@ -38,7 +38,7 @@ return baseclass.extend({ } }; - var percentage = { + const percentage = { detail: true, title: "%H: Frequency distribution - core %pi", alt_autoscale: true, diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/curl.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/curl.js index 718aa7bbb6..798912de08 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/curl.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/curl.js @@ -9,7 +9,7 @@ return baseclass.extend({ title: _('cUrl'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: cUrl Response Time for #%pi", y_min: "0", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/df.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/df.js index 9790788b88..2be92a7057 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/df.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/df.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Disk Space Usage'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var df_complex = { + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const df_complex = { title: "%H: Disk space usage on %pi", vlabel: "Bytes", number_format: "%5.1lf%sB", @@ -39,7 +39,7 @@ return baseclass.extend({ } }; - var percent_bytes = { + const percent_bytes = { title: "%H: Disk space usage on %pi", vlabel: "Percent", number_format: "%5.2lf %%", @@ -71,13 +71,13 @@ return baseclass.extend({ } }; - var types = graph.dataTypes(host, plugin, plugin_instance); - var p = []; + const types = graph.dataTypes(host, plugin, plugin_instance); + const p = []; - for (var i = 0; i < types.length; i++) - if (types[i] == 'percent_bytes') + for (let type of types) + if (type == 'percent_bytes') p.push(percent_bytes); - else if (types[i] == 'df_complex') + else if (type == 'df_complex') p.push(df_complex); return p; diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dhcpleases.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dhcpleases.js index b54a0af27e..54e6729b58 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dhcpleases.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dhcpleases.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('DHCP Leases'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: DHCP leases", alt_autoscale_max: true, diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/disk.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/disk.js index 12ed9568f6..e3724e5432 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/disk.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/disk.js @@ -9,7 +9,7 @@ return baseclass.extend({ title: _('Disk Usage'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return [{ title: "%H: Disk I/O operations on %pi", vlabel: "Operations/s", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dns.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dns.js index 347bd23317..1cc98760b9 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dns.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dns.js @@ -9,8 +9,8 @@ return baseclass.extend({ title: _('DNS'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var traffic = { + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const traffic = { title: "%H: DNS traffic", vlabel: "Bit/s", @@ -35,7 +35,7 @@ return baseclass.extend({ } }; - var opcode_query = { + const opcode_query = { title: "%H: DNS Opcode Query", vlabel: "Queries/s", data: { @@ -53,7 +53,7 @@ return baseclass.extend({ } }; - var qtype = { + const qtype = { title: "%H: DNS QType", vlabel: "Queries/s", data: { diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dsl.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dsl.js index 23ae3a5380..7f63683c04 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dsl.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/dsl.js @@ -5,9 +5,9 @@ return L.Class.extend({ title: _("DSL"), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var g = []; - var dtypes = graph.dataTypes(host, plugin, plugin_instance); + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const g = []; + const dtypes = graph.dataTypes(host, plugin, plugin_instance); const d_uptime = { title: _("%H: Line uptime on %pi"), @@ -416,23 +416,23 @@ return L.Class.extend({ g.push(d_bitrate); } if (dtypes.includes("errors")) { - var dinsts = graph.dataInstances(host, plugin, plugin_instance, "errors"); - var e = 0, - c = 0, - r = 0; - for (var i = 0; i < dinsts.length; i++) { + const dinsts = graph.dataInstances(host, plugin, plugin_instance, "errors"); + let e = 0; + let c = 0; + let r = 0; + for (let dinst of dinsts) { if ( !e && - (dinsts[i].indexOf("es") > -1 || - dinsts[i].indexOf("loss") > -1 || - dinsts[i].indexOf("uas") > -1) + (dinst.indexOf("es") > -1 || + dinst.indexOf("loss") > -1 || + dinst.indexOf("uas") > -1) ) { e = g.push(d_errors); - } else if (!c && dinsts[i].indexOf("crc") > -1) { + } else if (!c && dinst.indexOf("crc") > -1) { c = g.push(d_crc); } else if ( !r && - (dinsts[i].indexOf("rx_") == 0 || dinsts[i].indexOf("tx_") == 0) + (dinst.indexOf("rx_") == 0 || dinst.indexOf("tx_") == 0) ) { r = g.push(d_retx); } diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/entropy.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/entropy.js index b4f6f05948..247047b74b 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/entropy.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/entropy.js @@ -9,7 +9,7 @@ return baseclass.extend({ title: _('Entropy'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: Available entropy", vlabel: "bits", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/interface.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/interface.js index ccf1849243..ebdefeccc9 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/interface.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/interface.js @@ -6,11 +6,11 @@ return baseclass.extend({ title: _('Interfaces'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { /* * traffic diagram */ - var traffic = { + const traffic = { /* draw this diagram for each plugin instance */ per_instance: true, @@ -45,7 +45,7 @@ return baseclass.extend({ /* * packet diagram */ - var packets = { + const packets = { /* draw this diagram for each plugin instance */ per_instance: true, diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ip6tables.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ip6tables.js index c956c19881..56fe33bc32 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ip6tables.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ip6tables.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Firewall (IPv6)'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return [{ title: "%H: Firewall: Processed bytes in %pi", vlabel: "Bytes/s", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ipstatistics.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ipstatistics.js index 73bd16af11..144060971e 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ipstatistics.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ipstatistics.js @@ -6,9 +6,9 @@ return baseclass.extend({ title: _('IP-Statistics'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { - var traffic = { + const traffic = { title: "%H: IPv4 and IPv6 Comparison", vlabel: "Bytes/s", number_format: "%5.1lf%sB/s", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/iptables.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/iptables.js index 69a3a87eb7..6b146a1c43 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/iptables.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/iptables.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Firewall'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return [{ title: "%H: Firewall: Processed bytes in %pi", vlabel: "Bytes/s", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/irq.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/irq.js index 150bc497f3..7d968a5d38 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/irq.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/irq.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Interrupts'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: Interrupts", vlabel: "Issues/s", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/iwinfo.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/iwinfo.js index 9656f12e11..ad94ba0745 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/iwinfo.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/iwinfo.js @@ -6,11 +6,11 @@ return baseclass.extend({ title: _('Wireless'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { /* * signal/noise diagram */ - var snr = { + const snr = { title: "%H: Signal and noise on %pi", detail: true, vlabel: "dBm", @@ -35,7 +35,7 @@ return baseclass.extend({ /* * signal quality diagram */ - var quality = { + const quality = { title: "%H: Signal quality on %pi", vlabel: "Quality", number_format: "%3.0lf", @@ -54,7 +54,7 @@ return baseclass.extend({ /* * phy rate diagram */ - var bitrate = { + const bitrate = { title: "%H: Average phy rate on %pi", detail: true, vlabel: "Mbit/s", @@ -73,7 +73,7 @@ return baseclass.extend({ /* * associated stations */ - var stations = { + const stations = { title: "%H: Associated stations on %pi", detail: true, vlabel: "Stations", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/load.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/load.js index f3af09895d..d59ff42ea4 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/load.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/load.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('System Load'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: Load", vlabel: "Load", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/memory.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/memory.js index 960d98c108..08621d152e 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/memory.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/memory.js @@ -10,11 +10,11 @@ return baseclass.extend({ title: _('Memory'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var p = []; - var hide_free = uci.get("luci_statistics", "collectd_memory", "HideFree") == "1" ? true : false; + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const p = []; + const hide_free = uci.get("luci_statistics", "collectd_memory", "HideFree") == "1" ? true : false; - var memory = { + const memory = { title: "%H: Memory usage", vlabel: "MB", number_format: "%5.1lf%s", @@ -51,7 +51,7 @@ return baseclass.extend({ } }; - var percent = { + const percent = { title: "%H: Memory usage", vlabel: "Percent", number_format: "%5.1lf%%", @@ -87,12 +87,12 @@ return baseclass.extend({ } }; - var types = graph.dataTypes(host, plugin, plugin_instance); + const types = graph.dataTypes(host, plugin, plugin_instance); - for (var i = 0; i < types.length; i++) - if (types[i] == 'percent') + for (let type of types) + if (type == 'percent') p.push(percent); - else if (types[i] == 'memory') + else if (type == 'memory') p.push(memory); return p; diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/netlink.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/netlink.js index 3bf3756b04..a2cd39bdc2 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/netlink.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/netlink.js @@ -6,11 +6,11 @@ return baseclass.extend({ title: _('Netlink'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { /* * traffic diagram */ - var traffic = { + const traffic = { title: "%H: Netlink - Transfer on %pi", vlabel: "Bytes/s", @@ -42,7 +42,7 @@ return baseclass.extend({ /* * packet diagram */ - var packets = { + const packets = { title: "%H: Netlink - Packets on %pi", vlabel: "Packets/s", detail: true, @@ -123,7 +123,7 @@ return baseclass.extend({ /* * multicast diagram */ - var multicast = { + const multicast = { title: "%H: Netlink - Multicast on %pi", vlabel: "Packets/s", detail: true, @@ -147,7 +147,7 @@ return baseclass.extend({ /* * collision diagram */ - var collisions = { + const collisions = { title: "%H: Netlink - Collisions on %pi", vlabel: "Collisions/s", detail: true, @@ -171,7 +171,7 @@ return baseclass.extend({ /* * error diagram */ - var errors = { + const errors = { title: "%H: Netlink - Errors on %pi", vlabel: "Errors/s", detail: true, diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/nut.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/nut.js index dbd25f6c07..9c41766ade 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/nut.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/nut.js @@ -6,9 +6,9 @@ return baseclass.extend({ title: _('UPS'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var definitions = []; - var instances; + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const definitions = []; + let instances; function find_instances(dtype, wanted) { var matching = graph.dataInstances(host, plugin, plugin_instance, dtype).filter(function(instance) { diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/olsrd.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/olsrd.js index cafe2ac70e..9149a5fdb1 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/olsrd.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/olsrd.js @@ -9,8 +9,8 @@ return baseclass.extend({ title: _('OLSRd'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var g = []; + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const g = []; if (plugin_instance == "routes") { g.push({ @@ -75,15 +75,15 @@ return baseclass.extend({ } }); - var instances = graph.dataInstances(host, plugin, plugin_instance, "signal_quality").sort(); + const instances = graph.dataInstances(host, plugin, plugin_instance, "signal_quality").sort(); /* define one diagram per host, containing the rx and lq values */ - for (var i = 0; i < instances.length; i += 2) { - var dsn1 = "signal_quality_%s_value".format(instances[i].replace(/\W+/g, '_')), - dsn2 = "signal_quality_%s_value".format(instances[i+1].replace(/\W+/g, '_')), - host = instances[i].match(/^[^-]+-([^-]+)-.+$/), - host = host ? host[1] : 'avg', - opts = {}; + for (let i = 0; i < instances.length; i += 2) { + const dsn1 = "signal_quality_%s_value".format(instances[i].replace(/\W+/g, '_')); + const dsn2 = "signal_quality_%s_value".format(instances[i+1].replace(/\W+/g, '_')); + let host = instances[i].match(/^[^-]+-([^-]+)-.+$/); + host = host ? host[1] : 'avg'; + const opts = {}; opts[dsn1] = { color: "00ff00", title: "LQ (%s)".format(host) }; opts[dsn2] = { color: "0000ff", title: "NLQ (%s)".format(host), flip: true }; diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/openvpn.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/openvpn.js index fea570f8d3..94525e79b4 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/openvpn.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/openvpn.js @@ -6,11 +6,10 @@ return baseclass.extend({ title: _('OpenVPN'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var inst = plugin_instance.replace(/^openvpn\.(.+)\.status$/, '$1'); + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const inst = plugin_instance.replace(/^openvpn\.(.+)\.status$/, '$1'); const types = graph.dataTypes(host, plugin, plugin_instance); const rv = []; - let instances; const typeinstances = graph.dataInstances(host, plugin, plugin_instance, "if_octets").sort(); function find_instances(dtype, wanted) { @@ -20,7 +19,7 @@ return baseclass.extend({ return matching.length ? { [dtype]: matching } : null; } - if ((instances = find_instances('if_octets', ['overhead', 'traffic'])) !== null) { + if (find_instances('if_octets', ['overhead', 'traffic']) !== null) { rv.push({ title: "%%H: OpenVPN \"%s\" - Traffic".format(inst), vlabel: "Bytes/s", @@ -83,7 +82,7 @@ return baseclass.extend({ } }); } else { - console.error('Source "value" not found in any user instances:', sources); + console.error('Source "value" not found in any user instances.'); } } diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ping.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ping.js index 335e976794..0a30f5bc62 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ping.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ping.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Ping'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var ping = { + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const ping = { title: "%H: ICMP Round Trip Time", vlabel: "ms", number_format: "%5.1lf ms", @@ -25,7 +25,7 @@ return baseclass.extend({ } }; - var droprate = { + const droprate = { title: "%H: ICMP Drop Rate", vlabel: "%", y_min: "0", @@ -44,7 +44,7 @@ return baseclass.extend({ } }; - var stddev = { + const stddev = { title: "%H: ICMP Standard Deviation", vlabel: "ms", y_min: "0", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/processes.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/processes.js index 9087b8e33c..9f5a7c4e8a 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/processes.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/processes.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Processes'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { if (plugin_instance == "") { return { title: "%H: Processes", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js index f612e39f6b..f4d9c484a5 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sensors.js @@ -6,9 +6,9 @@ return baseclass.extend({ title: _('Sensors'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var rv = []; - var types = graph.dataTypes(host, plugin, plugin_instance); + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const rv = []; + const types = graph.dataTypes(host, plugin, plugin_instance); if (types.indexOf('temperature') > -1) { rv.push({ diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/snmp6.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/snmp6.js index 27e47d2ac0..1852863202 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/snmp6.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/snmp6.js @@ -6,9 +6,9 @@ return baseclass.extend({ title: _('SNMP6'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { - var traffic = { + const traffic = { title: "%H: IPv6 on %pi", vlabel: "Bytes/s", @@ -34,7 +34,7 @@ return baseclass.extend({ } }; - var mcast_traffic = { + const mcast_traffic = { title: "%H: IPv6 Multicast-Traffic on %pi", vlabel: "Bytes/s", @@ -61,7 +61,7 @@ return baseclass.extend({ }; - var bcast_traffic = { + const bcast_traffic = { title: "%H: IPv6 Broadcast-Traffic on %pi", vlabel: "Bytes/s", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/splash_leases.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/splash_leases.js index 33df893f86..c032f1411a 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/splash_leases.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/splash_leases.js @@ -9,7 +9,7 @@ return baseclass.extend({ title: _('Splash Leases'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: Splash Leases", vlabel: "Active Clients", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sqm.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sqm.js index bde179602b..d8de5e86c3 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sqm.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sqm.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('SQM'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var overview = { + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const overview = { per_instance: false, title: "%H: SQM qdisc %pi Overview", rrdopts: [ "--logarithmic" ], diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sqmcake.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sqmcake.js index a45c43af44..3a4e296e93 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sqmcake.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/sqmcake.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('SQM-Cake'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { - var tindrops = { + rrdargs(graph, host, plugin, plugin_instance, dtype) { + const tindrops = { per_instance: true, title: "%H: CAKE %pi %di Drops/s & Backlog", vlabel: "Bytes & Drops/s", @@ -25,7 +25,7 @@ return baseclass.extend({ } }; - var tinlatency = { + const tinlatency = { per_instance: true, title: "%H: CAKE %pi %di Latency", vlabel: "ms", @@ -42,7 +42,7 @@ return baseclass.extend({ } }; - var tinflows = { + const tinflows = { per_instance: true, title: "%H: CAKE %pi %di Flow Counts", vlabel: "Flows", @@ -58,7 +58,7 @@ return baseclass.extend({ } }; - var tinbytes = { + const tinbytes = { per_instance: true, title: "%H: CAKE %pi %di Traffic", vlabel: "Kb/s", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/tcpconns.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/tcpconns.js index 626e2c64bc..d3634bb14b 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/tcpconns.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/tcpconns.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('TCP Connections'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: TCP connections to port %pi", vlabel: "Connections/s", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/thermal.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/thermal.js index a94c83bdf5..bf87da95d5 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/thermal.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/thermal.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Thermal'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: Temperature of %pi", alt_autoscale: true, diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/uptime.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/uptime.js index 7a8d4b250a..8012633726 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/uptime.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/uptime.js @@ -14,7 +14,7 @@ You may obtain a copy of the License at return baseclass.extend({ title: _('Uptime'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: Uptime", vlabel: "seconds", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/users.js b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/users.js index 06921a3f76..3a58356bc3 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/users.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/users.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Users'), - rrdargs: function(graph, host, plugin, plugin_instance, dtype) { + rrdargs(graph, host, plugin, plugin_instance, dtype) { return { title: "%H: Users (console logins)", vlabel: "count", diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/collectd.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/collectd.js index dd045ebde5..85dbbf4c24 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/collectd.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/collectd.js @@ -7,18 +7,16 @@ 'require form'; return view.extend({ - load: function() { + load() { return Promise.all([ fs.list('/usr/lib/collectd'), fs.list('/usr/share/luci/statistics/plugins'), uci.load('luci_statistics') - ]).then(function(data) { - var installed = data[0], - plugins = data[1], - tasks = []; + ]).then(function([installed, plugins]) { + const tasks = []; - for (var i = 0; i < plugins.length; i++) { - tasks.push(fs.read_direct('/usr/share/luci/statistics/plugins/' + plugins[i].name, 'json').then(L.bind(function(name, spec) { + for (let plugin of plugins) { + tasks.push(fs.read_direct('/usr/share/luci/statistics/plugins/' + plugin.name, 'json').then(L.bind(function(name, spec) { return L.resolveDefault(L.require('view.statistics.plugins.' + name)).then(function(form) { if (!uci.get('luci_statistics', 'collectd_' + name)) uci.add('luci_statistics', 'statistics', 'collectd_' + name); @@ -30,18 +28,18 @@ return view.extend({ installed: installed.filter(function(e) { return e.name == name + '.so' }).length > 0 }; }); - }, this, plugins[i].name.replace(/\.json$/, '')))); + }, this, plugin.name.replace(/\.json$/, '')))); } return Promise.all(tasks); }); }, - render: function(plugins) { - var m, s, o, enabled; + render(plugins) { + let m, s, o, enabled; - for (var i = 0; i < plugins.length; i++) - plugins[plugins[i].name] = plugins[i]; + for (let plugin of plugins) + plugins[plugin.name] = plugin; m = new form.Map('luci_statistics', _('Collectd Settings')); m.tabbed = true; @@ -82,21 +80,21 @@ return view.extend({ o.optional = true; o.depends('Hostname', ''); - var groupNames = [ + let groupNames = [ 'general', _('General plugins'), 'network', _('Network plugins'), 'output', _('Output plugins') ]; - for (var i = 0; i < groupNames.length; i += 2) { + for (let i = 0; i < groupNames.length; i += 2) { s = m.section(form.GridSection, 'statistics_' + groupNames[i], groupNames[i + 1]); s.cfgsections = L.bind(function(category) { return this.map.data.sections('luci_statistics', 'statistics') .map(function(s) { return s['.name'] }) .filter(function(section_id) { - var name = section_id.replace(/^collectd_/, ''), - plugin = plugins[name]; + const name = section_id.replace(/^collectd_/, ''); + const plugin = plugins[name]; return (section_id.indexOf('collectd_') == 0 && plugin != null && plugin.installed && plugin.spec.category == category); @@ -104,8 +102,8 @@ return view.extend({ }, s, groupNames[i]); s.sectiontitle = function(section_id) { - var name = section_id.replace(/^collectd_/, ''), - plugin = plugins[name]; + const name = section_id.replace(/^collectd_/, ''); + const plugin = plugins[name]; return plugin ? plugin.spec.title : name }; @@ -114,7 +112,7 @@ return view.extend({ enabled.editable = true; enabled.modalonly = false; enabled.renderWidget = function(section_id, option_index, cfgvalue) { - var widget = form.Flag.prototype.renderWidget.apply(this, [section_id, option_index, cfgvalue]); + const widget = form.Flag.prototype.renderWidget.apply(this, [section_id, option_index, cfgvalue]); widget.querySelector('input[type="checkbox"]').addEventListener('click', L.bind(function(section_id, plugin, ev) { if (ev.target.checked && plugin && plugin.form.addFormOptions) @@ -128,27 +126,27 @@ return view.extend({ o.width = '50%'; o.modalonly = false; o.textvalue = function(section_id) { - var name = section_id.replace(/^collectd_/, ''), - section = uci.get('luci_statistics', section_id), - plugin = plugins[name]; + const name = section_id.replace(/^collectd_/, ''); + const section = uci.get('luci_statistics', section_id); + const plugin = plugins[name]; if (section.enable != '1') return E('em', {}, [_('Plugin is disabled')]); - var summary = plugin ? plugin.form.configSummary(section) : null; + const summary = plugin ? plugin.form.configSummary(section) : null; return summary || E('em', _('none')); }; s.modaltitle = function(section_id) { - var name = section_id.replace(/^collectd_/, ''), - plugin = plugins[name]; + const name = section_id.replace(/^collectd_/, ''); + const plugin = plugins[name]; return plugin ? plugin.form.title : null; }; s.addModalOptions = function(s) { - var name = s.section.replace(/^collectd_/, ''), - plugin = plugins[name]; + const name = s.section.replace(/^collectd_/, ''); + const plugin = plugins[name]; if (!plugin) return; @@ -157,7 +155,7 @@ return view.extend({ plugin.form.addFormOptions(s); - var opt = s.children.filter(function(o) { return o.option == 'enable' })[0]; + const opt = s.children.filter(function(o) { return o.option == 'enable' })[0]; if (opt) opt.cfgvalue = function(section_id, set_value) { if (arguments.length == 2) @@ -168,10 +166,10 @@ return view.extend({ }; s.renderRowActions = function(section_id) { - var name = section_id.replace(/^collectd_/, ''), - plugin = plugins[name]; + const name = section_id.replace(/^collectd_/, ''); + const plugin = plugins[name]; - var trEl = this.super('renderRowActions', [ section_id, _('Configure…') ]); + const trEl = this.super('renderRowActions', [ section_id, _('Configure…') ]); if (!plugin || !plugin.form.addFormOptions) dom.content(trEl, null); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js index 479dcbcbbc..e85ca69c94 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js @@ -11,11 +11,11 @@ var pollFn = null, activeInstance = null; return view.extend({ - load: function() { + load() { return rrdtool.load(); }, - updatePluginTab: function(host, span, time, ev) { + updatePluginTab(host, span, time, ev) { var container = ev.target, width = Math.max(200, container.offsetWidth - 100), plugin = ev.detail.tab, @@ -75,7 +75,7 @@ return view.extend({ 'data-plugin': plugin, 'data-plugin-instance': plugin_instance, 'data-is-index': i || render_instances.length == 1 ? null : true, - 'cbi-tab-active': function(ev) { activeInstance = ev.target.getAttribute('data-plugin-instance') } + 'cbi-tab-active'(ev) { activeInstance = ev.target.getAttribute('data-plugin-instance') } }, blobs.map(function(blob) { return E('img', { 'src': URL.createObjectURL(new Blob([blob], { type: 'image/png' })) @@ -90,7 +90,7 @@ return view.extend({ }); }, - updateGraphs: function(host, span, time, container, ev) { + updateGraphs(host, span, time, container, ev) { var plugin_names = rrdtool.pluginNames(host.value); container.querySelectorAll('img').forEach(function(img) { @@ -122,7 +122,7 @@ return view.extend({ ui.tabs.initTabGroup(container.childNodes); }, - refreshGraphs: function(host, span, time, container) { + refreshGraphs(host, span, time, container) { var div = document.querySelector('[data-plugin="%s"][data-plugin-instance="%s"]'.format(activePlugin, activeInstance || '')), width = Math.max(200, container.offsetWidth - 100), render_instances = activeInstance.split(/\|/); @@ -155,7 +155,7 @@ return view.extend({ }); }, - togglePolling: function(host, span, time, container, ev) { + togglePolling(host, span, time, container, ev) { var btn = ev.currentTarget; if (pollFn) { @@ -169,25 +169,25 @@ return view.extend({ } }, - render: function() { + render() { var hosts = rrdtool.hostInstances(); return hosts.length ? this.renderGraphs() : this.renderNoData(); }, - renderNoData: function() { + renderNoData() { ui.showModal(_('No RRD data found'), [ E('p', {}, _('There is no RRD data available yet to render graphs.')), E('p', {}, _('You need to configure <em>collectd</em> to gather data into <em>.rrd</em> files.')), E('div', { 'class': 'right' }, [ E('button', { 'class': 'cbi-button', - 'click': function(ev) { location.href = 'collectd' } + 'click'(ev) { location.href = 'collectd' } }, [ _('Set up collectd') ]) ]) ]); }, - renderGraphs: function() { + renderGraphs() { var hostSel = E('select', { 'style': 'max-width:170px', 'data-name': 'host' }, rrdtool.hostInstances().map(function(host) { return E('option', { 'selected': (rrdtool.opts.host == host) ? 'selected' : null diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/apcups.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/apcups.js index 32f0cecdab..cba4b9ee68 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/apcups.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/apcups.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('APCUPS Plugin Configuration'), description: _('The APCUPS plugin collects statistics about the APC UPS.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -22,7 +22,7 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { + configSummary(section) { return _('Monitoring APC UPS at host %s, port %d').format(section.Host || 'localhost', section.Port || 3551); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/chrony.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/chrony.js index 7dc98f3389..b3213441b1 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/chrony.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/chrony.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Chrony Plugin Configuration'), description: _('The chrony plugin will monitor chrony NTP server statistics'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -28,7 +28,7 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { + configSummary(section) { return _('Chrony monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/conntrack.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/conntrack.js index ac859c8553..fe046872e1 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/conntrack.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/conntrack.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Conntrack Plugin Configuration'), description: _('The conntrack plugin collects statistics about the number of tracked connections.'), - configSummary: function(section) { + configSummary(section) { return _('Conntrack monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/contextswitch.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/contextswitch.js index d978a556c2..4f16f204ed 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/contextswitch.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/contextswitch.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('CPU Context Switches Plugin Configuration'), description: _('This plugin collects statistics about the processor context switches.'), - configSummary: function(section) { + configSummary(section) { return _('Context switch monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpu.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpu.js index e013e80cd9..13bd7d991b 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpu.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpu.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('CPU Plugin Configuration'), description: _('The cpu plugin collects basic statistics about the processor usage.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -36,7 +36,7 @@ return baseclass.extend({ o.depends({ 'enable': '1', 'ReportByCpu': '1', 'ReportByState': '1' }); }, - configSummary: function(section) { + configSummary(section) { return _('CPU monitoring is enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpufreq.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpufreq.js index 636ac8f7c7..b8a91375e2 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpufreq.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/cpufreq.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('CPU Frequency Plugin Configuration'), description: _('This plugin collects statistics about the processor frequency scaling.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); o.default = '0'; @@ -17,7 +17,7 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { + configSummary(section) { return (section.ExtraItems == '1') ? _('Detailled CPU frequency monitoring enabled') : _('Simple CPU frequency monitoring enabled'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/csv.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/csv.js index 87d8c9f6b7..16c871e2c5 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/csv.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/csv.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('CSV Plugin Configuration'), description: _('The csv plugin stores collected data in csv file format for further processing by external programs.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -19,7 +19,7 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { + configSummary(section) { if (section.DataDir) return _('Storing CSV data in %s').format(section.DataDir); } diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/curl.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/curl.js index 60a167c244..a2ecf65cc8 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/curl.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/curl.js @@ -5,8 +5,8 @@ return baseclass.extend({ title: _('cUrl Plugin Configuration'), - addFormOptions: function(s) { - var o, ss; + addFormOptions(s) { + let o, ss; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -27,7 +27,7 @@ return baseclass.extend({ o = ss.option(form.Value, 'url', _('URL')); }, - configSummary: function(section) { + configSummary(section) { return _('cURL plugin enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/df.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/df.js index 2a82f64d5a..81bf218e40 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/df.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/df.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('DF Plugin Configuration'), description: _('The df plugin collects statistics about the disk space usage on different devices, mount points or filesystem types.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -17,18 +17,18 @@ return baseclass.extend({ o.depends('enable', '1'); o.load = function(section_id) { return fs.lines('/proc/partitions').then(L.bind(function(lines) { - var parts = []; + const parts = []; - for (var i = 0; i < lines.length; i++) { - var line = L.toArray(lines[i]); + for (let l of lines) { + const line = L.toArray(l); if (!isNaN(line[0])) parts.push('/dev/' + line[3]); } parts.sort(); - for (var i = 0; i < parts.length; i++) - this.value(parts[i]); + for (let p of parts) + this.value(p); return this.super('load', [section_id]); }, this)); @@ -40,17 +40,17 @@ return baseclass.extend({ o.depends('enable', '1'); o.load = function(section_id) { return fs.lines('/proc/mounts').then(L.bind(function(lines) { - var mounts = {}; + let mounts = {}; - for (var i = 0; i < lines.length; i++) { - var line = L.toArray(lines[i]); + for (let l of lines) { + const line = L.toArray(l); mounts[line[1]] = true; } mounts = Object.keys(mounts).sort(); - for (var i = 0; i < mounts.length; i++) - this.value(mounts[i]); + for (let m of mounts) + this.value(m); return this.super('load', [section_id]); }, this)); @@ -65,11 +65,11 @@ return baseclass.extend({ fs.lines('/etc/filesystems'), fs.lines('/proc/filesystems') ]).then(L.bind(function(lines) { - var fslines = lines[0].concat(lines[1]), - fstypes = {}; + const fslines = lines[0].concat(lines[1]); + let fstypes = {}; - for (var i = 0; i < fslines.length; i++) { - var line = L.toArray(fslines[i]); + for (let fsl of fslines) { + var line = L.toArray(fsl); if (line.length == 2 && line[0] == 'nodev') continue; @@ -79,8 +79,8 @@ return baseclass.extend({ fstypes = Object.keys(fstypes).sort(); - for (var i = 0; i < fstypes.length; i++) - this.value(fstypes[i]); + for (let fst of fstypes) + this.value(fst); return this.super('load', [section_id]); }, this)); @@ -93,12 +93,12 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var devs = L.toArray(section.Devices), - mounts = L.toArray(section.MountPoints), - fstypes = L.toArray(section.FSTypes), - count = devs.length + mounts.length + fstypes.length, - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const devs = L.toArray(section.Devices); + const mounts = L.toArray(section.MountPoints); + const fstypes = L.toArray(section.FSTypes); + const count = devs.length + mounts.length + fstypes.length; + const invert = section.IgnoreSelected == '1'; if (count == 0) return _('Monitoring all partitions'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dhcpleases.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dhcpleases.js index df185f7d8c..5c64afedb3 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dhcpleases.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dhcpleases.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('DHCP Leases Plugin Configuration'), description: _('The dhcpleases plugin collects information about assigned DHCP leases.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -15,7 +15,7 @@ return baseclass.extend({ o.default = '/tmp/dhcp.leases'; }, - configSummary: function(section) { + configSummary(section) { return _('Monitoring DHCP leases enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/disk.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/disk.js index c36df10258..a2e76cbec7 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/disk.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/disk.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('Disk Plugin Configuration'), description: _('The disk plugin collects detailed usage statistics for selected partitions or whole disks.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -17,10 +17,10 @@ return baseclass.extend({ o.depends('enable', '1'); o.load = function(section_id) { return fs.trimmed('/proc/partitions').then(L.bind(function(str) { - var lines = (str || '').split(/\n/); + const lines = (str || '').split(/\n/); - for (var i = 0; i < lines.length; i++) { - var m = lines[i].match(/^ +[0-9]+ +[0-9]+ +[0-9]+ (\S+)$/); + for (let line of lines) { + const m = line.match(/^ +[0-9]+ +[0-9]+ +[0-9]+ (\S+)$/); if (m) this.value(m[1]); } @@ -33,9 +33,9 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var disks = L.toArray(section.Disks), - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const disks = L.toArray(section.Disks); + const invert = section.IgnoreSelected == '1'; if (disks.length == 0) return _('Monitoring all disks'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dns.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dns.js index 1e130e0236..8dc86ab2b5 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dns.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/dns.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('DNS Plugin Configuration'), description: _('The dns plugin collects detailed statistics about dns related traffic on selected interfaces.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -25,8 +25,8 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var ifaces = L.toArray(section.Interfaces); + configSummary(section) { + const ifaces = L.toArray(section.Interfaces); if (ifaces.length == 0) return _('Monitoring DNS queries on all interfaces'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/email.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/email.js index 1ab44f31cc..3d260ede37 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/email.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/email.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('E-Mail Plugin Configuration'), description: _('The email plugin creates a unix socket which can be used to transmit email-statistics to a running collectd daemon. This plugin is primarily intended to be used in conjunction with Mail::SpamAssasin::Plugin::Collectd but can be used in other ways as well.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -42,7 +42,7 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { + configSummary(section) { if (section.SocketFile) return _('Awaiting email input at %s').format(section.SocketFile); } diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/entropy.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/entropy.js index ffe679194a..39a0d9e18f 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/entropy.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/entropy.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Entropy Plugin Configuration'), description: _('The entropy plugin collects statistics about the available entropy.'), - configSummary: function(section) { + configSummary(section) { return _('Entropy monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/exec.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/exec.js index d197144271..07620d1f24 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/exec.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/exec.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('Exec Plugin Configuration'), description: _('The exec plugin starts external commands to read values from or to notify external processes when certain threshold values have been reached.'), - addFormOptions: function(s) { - var o, ss; + addFormOptions(s) { + let o, ss; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -53,7 +53,7 @@ return baseclass.extend({ o.optional = true; }, - configSummary: function(section) { + configSummary(section) { return _('Command monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/interface.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/interface.js index 6ea79a6275..38dab725e3 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/interface.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/interface.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('Interface Plugin Configuration'), description: _('The interface plugin collects traffic statistics on selected interfaces.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -22,9 +22,9 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var ifaces = L.toArray(section.Interfaces), - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const ifaces = L.toArray(section.Interfaces); + const invert = section.IgnoreSelected == '1'; if (ifaces.length == 0) return _('Monitoring all interfaces'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ipstatistics.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ipstatistics.js index 1a41a284f3..ed72bb058f 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ipstatistics.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ipstatistics.js @@ -7,7 +7,7 @@ return baseclass.extend({ title: _('IP-Statistics Plugin Configuration'), description: _('The ipstatistics plugin collects IPv4 and IPv6 statistics to compare them.'), - configSummary: function(section) { + configSummary(section) { return _('IPv4/IPv6 Statistics monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iptables.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iptables.js index 6dcaf26de6..81616bfb38 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iptables.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iptables.js @@ -8,13 +8,13 @@ return baseclass.extend({ title: _('Iptables Plugin Configuration'), description: _('The iptables plugin will monitor selected firewall rules and collect information about processed bytes and packets per rule.'), - addFormOptions: function(s) { - var o, ss; + addFormOptions(s) { + let o, ss; o = s.option(form.Flag, 'enable', _('Enable this plugin')); - for (var family = 4; family <= 6; family += 2) { - var suffix = (family == 4 ? '' : '6'); + for (let family = 4; family <= 6; family += 2) { + const suffix = (family == 4 ? '' : '6'); o = s.option(form.SectionValue, '__match' + suffix, form.TableSection, 'collectd_iptables_match' + suffix, suffix ? _('Match IPv6 iptables rules') : _('Match IPv4 iptables rules'), @@ -23,17 +23,18 @@ return baseclass.extend({ o.depends('enable', '1'); o.load = L.bind(function(suffix, section_id) { return L.resolveDefault(fs.exec_direct('/usr/sbin/ip' + suffix + 'tables-save', []), '').then(L.bind(function(res) { - var lines = res.split(/\n/), - table, chain, count, iptables = {}; + const lines = res.split(/\n/); + let table, count; + const iptables = {}; - for (var i = 0; i < lines.length; i++) { - var m; + for (let line of lines) { + let m; - if ((m = lines[i].match(/^\*(\S+)$/)) != null) { + if ((m = line.match(/^\*(\S+)$/)) != null) { table = m[1]; count = {}; } - else if ((m = lines[i].match(/^-A (.+?) ([!-].+)$/)) != null) { + else if ((m = line.match(/^-A (.+?) ([!-].+)$/)) != null) { count[m[1]] = (count[m[1]] || 0) + 1; iptables[table] = iptables[table] || {}; @@ -50,7 +51,7 @@ return baseclass.extend({ * collectd currently does not support comments with spaces: * https://github.com/collectd/collectd/issues/2766 */ - var c = m[2].match(/-m comment --comment "(.+)" -/); + const c = m[2].match(/-m comment --comment "(.+)" -/); if (c && c[1] != '!fw3' && !c[1].match(/[ \t\n]/)) iptables[table][m[1]][c[1]] = E('span', {}, [ c[1] ]); } @@ -70,8 +71,8 @@ return baseclass.extend({ o = ss.option(form.Value, 'name', _('Instance name')); o.datatype = 'maxlength(63)'; o.validate = function(section_id, v) { - var table_opt = this.section.children.filter(function(o) { return o.option == 'table' })[0], - table_elem = table_opt.getUIElement(section_id); + const table_opt = this.section.children.filter(function(o) { return o.option == 'table' })[0]; + const table_elem = table_opt.getUIElement(section_id); table_elem.clearChoices(); table_elem.addChoices(Object.keys(this.section.iptables).sort()); @@ -87,8 +88,8 @@ return baseclass.extend({ o.optional = true; o.transformChoices = function() { return this.super('transformChoices', []) || {} }; o.validate = function(section_id, table) { - var chain_opt = this.section.children.filter(function(o) { return o.option == 'chain' })[0], - chain_elem = chain_opt.getUIElement(section_id); + const chain_opt = this.section.children.filter(function(o) { return o.option == 'chain' })[0]; + const chain_elem = chain_opt.getUIElement(section_id); chain_elem.clearChoices(); chain_elem.addChoices(Object.keys(this.section.iptables[table]).sort()); @@ -100,17 +101,17 @@ return baseclass.extend({ o.optional = true; o.transformChoices = function() { return this.super('transformChoices', []) || {} }; o.validate = function(section_id, chain) { - var table_opt = this.section.children.filter(function(o) { return o.option == 'table' })[0], - rule_opt = this.section.children.filter(function(o) { return o.option == 'rule' })[0], - rule_elem = rule_opt.getUIElement(section_id), - table = table_opt.formvalue(section_id); + const table_opt = this.section.children.filter(function(o) { return o.option == 'table' })[0]; + const rule_opt = this.section.children.filter(function(o) { return o.option == 'rule' })[0]; + const rule_elem = rule_opt.getUIElement(section_id); + const table = table_opt.formvalue(section_id); rule_elem.clearChoices(); if (this.section.iptables[table][chain]) { - var keys = Object.keys(this.section.iptables[table][chain]).sort(function(a, b) { - var x = a.match(/^(\d+)/), - y = b.match(/^(\d+)/); + const keys = Object.keys(this.section.iptables[table][chain]).sort(function(a, b) { + const x = a.match(/^(\d+)/); + const y = b.match(/^(\d+)/); if (x && y) return +x[1] > +y[1]; @@ -120,10 +121,10 @@ return baseclass.extend({ return a > b; }); - var labels = {}; + const labels = {}; - for (var i = 0; i < keys.length; i++) - labels[keys[i]] = this.section.iptables[table][chain][keys[i]].cloneNode(true); + for (let key of keys) + labels[key] = this.section.iptables[table][chain][key].cloneNode(true); rule_elem.addChoices(keys, labels); } @@ -138,10 +139,10 @@ return baseclass.extend({ o.optional = true; o.transformChoices = function() { return this.super('transformChoices', []) || {} }; o.load = function(section_id) { - var table = uci.get('luci_statistics', section_id, 'table'), - chain = uci.get('luci_statistics', section_id, 'chain'), - rule = uci.get('luci_statistics', section_id, 'rule'), - ipt = this.section.iptables; + const table = uci.get('luci_statistics', section_id, 'table'); + const chain = uci.get('luci_statistics', section_id, 'chain'); + const rule = uci.get('luci_statistics', section_id, 'rule'); + const ipt = this.section.iptables; if (ipt[table] && ipt[table][chain] && ipt[table][chain][rule]) this.value(rule, ipt[table][chain][rule].cloneNode(true)); @@ -157,7 +158,7 @@ return baseclass.extend({ } }, - configSummary: function(section) { + configSummary(section) { return _('Rule monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/irq.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/irq.js index 4271a8f819..ac4b6d7a46 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/irq.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/irq.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('IRQ Plugin Configuration'), description: _('The irq plugin will monitor the rate of issues per second for each selected interrupt. If no interrupt is selected then all interrupts are monitored.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -18,19 +18,18 @@ return baseclass.extend({ o.depends('enable', '1'); o.load = function(section_id) { return fs.trimmed('/proc/interrupts').then(L.bind(function(str) { - var lines = str.split(/\n/), - cpus = L.toArray(lines[0]); + const lines = str.split(/\n/); + const cpus = L.toArray(lines[0]); - for (var i = 1; i < lines.length; i++) { - var line = lines[i], - m = lines[i].match(/^\s*([^\s:]+):/); + for (let line of lines) { + const m = line.match(/^\s*([^\s:]+):/); if (!m) continue; line = line.replace(/^[^:]+:\s+/, ''); - for (var j = 0; j < cpus.length; j++) + for (let j = 0; j < cpus.length; j++) line = line.replace(/^\d+\s*/, ''); var desc = line.split(/ {2,}/).join(', '); @@ -46,9 +45,9 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var irqs = L.toArray(section.Irqs), - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const irqs = L.toArray(section.Irqs); + const invert = section.IgnoreSelected == '1'; if (irqs.length == 0) return _('Monitoring all interrupts'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iwinfo.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iwinfo.js index 868c1f3035..c4ec7ca6de 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iwinfo.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iwinfo.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('Wireless iwinfo Plugin Configuration'), description: _('The iwinfo plugin collects statistics about wireless signal strength, noise and quality.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -18,7 +18,7 @@ return baseclass.extend({ o.noinactive = true; o.depends('enable', '1'); o.filter = function(section_id, name) { - var dev = this.devices.filter(function(dev) { return dev.getName() == name })[0]; + const dev = this.devices.filter(function(dev) { return dev.getName() == name })[0]; return (dev && dev.getType() == 'wifi'); }; @@ -26,9 +26,9 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var ifaces = L.toArray(section.Interfaces), - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const ifaces = L.toArray(section.Interfaces); + const invert = section.IgnoreSelected == '1'; if (ifaces.length == 0) return _('Monitoring all interfaces'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/load.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/load.js index 25755637c8..e1cc0d7d3e 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/load.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/load.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Load Plugin Configuration'), description: _('The load plugin collects statistics about the general system load.'), - configSummary: function(section) { + configSummary(section) { return _('Load monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/memory.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/memory.js index 864857faa3..f2456de642 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/memory.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/memory.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Memory Plugin Configuration'), description: _('The memory plugin collects statistics about the memory usage.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -24,7 +24,7 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { + configSummary(section) { return _('Memory monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js index 73de2f5cf6..dbd95c9a6c 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/mqtt.js @@ -5,7 +5,7 @@ return baseclass.extend({ title: _('Mqtt Plugin Configuration'), - addFormOptions: function(s) { + addFormOptions(s) { let o, ss; o = s.option(form.Flag, 'enable', _('Sends or receives data via mqtt')); @@ -95,7 +95,7 @@ return baseclass.extend({ o.modalonly = true; }, - configSummary: function(section) { + configSummary(section) { return _('Mqtt plugin enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/netlink.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/netlink.js index 8910206929..2f4c51b7be 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/netlink.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/netlink.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('Netlink Plugin Configuration'), description: _('The netlink plugin collects extended information like qdisc-, class- and filter-statistics for selected interfaces.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); o.default = '0'; @@ -42,11 +42,11 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var basic = L.toArray(section.Interfaces), - verbose = L.toArray(section.VerboseInterfaces), - count = basic.length + verbose.length, - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const basic = L.toArray(section.Interfaces); + const verbose = L.toArray(section.VerboseInterfaces); + const count = basic.length + verbose.length; + const invert = section.IgnoreSelected == '1'; if (invert && count == 0) return _('Monitoring all interfaces'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/network.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/network.js index b184335f18..ba5551ed97 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/network.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/network.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Network Plugin Configuration'), description: _('The network plugin provides network based communication between different collectd instances. Collectd can operate both in client and server mode. In client mode locally collected data is transferred to a collectd server instance, in server mode the local instance receives data from other hosts.'), - addFormOptions: function(s) { - var o, ss; + addFormOptions(s) { + let o, ss; o = s.option(form.Flag, 'enable', _('Enable this plugin')); o.default = '0'; @@ -65,7 +65,7 @@ return baseclass.extend({ //o.optional = true; }, - configSummary: function(section) { + configSummary(section) { return _('Network communication enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/nut.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/nut.js index ca20e11721..2b28571f73 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/nut.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/nut.js @@ -6,16 +6,14 @@ return baseclass.extend({ title: _('UPS Plugin Configuration'), description: _('The NUT plugin reads information about Uninterruptible Power Supplies.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + s.option(form.Flag, 'enable', _('Enable this plugin')); - o = s.option(form.Flag, 'enable', _('Enable this plugin')); - - o = s.option(form.Value, 'UPS', _('UPS'), _('UPS name in NUT ups@host format')); + s.option(form.Value, 'UPS', _('UPS'), _('UPS name in NUT ups@host format')); }, - configSummary: function(section) { - var ups = L.toArray(section.UPS); + configSummary(section) { + const ups = L.toArray(section.UPS); if (ups.length) return N_(ups.length, 'Monitoring one UPS', 'Monitoring %d UPSes').format(ups.length); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/olsrd.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/olsrd.js index 4e6eca2344..1225ed45d6 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/olsrd.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/olsrd.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('OLSRd Plugin Configuration'), description: _('The OLSRd plugin reads information about meshed networks from the txtinfo plugin of OLSRd.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -40,7 +40,7 @@ return baseclass.extend({ o.value('Detail'); }, - configSummary: function(section) { + configSummary(section) { return _('Monitoring OLSRd status at %s:%d').format( section.Host || 'localhost', section.Port || 2006 diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/openvpn.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/openvpn.js index b48ed93a32..1905f620bb 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/openvpn.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/openvpn.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('OpenVPN Plugin Configuration'), description: _('The OpenVPN plugin gathers information about the current vpn connection status.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -28,17 +28,17 @@ return baseclass.extend({ o.depends('enable', '1'); o.load = function(section_id) { return L.resolveDefault(fs.list('/var/run'), []).then(L.bind(function(entries) { - for (var i = 0; i < entries.length; i++) - if (entries[i].type == 'file' && entries[i].name.match(/^openvpn\..+\.status$/)) - this.value('/var/run/' + entries[i].name); + for (let entry of entries) + if (entry.type == 'file' && entry.name.match(/^openvpn\..+\.status$/)) + this.value('/var/run/' + entry.name); return this.super('load', [section_id]); }, this)); }; }, - configSummary: function(section) { - var stats = L.toArray(section.StatusFile); + configSummary(section) { + const stats = L.toArray(section.StatusFile); if (stats.length) return N_(stats.length, 'Monitoring one OpenVPN instance', 'Monitoring %d OpenVPN instances').format(stats.length); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ping.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ping.js index 0c827e8a0b..518012db19 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ping.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/ping.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Ping Plugin Configuration'), description: _('The ping plugin will send icmp echo replies to selected hosts and measure the roundtrip time for each host.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -41,8 +41,8 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var hosts = L.toArray(section.Hosts); + configSummary(section) { + const hosts = L.toArray(section.Hosts); if (hosts.length) return N_(hosts.length, 'Monitoring one host', 'Monitoring %d hosts').format(hosts.length); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/processes.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/processes.js index d29ac87630..d72330d1ba 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/processes.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/processes.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Processes Plugin Configuration'), description: _('The processes plugin collects information like cpu time, page faults and memory usage of selected processes.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -16,8 +16,8 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var processes = L.toArray(section.Processes); + configSummary(section) { + const processes = L.toArray(section.Processes); if (processes.length) return N_(processes.length, 'Monitoring one process', 'Monitoring %d processes').format(processes.length); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/rrdtool.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/rrdtool.js index 7e2704a2c3..e59d1d029a 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/rrdtool.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/rrdtool.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('RRDTool Plugin Configuration'), description: _('The rrdtool plugin stores the collected data in rrd database files, the foundation of the diagrams.<br /><br /><strong>Warning: Setting the wrong values will result in a very high memory consumption in the temporary directory. This can render the device unusable!</strong>'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -77,7 +77,7 @@ return baseclass.extend({ o.datatype = 'uinteger'; o.placeholder = '0'; o.validate = function(section_id, value) { - var flushinp = this.map.findElement('id', 'widget.cbid.luci_statistics.collectd_rrdtool.CacheFlush'); + const flushinp = this.map.findElement('id', 'widget.cbid.luci_statistics.collectd_rrdtool.CacheFlush'); if (value != '' && !isNaN(value) && +value > 0) { flushinp.placeholder = 10 * +value; @@ -97,7 +97,7 @@ return baseclass.extend({ o.datatype = 'uinteger'; }, - configSummary: function(section) { + configSummary(section) { if (section.DataDir) return _('Writing *.rrd files to %s').format(section.DataDir); } diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/sensors.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/sensors.js index a55be1f4f4..149e82af07 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/sensors.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/sensors.js @@ -17,8 +17,8 @@ return baseclass.extend({ title: _('Sensors Plugin Configuration'), description: _('The sensors plugin uses the Linux Sensors framework to gather environmental statistics.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -28,12 +28,12 @@ return baseclass.extend({ o.depends('enable', '1'); o.load = function(section_id) { return fs.exec_direct('/usr/sbin/sensors', ['-j'], 'json').then(L.bind(function(output) { - for (var bus in output) { - for (var sensor in output[bus]) { + for (let bus in output) { + for (let sensor in output[bus]) { if (!L.isObject(output[bus][sensor])) continue; - for (var j = 0; j < sensorTypes.length; j += 2) { + for (let j = 0; j < sensorTypes.length; j += 2) { if (sensor.match(sensorTypes[j])) { this.value('%s/%s-%s'.format(bus, sensorTypes[j + 1], sensor)); break; @@ -50,9 +50,9 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var sensors = L.toArray(section.Sensor), - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const sensors = L.toArray(section.Sensor); + const invert = section.IgnoreSelected == '1'; if (invert && sensors.length) return N_(sensors.length, 'Monitoring all but one sensor', 'Monitoring all but %d sensors').format(sensors.length); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/snmp6.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/snmp6.js index 91f95376a1..bd86a6ecab 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/snmp6.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/snmp6.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('SNMP6 Plugin Configuration'), description: _('The snmp6 plugin collects IPv6 statistics for selected interfaces.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); o.default = '0'; @@ -22,10 +22,10 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var basic = L.toArray(section.Interfaces), - count = basic.length, - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const basic = L.toArray(section.Interfaces); + const count = basic.length; + const invert = section.IgnoreSelected == '1'; if (invert && count == 0) return _('Monitoring all interfaces'); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/splash_leases.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/splash_leases.js index 34d0ca9b49..5c3986f93d 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/splash_leases.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/splash_leases.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Splash Leases Plugin Configuration'), description: _('The splash leases plugin uses libuci to collect statistics about splash leases.'), - configSummary: function(section) { + configSummary(section) { return _('Monitoring splash leases'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/syslog.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/syslog.js index 7a58a16f55..f2ce2fb959 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/syslog.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/syslog.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('Syslog Plugin Configuration'), description: _('The SysLog plugin receives log messages from the daemon and dispatches them to syslog.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -28,7 +28,7 @@ return baseclass.extend({ o.default = 'WARNING'; }, - configSummary: function(section) { + configSummary(section) { return _('Syslog enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/tcpconns.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/tcpconns.js index 526b10f3c3..d5f821b3c1 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/tcpconns.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/tcpconns.js @@ -6,8 +6,8 @@ return baseclass.extend({ title: _('TCPConns Plugin Configuration'), description: _('The tcpconns plugin collects information about open tcp connections on selected ports.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -32,11 +32,11 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var lports = L.toArray(section.LocalPorts), - rports = L.toArray(section.RemotePorts), - listen = section.ListeningPorts == '1', - summary = section.AllPortsSummary == '1'; + configSummary(section) { + let lports = L.toArray(section.LocalPorts); + const rports = L.toArray(section.RemotePorts); + const listen = section.ListeningPorts == '1'; + const summary = section.AllPortsSummary == '1'; return _('Monitoring %s and %s, %s %s').format( N_(lports.length, 'one local', '%d local').format(lports.length), diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/thermal.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/thermal.js index 650e54747a..9fbb64dc59 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/thermal.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/thermal.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('Thermal Plugin Configuration'), description: _('The thermal plugin will monitor temperature of the system. Data is typically read from /sys/class/thermal/*/temp ( \'*\' denotes the thermal device to be read, e.g. thermal_zone1 )'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -17,12 +17,12 @@ return baseclass.extend({ return Promise.all([ L.resolveDefault(fs.list('/sys/class/thermal'), []), L.resolveDefault(fs.list('/proc/acpi/thermal_zone'), []) - ]).then(L.bind(function(res) { - var entries = res[0].concat(res[1]); + ]).then(L.bind(function([therm, therm_zone]) { + const entries = therm.concat(therm_zone); - for (var i = 0; i < entries.length; i++) - if (entries[i].type == 'directory' && !entries[i].name.match(/^cooling_device/)) - o.value(entries[i].name); + for (let e of entries) + if (e.type == 'directory' && !e.name.match(/^cooling_device/)) + o.value(e.name); return this.super('load', [ section_id ]); }, this)); @@ -37,9 +37,9 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { - var zones = L.toArray(section.Device), - invert = section.IgnoreSelected == '1'; + configSummary(section) { + const zones = L.toArray(section.Device); + const invert = section.IgnoreSelected == '1'; if (zones.length) return (invert diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/unixsock.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/unixsock.js index 88b0b26485..409294382d 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/unixsock.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/unixsock.js @@ -7,8 +7,8 @@ return baseclass.extend({ title: _('Unixsock Plugin Configuration'), description: _('The unixsock plugin creates a unix socket which can be used to read collected data from a running collectd instance.'), - addFormOptions: function(s) { - var o; + addFormOptions(s) { + let o; o = s.option(form.Flag, 'enable', _('Enable this plugin')); @@ -29,7 +29,7 @@ return baseclass.extend({ o.depends('enable', '1'); }, - configSummary: function(section) { + configSummary(section) { if (section.SocketFile) return _('Socket %s active').format(section.SocketFile); } diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/uptime.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/uptime.js index 2c42708ef6..ccc89d1589 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/uptime.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/uptime.js @@ -6,7 +6,7 @@ return baseclass.extend({ title: _('Uptime Plugin Configuration'), description: _('The uptime plugin collects statistics about the uptime of the system.'), - configSummary: function(section) { + configSummary(section) { return _('Uptime monitoring enabled'); } }); diff --git a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/users.js b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/users.js index 05b5eb8849..aea40869cf 100644 --- a/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/users.js +++ b/applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/users.js @@ -6,11 +6,11 @@ return baseclass.extend({ title: _('Users Plugin Configuration'), description: _('The users plugin collects statistics about users logged in locally via shell. NOTE: Local shell (wtmp) tracking is NOT enabled in default builds. Additional setup is required to get non-zero counts.'), - addFormOptions: function(s) { - var o = s.option(form.Flag, 'enable', _('Enable this plugin')); + addFormOptions(s) { + let o = s.option(form.Flag, 'enable', _('Enable this plugin')); }, - configSummary: function(section) { + configSummary(section) { return _('Monitoring shell users count'); } }); |