luci-mod-system: describe NTP server candidates
[project/luci.git] / modules / luci-mod-system / htdocs / luci-static / resources / view / system / system.js
index d207a5c9944c91e4d98b6b1aaef01b1a40b4b9c3..f7c13467831370b559f6e969879daacbdcb9b8c1 100644 (file)
@@ -5,13 +5,14 @@
 'require uci';
 'require rpc';
 'require form';
+'require tools.widgets as widgets';
 
-var callInitList, callInitAction, callTimezone,
+var callRcList, callRcInit, callTimezone,
     callGetLocaltime, callSetLocaltime, CBILocalTime;
 
-callInitList = rpc.declare({
-       object: 'luci',
-       method: 'getInitList',
+callRcList = rpc.declare({
+       object: 'rc',
+       method: 'list',
        params: [ 'name' ],
        expect: { '': {} },
        filter: function(res) {
@@ -21,9 +22,9 @@ callInitList = rpc.declare({
        }
 });
 
-callInitAction = rpc.declare({
-       object: 'luci',
-       method: 'setInitAction',
+callRcInit = rpc.declare({
+       object: 'rc',
+       method: 'init',
        params: [ 'name', 'action' ],
        expect: { result: false }
 });
@@ -82,7 +83,7 @@ CBILocalTime = form.DummyValue.extend({
                                this.ntpd_support ? E('button', {
                                        'class': 'cbi-button cbi-button-apply',
                                        'click': ui.createHandlerFn(this, function() {
-                                               return callInitAction('sysntpd', 'restart');
+                                               return callRcInit('sysntpd', 'restart');
                                        }),
                                        'disabled': (this.readonly != null) ? this.readonly : this.map.readonly
                                }, _('Sync with NTP-Server')) : ''
@@ -94,7 +95,7 @@ CBILocalTime = form.DummyValue.extend({
 return view.extend({
        load: function() {
                return Promise.all([
-                       callInitList('sysntpd'),
+                       callRcList('sysntpd'),
                        callTimezone(),
                        callGetLocaltime(),
                        uci.load('luci'),
@@ -227,10 +228,11 @@ return view.extend({
                o.ucioption = 'lang';
                o.value('auto');
 
-               var k = Object.keys(uci.get('luci', 'languages') || {}).sort();
+               var l = Object.assign({ en: 'English' }, uci.get('luci', 'languages')),
+                   k = Object.keys(l).sort();
                for (var i = 0; i < k.length; i++)
                        if (k[i].charAt(0) != '.')
-                               o.value(k[i], uci.get('luci', 'languages', k[i]));
+                               o.value(k[i], l[k[i]]);
 
                o = s.taboption('language', form.ListValue, '_mediaurlbase', _('Design'))
                o.uciconfig = 'luci';
@@ -269,7 +271,7 @@ return view.extend({
                                else
                                        uci.unset('system', 'ntp', 'enabled');
 
-                               return callInitAction('sysntpd', 'enable');
+                               return callRcInit('sysntpd', 'enable');
                        };
                        o.load = function(section_id) {
                                return (ntpd_enabled == 1 &&
@@ -281,12 +283,22 @@ return view.extend({
                        o.ucisection = 'ntp';
                        o.depends('enabled', '1');
 
+                       o = s.taboption('timesync', widgets.NetworkSelect, 'interface',
+                               _('Bind NTP server'),
+                               _('Provide the NTP server to the selected interface or, if unspecified, to all interfaces'));
+                       o.ucisection = 'ntp';
+                       o.depends('enable_server', '1');
+                       o.multiple = false;
+                       o.nocreate = true;
+                       o.optional = true;
+
                        o = s.taboption('timesync', form.Flag, 'use_dhcp', _('Use DHCP advertised servers'));
                        o.ucisection = 'ntp';
                        o.default = o.enabled;
                        o.depends('enabled', '1');
 
-                       o = s.taboption('timesync', form.DynamicList, 'server', _('NTP server candidates'));
+                       o = s.taboption('timesync', form.DynamicList, 'server', _('NTP server candidates'),
+                               _('List of upstream NTP server candidates with which to synchronize.'));
                        o.datatype = 'host(0)';
                        o.ucisection = 'ntp';
                        o.depends('enabled', '1');