summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-smartdns/htdocs/luci-static/resources
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-smartdns/htdocs/luci-static/resources')
-rw-r--r--applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js52
1 files changed, 41 insertions, 11 deletions
diff --git a/applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js b/applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js
index f44fd9b254..e26aeed33f 100644
--- a/applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js
+++ b/applications/luci-app-smartdns/htdocs/luci-static/resources/view/smartdns/smartdns.js
@@ -24,6 +24,7 @@
'require view';
'require poll';
'require rpc';
+'require ui';
var conf = 'smartdns';
var callServiceList = rpc.declare({
@@ -32,6 +33,7 @@ var callServiceList = rpc.declare({
params: ['name'],
expect: { '': {} }
});
+var pollAdded = false;
function getServiceStatus() {
return L.resolveDefault(callServiceList(conf), {})
@@ -106,14 +108,16 @@ return view.extend({
view.innerHTML = smartdnsRenderStatus(res);
});
}
- poll.add(renderStatus, 1);
-
- return E('div', { class: 'cbi-map' },
- E('div', { class: 'cbi-section' }, [
- E('div', { id: 'service_status' },
- _('Collecting data ...'))
- ])
- );
+
+ if (pollAdded == false) {
+ poll.add(renderStatus, 1);
+ pollAdded = true;
+ }
+
+ return E('div', { class: 'cbi-section' }, [
+ E('div', { id: 'service_status' },
+ _('Collecting data ...'))
+ ]);
}
// Basic;
@@ -296,7 +300,12 @@ return view.extend({
return fs.trimmed('/etc/smartdns/custom.conf');
};
o.write = function (section_id, formvalue) {
- return fs.write('/etc/smartdns/custom.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
+ return this.cfgvalue(section_id).then(function (value) {
+ if (value == formvalue) {
+ return
+ }
+ return fs.write('/etc/smartdns/custom.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
+ });
};
o = s.taboption("custom", form.Flag, "coredump", _("Generate Coredump"),
@@ -435,7 +444,12 @@ return view.extend({
return fs.trimmed('/etc/smartdns/address.conf');
};
o.write = function (section_id, formvalue) {
- return fs.write('/etc/smartdns/address.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
+ return this.cfgvalue(section_id).then(function (value) {
+ if (value == formvalue) {
+ return
+ }
+ return fs.write('/etc/smartdns/address.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
+ });
};
// IP Blacklist;
@@ -447,7 +461,12 @@ return view.extend({
return fs.trimmed('/etc/smartdns/blacklist-ip.conf');
};
o.write = function (section_id, formvalue) {
- return fs.write('/etc/smartdns/blacklist-ip.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
+ return this.cfgvalue(section_id).then(function (value) {
+ if (value == formvalue) {
+ return
+ }
+ return fs.write('/etc/smartdns/blacklist-ip.conf', formvalue.trim().replace(/\r\n/g, '\n') + '\n');
+ });
};
// Doman addresss;
@@ -471,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();
}
});