From 5b691d0e5b726674f67a77e8cb0b0837539109f9 Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sun, 2 Mar 2025 15:05:41 -0500 Subject: [PATCH] Add more search bar features --- .../src/components/general/VMSearchBar.vue | 110 ++++++++++++++---- 1 file changed, 85 insertions(+), 25 deletions(-) diff --git a/pvc-vue/src/components/general/VMSearchBar.vue b/pvc-vue/src/components/general/VMSearchBar.vue index fd61d99..f1d206a 100644 --- a/pvc-vue/src/components/general/VMSearchBar.vue +++ b/pvc-vue/src/components/general/VMSearchBar.vue @@ -46,7 +46,7 @@
-
Status
+
State
{{ vm.name }}
-
- +
+ {{ vm.state }}
+
+ + {{ vm.node }} +
@@ -435,7 +439,24 @@ const availableStates = computed(() => { props.vmList.forEach(vm => { if (vm.state) states.add(vm.state); }); - return Array.from(states).sort(); + + // Convert to array and ensure all important states are included + const statesArray = Array.from(states); + const importantStates = ['start', 'disable', 'migrate', 'unmigrate', 'provision', 'mirror', 'stop', 'fail', 'shutdown', 'restart']; + + // Add any missing important states + importantStates.forEach(state => { + if (!statesArray.includes(state)) { + statesArray.push(state); + } + }); + + // Sort with 'start' first, then alphabetically + return statesArray.sort((a, b) => { + if (a.toLowerCase() === 'start') return -1; + if (b.toLowerCase() === 'start') return 1; + return a.localeCompare(b); + }); }); // Calculate available nodes from vmList @@ -479,15 +500,39 @@ const activeFiltersCount = computed(() => { return count; }); -// Status class helper -const getStatusClass = (state) => { +// Update function name from getStatusClass to getStateClass +const getStateClass = (state) => { if (!state) return 'status-unknown'; - switch(state.toLowerCase()) { - case 'start': return 'status-running'; - case 'stop': return 'status-stopped'; - case 'disable': return 'status-paused'; - default: return 'status-unknown'; + + const lowerState = state.toLowerCase(); + + // Green for running VMs + if (lowerState === 'start') { + return 'status-running'; } + + // Blue for provisioning, migration, etc. + if (['disable', 'migrate', 'unmigrate', 'provision'].includes(lowerState)) { + return 'status-provisioning'; + } + + // Purple for mirror + if (lowerState === 'mirror') { + return 'status-mirror'; + } + + // Red for stopped or failed VMs + if (['stop', 'fail'].includes(lowerState)) { + return 'status-stopped'; + } + + // Yellow for shutdown or restart + if (['shutdown', 'restart'].includes(lowerState)) { + return 'status-restarting'; + } + + // Default to unknown (black) for any other states + return 'status-unknown'; }; // Watch for changes in showList @@ -720,45 +765,60 @@ const loadFiltersFromLocalStorage = () => { .vm-item-content { display: flex; - justify-content: space-between; align-items: center; width: 100%; + gap: 1rem; } .vm-name { font-weight: 500; + flex: 1; } -.vm-status { +.vm-state { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; + width: 100px; } -.status-indicator { +.vm-node { + display: flex; + align-items: center; + gap: 0.5rem; + font-size: 0.875rem; + color: #6c757d; + width: 100px; +} + +.node-icon { + font-size: 0.75rem; +} + +.state-indicator { font-size: 0.625rem; } -/* Status colors */ +/* Status colors - updated */ .status-running { - color: #28a745; + color: #28a745; /* Green */ } .status-stopped { - color: #6c757d; + color: #dc3545; /* Red */ } -.status-paused { - color: #ffc107; +.status-provisioning { + color: #0d6efd; /* Blue */ } -.status-error { - color: #dc3545; +.status-mirror { + color: #6f42c1; /* Purple */ } -.status-unknown { - color: #6c757d; +.status-restarting { + color: #ffc107; /* Yellow */ } .no-vms-message { @@ -773,7 +833,7 @@ const loadFiltersFromLocalStorage = () => { top: 100%; right: 0; z-index: 1000; - min-width: 250px; + min-width: 350px; padding: 1rem; margin-top: 0.5rem; background-color: white; @@ -794,7 +854,7 @@ const loadFiltersFromLocalStorage = () => { } .filter-options-dropdown { - max-height: 150px; + max-height: 200px; overflow-y: auto; display: flex; flex-direction: column;