Skip to content

Commit

Permalink
luci-app-ntpc: convert to JavaScript
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nilsson <daniel.nilsson94@outlook.com>
  • Loading branch information
dannil committed Feb 28, 2024
1 parent 0b24d1f commit 984b9a4
Show file tree
Hide file tree
Showing 44 changed files with 888 additions and 1,018 deletions.
3 changes: 2 additions & 1 deletion applications/luci-app-ntpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
include $(TOPDIR)/rules.mk

LUCI_TITLE:=NTP time synchronisation configuration module
LUCI_DEPENDS:=+luci-base +luci-compat +ntpclient
LUCI_DESCRIPTION:=LuCI support for configuring the ntpclient package
LUCI_DEPENDS:=+luci-base +ntpclient

include ../../luci.mk

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'use strict';

'require form';
'require rpc';
'require view';

var callSystemInfo = rpc.declare({
object: 'system',
method: 'info'
});

return view.extend({
load: function() {
return Promise.all([
L.resolveDefault(callSystemInfo(), {})
]);
},

render: function (data) {
var system_info = data[0];

var m, s1, time, interval, count, freq, s2, s3, hostname, port;

m = new form.Map('ntpclient', _('Time Synchronisation'), _('Synchronizes the system time.'));

s1 = m.section(form.TypedSection, 'ntpclient', _('General'));
s1.anonymous = true;
s1.addremove = false;

var datestr = null;

if (system_info.localtime) {
var date = new Date(system_info.localtime * 1000);

datestr = '%04d-%02d-%02d %02d:%02d:%02d'.format(
date.getUTCFullYear(),
date.getUTCMonth() + 1,
date.getUTCDate(),
date.getUTCHours(),
date.getUTCMinutes(),
date.getUTCSeconds()
);
}

time = s1.option(form.DummyValue, '_time', _('Current system time'));
time.default = datestr;

interval = s1.option(form.Value, 'interval', _('Update interval (in seconds)'));
interval.datatype = 'and(uinteger,min(1))';
interval.rmempty = true;

count = s1.option(form.Value, 'count', _('Count of time measurements'), _('empty = infinite'));
count.datatype = 'and(uinteger,min(1))';
count.rmempty = true;

s2 = m.section(form.TypedSection, 'ntpdrift', _('Clock Adjustment'));
s2.anonymous = true;
s2.addremove = false;

freq = s2.option(form.Value, 'freq', _('Offset frequency'));
freq.datatype = 'integer';
freq.rmempty = true;

s3 = m.section(form.TableSection, 'ntpserver', _('Time Servers'));
s3.anonymous = true;
s3.addremove = true;

hostname = s3.option(form.Value, 'hostname', _('Hostname'));
hostname.placeholder = _('Hostname');

port = s3.option(form.Value, 'port', _('Port'));
port.datatype = 'port';
port.rmempty = true;
port.placeholder = _('Port');

return m.render();
}
});
39 changes: 0 additions & 39 deletions applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua

This file was deleted.

28 changes: 0 additions & 28 deletions applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua

This file was deleted.

47 changes: 22 additions & 25 deletions applications/luci-app-ntpc/po/ar/ntpc.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,63 @@ msgstr ""
"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n"
"X-Generator: Weblate 4.5.1\n"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:21
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:56
msgid "Clock Adjustment"
msgstr "ضبط الساعة"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:17
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:52
msgid "Count of time measurements"
msgstr "عد قياسات الوقت"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:11
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:12
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:45
msgid "Current system time"
msgstr "وقت النظام الحالي"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:7
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:8
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:26
msgid "General"
msgstr "عام"

#: applications/luci-app-ntpc/root/usr/share/rpcd/acl.d/luci-app-ntpc.json:3
msgid "Grant UCI access for luci-app-ntpc"
msgstr "منح وصول UCI ل luci-app-ntpc"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:34
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:23
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:68
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:69
msgid "Hostname"
msgstr "اسم المضيف"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:25
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:60
msgid "Offset frequency"
msgstr "تردد الإزاحة"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:35
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:24
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:71
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:74
msgid "Port"
msgstr "المنفذ"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:5
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:6
msgid "Synchronizes the system time"
msgstr "يزامن وقت النظام"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:18
msgid "Time Server"
msgstr "خادم الوقت"
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:24
msgid "Synchronizes the system time."
msgstr ""

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:29
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:64
msgid "Time Servers"
msgstr "خوادم الوقت"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:5
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:6
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:24
#: applications/luci-app-ntpc/root/usr/share/luci/menu.d/luci-app-ntpc.json:3
msgid "Time Synchronisation"
msgstr "تزامن الوقت"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:13
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:14
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:48
msgid "Update interval (in seconds)"
msgstr "الفاصل الزمني للتحديث (بالثواني)"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:17
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:52
msgid "empty = infinite"
msgstr "فارغ = لانهائي"

#~ msgid "Synchronizes the system time"
#~ msgstr "يزامن وقت النظام"

#~ msgid "Time Server"
#~ msgstr "خادم الوقت"
47 changes: 22 additions & 25 deletions applications/luci-app-ntpc/po/bg/ntpc.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,63 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.4-dev\n"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:21
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:56
msgid "Clock Adjustment"
msgstr "Настройка на часа"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:17
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:52
msgid "Count of time measurements"
msgstr "Брой времеви измервания"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:11
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:12
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:45
msgid "Current system time"
msgstr "Настоящо време на системата"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:7
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:8
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:26
msgid "General"
msgstr "Общи"

#: applications/luci-app-ntpc/root/usr/share/rpcd/acl.d/luci-app-ntpc.json:3
msgid "Grant UCI access for luci-app-ntpc"
msgstr "Позволи UCI достъп на luci-app-ntpc"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:34
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:23
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:68
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:69
msgid "Hostname"
msgstr "Хостнейм"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:25
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:60
msgid "Offset frequency"
msgstr "Честота на офсета"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:35
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:24
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:71
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:74
msgid "Port"
msgstr "Порт"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:5
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:6
msgid "Synchronizes the system time"
msgstr "Синхронизира системното време"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:18
msgid "Time Server"
msgstr "Времеви Сървър"
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:24
msgid "Synchronizes the system time."
msgstr ""

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:29
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:64
msgid "Time Servers"
msgstr "Времеви Сървъри"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:5
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:6
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:24
#: applications/luci-app-ntpc/root/usr/share/luci/menu.d/luci-app-ntpc.json:3
msgid "Time Synchronisation"
msgstr "Времева Синхронизация"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:13
#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpcmini.lua:14
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:48
msgid "Update interval (in seconds)"
msgstr "Период на обновление (в секунди)"

#: applications/luci-app-ntpc/luasrc/model/cbi/ntpc/ntpc.lua:17
#: applications/luci-app-ntpc/htdocs/luci-static/resources/view/ntpc.js:52
msgid "empty = infinite"
msgstr "празно = неограничено"

#~ msgid "Synchronizes the system time"
#~ msgstr "Синхронизира системното време"

#~ msgid "Time Server"
#~ msgstr "Времеви Сървър"
Loading

0 comments on commit 984b9a4

Please sign in to comment.