From 836626260ab0b9bde6d10a3d50b6ba9d581e2d4e Mon Sep 17 00:00:00 2001 From: Van Waholtz Date: Sat, 9 May 2020 10:04:25 +0800 Subject: luci-app-hd-idle: convert to client side rendering Signed-off-by: Van Waholtz --- .../htdocs/luci-static/resources/view/hd_idle.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js (limited to 'applications/luci-app-hd-idle/htdocs/luci-static') diff --git a/applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js b/applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js new file mode 100644 index 0000000000..f510229523 --- /dev/null +++ b/applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js @@ -0,0 +1,44 @@ +'use strict'; +'require form'; +'require fs'; +'require view'; + +return view.extend({ + load: function() { + return fs.list('/dev').then(function(devs) { + return devs.filter(function(dev) { + return dev.type == 'block' ? dev.name.match(/^[sh]d[a-z]$/) : false; + }); + }); + }, + + render: function(devs) { + var m, s, o; + m = new form.Map('hd-idle', _('HDD Idle'), _('HDD Idle is a utility program for spinning-down external disks after a period of idle time.')); + + s = m.section(form.TypedSection, 'hd-idle', _('Settings')); + s.anonymous = true; + s.addremove = true; + s.addbtntitle = _('Add new hdd setting...'); + + o = s.option(form.Flag, 'enabled', _('Enable')); + o.rmempty = false; + + o = s.option(form.Value, 'disk', _('Disk')); + devs.forEach(function(dev) { + o.value(dev.name); + }); + + o = s.option(form.Value, 'idle_time_interval', _('Idle time')); + o.default = 10; + + o = s.option(form.ListValue, 'idle_time_unit', _('Idle time unit')); + o.value('seconds', _('s', 'Abbreviation for seconds')); + o.value('minutes', _('min', 'Abbreviation for minutes')); + o.value('hours', _('h', 'Abbreviation for hours')); + o.value('days', _('d', 'Abbreviation for days')); + o.default = 'minutes'; + + return m.render(); + } +}); -- cgit v1.2.3