From a8fad6ac7479a08846d6b833f8602bbe64b074fb Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Tue, 23 Apr 2024 22:57:24 +1000 Subject: [PATCH] =?UTF-8?q?Double-click=20to=20remove=20in=20Settings=20li?= =?UTF-8?q?sts=20=E2=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/css/app.css | 21 +++++++++++++++++++++ front/js/settings_utils.js | 17 +++++++++++++++++ front/php/templates/language/en_us.json | 2 +- front/settings.php | 23 ++++++++++++++++++----- 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/front/css/app.css b/front/css/app.css index d0d81e79..5fa97460 100755 --- a/front/css/app.css +++ b/front/css/app.css @@ -875,6 +875,27 @@ input[readonly] { cursor: not-allowed; } + .removable-option:hover::before { + opacity: 1; +} + + .removable-option::before { + content: 'Double-click to ❌'; + position: absolute; + right: 0; + top: 0; + color: white; + background-color: rgb(255, 87, 87); + padding: 3px; + transition: opacity 0.5s; + opacity: 0; + border-radius: 3px; +} + +.removable-option:hover { + transition: background-color 2s; + cursor: pointer; +} /* ----------------------------------------------------------------- */ /* Devices page */ diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js index 04ce38f0..dc4d3ddf 100755 --- a/front/js/settings_utils.js +++ b/front/js/settings_utils.js @@ -175,9 +175,26 @@ } else { return false; } + } + +// ------------------------------------------------------------------- + // Function to remove an item from the select element + function removeOptionItem(option) { + option.remove(); + } + +// ------------------------------------------------------------------- +// Function to initialize remove functionality on select options +function initRemoveBtnOptn(selectorId) { + // Attach double-click event listeners to "Remove" + $(`#${selectorId} option`).addClass('removable-option').on('dblclick', function() { + const $option = $(this); + removeOptionItem($option); + }); } + diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 4df10423..633e15dd 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -528,7 +528,7 @@ "REPORT_MAIL_name": "Enable email", "REPORT_TITLE": "Report", "RandomMAC_hover": "Autodetected - indicates if the device randomizes it's MAC address.", - "SCAN_SUBNETS_description": "Most on-network scanners (ARP-SCAN, NMAP, NSLOOKUP, DIG, PHOLUS) rely on scanning specific network interfaces and subnets. Check the subnets documentation for help on this setting, especially VLANs, what VLANs are supported, or how to figure out the network mask and your interface.

An alternative to on-network scanners is to enable some other Device scanners/importers that don't rely on NetALertX having access to the network (UNIFI, dhcp.leases, PiHole, etc.).

Note: The scan time itself depends on the number of IP addresses to check so set this up carefully with the appropriate network mask and interface.", + "SCAN_SUBNETS_description": "Most on-network scanners (ARP-SCAN, NMAP, NSLOOKUP, DIG, PHOLUS) rely on scanning specific network interfaces and subnets. Check the subnets documentation for help on this setting, especially VLANs, what VLANs are supported, or how to figure out the network mask and your interface.

An alternative to on-network scanners is to enable some other Device scanners/importers that don't rely on NetALertX having access to the network (UNIFI, dhcp.leases, PiHole, etc.).

Note: The scan time itself depends on the number of IP addresses to check, so set this up carefully with the appropriate network mask and interface.", "SYSTEM_TITLE": "System Information", "Setting_Override": "Override value", "Setting_Override_Description": "Enabling this option will override an App supplied default value with the value specified above.", diff --git a/front/settings.php b/front/settings.php index 09325963..b33695ce 100755 --- a/front/settings.php +++ b/front/settings.php @@ -441,11 +441,11 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
- +
- `; options = createArray(val); @@ -454,8 +454,13 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { inputHtml += ``; }); - inputHtml += '
' + - `
`; + + + inputHtml += ` + +
+ +
`; } else if (setType === 'list' || setType === 'list.readonly') { settingKeyOfLists.push(codeName); @@ -466,7 +471,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
- +
@@ -475,6 +480,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { let options = createArray(val); options.forEach(option => { + inputHtml += ``; }); @@ -513,6 +519,12 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { // generate settings in the correct group section $(`#${group} .panel-body`).append(setHtml); + + // init remove list item buttons + if(['subnets', 'list' ].includes(setType)) + { + initRemoveBtnOptn(codeName) + } } }); @@ -615,6 +627,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { { settingsChanged(); $(`#${$(element).attr('my-input')}`).find("option:last").remove(); + } // --------------------------------------------------------- function addInterface()