summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js
blob: f510229523bca07842502b8a46fdb23fc3415080 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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();
	}
});