feat(node): active 'update subscription' button

This commit is contained in:
Tianling Shen 2022-08-13 22:36:50 +08:00 committed by GitHub
parent 89b0e756b0
commit 0fc49ad94d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View file

@ -450,7 +450,14 @@ return view.extend({
}
}
o.onclick = function() {
/* TODO: add corresponding script. */
var _this = this;
return fs.exec('/etc/homeproxy/scripts/subscribe.lua').then(function (res) {
return location.reload();
}).catch(function (err) {
ui.addNotification(null, E('p', _('An error occurred during updating subscriptions: %s').format(err)));
return _this.map.reset();
});
}
o = s.option(form.Button, '_remove_subscriptions', _('Remove all nodes from subscriptions'));

View file

@ -520,7 +520,7 @@ local function main()
local first_server = uci:get_first(uciname, ucisection)
if first_server then
if not uci:get(uciname, main_server) then
uci:set(uciname, "config", "main_server", first_server[".name"])
uci:set(uciname, "config", "main_server", first_server)
need_restart = true
log("Main node is gone, switching to first node.")
end
@ -528,7 +528,7 @@ local function main()
local udp_server = uci:get(uciname, "config", "main_udp_server", "null")
if udp_server ~= "nil" and udp_server ~= "null" then
if not uci:get(uciname, udp_server) then
uci:set(uciname, "config", "main_udp_server", first_server[".name"])
uci:set(uciname, "config", "main_udp_server", first_server)
need_restart = true
log("UDP node is gone, switching to main node.")
end
@ -553,7 +553,7 @@ end
if notEmpty(subscription_urls) then
xpcall(main, function(e)
log("Errors occurred during updating subscriptions:")
log("An error occurred during updating subscriptions:")
log(e)
log(debug.traceback())

View file

@ -3,7 +3,7 @@
"description": "Grant access to homeproxy configuration",
"read": {
"file": {
"/etc/homeproxy/*": [ "read" ],
"/etc/homeproxy/scripts/subscribe.lua": [ "exec" ],
"/usr/bin/which": [ "exec" ],
"/bin/mkdir -p /etc/homeproxy/certs/": [ "exec" ]
},
@ -14,7 +14,9 @@
},
"write": {
"file": {
"/etc/homeproxy/*": [ "write" ]
"/etc/homeproxy/certs/client_ca.pem": [ "write" ],
"/etc/homeproxy/certs/server_publickey.pem": [ "write" ],
"/etc/homeproxy/certs/server_privatekey.pem": [ "write" ]
},
"uci": [ "homeproxy" ]
}