From dbd795a158c4050d7c8cc25680552098c11f1a7f Mon Sep 17 00:00:00 2001 From: Toby Chui Date: Sat, 6 Sep 2025 13:36:00 +0800 Subject: [PATCH] Fixed #799 - Fixed UI bug in loopback options toggle - Optimized plugin select ui --- src/accesslist.go | 7 ++++--- src/web/components/access.html | 16 ++++++++++++++-- src/web/components/plugins.html | 6 ++++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/accesslist.go b/src/accesslist.go index 3c18321..5fd0779 100644 --- a/src/accesslist.go +++ b/src/accesslist.go @@ -566,11 +566,12 @@ func handleWhitelistAllowLoopback(w http.ResponseWriter, r *http.Request) { js, _ := json.Marshal(currentEnabled) utils.SendJSONResponse(w, string(js)) } else { - if enable == "true" { + switch enable { + case "true": rule.ToggleAllowLoopback(true) - } else if enable == "false" { + case "false": rule.ToggleAllowLoopback(false) - } else { + default: utils.SendErrorResponse(w, "invalid enable state: only true and false is accepted") return } diff --git a/src/web/components/access.html b/src/web/components/access.html index 202b2b4..9ea0e16 100644 --- a/src/web/components/access.html +++ b/src/web/components/access.html @@ -1059,7 +1059,7 @@ }) }); - $.get("/api/whitelist/allowLocal", function(data){ + $.get("/api/whitelist/allowLocal?id=" + currentEditingAccessRule, function(data){ if (data == true){ $('#enableWhitelistLoopback').parent().checkbox("set checked"); }else{ @@ -1080,7 +1080,19 @@ url: '/api/whitelist/allowLocal', data: { enable: isChecked, id: currentEditingAccessRule}, success: function(data){ - msgbox("Loopback whitelist " + (isChecked ? "enabled" : "disabled"), true); + if (data.error != undefined){ + msgbox("Failed to update loopback whitelist: " + data.error, false); + //Revert the checkbox state + if (isChecked){ + $('#enableWhitelistLoopback').parent().checkbox("set unchecked"); + }else{ + $('#enableWhitelistLoopback').parent().checkbox("set checked"); + } + return; + }else{ + msgbox("Loopback whitelist " + (isChecked ? "enabled" : "disabled"), true); + } + } }); } diff --git a/src/web/components/plugins.html b/src/web/components/plugins.html index 870d701..43c02b2 100644 --- a/src/web/components/plugins.html +++ b/src/web/components/plugins.html @@ -120,7 +120,7 @@
Unassigned Plugins
- Select a tag to view available plugins + No selected tag
@@ -314,7 +314,9 @@ loadTags(); //This is used as a dummy function to initialize the selectable plugin list function initSelectablePluginList(){ - $("#selectablePluginList").html(""); + $("#selectablePluginList").html(`
+ No selected tag +
`); $.get(`/api/plugins/list`, function(data){ data.forEach(plugin => { if (plugin.Spec.type != 0) {