luci: Fix RPC error when config is empty and add restart button.

This commit is contained in:
Nick Peng
2022-10-08 21:59:35 +08:00
parent eeaadcf313
commit 6c800ea12f
3 changed files with 24 additions and 7 deletions

View File

@@ -184,6 +184,12 @@ msgstr "解析本地主机名"
msgid "Resolve local hostnames by reading Dnsmasq lease file."
msgstr "读取Dnsmasq的租约文件解析本地主机名。"
msgid "Restart"
msgstr "重启"
msgid "Restart Service"
msgstr "重启服务"
msgid "Second Server Settings"
msgstr "第二DNS服务器"

View File

@@ -4,7 +4,8 @@
"read": {
"file": {
"/etc/smartdns/*": [ "read" ],
"/usr/sbin/smartdns": [ "exec" ]
"/usr/sbin/smartdns": [ "exec" ],
"/etc/init.d/smartdns restart" : [ "exec" ]
},
"ubus": {
"service": [ "list" ]

View File

@@ -24,6 +24,7 @@
'require view';
'require poll';
'require rpc';
'require ui';
var conf = 'smartdns';
var callServiceList = rpc.declare({
@@ -113,12 +114,10 @@ return view.extend({
pollAdded = true;
}
return E('div', { class: 'cbi-map' },
E('div', { class: 'cbi-section' }, [
E('div', { id: 'service_status' },
_('Collecting data ...'))
])
);
return E('div', { class: 'cbi-section' }, [
E('div', { id: 'service_status' },
_('Collecting data ...'))
]);
}
// Basic;
@@ -491,6 +490,17 @@ return view.extend({
window.open("https://pymumu.github.io/smartdns/#donate", '_blank');
};
o = s.option(form.DummyValue, "_restart", _("Restart Service"));
o.renderWidget = function () {
return E('button', {
'class': 'btn cbi-button cbi-button-apply',
'id': 'btn_restart',
'click': ui.createHandlerFn(this, function () {
return fs.exec('/etc/init.d/smartdns', ['restart'])
.catch(function (e) { ui.addNotification(null, E('p', e.message), 'error') });
})
}, [_("Restart")]);
}
return m.render();
}
});