summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-mod-system
diff options
context:
space:
mode:
Diffstat (limited to 'modules/luci-mod-system')
-rw-r--r--modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js152
-rw-r--r--modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js295
-rw-r--r--modules/luci-mod-system/luasrc/controller/admin/system.lua4
-rw-r--r--modules/luci-mod-system/luasrc/model/cbi/admin_system/leds.lua188
-rw-r--r--modules/luci-mod-system/luasrc/model/cbi/admin_system/system.lua271
-rw-r--r--modules/luci-mod-system/luasrc/view/admin_system/clock_status.htm56
6 files changed, 449 insertions, 517 deletions
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js
new file mode 100644
index 0000000000..c1109b5d64
--- /dev/null
+++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/leds.js
@@ -0,0 +1,152 @@
+'use strict';
+'require uci';
+'require rpc';
+'require form';
+
+var callInitAction, callLeds, callUSB, callNetdevs;
+
+callInitAction = rpc.declare({
+ object: 'luci',
+ method: 'initCall',
+ params: [ 'name', 'action' ],
+ expect: { result: false }
+});
+
+callLeds = rpc.declare({
+ object: 'luci',
+ method: 'leds'
+});
+
+callUSB = rpc.declare({
+ object: 'luci',
+ method: 'usb'
+});
+
+callNetdevs = rpc.declare({
+ object: 'luci',
+ method: 'ifaddrs',
+ expect: { result: [] },
+ filter: function(res) {
+ var devs = {};
+ for (var i = 0; i < res.length; i++)
+ devs[res[i].name] = true;
+ return Object.keys(devs).sort();
+ }
+});
+
+return L.view.extend({
+ load: function() {
+ return Promise.all([
+ callLeds(),
+ callUSB(),
+ callNetdevs()
+ ]);
+ },
+
+ render: function(results) {
+ var leds = results[0],
+ usb = results[1],
+ netdevs = results[2],
+ triggers = {},
+ trigger, m, s, o;
+
+ for (var k in leds)
+ for (var i = 0; i < leds[k].triggers.length; i++)
+ triggers[leds[k].triggers[i]] = true;
+
+ m = new form.Map('system',
+ _('<abbr title="Light Emitting Diode">LED</abbr> Configuration'),
+ _('Customizes the behaviour of the device <abbr title="Light Emitting Diode">LED</abbr>s if possible.'));
+
+ s = m.section(form.TypedSection, 'led', '');
+ s.anonymous = true;
+ s.addremove = true;
+
+ s.option(form.Value, 'name', _('Name'));
+
+ o = s.option(form.ListValue, 'sysfs', _('<abbr title="Light Emitting Diode">LED</abbr> Name'));
+ Object.keys(leds).sort().forEach(function(name) { o.value(name) });
+
+ o = s.option(form.Flag, 'default', _('Default state'));
+ o.rmempty = false;
+
+ trigger = s.option(form.ListValue, 'trigger', _('Trigger'));
+ Object.keys(triggers).sort().forEach(function(t) { trigger.value(t, t.replace(/-/g, '')) });
+ if (usb.devices && usb.devices.length)
+ trigger.value('usbdev');
+ if (usb.ports && usb.ports.length)
+ trigger.value('usbport');
+
+ o = s.option(form.Value, 'delayon', _('On-State Delay'));
+ o.depends('trigger', 'timer');
+
+ o = s.option(form.Value, 'delayoff', _('Off-State Delay'));
+ o.depends('trigger', 'timer');
+
+ o = s.option(form.ListValue, '_net_dev', _('Device'));
+ o.rmempty = true;
+ o.ucioption = 'dev';
+ o.depends('trigger', 'netdev');
+ o.remove = function(section_id) {
+ var t = trigger.formvalue(section_id);
+ if (t != 'netdev' && t != 'usbdev')
+ uci.unset('system', section_id, 'dev');
+ };
+ o.value('');
+ netdevs.sort().forEach(function(dev) { o.value(dev) });
+
+ o = s.option(form.MultiValue, 'mode', _('Trigger Mode'));
+ o.rmempty = true;
+ o.depends('trigger', 'netdev');
+ o.value('link', _('Link On'));
+ o.value('tx', _('Transmit'));
+ o.value('rx', _('Receive'));
+
+ if (usb.devices && usb.devices.length) {
+ o = s.option(form.ListValue, '_usb_dev', _('USB Device'));
+ o.depends('trigger', 'usbdev');
+ o.rmempty = true;
+ o.ucioption = 'dev';
+ o.remove = function(section_id) {
+ var t = trigger.formvalue(section_id);
+ if (t != 'netdev' && t != 'usbdev')
+ uci.unset('system', section_id, 'dev');
+ }
+ o.value('');
+ usb.devices.forEach(function(usbdev) {
+ o.value(usbdev.id, '%s (%s - %s)'.format(usbdev.id, usbdev.vendor || '?', usbdev.product || '?'));
+ });
+ }
+
+ if (usb.ports && usb.ports.length) {
+ o = s.option(form.MultiValue, 'port', _('USB Ports'));
+ o.depends('trigger', 'usbport');
+ o.rmempty = true;
+ o.cfgvalue = function(section_id) {
+ var ports = [],
+ value = uci.get('system', section_id, 'port');
+
+ if (!Array.isArray(value))
+ value = String(value || '').split(/\s+/);
+
+ for (var i = 0; i < value.length; i++)
+ if (value[i].match(/^usb(\d+)-port(\d+)$/))
+ ports.push(value[i]);
+ else if (value[i].match(/^(\d+)-(\d+)$/))
+ ports.push('usb%d-port%d'.format(Regexp.$1, Regexp.$2));
+
+ return ports;
+ };
+ usb.ports.forEach(function(usbport) {
+ o.value('usb%d-port%d'.format(usbport.hub, usbport.port),
+ 'Hub %d, Port %d'.format(usbport.hub, usbport.port));
+ });
+ }
+
+ o = s.option(form.Value, 'port_mask', _('Switch Port Mask'));
+ o.depends('trigger', 'switch0');
+ o.depends('trigger', 'switch1');
+
+ return m.render();
+ }
+});
diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js
new file mode 100644
index 0000000000..6db973a8df
--- /dev/null
+++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/system.js
@@ -0,0 +1,295 @@
+'use strict';
+'require uci';
+'require rpc';
+'require form';
+
+var callInitList, callInitAction, callTimezone,
+ callGetLocaltime, callSetLocaltime, CBILocalTime;
+
+callInitList = rpc.declare({
+ object: 'luci',
+ method: 'initList',
+ params: [ 'name' ],
+ expect: { result: {} },
+ filter: function(res) {
+ for (var k in res)
+ return +res[k].enabled;
+ return null;
+ }
+});
+
+callInitAction = rpc.declare({
+ object: 'luci',
+ method: 'initCall',
+ params: [ 'name', 'action' ],
+ expect: { result: false }
+});
+
+callGetLocaltime = rpc.declare({
+ object: 'luci',
+ method: 'getLocaltime',
+ expect: { localtime: 0 }
+});
+
+callSetLocaltime = rpc.declare({
+ object: 'luci',
+ method: 'setLocaltime',
+ params: [ 'localtime' ],
+ expect: { localtime: 0 }
+});
+
+callTimezone = rpc.declare({
+ object: 'luci',
+ method: 'timezone',
+ expect: { result: {} }
+});
+
+CBILocalTime = form.DummyValue.extend({
+ renderWidget: function(section_id, option_id, cfgvalue) {
+ return E([], [
+ E('span', { 'id': 'localtime' },
+ new Date(cfgvalue * 1000).toLocaleString()),
+ ' ',
+ E('button', {
+ 'class': 'cbi-button cbi-button-apply',
+ 'click': function() {
+ this.blur();
+ this.classList.add('spinning');
+ this.disabled = true;
+ callSetLocaltime(Math.floor(Date.now() / 1000)).then(L.bind(function() {
+ this.classList.remove('spinning');
+ this.disabled = false;
+ }, this));
+ }
+ }, _('Sync with browser')),
+ ' ',
+ this.ntpd_support ? E('button', {
+ 'class': 'cbi-button cbi-button-apply',
+ 'click': function() {
+ this.blur();
+ this.classList.add('spinning');
+ this.disabled = true;
+ callInitAction('sysntpd', 'restart').then(L.bind(function() {
+ this.classList.remove('spinning');
+ this.disabled = false;
+ }, this));
+ }
+ }, _('Sync with NTP-Server')) : ''
+ ]);
+ },
+});
+
+return L.view.extend({
+ load: function() {
+ return Promise.all([
+ callInitList('sysntpd'),
+ callInitList('zram'),
+ callTimezone(),
+ callGetLocaltime(),
+ uci.load('luci'),
+ uci.load('system')
+ ]);
+ },
+
+ render: function(rpc_replies) {
+ var ntpd_support = rpc_replies[0],
+ zram_support = rpc_replies[1],
+ timezones = rpc_replies[2],
+ localtime = rpc_replies[3],
+ ntp_setup, ntp_enabled, m, s, o;
+
+ m = new form.Map('system',
+ _('System'),
+ _('Here you can configure the basic aspects of your device like its hostname or the timezone.'));
+
+ m.chain('luci');
+ m.tabbed = true;
+
+ s = m.section(form.TypedSection, 'system', _('System Properties'));
+ s.anonymous = true;
+ s.addremove = false;
+
+ s.tab('general', _('General Settings'));
+ s.tab('logging', _('Logging'));
+ s.tab('timesync', _('Time Synchronization'));
+ s.tab('language', _('Language and Style'));
+
+ /*
+ * System Properties
+ */
+
+ o = s.taboption('general', CBILocalTime, '_systime', _('Local Time'));
+ o.cfgvalue = function() { return localtime };
+ o.ntpd_support = ntpd_support;
+
+ o = s.taboption('general', form.Value, 'hostname', _('Hostname'));
+ o.datatype = 'hostname';
+
+ o = s.taboption('general', form.ListValue, 'zonename', _('Timezone'));
+ o.value('UTC');
+
+ var zones = Object.keys(timezones || {}).sort();
+ for (var i = 0; i < zones.length; i++)
+ o.value(zones[i]);
+
+ o.write = function(section_id, formvalue) {
+ var tz = timezones[formvalue] ? timezones[formvalue].tzstring : null;
+ uci.set('system', section_id, 'zonename', formvalue);
+ uci.set('system', section_id, 'timezone', tz);
+ };
+
+ /*
+ * Logging
+ */
+
+ o = s.taboption('logging', form.Value, 'log_size', _('System log buffer size'), "kiB")
+ o.optional = true
+ o.placeholder = 16
+ o.datatype = 'uinteger'
+
+ o = s.taboption('logging', form.Value, 'log_ip', _('External system log server'))
+ o.optional = true
+ o.placeholder = '0.0.0.0'
+ o.datatype = 'ip4addr'
+
+ o = s.taboption('logging', form.Value, 'log_port', _('External system log server port'))
+ o.optional = true
+ o.placeholder = 514
+ o.datatype = 'port'
+
+ o = s.taboption('logging', form.ListValue, 'log_proto', _('External system log server protocol'))
+ o.value('udp', 'UDP')
+ o.value('tcp', 'TCP')
+
+ o = s.taboption('logging', form.Value, 'log_file', _('Write system log to file'))
+ o.optional = true
+ o.placeholder = '/tmp/system.log'
+
+ o = s.taboption('logging', form.ListValue, 'conloglevel', _('Log output level'))
+ o.value(8, _('Debug'))
+ o.value(7, _('Info'))
+ o.value(6, _('Notice'))
+ o.value(5, _('Warning'))
+ o.value(4, _('Error'))
+ o.value(3, _('Critical'))
+ o.value(2, _('Alert'))
+ o.value(1, _('Emergency'))
+
+ o = s.taboption('logging', form.ListValue, 'cronloglevel', _('Cron Log Level'))
+ o.default = 8
+ o.value(5, _('Debug'))
+ o.value(8, _('Normal'))
+ o.value(9, _('Warning'))
+
+ /*
+ * Zram Properties
+ */
+
+ if (zram_support != null) {
+ s.tab('zram', _('ZRam Settings'));
+
+ o = s.taboption('zram', form.Value, 'zram_size_mb', _('ZRam Size'), _('Size of the ZRam device in megabytes'));
+ o.optional = true;
+ o.placeholder = 16;
+ o.datatype = 'uinteger';
+
+ o = s.taboption('zram', form.ListValue, 'zram_comp_algo', _('ZRam Compression Algorithm'));
+ o.optional = true;
+ o.placeholder = 'lzo';
+ o.value('lzo', 'lzo');
+ o.value('lz4', 'lz4');
+ o.value('deflate', 'deflate');
+
+ o = s.taboption('zram', form.Value, 'zram_comp_streams', _('ZRam Compression Streams'), _('Number of parallel threads used for compression'));
+ o.optional = true;
+ o.placeholder = 1;
+ o.datatype = 'uinteger';
+ }
+
+ /*
+ * Language & Style
+ */
+
+ o = s.taboption('language', form.ListValue, '_lang', _('Language'))
+ o.uciconfig = 'luci';
+ o.ucisection = 'main';
+ o.ucioption = 'lang';
+ o.value('auto');
+
+ var k = Object.keys(uci.get('luci', 'languages') || {}).sort();
+ for (var i = 0; i < k.length; i++)
+ if (k[i].charAt(0) != '.')
+ o.value(k[i], uci.get('luci', 'languages', k[i]));
+
+ o = s.taboption('language', form.ListValue, '_mediaurlbase', _('Design'))
+ o.uciconfig = 'luci';
+ o.ucisection = 'main';
+ o.ucioption = 'mediaurlbase';
+
+ var k = Object.keys(uci.get('luci', 'themes') || {}).sort();
+ for (var i = 0; i < k.length; i++)
+ if (k[i].charAt(0) != '.')
+ o.value(uci.get('luci', 'themes', k[i]), k[i]);
+
+ /*
+ * NTP
+ */
+
+ if (ntpd_support != null) {
+ var default_servers = [
+ '0.openwrt.pool.ntp.org', '1.openwrt.pool.ntp.org',
+ '2.openwrt.pool.ntp.org', '3.openwrt.pool.ntp.org'
+ ];
+
+ o = s.taboption('timesync', form.Flag, 'enabled', _('Enable NTP client'));
+ o.rmempty = false;
+ o.ucisection = 'ntp';
+ o.default = o.disabled;
+ o.write = function(section_id, value) {
+ ntpd_support = +value;
+
+ if (ntpd_support && !uci.get('system', 'ntp')) {
+ uci.add('system', 'timeserver', 'ntp');
+ uci.set('system', 'ntp', 'server', default_servers);
+ }
+
+ if (!ntpd_support)
+ uci.set('system', 'ntp', 'enabled', 0);
+ else
+ uci.unset('system', 'ntp', 'enabled');
+
+ return callInitAction('sysntpd', 'enable');
+ };
+ o.load = function(section_id) {
+ return (ntpd_support == 1 &&
+ uci.get('system', 'ntp') != null &&
+ uci.get('system', 'ntp', 'enabled') != 0) ? '1' : '0';
+ };
+
+ o = s.taboption('timesync', form.Flag, 'enable_server', _('Provide NTP server'));
+ o.ucisection = 'ntp';
+ o.depends('enabled', '1');
+
+ o = s.taboption('timesync', form.DynamicList, 'server', _('NTP server candidates'));
+ o.datatype = 'host(0)';
+ o.ucisection = 'ntp';
+ o.depends('enabled', '1');
+ o.remove = function() {}; // retain server list even if disabled
+ o.load = function(section_id) {
+ return uci.get('system', 'ntp')
+ ? uci.get('system', 'ntp', 'server')
+ : default_servers;
+ };
+ }
+
+ return m.render().then(function(mapEl) {
+ L.Poll.add(function() {
+ return callGetLocaltime().then(function(t) {
+ mapEl.querySelector('#localtime').innerHTML = new Date(t * 1000).toLocaleString();
+ });
+ });
+
+ return mapEl;
+ });
+ }
+});
diff --git a/modules/luci-mod-system/luasrc/controller/admin/system.lua b/modules/luci-mod-system/luasrc/controller/admin/system.lua
index 49d4476c4e..d73a1cbdb4 100644
--- a/modules/luci-mod-system/luasrc/controller/admin/system.lua
+++ b/modules/luci-mod-system/luasrc/controller/admin/system.lua
@@ -7,7 +7,7 @@ module("luci.controller.admin.system", package.seeall)
function index()
local fs = require "nixio.fs"
- entry({"admin", "system", "system"}, cbi("admin_system/system"), _("System"), 1)
+ entry({"admin", "system", "system"}, view("system/system"), _("System"), 1)
entry({"admin", "system", "clock_status"}, post_on({ set = true }, "action_clock_status"))
entry({"admin", "system", "ntp_restart"}, call("action_ntp_restart"), nil).leaf = true
@@ -32,7 +32,7 @@ function index()
local nodes, number = fs.glob("/sys/class/leds/*")
if number > 0 then
- entry({"admin", "system", "leds"}, cbi("admin_system/leds"), _("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), 60)
+ entry({"admin", "system", "leds"}, view("system/leds"), _("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), 60)
end
entry({"admin", "system", "flashops"}, call("action_flashops"), _("Backup / Flash Firmware"), 70)
diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/leds.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/leds.lua
deleted file mode 100644
index 525ce71bf9..0000000000
--- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/leds.lua
+++ /dev/null
@@ -1,188 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Licensed to the public under the Apache License 2.0.
-
-m = Map("system", translate("<abbr title=\"Light Emitting Diode\">LED</abbr> Configuration"), translate("Customizes the behaviour of the device <abbr title=\"Light Emitting Diode\">LED</abbr>s if possible."))
-
-local sysfs_path = "/sys/class/leds/"
-local leds = {}
-
-local fs = require "nixio.fs"
-local nu = require "nixio.util"
-local util = require "luci.util"
-
-if fs.access(sysfs_path) then
- leds = nu.consume((fs.dir(sysfs_path)))
-end
-
-if #leds == 0 then
- return m
-end
-
-
-s = m:section(TypedSection, "led", "")
-s.anonymous = true
-s.addremove = true
-
-function s.parse(self, ...)
- TypedSection.parse(self, ...)
- os.execute("/etc/init.d/led enable")
-end
-
-
-s:option(Value, "name", translate("Name"))
-
-
-sysfs = s:option(ListValue, "sysfs", translate("<abbr title=\"Light Emitting Diode\">LED</abbr> Name"))
-for k, v in ipairs(leds) do
- sysfs:value(v)
-end
-
-s:option(Flag, "default", translate("Default state")).rmempty = false
-
-
-trigger = s:option(ListValue, "trigger", translate("Trigger"))
-
-local triggers = fs.readfile(sysfs_path .. leds[1] .. "/trigger")
-for t in triggers:gmatch("[%w-]+") do
- if t == "default-on" then
- trigger:value(t, translatef("Always on (%s)", t))
- elseif t == "none" then
- trigger:value(t, translatef("Always off (%s)", t))
- elseif t == "timer" then
- trigger:value(t, translatef("Custom flash interval (%s)", t))
- elseif t == "netdev" then
- trigger:value(t, translatef("Network device activity (%s)", t))
- elseif t == "heartbeat" then
- trigger:value(t, translatef("Heartbeat interval (%s)", t))
- elseif t == "nand-disk" then
- trigger:value(t, translatef("Flash memory activity (%s)", t))
- elseif t == "mtd" then
- trigger:value(t, translatef("Flash memory activity (%s)", t))
- elseif t:match("mmc[0-9]") then
- trigger:value(t, translatef("Flash memory activity (%s)", t))
- elseif t:match("switch[0-9]") then
- trigger:value(t, translatef("Switchport activity (%s)", t))
- elseif t:match("phy[0-9]rx") then
- trigger:value(t, translatef("Wi-Fi data reception (%s)", t))
- elseif t:match("phy[0-9]tx") then
- trigger:value(t, translatef("Wi-Fi data transmission (%s)", t))
- elseif t:match("phy[0-9]assoc") then
- trigger:value(t, translatef("Wi-Fi client association (%s)", t))
- elseif t:match("phy[0-9]radio") then
- trigger:value(t, translatef("Wi-Fi on (%s)", t))
- elseif t:match("phy[0-9]tpt") then
- trigger:value(t, translatef("Wi-Fi activity (%s)", t))
- else
- trigger:value(t, translate(t:gsub("-", "")))
- end
-end
-
-
-delayon = s:option(Value, "delayon", translate ("On-State Delay"))
-delayon:depends("trigger", "timer")
-
-delayoff = s:option(Value, "delayoff", translate ("Off-State Delay"))
-delayoff:depends("trigger", "timer")
-
-
-dev = s:option(Value, "_net_dev", translate("Device"))
-dev.rmempty = true
-dev:value("")
-dev:depends("trigger", "netdev")
-
-function dev.cfgvalue(self, section)
- return m.uci:get("system", section, "dev")
-end
-
-function dev.write(self, section, value)
- m.uci:set("system", section, "dev", value)
-end
-
-function dev.remove(self, section)
- local t = trigger:formvalue(section)
- if t ~= "netdev" and t ~= "usbdev" then
- m.uci:delete("system", section, "dev")
- end
-end
-
-for k, v in pairs(luci.sys.net.devices()) do
- if v ~= "lo" then
- dev:value(v)
- end
-end
-
-
-mode = s:option(MultiValue, "mode", translate("Trigger Mode"))
-mode.rmempty = true
-mode:depends("trigger", "netdev")
-mode:value("link", translate("Link On"))
-mode:value("tx", translate("Transmit"))
-mode:value("rx", translate("Receive"))
-
-
-usbdev = s:option(ListValue, "_usb_dev", translate("USB Device"))
-usbdev:depends("trigger", "usbdev")
-usbdev.rmempty = true
-usbdev:value("")
-
-function usbdev.cfgvalue(self, section)
- return m.uci:get("system", section, "dev")
-end
-
-function usbdev.write(self, section, value)
- m.uci:set("system", section, "dev", value)
-end
-
-function usbdev.remove(self, section)
- local t = trigger:formvalue(section)
- if t ~= "netdev" and t ~= "usbdev" then
- m.uci:delete("system", section, "dev")
- end
-end
-
-
-usbport = s:option(MultiValue, "port", translate("USB Ports"))
-usbport:depends("trigger", "usbport")
-usbport.rmempty = true
-usbport.widget = "checkbox"
-usbport.cast = "table"
-usbport.size = 1
-
-function usbport.valuelist(self, section)
- local port, ports = nil, {}
- for port in util.imatch(m.uci:get("system", section, "port")) do
- local b, n = port:match("^usb(%d+)-port(%d+)$")
- if not (b and n) then
- b, n = port:match("^(%d+)-(%d+)$")
- end
- if b and n then
- ports[#ports+1] = "usb%u-port%u" %{ tonumber(b), tonumber(n) }
- end
- end
- return ports
-end
-
-function usbport.validate(self, value)
- return type(value) == "string" and { value } or value
-end
-
-
-for p in nixio.fs.glob("/sys/bus/usb/devices/[0-9]*/manufacturer") do
- local id = p:match("%d+-%d+")
- local mf = nixio.fs.readfile("/sys/bus/usb/devices/" .. id .. "/manufacturer") or "?"
- local pr = nixio.fs.readfile("/sys/bus/usb/devices/" .. id .. "/product") or "?"
- usbdev:value(id, "%s (%s - %s)" %{ id, mf, pr })
-end
-
-for p in nixio.fs.glob("/sys/bus/usb/devices/*/usb[0-9]*-port[0-9]*") do
- local bus, port = p:match("usb(%d+)-port(%d+)")
- if bus and port then
- usbport:value("usb%u-port%u" %{ tonumber(bus), tonumber(port) },
- "Hub %u, Port %u" %{ tonumber(bus), tonumber(port) })
- end
-end
-
-port_mask = s:option(Value, "port_mask", translate ("Switch Port Mask"))
-port_mask:depends("trigger", "switch0")
-
-return m
diff --git a/modules/luci-mod-system/luasrc/model/cbi/admin_system/system.lua b/modules/luci-mod-system/luasrc/model/cbi/admin_system/system.lua
deleted file mode 100644
index 33ec027e0d..0000000000
--- a/modules/luci-mod-system/luasrc/model/cbi/admin_system/system.lua
+++ /dev/null
@@ -1,271 +0,0 @@
--- Copyright 2008 Steven Barth <steven@midlink.org>
--- Copyright 2011 Jo-Philipp Wich <jow@openwrt.org>
--- Licensed to the public under the Apache License 2.0.
-
-local sys = require "luci.sys"
-local zones = require "luci.sys.zoneinfo"
-local fs = require "nixio.fs"
-local conf = require "luci.config"
-
-local m, s, o
-local has_ntpd = fs.access("/usr/sbin/ntpd")
-local has_zram = fs.access("/etc/init.d/zram")
-
-m = Map("system", translate("System"), translate("Here you can configure the basic aspects of your device like its hostname or the timezone."))
-m:chain("luci")
-
-
-s = m:section(TypedSection, "system", translate("System Properties"))
-s.anonymous = true
-s.addremove = false
-
-s:tab("general", translate("General Settings"))
-s:tab("logging", translate("Logging"))
-s:tab("language", translate("Language and Style"))
-s:tab("advanced", translate("Advanced"))
-if has_zram then s:tab("zram", translate("ZRam Settings")) end
-
---
--- System Properties
---
-
-o = s:taboption("general", DummyValue, "_systime", translate("Local Time"))
-o.template = "admin_system/clock_status"
-
-
-o = s:taboption("general", Value, "hostname", translate("Hostname"))
-o.datatype = "hostname"
-
-function o.write(self, section, value)
- Value.write(self, section, value)
- sys.hostname(value)
-end
-
-
-o = s:taboption("general", ListValue, "zonename", translate("Timezone"))
-o:value("UTC")
-
-for i, zone in ipairs(zones.TZ) do
- o:value(zone[1])
-end
-
-function o.write(self, section, value)
- local function lookup_zone(title)
- for _, zone in ipairs(zones.TZ) do
- if zone[1] == title then return zone[2] end
- end
- end
-
- AbstractValue.write(self, section, value)
- local timezone = lookup_zone(value) or "GMT0"
- self.map.uci:set("system", section, "timezone", timezone)
- fs.writefile("/etc/TZ", timezone .. "\n")
-end
-
-
---
--- Logging
---
-
-o = s:taboption("logging", Value, "log_size", translate("System log buffer size"), translate("KiB"))
-o.optional = true
-o.placeholder = 16
-o.datatype = "uinteger"
-
-o = s:taboption("logging", Value, "log_ip", translate("External system log server"))
-o.optional = true
-o.placeholder = "0.0.0.0"
-o.datatype = "ip4addr"
-
-o = s:taboption("logging", Value, "log_port", translate("External system log server port"))
-o.optional = true
-o.placeholder = 514
-o.datatype = "port"
-
-o = s:taboption("logging", ListValue, "log_proto", translate("External system log server protocol"))
-o:value("udp", "UDP")
-o:value("tcp", "TCP")
-
-o = s:taboption("logging", Value, "log_file", translate("Write system log to file"))
-o.optional = true
-o.placeholder = "/tmp/system.log"
-
-o = s:taboption("logging", ListValue, "conloglevel", translate("Log output level"))
-o:value(8, translate("Debug"))
-o:value(7, translate("Info"))
-o:value(6, translate("Notice"))
-o:value(5, translate("Warning"))
-o:value(4, translate("Error"))
-o:value(3, translate("Critical"))
-o:value(2, translate("Alert"))
-o:value(1, translate("Emergency"))
-
-o = s:taboption("logging", ListValue, "cronloglevel", translate("Cron Log Level"))
-o.default = 8
-o:value(5, translate("Debug"))
-o:value(8, translate("Normal"))
-o:value(9, translate("Warning"))
-
-
---
--- Zram Properties
---
-if has_zram then
- o = s:taboption("zram", Value, "zram_size_mb", translate("ZRam Size"), translate("Size of the ZRam device in megabytes"))
- o.optional = true
- o.placeholder = 16
- o.datatype = "uinteger"
-
- o = s:taboption("zram", ListValue, "zram_comp_algo", translate("ZRam Compression Algorithm"))
- o.optional = true
- o.placeholder = lzo
- o:value("lzo", "lzo")
- o:value("lz4", "lz4")
- o:value("deflate", "deflate")
-
- o = s:taboption("zram", Value, "zram_comp_streams", translate("ZRam Compression Streams"), translate("Number of parallel threads used for compression"))
- o.optional = true
- o.placeholder = 1
- o.datatype = "uinteger"
-end
-
-
---
--- Language & Style
---
-
-o = s:taboption("language", ListValue, "_lang", translate("Language"))
-o:value("auto")
-
-local i18ndir = luci.i18n.i18ndir .. "base."
-for k, v in luci.util.kspairs(conf.languages) do
- local file = i18ndir .. k:gsub("_", "-")
- if k:sub(1, 1) ~= "." and fs.access(file .. ".lmo") then
- o:value(k, v)
- end
-end
-
-function o.cfgvalue(...)
- return m.uci:get("luci", "main", "lang")
-end
-
-function o.write(self, section, value)
- m.uci:set("luci", "main", "lang", value)
-end
-
-
-o = s:taboption("language", ListValue, "_mediaurlbase", translate("Theme"))
-for k, v in pairs(conf.themes) do
- if k:sub(1, 1) ~= "." then
- o:value(v, k)
- end
-end
-
-function o.cfgvalue(...)
- return m.uci:get("luci", "main", "mediaurlbase")
-end
-
-function o.write(self, section, value)
- m.uci:set("luci", "main", "mediaurlbase", value)
-end
-
-
---
--- Advanced
---
-
-o = s:taboption("advanced", Value, "_pollinterval",
- translate("Polling interval"),
- translate("Polling interval for status queries in seconds"))
-o.datatype = "range(3, 20)"
-o.default = 5
-o:value("3")
-o:value("5")
-o:value("10")
-
-function o.cfgvalue(...)
- return m.uci:get("luci", "main", "pollinterval")
-end
-
-function o.write(self, section, value)
- m.uci:set("luci", "main", "pollinterval", value)
-end
-
-
---
--- NTP
---
-
-if has_ntpd then
-
- -- timeserver setup was requested, create section and reload page
- if m:formvalue("cbid.system._timeserver._enable") then
- m.uci:section("system", "timeserver", "ntp",
- {
- server = { "0.openwrt.pool.ntp.org", "1.openwrt.pool.ntp.org", "2.openwrt.pool.ntp.org", "3.openwrt.pool.ntp.org" }
- }
- )
-
- m.uci:save("system")
- luci.http.redirect(luci.dispatcher.build_url("admin/system", arg[1]))
- return
- end
-
- local has_section = false
- m.uci:foreach("system", "timeserver",
- function(s)
- has_section = true
- return false
- end)
-
- if not has_section then
-
- s = m:section(TypedSection, "timeserver", translate("Time Synchronization"))
- s.anonymous = true
- s.cfgsections = function() return { "_timeserver" } end
-
- x = s:option(Button, "_enable")
- x.title = translate("Time Synchronization is not configured yet.")
- x.inputtitle = translate("Set up Time Synchronization")
- x.inputstyle = "apply"
-
- else
-
- s = m:section(TypedSection, "timeserver", translate("Time Synchronization"))
- s.anonymous = true
- s.addremove = false
-
- o = s:option(Flag, "enable", translate("Enable NTP client"))
- o.rmempty = false
-
- function o.cfgvalue(self)
- return sys.init.enabled("sysntpd")
- and self.enabled or self.disabled
- end
-
- function o.write(self, section, value)
- if value == self.enabled then
- sys.init.enable("sysntpd")
- sys.call("env -i /etc/init.d/sysntpd start >/dev/null")
- else
- sys.call("env -i /etc/init.d/sysntpd stop >/dev/null")
- sys.init.disable("sysntpd")
- end
- end
-
-
- o = s:option(Flag, "enable_server", translate("Provide NTP server"))
- o:depends("enable", "1")
-
-
- o = s:option(DynamicList, "server", translate("NTP server candidates"))
- o.datatype = "host(0)"
- o:depends("enable", "1")
-
- -- retain server list even if disabled
- function o.remove() end
-
- end
-end
-
-return m
diff --git a/modules/luci-mod-system/luasrc/view/admin_system/clock_status.htm b/modules/luci-mod-system/luasrc/view/admin_system/clock_status.htm
deleted file mode 100644
index 796aa695c6..0000000000
--- a/modules/luci-mod-system/luasrc/view/admin_system/clock_status.htm
+++ /dev/null
@@ -1,56 +0,0 @@
-<%+cbi/valueheader%>
-
-<script type="text/javascript">//<![CDATA[
- XHR.poll(-1, '<%=url('admin/system/clock_status')%>', null,
- function(x, rv)
- {
- var s = document.getElementById('<%=self.option%>-clock-status');
- if (s)
- {
- s.innerHTML = rv.timestring || '?';
- }
- }
- );
-
- function sync_clock(btn)
- {
- btn.disabled = true;
- btn.value = '<%:Synchronizing...%>';
-
- (new XHR()).post('<%=url('admin/system/clock_status')%>',
- { token: '<%=token%>', set: Math.floor((new Date()).getTime() / 1000) },
- function()
- {
- btn.disabled = false;
- btn.value = '<%:Sync with browser%>';
- }
- );
-
- return false;
- }
-
- function btn_action(action)
- {
- if (action.name === "do_ntp_restart")
- {
- new XHR.get('<%=luci.dispatcher.build_url("admin", "system", "ntp_restart")%>', null,
- function(x)
- {
- if (!x)
- {
- return;
- }
- });
- }
- }
-
-//]]></script>
-
-<span id="<%=self.option%>-clock-status"><em><%:Collecting data...%></em></span>
-<input type="button" class="cbi-button cbi-button-apply" value="<%:Sync with browser%>" onclick="return sync_clock(this)" />
-
-<% if require("nixio.fs").access("/etc/init.d/sysntpd") then %>
-<input type="button" class="cbi-button cbi-button-apply" name="do_ntp_restart" value="<%:Sync with NTP-Server%>" onclick="btn_action(this)" />
-<% end %>
-
-<%+cbi/valuefooter%>