From 0a9ae5e9d91480dd4dc5df9352d301dbd6ec581f Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Thu, 11 Jul 2024 15:27:37 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8CNBTSCAN=20plugin=20#693?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- Dockerfile.debian | 2 +- front/css/app.css | 7 +- front/js/settings_utils.js | 59 +++-- front/maintenance.php | 4 +- front/plugins/dhcp_leases/config.json | 10 +- front/plugins/nbtscan_scan/README.md | 23 ++ front/plugins/nbtscan_scan/config.json | 337 +++++++++++++++++++++++++ front/plugins/nbtscan_scan/nbtscan.py | 139 ++++++++++ front/plugins/pihole_scan/config.json | 4 +- front/plugins/sync/config.json | 8 - front/settings.php | 2 +- install/install_dependencies.debian.sh | 2 +- server/helper.py | 36 ++- 14 files changed, 584 insertions(+), 51 deletions(-) create mode 100755 front/plugins/nbtscan_scan/README.md create mode 100755 front/plugins/nbtscan_scan/config.json create mode 100755 front/plugins/nbtscan_scan/nbtscan.py diff --git a/Dockerfile b/Dockerfile index c9a8d739..9ce5e9e2 100755 --- a/Dockerfile +++ b/Dockerfile @@ -40,7 +40,7 @@ ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 RUN apk update --no-cache \ && apk add --no-cache bash zip lsblk gettext-envsubst sudo mtr tzdata s6-overlay \ - && apk add --no-cache curl arp-scan iproute2 iproute2-ss nmap nmap-scripts traceroute net-tools net-snmp-tools bind-tools awake ca-certificates \ + && apk add --no-cache curl arp-scan iproute2 iproute2-ss nmap nmap-scripts traceroute nbtscan net-tools net-snmp-tools bind-tools awake ca-certificates \ && apk add --no-cache sqlite php83 php83-fpm php83-cgi php83-curl php83-sqlite3 php83-session \ && apk add --no-cache python3 nginx \ && apk add --no-cache dcron \ diff --git a/Dockerfile.debian b/Dockerfile.debian index 887f9c0a..5a0e3f10 100755 --- a/Dockerfile.debian +++ b/Dockerfile.debian @@ -33,7 +33,7 @@ COPY --chmod=775 --chown=${USER_ID}:${USER_GID} . ${INSTALL_DIR}/ RUN apt-get install -y \ tini snmp ca-certificates curl libwww-perl arp-scan perl apt-utils cron sudo \ nginx-light php php-cgi php-fpm php-sqlite3 php-curl sqlite3 dnsutils net-tools php-openssl \ - python3 python3-dev iproute2 nmap python3-pip zip systemctl usbutils traceroute + python3 python3-dev iproute2 nmap python3-pip zip systemctl usbutils traceroute nbtscan # Alternate dependencies RUN apt-get install nginx nginx-core mtr php-fpm php8.2-fpm php-cli php8.2 php8.2-sqlite3 -y diff --git a/front/css/app.css b/front/css/app.css index fc5d9851..16593145 100755 --- a/front/css/app.css +++ b/front/css/app.css @@ -232,7 +232,12 @@ .content-wrapper, .right-side, .main-footer { - margin-left: 150px; + margin-left: 150px; +} + +#settingsPage +{ + display: grid; } @media (max-width: 767px) { diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js index d5428f32..b70063ba 100755 --- a/front/js/settings_utils.js +++ b/front/js/settings_utils.js @@ -383,27 +383,56 @@ function filterRows(inputText) { inputText = ""; } - $(".table_row").each(function () { - // Check if the row id ends with '__metadata' - var idAttribute = $(this).attr("id"); - if (idAttribute && idAttribute.endsWith("__metadata")) { - $(this).hide(); // Hide the row if it ends with '__metadata' - return; // Skip to the next iteration - } + $(".panel").each(function () { + var $panel = $(this); + var $panelHeader = $panel.find('.panel-heading'); + var $panelBody = $panel.find('.panel-collapse'); - var description = $(this).find(".setting_description").text().toLowerCase(); - var codeName = $(this).find(".setting_name code").text().toLowerCase(); - if ( - description.includes(inputText.toLowerCase()) || - codeName.includes(inputText.toLowerCase()) - ) { - $(this).show(); // Show the row if it matches the input text + var anyVisible = false; // Flag to check if any row is visible + + $panelBody.find(".table_row:not(.docs)").each(function () { + var $row = $(this); + + // Check if the row ID ends with "__metadata" + var rowId = $row.attr("id"); + var isMetadataRow = rowId && rowId.endsWith("__metadata"); + + // Always hide metadata rows + if (isMetadataRow) { + $row.hide(); + return; // Skip further processing for metadata rows + } + + var description = $row.find(".setting_description").text().toLowerCase(); + var codeName = $row.find(".setting_name code").text().toLowerCase(); + + if ( + description.includes(inputText.toLowerCase()) || + codeName.includes(inputText.toLowerCase()) + ) { + $row.show(); + anyVisible = true; // Set the flag to true if at least one row is visible + } else { + $row.hide(); + } + }); + + // Determine whether to hide or show the panel based on visibility of rows + if (anyVisible) { + $panelBody.collapse('show'); // Ensure the panel body is shown if there are visible rows + $panelHeader.show(); // Show the panel header + $panel.show(); // Show the entire panel if there are visible rows } else { - $(this).hide(); // Hide the row if it doesn't match the input text + $panelBody.collapse('hide'); // Hide the panel body if no rows are visible + $panelHeader.hide(); // Hide the panel header if no rows are visible + $panel.hide(); // Hide the entire panel if no rows are visible } }); } + + + setTimeout(() => { // Event listener for input change $("#settingsSearch").on("input", function () { diff --git a/front/maintenance.php b/front/maintenance.php index 94636c8f..37502984 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -408,7 +408,7 @@ $db->close();
-
-