diff options
7 files changed, 55 insertions, 23 deletions
diff --git a/applications/luci-app-statistics/Makefile b/applications/luci-app-statistics/Makefile index e1919b682c..8010e7e242 100644 --- a/applications/luci-app-statistics/Makefile +++ b/applications/luci-app-statistics/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=LuCI Statistics Application LUCI_DEPENDS:= \ - +luci-compat +luci-lib-iptparser +luci-lib-jsonc \ + +luci-base +luci-lib-jsonc \ +collectd +rrdtool1 +collectd-mod-rrdtool +collectd-mod-iwinfo \ +collectd-mod-cpu +collectd-mod-memory \ +collectd-mod-interface +collectd-mod-load +collectd-mod-network 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 6ba571e8b8..d92693525a 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 @@ -8,7 +8,8 @@ return L.view.extend({ load: function() { return Promise.all([ fs.list('/usr/lib/collectd'), - fs.list('/usr/share/luci/statistics/plugins') + fs.list('/usr/share/luci/statistics/plugins'), + uci.load('luci_statistics') ]).then(function(data) { var installed = data[0], plugins = data[1], @@ -17,6 +18,9 @@ return L.view.extend({ 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) { 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); + return { name: name, spec: spec, @@ -32,7 +36,7 @@ return L.view.extend({ }, render: function(plugins) { - var m, s, o; + var m, s, o, enabled; for (var i = 0; i < plugins.length; i++) plugins[plugins[i].name] = plugins[i]; @@ -104,9 +108,19 @@ return L.view.extend({ return plugin ? plugin.spec.title : name }; - o = s.option(form.Flag, 'enable', _('Enabled')); - o.editable = true; - o.modalonly = false; + enabled = s.option(form.Flag, 'enable', _('Enabled')); + 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]); + + widget.querySelector('input[type="checkbox"]').addEventListener('click', L.bind(function(section_id, plugin, ev) { + if (ev.target.checked && plugin && plugin.form.addFormOptions) + this.section.renderMoreOptionsModal(section_id); + }, this, section_id, plugins[section_id.replace(/^collectd_/, '')])); + + return widget; + }; o = s.option(form.DummyValue, '_dummy', _('Status')); o.width = '50%'; @@ -140,6 +154,15 @@ return L.view.extend({ s.description = plugin.form.description; plugin.form.addFormOptions(s); + + var opt = s.children.filter(function(o) { return o.option == 'enable' })[0]; + if (opt) + opt.cfgvalue = function(section_id, set_value) { + if (arguments.length == 2) + return form.Flag.prototype.cfgvalue.apply(this, [section_id, enabled.formvalue(section_id)]); + else + return form.Flag.prototype.cfgvalue.apply(this, [section_id]); + }; }; s.renderRowActions = function(section_id) { diff --git a/applications/luci-app-statistics/po/es/statistics.po b/applications/luci-app-statistics/po/es/statistics.po index 58f7101278..f0063c06ae 100644 --- a/applications/luci-app-statistics/po/es/statistics.po +++ b/applications/luci-app-statistics/po/es/statistics.po @@ -3,7 +3,7 @@ msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2009-06-10 03:41+0200\n" -"PO-Revision-Date: 2020-02-13 10:27+0000\n" +"PO-Revision-Date: 2020-02-14 14:43+0000\n" "Last-Translator: Franco Castillo <castillofrancodamian@gmail.com>\n" "Language-Team: Spanish <https://hosted.weblate.org/projects/openwrt/" "luciapplicationsstatistics/es/>\n" @@ -53,7 +53,7 @@ msgstr "Agregar número de usuarios conectados" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:190 msgid "Apply interval »" -msgstr "" +msgstr "Aplicar intervalo »" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/email.js:50 msgid "Awaiting email input at %s" @@ -230,7 +230,7 @@ msgstr "Mostrar lapso de tiempo »" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:162 msgid "Do not refresh" -msgstr "" +msgstr "No actualizar" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/email.js:6 msgid "E-Mail Plugin Configuration" @@ -297,15 +297,15 @@ msgstr "Monitoreo de entropía activado" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:164 msgid "Every 30 seconds" -msgstr "" +msgstr "Cada 30 segundos" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:163 msgid "Every 5 seconds" -msgstr "" +msgstr "Cada 5 segundos" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:165 msgid "Every minute" -msgstr "" +msgstr "Cada minuto" #: applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/exec.json:2 msgid "Exec" @@ -342,7 +342,7 @@ msgstr "Firewall" #: applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/ip6tables.js:6 msgid "Firewall (IPv6)" -msgstr "" +msgstr "Firewall (IPv6)" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/rrdtool.js:80 msgid "Flush cache after" @@ -471,7 +471,7 @@ msgstr "Monitoreo de carga activado" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:24 #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:81 msgid "Loading data…" -msgstr "" +msgstr "Cargando datos…" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/iptables.js:20 msgid "Match IPv4 iptables rules" @@ -756,7 +756,7 @@ msgstr "Plugins de red" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:136 msgid "No RRD data found" -msgstr "" +msgstr "No se encontraron datos de RRD" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/rrdtool.js:15 msgid "" @@ -930,7 +930,7 @@ msgstr "Configuración" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:143 msgid "Setup collectd" -msgstr "" +msgstr "Configuración de collectd" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/netlink.js:30 msgid "Shaping class monitoring" @@ -1291,7 +1291,7 @@ msgstr "" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/graphs.js:137 msgid "There is no RRD data available yet to render graphs." -msgstr "" +msgstr "Todavía no hay datos RRD disponibles para representar gráficos." #: applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/thermal.js:6 #: applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/thermal.json:2 @@ -1431,6 +1431,8 @@ msgid "" "You need to configure <em>collectd</em> to gather data into <em>.rrd</em> " "files." msgstr "" +"Debe configurar <em>collectd</em> para recopilar datos en archivos " +"<em>.rrd</em>." #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/curl.js:30 msgid "cURL plugin enabled" diff --git a/applications/luci-app-statistics/po/hu/statistics.po b/applications/luci-app-statistics/po/hu/statistics.po index c84b522d6d..7e63375f79 100644 --- a/applications/luci-app-statistics/po/hu/statistics.po +++ b/applications/luci-app-statistics/po/hu/statistics.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"PO-Revision-Date: 2020-02-02 09:01+0000\n" +"PO-Revision-Date: 2020-02-15 09:27+0000\n" "Last-Translator: Balázs Úr <balazs@urbalazs.hu>\n" "Language-Team: Hungarian <https://hosted.weblate.org/projects/openwrt/" "luciapplicationsstatistics/hu/>\n" @@ -277,7 +277,7 @@ msgstr "Bővítmény engedélyezése" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/collectd.js:107 msgid "Enabled" -msgstr "" +msgstr "Engedélyezve" #: applications/luci-app-statistics/htdocs/luci-static/resources/statistics/rrdtool/definitions/entropy.js:9 #: applications/luci-app-statistics/root/usr/share/luci/statistics/plugins/entropy.json:2 @@ -998,7 +998,7 @@ msgstr "Statisztikák" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/collectd.js:111 msgid "Status" -msgstr "" +msgstr "Állapot" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/rrdtool.js:14 msgid "Storage directory" @@ -1443,7 +1443,7 @@ msgstr "cUrl bővítmény beállítása" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/collectd.js:123 msgid "none" -msgstr "" +msgstr "nincs" #: applications/luci-app-statistics/htdocs/luci-static/resources/view/statistics/plugins/df.js:105 msgid "one device" diff --git a/applications/luci-app-statistics/root/usr/bin/stat-genconfig b/applications/luci-app-statistics/root/usr/bin/stat-genconfig index 8b14c29e57..152e584da4 100755 --- a/applications/luci-app-statistics/root/usr/bin/stat-genconfig +++ b/applications/luci-app-statistics/root/usr/bin/stat-genconfig @@ -302,7 +302,7 @@ end preprocess = { RRATimespans = function(val) local rv = { } - for time in val:gmatch("[^%s]+") do + for time in luci.util.imatch(val) do table.insert( rv, luci.util.parse_units(time) ) end return table.concat(rv, " ") diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index d962a1d1af..92c41515fb 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -101,7 +101,8 @@ function trimws(s) { } function _(s, c) { - return (window.TR && TR[sfh(trimws(s))]) || s; + var k = (c != null ? trimws(c) + '\u0001' : '') + trimws(s); + return (window.TR && TR[sfh(k)]) || s; } function N_(n, s, p, c) { @@ -730,6 +731,9 @@ if (typeof(window.CustomEvent) !== 'function') { } function cbi_dropdown_init(sb) { + if (sb && L.dom.findClassInstance(sb) instanceof L.ui.Dropdown) + return; + var dl = new L.ui.Dropdown(sb, null, { name: sb.getAttribute('name') }); return dl.bind(sb); } diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js index 2cb346c81b..8d056ec03d 100644 --- a/modules/luci-base/htdocs/luci-static/resources/luci.js +++ b/modules/luci-base/htdocs/luci-static/resources/luci.js @@ -2554,6 +2554,9 @@ * be found. */ data: function(node, key, val) { + if (!node || !node.getAttribute) + return null; + var id = node.getAttribute('data-idref'); /* clear all data */ |