From 97a6cf016a5431805ec8197e67e729e731b7ddb6 Mon Sep 17 00:00:00 2001 From: adoolaard Date: Fri, 31 Jan 2025 00:17:10 +0100 Subject: [PATCH] Point on the I --- src/reverseproxy.go | 22 ++++++++++++++-------- src/web/components/httprp.html | 16 +++++++++++++--- src/web/components/rules.html | 1 + 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/reverseproxy.go b/src/reverseproxy.go index ced72f5..c0f3fe9 100644 --- a/src/reverseproxy.go +++ b/src/reverseproxy.go @@ -287,10 +287,13 @@ func ReverseProxyHandleAddEndpoint(w http.ResponseWriter, r *http.Request) { } } - tagsStr, _ := utils.PostPara(r, "tags") - tags := strings.Split(tagsStr, ",") - for i := range tags { - tags[i] = strings.TrimSpace(tags[i]) + tagStr, _ := utils.PostPara(r, "tags") + tags := []string{} + if tagStr != "" { + tags = strings.Split(tagStr, ",") + for i := range tags { + tags[i] = strings.TrimSpace(tags[i]) + } } var proxyEndpointCreated *dynamicproxy.ProxyEndpoint @@ -523,10 +526,13 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) { return } - tagsStr, _ := utils.PostPara(r, "tags") - tags := strings.Split(tagsStr, ",") - for i := range tags { - tags[i] = strings.TrimSpace(tags[i]) + tagStr, _ := utils.PostPara(r, "tags") + tags := []string{} + if tagStr != "" { + tags = strings.Split(tagStr, ",") + for i := range tags { + tags[i] = strings.TrimSpace(tags[i]) + } } //Generate a new proxyEndpoint from the new config diff --git a/src/web/components/httprp.html b/src/web/components/httprp.html index 0e2ce06..1624fc5 100644 --- a/src/web/components/httprp.html +++ b/src/web/components/httprp.html @@ -138,7 +138,9 @@ ${vdList} - ${subd.Tags.join(", ")} + + ${subd.Tags.map(tag => `${tag}`).join("")} + ${subd.AuthenticationProvider.AuthMethod == 0x1?` Basic Auth`:``} ${subd.AuthenticationProvider.AuthMethod == 0x2?` Authelia`:``} @@ -170,10 +172,11 @@ data.forEach(subd => { subd.Tags.forEach(tag => tags.add(tag)); }); + tags = Array.from(tags).sort((a, b) => a.localeCompare(b)); let dropdownMenu = $("#tagFilterDropdown .menu"); - dropdownMenu.html('
All
'); + dropdownMenu.html('
All
'); tags.forEach(tag => { - dropdownMenu.append(`
${tag}
`); + dropdownMenu.append(`
${tag}
`); }); $('#tagFilterDropdown').dropdown(); } @@ -669,5 +672,12 @@ // Initialize the proxy list on page load $(document).ready(function() { listProxyEndpoints(); + + // Event listener for clicking on tags + $(document).on('click', '.tag-select', function() { + let tag = $(this).text().trim(); + $('#tagFilterDropdown').dropdown('set selected', tag); + filterProxyList(); + }); }); \ No newline at end of file diff --git a/src/web/components/rules.html b/src/web/components/rules.html index dd37efd..642798f 100644 --- a/src/web/components/rules.html +++ b/src/web/components/rules.html @@ -246,6 +246,7 @@ //Clear old data $("#rootname").val(""); $("#proxyDomain").val(""); + $("#proxyTags").val(""); credentials = []; updateTable(); reloadUptimeList();