luci-app-hd-idle: Improve content shown by luci.

Signed-off-by: Patrick Siegl <3261314+psiegl@users.noreply.github.com>
This commit is contained in:
Patrick Siegl 2021-10-13 21:24:56 +02:00
parent e9039ae8f5
commit 55e725ab7b
28 changed files with 111 additions and 59 deletions

View file

@ -2,43 +2,95 @@
'require form';
'require fs';
'require view';
'require uci';
function disk(devs, options, section_id) {
var v = uci.get('hd-idle', section_id, 'disk') || '';
var disk = devs.find(function(itm){ return itm.name == v; });
var out = '';
if(disk != undefined){
out = options.map(function(opt){ return disk[opt].trim(); });
out = out.filter(function(o){ return o != ''; });
out = out.join(' ');
}
return E('span', out);
}
function prettytime(section_id) {
return E('span', (uci.get('hd-idle', section_id, 'idle_time_interval') || '')
+ ' '
+ (uci.get('hd-idle', section_id, 'idle_time_unit') || ''));
}
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;
});
return fs.exec("/usr/bin/lsblk", ["-n", "-J", "-do", "NAME,TRAN,ROTA,RM,VENDOR,MODEL"]).then(function(res) {
if( res.code )
return [];
var json = JSON.parse(res.stdout);
return ( 'blockdevices' in json ) ? json['blockdevices'] : [];
});
},
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.'));
m = new form.Map('hd-idle', _('HDD Idle'), _('HDD Idle is a utility program for spinning-down disks after a period of idle time.'));
s = m.section(form.TypedSection, 'hd-idle', _('Settings'));
s = m.section(form.GridSection, 'hd-idle', _('Settings'));
s.anonymous = true;
s.addremove = true;
s.sortable = true;
s.addbtntitle = _('Add new hdd setting...');
o = s.option(form.Flag, 'enabled', _('Enable'));
o.rmempty = false;
o = s.option(form.Value, 'disk', _('Disk'));
s.tab('general', _('Disk Settings'));
o = s.taboption('general', form.Flag, 'enabled', _('Enable'));
o.rmempty = false;
o.editable = true;
o = s.taboption('general', form.ListValue, 'disk', _('Disk'));
devs.forEach(function(dev) {
o.value(dev.name);
if( dev.rota ) {
o.value(dev.name, `/dev/${dev.name} [${dev.tran}:${dev.vendor} ${dev.model}]`);
}
});
o = s.option(form.Value, 'idle_time_interval', _('Idle time'));
o = s.taboption('general', form.Value, '_bus', _('Bus'));
o.rawhtml = true;
o.write = function() {};
o.remove = function() {};
o.modalonly = false;
o.textvalue = disk.bind(o, devs, ['tran']);
o = s.taboption('general', form.Value, '_vendorModel', _('Vendor / Model'));
o.rawhtml = true;
o.write = function() {};
o.remove = function() {};
o.modalonly = false;
o.textvalue = disk.bind(o, devs, ['vendor', 'model'] );
o = s.taboption('general', form.Value, 'idle_time_interval', _('Idle time'));
o.modalonly = true;
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 = s.taboption('general', form.ListValue, 'idle_time_unit', _('Idle time unit'));
o.modalonly = true;
o.value('seconds', _('seconds', 'Abbreviation for seconds'));
o.value('minutes', _('minutes', 'Abbreviation for minutes'));
o.value('hours', _('hours', 'Abbreviation for hours'));
o.value('days', _('days', 'Abbreviation for days'));
o.default = 'minutes';
o = s.taboption('general', form.Value, '_prettytime', _('Idle time'));
o.rawhtml = true;
o.write = function() {};
o.remove = function() {};
o.modalonly = false;
o.textvalue = prettytime.bind(o);
return m.render();
}
});

View file

@ -39,10 +39,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle és un programa per ralentitzar els discos externs després d'un "
"HDD Idle és un programa per ralentitzar els discos després d'un "
"període de temps inactiu."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -39,10 +39,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle je utilita pro vypnutí externích pevných disků po určité době "
"HDD Idle je utilita pro vypnutí pevných disků po určité době "
"nečinnosti."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -37,10 +37,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle ist ein Hilfsprogramm um externe Festplatten nach einer "
"HDD Idle ist ein Hilfsprogramm um Festplatten nach einer "
"festgelegten Leerlaufzeit herunter zu fahren."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -36,7 +36,7 @@ msgstr ""
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""

View file

@ -34,10 +34,10 @@ msgstr ""
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -37,10 +37,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle es un programa que administra la suspensión de discos externos tras "
"HDD Idle es un programa que administra la suspensión de discos tras "
"un tiempo de inactividad."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -37,10 +37,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle est un utilitaire pour arrêter la rotation des disques externes "
"HDD Idle est un utilitaire pour arrêter la rotation des disques "
"après une période d'inactivité."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -39,10 +39,10 @@ msgstr ""
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle הינה תוכנת שירות שמטרתה להקטין את מהירות הסיבוב של כוננים חיצוניים "
"HDD Idle הינה תוכנת שירות שמטרתה להקטין את מהירות הסיבוב של כוננים "
"לאחר זמן מסוים של חוסר פעילות."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -41,7 +41,7 @@ msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"period of idle time."
msgstr ""
"HDD Idle egy a külső lemezek adott üresjárati idő után történő leállítására "
"HDD Idle egy a lemezek adott üresjárati idő után történő leállítására "
"szolgáló segédprogram."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -37,10 +37,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle è un programma per mettere in standby i dischi esterni dopo un "
"HDD Idle è un programma per mettere in standby i dischi dopo un "
"periodo di inattività."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -40,7 +40,7 @@ msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"period of idle time."
msgstr ""
"HDD Idleはアイドル時に外部ディスクをスピンダウンさせるための、ユーティリティ"
"HDD Idleはアイドル時にィスクをスピンダウンさせるための、ユーティリティ"
"プログラムです。"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -35,7 +35,7 @@ msgstr ""
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""

View file

@ -33,10 +33,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle er et verktøy for å spinne ned eksterne disker etter en periode med "
"HDD Idle er et verktøy for å spinne ned disker etter en periode med "
"inaktivitet."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -38,10 +38,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle jest narzędziem do zwalniania obrotów zewnętrznych dysków po "
"HDD Idle jest narzędziem do zwalniania obrotów dysków po "
"określonym czasie bezczynności."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -37,11 +37,11 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle é um programa utilitário para activar o modo \"economia de energia"
"\" (spinning-down) de discos externos após um período de ociosidade."
"\" (spinning-down) de discos após um período de ociosidade."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32
msgid "Idle time"

View file

@ -37,11 +37,11 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle é um programa utilitário para ativar o modo \"economia de energia"
"\" (spinning-down) de discos externos após um período de ociosidade."
"\" (spinning-down) de discos após um período de ociosidade."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32
msgid "Idle time"

View file

@ -39,10 +39,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle este un utilitar pentru a oprit din rotatie hard disc-urile externe "
"HDD Idle este un utilitar pentru a oprit din rotatie hard disc-urile "
"dupa o anumita perioada de inactivitate."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -39,10 +39,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"Утилита HDD Idle позволяет замедлять внешние диски после определённого "
"Утилита HDD Idle позволяет замедлять диски после определённого "
"времени бездействия."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -35,7 +35,7 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr "HDD Idle je program na uspanie disku po nastavenom čase."

View file

@ -35,7 +35,7 @@ msgstr ""
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""

View file

@ -24,7 +24,7 @@ msgstr ""
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""

View file

@ -39,7 +39,7 @@ msgstr "Harddisk-Park"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle, belirli bir zaman sonra diskleri beklemeye alan bir yardımcı "

View file

@ -40,10 +40,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"Засіб HDD Idle дозволяє уповільнювати зовнішні диски після певного часу "
"Засіб HDD Idle дозволяє уповільнювати диски після певного часу "
"бездіяльності."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -37,10 +37,10 @@ msgstr "HDD Idle"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr ""
"HDD Idle là một chương trình tiện ích để quay các đĩa ngoài sau một khoảng "
"HDD Idle là một chương trình tiện ích để quay các đĩa sau một khoảng "
"thời gian idle."
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32

View file

@ -37,7 +37,7 @@ msgstr "硬盘休眠"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:17
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"HDD Idle is a utility program for spinning-down disks after a "
"period of idle time."
msgstr "硬盘休眠是控制当硬盘在空闲一段时间后进入休眠模式的工具。"

View file

@ -37,7 +37,7 @@ msgstr "硬碟休眠"
msgid ""
"HDD Idle is a utility program for spinning-down external disks after a "
"period of idle time."
msgstr "HDD Idle是一個實用程式用於在一段時間的空閒時間後對部磁盤降低轉速。"
msgstr "HDD Idle是一個實用程式用於在一段時間的空閒時間後對部磁盤降低轉速。"
#: applications/luci-app-hd-idle/htdocs/luci-static/resources/view/hd_idle.js:32
msgid "Idle time"

View file

@ -3,7 +3,7 @@
"description": "Grant UCI access for luci-app-hd-idle",
"read": {
"file": {
"/dev": [ "list" ]
"/usr/bin/lsblk -n -J -do NAME,TRAN,ROTA,RM,VENDOR,MODEL": [ "exec" ]
},
"uci": [ "hd-idle" ]
},