improve command filtering and handling
This commit is contained in:
parent
a4bce0c747
commit
e66089e4c7
@ -43,7 +43,7 @@ webhook:
|
|||||||
ping:
|
ping:
|
||||||
display_name: "Ping"
|
display_name: "Ping"
|
||||||
format: "ping -{ip_version} -c 4 {target}"
|
format: "ping -{ip_version} -c 4 {target}"
|
||||||
description: "Test network connectivity"
|
description: "Performs ping with 4 ICMP requests to target"
|
||||||
field:
|
field:
|
||||||
type: "text"
|
type: "text"
|
||||||
placeholder: "Enter IP address or hostname"
|
placeholder: "Enter IP address or hostname"
|
||||||
@ -51,7 +51,7 @@ ping:
|
|||||||
traceroute:
|
traceroute:
|
||||||
display_name: "Traceroute"
|
display_name: "Traceroute"
|
||||||
format: "traceroute -{ip_version} {target}"
|
format: "traceroute -{ip_version} {target}"
|
||||||
description: "Trace network path to destination"
|
description: "Performs traceroute to target"
|
||||||
field:
|
field:
|
||||||
type: "text"
|
type: "text"
|
||||||
placeholder: "Enter IP address or hostname"
|
placeholder: "Enter IP address or hostname"
|
||||||
@ -59,7 +59,7 @@ traceroute:
|
|||||||
mtr:
|
mtr:
|
||||||
display_name: "MTR"
|
display_name: "MTR"
|
||||||
format: "mtr -{ip_version} -r {target}"
|
format: "mtr -{ip_version} -r {target}"
|
||||||
description: "Trace network path with stats"
|
description: "Performs MTR to target"
|
||||||
field:
|
field:
|
||||||
type: "text"
|
type: "text"
|
||||||
placeholder: "Enter IP address or hostname"
|
placeholder: "Enter IP address or hostname"
|
||||||
|
@ -30,7 +30,13 @@ const app = Vue.createApp({
|
|||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
this.resetCommandState();
|
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
|
immediate: true
|
||||||
},
|
},
|
||||||
selectedCommand: {
|
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() {
|
showIpVersionSelector() {
|
||||||
if (!this.targetIp) return true;
|
if (!this.targetIp) return true;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="flex flex-col md:flex-row justify-between items-center space-y-6 md:space-y-0">
|
<div class="flex flex-col md:flex-row justify-between items-center space-y-6 md:space-y-0">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="text-sm text-gray-600 dark:text-gray-400">
|
<span class="text-sm text-gray-600 dark:text-gray-400">
|
||||||
{{ site.footer.text }} - v1.0.0
|
{{ site.footer.text }} - v1.0.1
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -121,7 +121,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="space-y-4">
|
<div class="space-y-4">
|
||||||
{% for command in commands %}
|
{% for command in commands.values() %}
|
||||||
<div class="border-b border-gray-200 dark:border-gray-700 last:border-0 pb-4 last:pb-0">
|
<div class="border-b border-gray-200 dark:border-gray-700 last:border-0 pb-4 last:pb-0">
|
||||||
<h4 class="font-medium text-gray-900 dark:text-white mb-2">
|
<h4 class="font-medium text-gray-900 dark:text-white mb-2">
|
||||||
<p class="bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200 px-3 py-1.5 rounded-lg text-sm font-mono">
|
<p class="bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200 px-3 py-1.5 rounded-lg text-sm font-mono">
|
||||||
|
@ -64,21 +64,20 @@
|
|||||||
leave-to-class="transform opacity-0 scale-95 -translate-y-2">
|
leave-to-class="transform opacity-0 scale-95 -translate-y-2">
|
||||||
<div v-if="isOpen"
|
<div v-if="isOpen"
|
||||||
class="absolute z-10 mt-1 w-full bg-white dark:bg-gray-800 shadow-lg max-h-60 rounded-lg py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm">
|
class="absolute z-10 mt-1 w-full bg-white dark:bg-gray-800 shadow-lg max-h-60 rounded-lg py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm">
|
||||||
{% for command_key, command in commands.items() %}
|
<div v-for="command in filteredCommands" :key="command.key"
|
||||||
<div @click.stop.prevent="selectCommand('{{ command_key }}')"
|
@click.stop.prevent="selectCommand(command.key)"
|
||||||
:class="['cursor-pointer select-none relative py-2 pl-3 pr-9 transition-all duration-200 ease-in-out hover:bg-gray-200 dark:hover:bg-gray-600 hover:text-gray-900 dark:hover:text-white',
|
:class="['cursor-pointer select-none relative py-2 pl-3 pr-9 transition-all duration-200 ease-in-out hover:bg-gray-200 dark:hover:bg-gray-600 hover:text-gray-900 dark:hover:text-white',
|
||||||
selectedCommand === '{{ command_key }}' ? 'bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white' : 'text-gray-700 dark:text-gray-300']">
|
selectedCommand === command.key ? 'bg-gray-100 dark:bg-gray-700 text-gray-900 dark:text-white' : 'text-gray-700 dark:text-gray-300']">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="block truncate font-medium">{{ command.display_name }}</span>
|
<span class="block truncate font-medium">${command.display_name}</span>
|
||||||
</div>
|
|
||||||
<span v-if="selectedCommand === '{{ command_key }}'"
|
|
||||||
class="absolute inset-y-0 right-0 flex items-center pr-4 text-gray-600 dark:text-gray-400">
|
|
||||||
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
|
||||||
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
|
||||||
</svg>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
<span v-if="selectedCommand === command.key"
|
||||||
|
class="absolute inset-y-0 right-0 flex items-center pr-4 text-gray-600 dark:text-gray-400">
|
||||||
|
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||||
|
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user