Skip to content

Commit 46e1e52

Browse files
committed
luci-app-smart-reboot: add LuCI frontend
Add LuCI UI for configuring smart-reboot. - Enable/disable toggle and HH:MM reboot time input - Interface selection with select-all option - Show last automatic reboot timestamp - Provide i18n catalogs for 18 languages Signed-off-by: Minicom Developer <3387910@naver.com> Signed-off-by: minicom365 <3387910@naver.com>
1 parent 90cf1c1 commit 46e1e52

File tree

22 files changed

+849
-0
lines changed

22 files changed

+849
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_NAME:=luci-app-smart-reboot
4+
PKG_RELEASE:=6
5+
6+
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
7+
PO2LMO:=$(STAGING_DIR_HOSTPKG)/bin/po2lmo
8+
9+
include $(INCLUDE_DIR)/package.mk
10+
11+
define Package/luci-app-smart-reboot
12+
SECTION:=luci
13+
CATEGORY:=LuCI
14+
SUBMENU:=3. Applications
15+
TITLE:=LuCI support for smart-reboot
16+
DEPENDS:=+luci-base +smart-reboot
17+
endef
18+
19+
define Package/luci-app-smart-reboot/description
20+
LuCI support for smart-reboot package.
21+
endef
22+
23+
define Build/Compile
24+
$(INSTALL_DIR) $(PKG_BUILD_DIR)/i18n
25+
for po in ./po/*/smart-reboot.po; do \
26+
lang=$$(basename $$(dirname $$$$po)); \
27+
$(PO2LMO) $$$$po $(PKG_BUILD_DIR)/i18n/smart-reboot.$$$$lang.lmo; \
28+
done
29+
endef
30+
31+
define Package/luci-app-smart-reboot/install
32+
$(INSTALL_DIR) $(1)/www
33+
$(CP) ./htdocs/* $(1)/www/
34+
35+
$(INSTALL_DIR) $(1)/
36+
$(CP) ./root/* $(1)/
37+
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
38+
$(CP) $(PKG_BUILD_DIR)/i18n/*.lmo $(1)/usr/lib/lua/luci/i18n/
39+
endef
40+
41+
$(eval $(call BuildPackage,luci-app-smart-reboot))
42+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
'use strict';
2+
'require view';
3+
'require form';
4+
'require network';
5+
'require uci';
6+
7+
return view.extend({
8+
load: function() {
9+
return Promise.all([
10+
network.getNetworks(),
11+
network.getDevices()
12+
]);
13+
},
14+
15+
render: function(data) {
16+
var m, s, o;
17+
var networks = data[0] || [];
18+
var devices = data[1] || [];
19+
var ifaceMap = {};
20+
21+
m = new form.Map('smart-reboot', _('Smart Reboot'),
22+
_('Reboot only when the network is idle at the configured dawn time.'));
23+
24+
s = m.section(form.TypedSection, 'settings', _('Settings'));
25+
s.anonymous = true;
26+
27+
o = s.option(form.Flag, 'enabled', _('Enable'));
28+
o.rmempty = false;
29+
30+
o = s.option(form.DummyValue, 'last_auto_reboot', _('Last automatic reboot'));
31+
o.cfgvalue = function(section_id) {
32+
return uci.get('smart-reboot', section_id, 'last_auto_reboot') || _('Never');
33+
};
34+
35+
o = s.option(form.Value, 'time', _('Reboot time (HH:MM)'));
36+
o.placeholder = '04:00';
37+
o.rmempty = false;
38+
o.validate = function(section_id, value) {
39+
if (!value || !value.match(/^([01][0-9]|2[0-3]):[0-5][0-9]$/))
40+
return _('Time format must be HH:MM (24-hour). Example: 04:00');
41+
42+
return true;
43+
};
44+
45+
o = s.option(form.Flag, 'all_ifaces', _('Select all interfaces'));
46+
o.rmempty = false;
47+
48+
o = s.option(form.MultiValue, 'ifaces', _('Monitored interfaces'));
49+
o.widget = 'select';
50+
o.size = 8;
51+
o.depends('all_ifaces', '0');
52+
o.depends('all_ifaces', '');
53+
54+
networks.forEach(function(netif) {
55+
var logical = netif.getName();
56+
var dev = netif.getL3Device() || netif.getL2Device() || netif.getDevice();
57+
var ifname = dev && dev.getName ? dev.getName() : null;
58+
59+
if (!ifname || ifname === 'lo')
60+
return;
61+
62+
ifaceMap[ifname] = ifaceMap[ifname] || { labels: [] };
63+
if (logical && ifaceMap[ifname].labels.indexOf(logical) < 0)
64+
ifaceMap[ifname].labels.push(logical);
65+
});
66+
67+
(devices || []).forEach(function(dev) {
68+
var name = dev.getName();
69+
if (!name || name === 'lo')
70+
return;
71+
72+
ifaceMap[name] = ifaceMap[name] || { labels: [] };
73+
});
74+
75+
Object.keys(ifaceMap).sort().forEach(function(ifname) {
76+
var labels = ifaceMap[ifname].labels;
77+
var text = labels.length ? '%s (%s)'.format(labels.join(', '), ifname) : ifname;
78+
o.value(ifname, text);
79+
});
80+
81+
o = s.option(form.Value, 'sample_seconds', _('Idle sampling duration (seconds)'));
82+
o.datatype = 'uinteger';
83+
o.placeholder = '120';
84+
o.rmempty = false;
85+
86+
o = s.option(form.Value, 'byte_threshold', _('Idle threshold (bytes)'));
87+
o.datatype = 'uinteger';
88+
o.placeholder = '262144';
89+
o.rmempty = false;
90+
91+
return m.render();
92+
}
93+
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
msgid ""
2+
msgstr "Content-Type: text/plain; charset=UTF-8\nLanguage: ar\n"
3+
4+
msgid "Smart Reboot"
5+
msgstr "إعادة تشغيل ذكية"
6+
7+
msgid "Reboot only when the network is idle at the configured dawn time."
8+
msgstr "أعد التشغيل فقط عندما تكون الشبكة خاملة في وقت الفجر المحدد."
9+
10+
msgid "Settings"
11+
msgstr "الإعدادات"
12+
13+
msgid "Enable"
14+
msgstr "تمكين"
15+
16+
msgid "Last automatic reboot"
17+
msgstr "آخر إعادة تشغيل تلقائية"
18+
19+
msgid "Never"
20+
msgstr "أبدًا"
21+
22+
msgid "Reboot time (HH:MM)"
23+
msgstr "وقت إعادة التشغيل (HH:MM)"
24+
25+
msgid "Time format must be HH:MM (24-hour). Example: 04:00"
26+
msgstr "يجب أن يكون تنسيق الوقت HH:MM (24 ساعة). مثال: 04:00"
27+
28+
msgid "Select all interfaces"
29+
msgstr "تحديد جميع الواجهات"
30+
31+
msgid "Monitored interfaces"
32+
msgstr "الواجهات المُراقبة"
33+
34+
msgid "Idle sampling duration (seconds)"
35+
msgstr "مدة أخذ عينات الخمول (ثوانٍ)"
36+
37+
msgid "Idle threshold (bytes)"
38+
msgstr "حد الخمول (بايت)"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
msgid ""
2+
msgstr "Content-Type: text/plain; charset=UTF-8\nLanguage: de\n"
3+
4+
msgid "Smart Reboot"
5+
msgstr "Intelligenter Neustart"
6+
7+
msgid "Reboot only when the network is idle at the configured dawn time."
8+
msgstr "Nur neu starten, wenn das Netzwerk zur konfigurierten Zeit im Leerlauf ist."
9+
10+
msgid "Settings"
11+
msgstr "Einstellungen"
12+
13+
msgid "Enable"
14+
msgstr "Aktivieren"
15+
16+
msgid "Last automatic reboot"
17+
msgstr "Letzter automatischer Neustart"
18+
19+
msgid "Never"
20+
msgstr "Nie"
21+
22+
msgid "Reboot time (HH:MM)"
23+
msgstr "Neustartzeit (HH:MM)"
24+
25+
msgid "Time format must be HH:MM (24-hour). Example: 04:00"
26+
msgstr "Zeitformat muss HH:MM (24-Stunden) sein. Beispiel: 04:00"
27+
28+
msgid "Select all interfaces"
29+
msgstr "Alle Schnittstellen auswählen"
30+
31+
msgid "Monitored interfaces"
32+
msgstr "Überwachte Schnittstellen"
33+
34+
msgid "Idle sampling duration (seconds)"
35+
msgstr "Leerlauf-Abtastdauer (Sekunden)"
36+
37+
msgid "Idle threshold (bytes)"
38+
msgstr "Leerlauf-Schwellenwert (Bytes)"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
msgid ""
2+
msgstr "Content-Type: text/plain; charset=UTF-8\nLanguage: es\n"
3+
4+
msgid "Smart Reboot"
5+
msgstr "Reinicio inteligente"
6+
7+
msgid "Reboot only when the network is idle at the configured dawn time."
8+
msgstr "Reiniciar solo cuando la red esté inactiva a la hora de madrugada configurada."
9+
10+
msgid "Settings"
11+
msgstr "Configuración"
12+
13+
msgid "Enable"
14+
msgstr "Habilitar"
15+
16+
msgid "Last automatic reboot"
17+
msgstr "Último reinicio automático"
18+
19+
msgid "Never"
20+
msgstr "Nunca"
21+
22+
msgid "Reboot time (HH:MM)"
23+
msgstr "Hora de reinicio (HH:MM)"
24+
25+
msgid "Time format must be HH:MM (24-hour). Example: 04:00"
26+
msgstr "El formato de hora debe ser HH:MM (24 horas). Ejemplo: 04:00"
27+
28+
msgid "Select all interfaces"
29+
msgstr "Seleccionar todas las interfaces"
30+
31+
msgid "Monitored interfaces"
32+
msgstr "Interfaces monitorizadas"
33+
34+
msgid "Idle sampling duration (seconds)"
35+
msgstr "Duración de muestreo de inactividad (segundos)"
36+
37+
msgid "Idle threshold (bytes)"
38+
msgstr "Umbral de inactividad (bytes)"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
msgid ""
2+
msgstr "Content-Type: text/plain; charset=UTF-8\nLanguage: fr\n"
3+
4+
msgid "Smart Reboot"
5+
msgstr "Redémarrage intelligent"
6+
7+
msgid "Reboot only when the network is idle at the configured dawn time."
8+
msgstr "Redémarrer uniquement lorsque le réseau est inactif à l'heure d'aube configurée."
9+
10+
msgid "Settings"
11+
msgstr "Paramètres"
12+
13+
msgid "Enable"
14+
msgstr "Activer"
15+
16+
msgid "Last automatic reboot"
17+
msgstr "Dernier redémarrage automatique"
18+
19+
msgid "Never"
20+
msgstr "Jamais"
21+
22+
msgid "Reboot time (HH:MM)"
23+
msgstr "Heure de redémarrage (HH:MM)"
24+
25+
msgid "Time format must be HH:MM (24-hour). Example: 04:00"
26+
msgstr "Le format de l'heure doit être HH:MM (24h). Exemple : 04:00"
27+
28+
msgid "Select all interfaces"
29+
msgstr "Sélectionner toutes les interfaces"
30+
31+
msgid "Monitored interfaces"
32+
msgstr "Interfaces surveillées"
33+
34+
msgid "Idle sampling duration (seconds)"
35+
msgstr "Durée d'échantillonnage d'inactivité (secondes)"
36+
37+
msgid "Idle threshold (bytes)"
38+
msgstr "Seuil d'inactivité (octets)"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
msgid ""
2+
msgstr "Content-Type: text/plain; charset=UTF-8\nLanguage: id\n"
3+
4+
msgid "Smart Reboot"
5+
msgstr "Reboot Cerdas"
6+
7+
msgid "Reboot only when the network is idle at the configured dawn time."
8+
msgstr "Reboot hanya saat jaringan idle pada waktu dini hari yang dikonfigurasi."
9+
10+
msgid "Settings"
11+
msgstr "Pengaturan"
12+
13+
msgid "Enable"
14+
msgstr "Aktifkan"
15+
16+
msgid "Last automatic reboot"
17+
msgstr "Reboot otomatis terakhir"
18+
19+
msgid "Never"
20+
msgstr "Tidak pernah"
21+
22+
msgid "Reboot time (HH:MM)"
23+
msgstr "Waktu reboot (HH:MM)"
24+
25+
msgid "Time format must be HH:MM (24-hour). Example: 04:00"
26+
msgstr "Format waktu harus HH:MM (24 jam). Contoh: 04:00"
27+
28+
msgid "Select all interfaces"
29+
msgstr "Pilih semua antarmuka"
30+
31+
msgid "Monitored interfaces"
32+
msgstr "Antarmuka yang dipantau"
33+
34+
msgid "Idle sampling duration (seconds)"
35+
msgstr "Durasi sampling idle (detik)"
36+
37+
msgid "Idle threshold (bytes)"
38+
msgstr "Ambang idle (byte)"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
msgid ""
2+
msgstr "Content-Type: text/plain; charset=UTF-8\nLanguage: it\n"
3+
4+
msgid "Smart Reboot"
5+
msgstr "Riavvio intelligente"
6+
7+
msgid "Reboot only when the network is idle at the configured dawn time."
8+
msgstr "Riavvia solo quando la rete è inattiva all'ora dell'alba configurata."
9+
10+
msgid "Settings"
11+
msgstr "Impostazioni"
12+
13+
msgid "Enable"
14+
msgstr "Abilita"
15+
16+
msgid "Last automatic reboot"
17+
msgstr "Ultimo riavvio automatico"
18+
19+
msgid "Never"
20+
msgstr "Mai"
21+
22+
msgid "Reboot time (HH:MM)"
23+
msgstr "Ora di riavvio (HH:MM)"
24+
25+
msgid "Time format must be HH:MM (24-hour). Example: 04:00"
26+
msgstr "Il formato orario deve essere HH:MM (24 ore). Esempio: 04:00"
27+
28+
msgid "Select all interfaces"
29+
msgstr "Seleziona tutte le interfacce"
30+
31+
msgid "Monitored interfaces"
32+
msgstr "Interfacce monitorate"
33+
34+
msgid "Idle sampling duration (seconds)"
35+
msgstr "Durata campionamento inattività (secondi)"
36+
37+
msgid "Idle threshold (bytes)"
38+
msgstr "Soglia inattività (byte)"

0 commit comments

Comments
 (0)