3 var m = new L.cbi.Map('system', {
4 caption: L.tr('System'),
5 description: L.tr('Here you can configure the basic aspects of your device like its hostname or the timezone.'),
9 var s = m.section(L.cbi.TypedSection, 'system', {
10 caption: L.tr('System Properties'),
11 teasers: [ 'hostname', 'zonename', 'languages', 'themes' ],
12 readonly: !this.options.acls.system
17 caption: L.tr('General Settings')
20 var t = s.taboption('general', L.cbi.DummyValue, '__time', {
21 caption: L.tr('Local Time')
24 t.load = function(sid)
26 var id = this.id(sid);
28 return L.system.getSystemInfo().then(function(info) {
29 var date = new Date();
30 var time = info.localtime;
32 window.setInterval(function() {
33 date.setTime(++time * 1000);
35 $('#' + id).text('%04d/%02d/%02d %02d:%02d:%02d'.format(
36 date.getUTCFullYear(),
37 date.getUTCMonth() + 1,
48 s.taboption('general', L.cbi.InputValue, 'hostname', {
49 caption: L.tr('Hostname'),
54 var z = s.taboption('general', L.cbi.ListValue, 'zonename', {
55 caption: L.tr('Timezone')
58 z.load = function(sid) {
59 return L.system.getZoneInfo(function(zones) {
62 for (var i = 0; i < zones.length; i++)
63 for (var j = 5; j < zones[i].length; j++)
64 znames.push(zones[i][j]);
68 for (var i = 0; i < znames.length; i++)
75 z.save = function(sid)
77 var uci = this.ucipath(sid);
78 var val = this.formvalue(sid);
80 if (!this.callSuper('save', sid))
83 for (var i = 0; i < z.zones.length; i++)
84 for (var j = 5; j < z.zones[i].length; j++)
85 if (z.zones[i][j] == val)
87 m.set(uci.config, uci.section, 'timezone', z.zones[i][0]);
91 m.set(uci.config, uci.section, 'timezone', 'GMT0');
98 caption: L.tr('Logging')
101 s.taboption('logging', L.cbi.InputValue, 'log_size', {
102 caption: L.tr('System log buffer size'),
103 description: L.tr('kiB'),
106 datatype: 'range(0, 32)'
109 s.taboption('logging', L.cbi.InputValue, 'log_ip', {
110 caption: L.tr('External system log server'),
111 placeholder: '0.0.0.0',
116 s.taboption('logging', L.cbi.InputValue, 'log_port', {
117 caption: L.tr('External system log server port'),
123 s.taboption('logging', L.cbi.ListValue, 'conloglevel', {
124 caption: L.tr('Log output level')
125 }).value(8, L.tr('Debug'))
126 .value(7, L.tr('Info'))
127 .value(6, L.tr('Notice'))
128 .value(5, L.tr('Warning'))
129 .value(4, L.tr('Error'))
130 .value(3, L.tr('Critical'))
131 .value(2, L.tr('Alert'))
132 .value(1, L.tr('Emergency'));
134 s.taboption('logging', L.cbi.ListValue, 'cronloglevel', {
135 caption: L.tr('Cron Log level')
136 }).value(5, L.tr('Debug'))
137 .value(8, L.tr('Normal'))
138 .value(9, L.tr('Warning'));
142 caption: L.tr('Language and Style')
146 var l = s.taboption('language', L.cbi.ListValue, 'languages', {
147 caption: L.tr('Language'),
151 }).value('auto', L.tr('Automatic'));
153 l.load = function(sid)
155 var langs = m.get('luci', 'languages');
156 for (var key in langs)
157 if (key.charAt(0) != '.')
158 l.value(key, langs[key]);
162 var t = s.taboption('language', L.cbi.ListValue, 'themes', {
163 caption: L.tr('Design'),
166 uci_option: 'mediaurlbase'
169 t.load = function(sid)
171 var themes = m.get('luci', 'themes');
172 for (var key in themes)
173 if (key.charAt(0) != '.')
174 t.value(themes[key], key);
178 var s2 = m.section(L.cbi.NamedSection, 'ntp', {
179 caption: L.tr('Time Synchronization'),
180 readonly: !this.options.acls.system
183 var e = s2.option(L.cbi.CheckboxValue, '.enable', {
184 caption: L.tr('Enable NTP client'),
188 e.load = function(sid) {
189 return L.system.initEnabled('sysntpd').then(function(enabled) {
190 e.options.initial = enabled;
194 e.save = function(sid) {
195 if (this.formvalue(sid))
196 return L.system.initEnable('sysntpd');
198 return L.system.initDisable('sysntpd');
201 s2.option(L.cbi.CheckboxValue, 'enable_server', {
202 caption: L.tr('Enable NTP server')
203 }).depends('.enable');
205 s2.option(L.cbi.DynamicList, 'server', {
206 caption: L.tr('NTP server candidates'),
208 }).depends('.enable');
210 return m.insertInto('#map');