diff --git a/src/web/components/httprp.html b/src/web/components/httprp.html index 1624fc5..871d0eb 100644 --- a/src/web/components/httprp.html +++ b/src/web/components/httprp.html @@ -11,20 +11,47 @@ .subdEntry td:not(.ignoremw){ min-width: 200px; } + + .httpProxyListTools{ + width: 100%; + } + + .tag-select{ + cursor: pointer; + } + + .tag-select:hover{ + text-decoration: underline; + opacity: 0.8; + } -
Host | Destination | Virtual Directory | -Tags | +Tags | Advanced Settings | Actions | @@ -138,8 +165,10 @@${vdList} | -- ${subd.Tags.map(tag => `${tag}`).join("")} + |
+
+ ${subd.Tags.length >0 ? subd.Tags.map(tag => `${tag}`).join(""):"No Tags"}
+
|
${subd.AuthenticationProvider.AuthMethod == 0x1?` Basic Auth`:``}
@@ -166,36 +195,6 @@
});
}
- // Function to populate the tag filter dropdown
- function populateTagFilterDropdown(data) {
- let tags = new Set();
- 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 ');
- tags.forEach(tag => {
- dropdownMenu.append(`${tag} `);
- });
- $('#tagFilterDropdown').dropdown();
- }
-
- // Function to filter the proxy list
- function filterProxyList() {
- let searchInput = $("#searchInput").val().toLowerCase();
- let selectedTag = $("#tagFilterDropdown").dropdown('get value');
- $("#httpProxyList tr").each(function() {
- let host = $(this).find("td[data-label='']").text().toLowerCase();
- let tags = $(this).find("td[data-label='tags']").text().toLowerCase();
- if ((host.includes(searchInput) || searchInput === "") && (tags.includes(selectedTag) || selectedTag === "")) {
- $(this).show();
- } else {
- $(this).hide();
- }
- });
- }
-
//Perform realtime alias update without refreshing the whole page
function updateAliasListForEndpoint(endpointName, newAliasDomainList){
let targetEle = $(`.aliasDomains[eptuuid='${endpointName}']`);
@@ -333,7 +332,11 @@
column.append(``);
-
+ }else if (datatype == "tags"){
+ column.append(`
+
+
+ `);
}else if (datatype == "advanced"){
let authProvider = payload.AuthenticationProvider.AuthMethod;
@@ -463,7 +466,6 @@
-
`);
$(".hostAccessRuleSelector").dropdown();
@@ -506,8 +508,12 @@
let requireRateLimit = $(row).find(".RequireRateLimit")[0].checked;
let rateLimit = $(row).find(".RateLimit").val();
let bypassGlobalTLS = $(row).find(".BypassGlobalTLS")[0].checked;
- let tags = $("#proxyTags").val().trim();
-
+ let tags = getTagsArrayFromEndpoint(uuid);
+ if (tags.length > 0){
+ tags = tags.join(",");
+ }else{
+ tags = "";
+ }
$.cjax({
url: "/api/proxy/edit",
method: "POST",
@@ -661,6 +667,75 @@
listProxyEndpoints();
}
+ /* Tags & Search */
+ function handleSearchInput(event){
+ if (event.key == "Escape"){
+ $("#searchInput").val("");
+ }
+ filterProxyList();
+ }
+
+ // Function to filter the proxy list
+ function filterProxyList() {
+ let searchInput = $("#searchInput").val().toLowerCase();
+ let selectedTag = $("#tagFilterDropdown").dropdown('get value');
+ $("#httpProxyList tr").each(function() {
+ let host = $(this).find("td[data-label='']").text().toLowerCase();
+ let tagElements = $(this).find("td[data-label='tags']");
+ let tags = tagElements.attr("payload");
+ tags = JSON.parse(decodeURIComponent(tags));
+ if ((host.includes(searchInput) || searchInput === "") && (tags.includes(selectedTag) || selectedTag === "")) {
+ $(this).show();
+ } else {
+ $(this).hide();
+ }
+ });
+ }
+
+ // Function to generate a color based on a tag name
+ function getTagColorByName(tagName) {
+ function hashCode(str) {
+ return str.split('').reduce((prevHash, currVal) =>
+ ((prevHash << 5) - prevHash) + currVal.charCodeAt(0), 0);
+ }
+ let hash = hashCode(tagName);
+ let color = '#' + ((hash >> 24) & 0xFF).toString(16).padStart(2, '0') +
+ ((hash >> 16) & 0xFF).toString(16).padStart(2, '0') +
+ ((hash >> 8) & 0xFF).toString(16).padStart(2, '0');
+ return color;
+ }
+
+ function getTagTextColor(tagName){
+ let color = getTagColorByName(tagName);
+ let r = parseInt(color.substr(1, 2), 16);
+ let g = parseInt(color.substr(3, 2), 16);
+ let b = parseInt(color.substr(5, 2), 16);
+ let brightness = Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000);
+ return brightness > 125 ? "#000000" : "#ffffff";
+ }
+
+ // Populate the tag filter dropdown
+ function populateTagFilterDropdown(data) {
+ let tags = new Set();
+ data.forEach(subd => {
+ subd.Tags.forEach(tag => tags.add(tag));
+ });
+ tags = Array.from(tags).sort((a, b) => a.localeCompare(b));
+ let dropdownMenu = $("#tagFilterDropdown .tagList");
+ dropdownMenu.html(`
+
+ Show all
+ `);
+ tags.forEach(tag => {
+ let thisTagColor = getTagColorByName(tag);
+ dropdownMenu.append(`
+
+ ${tag}
+ `);
+ });
+ }
+
+ // Edit tags for a specific endpoint
function editTags(uuid){
let payload = encodeURIComponent(JSON.stringify({
ept: "host",
@@ -669,6 +744,23 @@
showSideWrapper("snippet/tagEditor.html?t=" + Date.now() + "#" + payload);
}
+ // Render the tags preview from tag editing snippet
+ function renderTagsPreview(endpoint, tags){
+ let targetProxyRuleEle = $(".subdEntry[eptuuid='" + endpoint + "'] td[data-label='tags']");
+ //Update the tag DOM
+ let newTagDOM = tags.map(tag => `${tag}`).join("");
+ $(targetProxyRuleEle).find(".tags-list").html(newTagDOM);
+
+ //Update the tag payload
+ $(targetProxyRuleEle).attr("payload", encodeURIComponent(JSON.stringify(tags)));
+ }
+
+ function getTagsArrayFromEndpoint(endpoint){
+ let targetProxyRuleEle = $(".subdEntry[eptuuid='" + endpoint + "'] td[data-label='tags']");
+ let tags = $(targetProxyRuleEle).attr("payload");
+ return JSON.parse(decodeURIComponent(tags));
+ }
+
// Initialize the proxy list on page load
$(document).ready(function() {
listProxyEndpoints();
diff --git a/src/web/darktheme.css b/src/web/darktheme.css
index 16b9042..a2d52ae 100644
--- a/src/web/darktheme.css
+++ b/src/web/darktheme.css
@@ -121,6 +121,9 @@ body.darkTheme .ui.basic.button:not(.red) {
body.darkTheme .ui.basic.button:not(.red):hover {
border: 1px solid var(--button_border_color) !important;
background-color: var(--theme_bg) !important;
+}
+
+body.darkTheme .ui.basic.button:not(.red):not(.dropdown):hover {
opacity: 0.8;
}
@@ -549,6 +552,18 @@ body.darkTheme .RateLimit input {
border-color: var(--theme_highlight) !important;
}
+body.darkTheme .menu.transition{
+ background-color: var(--theme_bg) !important;
+ color: var(--text_color) !important;
+}
+
+body.darkTheme .ui.dropdown .menu{
+ background: var(--theme_bg_primary) !important;
+}
+
+body.darkTheme .ui.dropdown .menu .item{
+ color: var(--text_color) !important;
+}
/*
Virtual Directorie Table
*/
diff --git a/src/web/snippet/tagEditor.html b/src/web/snippet/tagEditor.html
index e4c5a32..d93145d 100644
--- a/src/web/snippet/tagEditor.html
+++ b/src/web/snippet/tagEditor.html
@@ -9,6 +9,9 @@
+
+
+
@@ -67,7 +70,9 @@
parent.msgbox(data.error, false);
} else {
parent.msgbox("Tags updated");
- parent.hideSideWrapper();
+ //Update the preview on parent page
+ parent.renderTagsPreview(editingEndpoint.ep, tags);
+ //parent.hideSideWrapper();
}
}
});
|
---|