From 25235340cc921e058cefcf5ee0cfb710f52b6591 Mon Sep 17 00:00:00 2001 From: sbwml Date: Sun, 2 Mar 2025 14:32:28 +0800 Subject: [PATCH] luci-app-mosdns: refresh the page after saving the rules * convenient to continue editing rule content. Signed-off-by: sbwml --- luci-app-mosdns/Makefile | 2 +- .../resources/view/mosdns/rules.js | 32 ++++--------------- luci-app-mosdns/po/zh_Hans/mosdns.po | 4 +-- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/luci-app-mosdns/Makefile b/luci-app-mosdns/Makefile index 99014cc..99b29fa 100644 --- a/luci-app-mosdns/Makefile +++ b/luci-app-mosdns/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-mosdns -PKG_VERSION:=1.6.9 +PKG_VERSION:=1.6.10 PKG_RELEASE:=1 LUCI_TITLE:=LuCI Support for mosdns diff --git a/luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js b/luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js index b58ca70..ad6774c 100644 --- a/luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js +++ b/luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js @@ -42,9 +42,6 @@ return view.extend({ return; } return fs.write('/etc/mosdns/rule/whitelist.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('White Lists') + ' ' + _('Rules have been saved.')), 'info'); - }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); @@ -69,9 +66,6 @@ return view.extend({ return; } return fs.write('/etc/mosdns/rule/blocklist.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('Block Lists') + ' ' + _('Rules have been saved.')), 'info'); - }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); @@ -96,9 +90,6 @@ return view.extend({ return; } return fs.write('/etc/mosdns/rule/greylist.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('Grey Lists') + ' ' + _('Rules have been saved.')), 'info'); - }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); @@ -123,9 +114,6 @@ return view.extend({ return; } return fs.write('/etc/mosdns/rule/ddnslist.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('DDNS Lists') + ' ' + _('Rules have been saved.')), 'info'); - }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); @@ -150,9 +138,6 @@ return view.extend({ return; } return fs.write('/etc/mosdns/rule/hosts.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('Hosts') + ' ' + _('Rules have been saved.')), 'info'); - }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); @@ -177,9 +162,6 @@ return view.extend({ return; } return fs.write('/etc/mosdns/rule/redirect.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('Redirect') + ' ' + _('Rules have been saved.')), 'info'); - }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); @@ -204,9 +186,6 @@ return view.extend({ return; } return fs.write('/etc/mosdns/rule/local-ptr.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('Block PTR') + ' ' + _('Rules have been saved.')), 'info'); - }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); @@ -231,9 +210,6 @@ return view.extend({ return; } return fs.write('/etc/mosdns/rule/streaming.txt', formvalue.trim().replace(/\r\n/g, '\n') + '\n') - .then(function (i) { - ui.addNotification(null, E('p', _('Streaming Media') + ' ' + _('Rules have been saved.')), 'info'); - }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); }); @@ -246,7 +222,13 @@ return view.extend({ handleSaveApply: function (ev) { var m = this.map; onclick = L.bind(this.handleSave, this, m); - return fs.exec('/etc/init.d/mosdns', ['restart']); + return fs.exec('/etc/init.d/mosdns', ['restart']) + .then(function () { + window.location.reload(); + }) + .catch(function (e) { + ui.addNotification(null, E('p', _('Failed to restart mosdns: %s').format(e.message))); + }); }, handleReset: null }); diff --git a/luci-app-mosdns/po/zh_Hans/mosdns.po b/luci-app-mosdns/po/zh_Hans/mosdns.po index 72be238..80ae353 100644 --- a/luci-app-mosdns/po/zh_Hans/mosdns.po +++ b/luci-app-mosdns/po/zh_Hans/mosdns.po @@ -386,8 +386,8 @@ msgstr "规则列表" msgid "Rule Settings" msgstr "自定义规则列表" -msgid "Rules have been saved." -msgstr "规则已保存。" +msgid "Failed to restart mosdns: %s" +msgstr "无法重启 MosDNS:%s" msgid "Unable to save contents: %s" msgstr "无法保存内容:%s"