From e66089e4c71174846d3300d31f01059c6f762705 Mon Sep 17 00:00:00 2001 From: Micky <60691199+AliMickey@users.noreply.github.com> Date: Sat, 28 Dec 2024 14:57:31 +1100 Subject: [PATCH] improve command filtering and handling --- CONFIGURATION.md | 6 +++--- app/static/js/main.js | 14 ++++++++++++++ app/templates/footer.html | 4 ++-- app/templates/index.html | 27 +++++++++++++-------------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 1021568..06937c2 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -43,7 +43,7 @@ webhook: ping: display_name: "Ping" format: "ping -{ip_version} -c 4 {target}" - description: "Test network connectivity" + description: "Performs ping with 4 ICMP requests to target" field: type: "text" placeholder: "Enter IP address or hostname" @@ -51,7 +51,7 @@ ping: traceroute: display_name: "Traceroute" format: "traceroute -{ip_version} {target}" - description: "Trace network path to destination" + description: "Performs traceroute to target" field: type: "text" placeholder: "Enter IP address or hostname" @@ -59,7 +59,7 @@ traceroute: mtr: display_name: "MTR" format: "mtr -{ip_version} -r {target}" - description: "Trace network path with stats" + description: "Performs MTR to target" field: type: "text" placeholder: "Enter IP address or hostname" diff --git a/app/static/js/main.js b/app/static/js/main.js index b48dfdc..feec0e5 100644 --- a/app/static/js/main.js +++ b/app/static/js/main.js @@ -30,7 +30,13 @@ const app = Vue.createApp({ if (!newVal) { this.resetCommandState(); } + // Check if the current command is valid for the new device + const validCommands = this.currentDevice?.commands || []; + if (!validCommands.includes(this.selectedCommand)) { + this.selectedCommand = ''; // Reset command if invalid + } }, + immediate: true }, selectedCommand: { @@ -49,6 +55,14 @@ const app = Vue.createApp({ })); }, + filteredCommands() { + if (!this.currentDevice) return []; + return this.currentDevice.commands.map(commandKey => ({ + key: commandKey, + ...this.commands[commandKey] + })); + }, + showIpVersionSelector() { if (!this.targetIp) return true; diff --git a/app/templates/footer.html b/app/templates/footer.html index 45a22b3..8321bd0 100644 --- a/app/templates/footer.html +++ b/app/templates/footer.html @@ -4,7 +4,7 @@
- {{ site.footer.text }} - v1.0.0 + {{ site.footer.text }} - v1.0.1
@@ -121,7 +121,7 @@
- {% for command in commands %} + {% for command in commands.values() %}

diff --git a/app/templates/index.html b/app/templates/index.html index cb8f2c1..c08786c 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -64,21 +64,20 @@ leave-to-class="transform opacity-0 scale-95 -translate-y-2">

- {% for command_key, command in commands.items() %} -
-
- {{ command.display_name }} -
- - - - - +
+
+ ${command.display_name}
- {% endfor %} + + + + + +