Compare commits
13 Commits
804f049111
...
master
Author | SHA1 | Date | |
---|---|---|---|
47b4e6e182 | |||
acfd2554b0 | |||
8d1028ab47 | |||
e26c5defa4 | |||
61dbe8eed1 | |||
779dbe1632 | |||
e6da8ec2c0 | |||
e11217e28a | |||
4ca93fcc9a | |||
0200df7b16 | |||
d581d17273 | |||
5b691d0e5b | |||
745d554768 |
@ -1,368 +0,0 @@
|
|||||||
/* Global spacing adjustments */
|
|
||||||
.content-grid {
|
|
||||||
gap: 0.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-content {
|
|
||||||
padding-top: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reduce space between page title and content */
|
|
||||||
.content-grid > *:first-child + * {
|
|
||||||
margin-top: 0.375rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the specific space between title underline and first card */
|
|
||||||
.content-grid > div:first-child {
|
|
||||||
margin-bottom: 0.375rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reduce space after PageTitle component */
|
|
||||||
.page-title {
|
|
||||||
margin-bottom: 0.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove left padding from node tabs */
|
|
||||||
.nav-tabs {
|
|
||||||
padding-left: 0 !important;
|
|
||||||
margin-left: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure node content aligns with left edge */
|
|
||||||
.node-content, .tab-content {
|
|
||||||
padding-left: 0 !important;
|
|
||||||
margin-left: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the specific element causing the padding */
|
|
||||||
div.node-tabs {
|
|
||||||
padding-left: 0 !important;
|
|
||||||
padding-right: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* More aggressive targeting for node tabs */
|
|
||||||
.node-overview .nav,
|
|
||||||
.node-overview .nav-tabs,
|
|
||||||
.node-overview ul.nav,
|
|
||||||
.node-overview ul.nav-tabs {
|
|
||||||
padding-left: 0 !important;
|
|
||||||
margin-left: 0 !important;
|
|
||||||
border-left: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the first tab item specifically */
|
|
||||||
.node-overview .nav-item:first-child,
|
|
||||||
.node-overview .nav-link:first-child {
|
|
||||||
margin-left: 0 !important;
|
|
||||||
padding-left: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target any container that might be wrapping the tabs */
|
|
||||||
.node-overview > div,
|
|
||||||
.node-overview > ul {
|
|
||||||
padding-left: 0 !important;
|
|
||||||
margin-left: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Style VM search bar section like node tabs */
|
|
||||||
.vm-search-container,
|
|
||||||
.vm-list-header,
|
|
||||||
.vm-controls {
|
|
||||||
border: none !important;
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.125) !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
background-color: transparent !important;
|
|
||||||
padding: 0.5rem 0 !important;
|
|
||||||
margin-bottom: 1rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove any box shadow from VM search elements */
|
|
||||||
.vm-search-container *,
|
|
||||||
.vm-list-header *,
|
|
||||||
.vm-controls * {
|
|
||||||
box-shadow: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure search input has proper styling */
|
|
||||||
.vm-search-input {
|
|
||||||
border: 1px solid rgba(0, 0, 0, 0.2) !important;
|
|
||||||
border-radius: 0.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the specific VM list controls more directly */
|
|
||||||
.vm-overview .list-vms-container,
|
|
||||||
.vm-overview .vm-controls-container {
|
|
||||||
border: none !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
background: transparent !important;
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.125) !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
padding-left: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the buttons and inputs directly */
|
|
||||||
.vm-overview .btn-group,
|
|
||||||
.vm-overview .input-group {
|
|
||||||
margin: 0 !important;
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the List VMs button specifically */
|
|
||||||
.vm-overview .btn-secondary,
|
|
||||||
.vm-overview button[type="button"] {
|
|
||||||
background-color: #6c757d !important;
|
|
||||||
border-color: #6c757d !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Super aggressive targeting for VM search container */
|
|
||||||
.vm-list-container > div:first-child,
|
|
||||||
.vm-overview > div:first-child,
|
|
||||||
div[class*="vm-"] > div:first-child {
|
|
||||||
border: none !important;
|
|
||||||
background: transparent !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.125) !important;
|
|
||||||
padding: 0.5rem 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the actual search box and buttons */
|
|
||||||
.input-group,
|
|
||||||
.btn-group {
|
|
||||||
margin-bottom: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target any card or container in the VM list header */
|
|
||||||
.card,
|
|
||||||
.card-header,
|
|
||||||
.card-body {
|
|
||||||
/* Target only VM list cards, not ValueCards */
|
|
||||||
.vm-list-container .card,
|
|
||||||
.vm-list-container .card-header,
|
|
||||||
.vm-list-container .card-body,
|
|
||||||
.vm-controls-container .card,
|
|
||||||
.vm-controls-container .card-header,
|
|
||||||
.vm-controls-container .card-body {
|
|
||||||
border: none !important;
|
|
||||||
background: transparent !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
padding: 0.5rem 0 !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the specific vm-controls-container element */
|
|
||||||
div.vm-controls-container {
|
|
||||||
background-color: transparent !important;
|
|
||||||
border-radius: 0 !important;
|
|
||||||
box-shadow: none !important;
|
|
||||||
padding: 0.5rem 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the light blue background */
|
|
||||||
div.vm-controls-container[data-v-8e678963] {
|
|
||||||
background-color: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust spacing after page title on VM page */
|
|
||||||
.vm-overview .page-title,
|
|
||||||
.vm-overview .page-title-container {
|
|
||||||
margin-bottom: 0.05rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure consistent spacing between title and controls */
|
|
||||||
.vm-overview .content-grid > *:first-child + * {
|
|
||||||
margin-top: 0.05rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove lines under VM names */
|
|
||||||
.vm-list-item,
|
|
||||||
.vm-item {
|
|
||||||
border-bottom: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure only the controls container has the bottom border */
|
|
||||||
.vm-list-container > div:not(:first-child),
|
|
||||||
.vm-overview > div:not(:first-child) {
|
|
||||||
border-bottom: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Further reduce spacing between title and controls */
|
|
||||||
.content-grid > div:first-child {
|
|
||||||
margin-bottom: 0.05rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Extremely aggressive spacing reduction */
|
|
||||||
.page-title + *,
|
|
||||||
.page-title-container + * {
|
|
||||||
margin-top: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Specifically target VM list items to remove bottom borders */
|
|
||||||
.vm-list > div,
|
|
||||||
.vm-list-item,
|
|
||||||
.vm-item,
|
|
||||||
div[class*="vm-list"] > div {
|
|
||||||
border-bottom: none !important;
|
|
||||||
border: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the VM list container to remove any borders from its children except the first */
|
|
||||||
.vm-list-container > div:not(:first-child) *,
|
|
||||||
.vm-overview > div:not(:first-child) * {
|
|
||||||
border-bottom: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Zero out all margins between title and controls */
|
|
||||||
.page-title,
|
|
||||||
.page-title-container,
|
|
||||||
.content-grid > div:first-child {
|
|
||||||
margin-bottom: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reduce padding above the VM controls container */
|
|
||||||
div.vm-controls-container,
|
|
||||||
.vm-list-container > div:first-child {
|
|
||||||
margin-top: 0.05rem !important;
|
|
||||||
padding-top: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fix double border issue - ensure only one border appears below search */
|
|
||||||
.vm-list-container > div:first-child,
|
|
||||||
.vm-overview > div:first-child,
|
|
||||||
div[class*="vm-"] > div:first-child {
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.125) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove ALL borders from VM list items - extremely aggressive */
|
|
||||||
.vm-list-container .vm-list-item,
|
|
||||||
.vm-list-container .vm-item,
|
|
||||||
.vm-list-container li,
|
|
||||||
.vm-list-container tr,
|
|
||||||
.vm-list-container div[class*="vm-"],
|
|
||||||
.vm-list > div,
|
|
||||||
.vm-list > li,
|
|
||||||
.vm-list > tr,
|
|
||||||
.vm-list-item,
|
|
||||||
.vm-item,
|
|
||||||
div[class*="vm-list"] > div,
|
|
||||||
div[class*="vm-list"] div {
|
|
||||||
border: none !important;
|
|
||||||
border-bottom: none !important;
|
|
||||||
border-top: none !important;
|
|
||||||
border-left: none !important;
|
|
||||||
border-right: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure VM list container itself doesn't have a border */
|
|
||||||
.vm-list-container {
|
|
||||||
border: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the actual VM list to remove borders */
|
|
||||||
.vm-list {
|
|
||||||
border: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Override any hr elements that might be creating lines */
|
|
||||||
.vm-list-container hr,
|
|
||||||
.vm-list hr,
|
|
||||||
.vm-item + hr,
|
|
||||||
.vm-list-item + hr {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Single border under search bar */
|
|
||||||
.vm-controls-container {
|
|
||||||
border: none !important;
|
|
||||||
background: transparent !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target VM list items specifically */
|
|
||||||
.vm-list-container .vm-list-item {
|
|
||||||
border: none !important;
|
|
||||||
background: transparent !important;
|
|
||||||
padding-top: 0.25rem !important;
|
|
||||||
padding-bottom: 0.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target the VM item content to reduce spacing */
|
|
||||||
.vm-item-content,
|
|
||||||
.vm-list-item > div,
|
|
||||||
button.vm-list-item {
|
|
||||||
padding-top: 0.25rem !important;
|
|
||||||
padding-bottom: 0.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Also target any nested content */
|
|
||||||
.vm-name,
|
|
||||||
.vm-status {
|
|
||||||
padding-top: 0.25rem !important;
|
|
||||||
padding-bottom: 0.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove any dividers between VM items */
|
|
||||||
.vm-list-container .divider,
|
|
||||||
.vm-list-container hr,
|
|
||||||
.vm-list-item::after,
|
|
||||||
.vm-list-item::before {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust spacing between title and search */
|
|
||||||
.page-title + .vm-controls-container {
|
|
||||||
margin-top: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Let's also clean up any duplicate rules */
|
|
||||||
.controls-row {
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.125) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove border from vm-name elements */
|
|
||||||
.vm-name {
|
|
||||||
border: none !important;
|
|
||||||
border-bottom: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Target both instances of the border */
|
|
||||||
div[class*="vm-"] > div:first-child div[class*="vm-"] > div:first-child,
|
|
||||||
.vm-list-container > div:first-child div[class*="vm-"] > div:first-child {
|
|
||||||
border: none !important;
|
|
||||||
border-bottom: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Super specific targeting for the border issue */
|
|
||||||
div[class*="vm-"] > div:first-child H {
|
|
||||||
border: none !important;
|
|
||||||
border-bottom: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Keep node tabs close to title but adjust content below tabs */
|
|
||||||
.node-overview .node-tabs-wrapper {
|
|
||||||
margin-top: 0.25rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust spacing below tabs to match overview spacing */
|
|
||||||
.node-overview .node-tabs-wrapper + * {
|
|
||||||
margin-top: 0.375rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure consistent spacing in overview page */
|
|
||||||
.overview-container > *:first-child {
|
|
||||||
margin-top: 0.375rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Override spacing specifically for node tabs - keep tight to title */
|
|
||||||
.node-overview .content-grid > *:first-child + * {
|
|
||||||
margin-top: 0.25rem !important; /* Keep tabs close to title */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust spacing between tabs and content below */
|
|
||||||
.node-overview .node-tabs-wrapper {
|
|
||||||
margin-bottom: 0.375rem !important; /* Match overview spacing */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Remove any extra spacing that might be added by other elements */
|
|
||||||
.node-overview .node-details {
|
|
||||||
margin-top: 0 !important;
|
|
||||||
}
|
|
@ -4,7 +4,7 @@
|
|||||||
<div v-if="!isExpanded" class="section-content-wrapper">
|
<div v-if="!isExpanded" class="section-content-wrapper">
|
||||||
<div class="section-content">
|
<div class="section-content">
|
||||||
<div class="collapsed-section-header">
|
<div class="collapsed-section-header">
|
||||||
<h6 class="card-title mb-0 metric-label">{{ title }}</h6>
|
<h5 class="section-title" v-if="title">{{ title }}</h5>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="toggle-column">
|
<div class="toggle-column">
|
||||||
@ -137,4 +137,19 @@ const toggleSection = () => {
|
|||||||
.section-container.collapsed .section-content-wrapper {
|
.section-container.collapsed .section-content-wrapper {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section-header h6 {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #495057;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -1,19 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="node-select-bar">
|
<div class="node-select-bar">
|
||||||
<button
|
<div class="node-select-row">
|
||||||
v-for="node in nodes"
|
<button
|
||||||
:key="node"
|
v-for="node in nodes"
|
||||||
class="node-tab"
|
:key="node"
|
||||||
:class="{ 'active': modelValue === node }"
|
class="node-tab"
|
||||||
@click="selectNode(node)"
|
:class="{ 'active': modelValue === node }"
|
||||||
>
|
@click="selectNode(node)"
|
||||||
{{ node }}
|
>
|
||||||
</button>
|
{{ node }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps, defineEmits } from 'vue';
|
import { ref, onMounted, watch } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@ -24,31 +26,70 @@ const props = defineProps({
|
|||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
default: () => []
|
default: () => []
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
type: String,
|
||||||
|
default: null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'select']);
|
const emit = defineEmits(['update:modelValue', 'select']);
|
||||||
|
|
||||||
|
const selectedNode = ref(props.value || props.modelValue);
|
||||||
|
|
||||||
const selectNode = (node) => {
|
const selectNode = (node) => {
|
||||||
|
selectedNode.value = node;
|
||||||
emit('update:modelValue', node);
|
emit('update:modelValue', node);
|
||||||
emit('select', node);
|
emit('select', node);
|
||||||
|
|
||||||
|
// Save to localStorage
|
||||||
|
localStorage.setItem('selectedNodeId', node);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// Restore selected node from localStorage if available
|
||||||
|
const savedNodeId = localStorage.getItem('selectedNodeId');
|
||||||
|
if (savedNodeId && props.nodes.includes(savedNodeId)) {
|
||||||
|
// Only select if the node exists in the available nodes
|
||||||
|
selectedNode.value = savedNodeId;
|
||||||
|
emit('update:modelValue', savedNodeId);
|
||||||
|
emit('select', savedNodeId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(() => props.value, (newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
selectedNode.value = newValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(() => props.modelValue, (newValue) => {
|
||||||
|
if (newValue) {
|
||||||
|
selectedNode.value = newValue;
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.node-select-bar {
|
.node-select-bar {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.25rem;
|
flex-direction: column;
|
||||||
padding: 0.5rem;
|
gap: 0.5rem;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
overflow-x: auto;
|
padding-top: 0.25rem;
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
|
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
|
||||||
margin-bottom: 0.5rem;
|
}
|
||||||
|
|
||||||
|
.node-select-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding-bottom: 0.75rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.node-tab {
|
.node-tab {
|
||||||
padding: 0.375rem 0.75rem;
|
padding: 0.45rem 0.75rem;
|
||||||
border: none;
|
border: none;
|
||||||
background: none;
|
background: none;
|
||||||
color: #495057;
|
color: #495057;
|
||||||
@ -66,5 +107,7 @@ const selectNode = (node) => {
|
|||||||
.node-tab.active {
|
.node-tab.active {
|
||||||
color: #0d6efd;
|
color: #0d6efd;
|
||||||
background-color: rgba(13, 110, 253, 0.1);
|
background-color: rgba(13, 110, 253, 0.1);
|
||||||
|
border-bottom: 4px solid rgba(13, 110, 253, 0.25);
|
||||||
|
margin-bottom: -4px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -21,7 +21,6 @@ defineProps({
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 1rem;
|
|
||||||
padding-bottom: 0.5rem;
|
padding-bottom: 0.5rem;
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="controls-bar" ref="controlsBar">
|
<div class="vm-selector-bar" ref="controlsBar">
|
||||||
<div class="controls-row">
|
<div class="vm-selector-row">
|
||||||
<button
|
<button
|
||||||
class="btn btn-outline-secondary list-toggle-btn"
|
class="btn btn-outline-secondary list-toggle-btn"
|
||||||
@click="toggleList"
|
@click="toggleList"
|
||||||
@ -27,9 +27,10 @@
|
|||||||
class="form-control search-input"
|
class="form-control search-input"
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
v-if="modelValue && showList && showClearButton"
|
v-if="shouldShowClearButton"
|
||||||
class="btn-clear"
|
class="btn-clear"
|
||||||
@click.stop="clearSearch"
|
@click.stop="handleClearButton"
|
||||||
|
:title="showList ? 'Clear search' : 'Clear selected VM'"
|
||||||
>
|
>
|
||||||
<i class="fas fa-times"></i>
|
<i class="fas fa-times"></i>
|
||||||
</button>
|
</button>
|
||||||
@ -46,7 +47,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="filter-menu" v-show="showFilterMenu" ref="filterMenu">
|
<div class="filter-menu" v-show="showFilterMenu" ref="filterMenu">
|
||||||
<div class="filter-section">
|
<div class="filter-section">
|
||||||
<h6>Status</h6>
|
<h6>State</h6>
|
||||||
<div class="filter-options-dropdown">
|
<div class="filter-options-dropdown">
|
||||||
<div class="filter-pills">
|
<div class="filter-pills">
|
||||||
<button
|
<button
|
||||||
@ -98,16 +99,20 @@
|
|||||||
:key="vm.name"
|
:key="vm.name"
|
||||||
:data-vm-name="vm.name"
|
:data-vm-name="vm.name"
|
||||||
class="vm-list-item"
|
class="vm-list-item"
|
||||||
:class="{ 'active': selectedVM === vm.name || vmFromUrl === vm.name }"
|
:class="{ 'active': isVMSelected(vm.name) }"
|
||||||
@click="handleVMSelect(vm)"
|
@click="handleVMSelect(vm)"
|
||||||
>
|
>
|
||||||
<div v-if="selectedVM === vm.name || vmFromUrl === vm.name" class="active-indicator"></div>
|
<div v-if="isVMSelected(vm.name)" class="active-indicator"></div>
|
||||||
<div class="vm-item-content">
|
<div class="vm-item-content">
|
||||||
<div class="vm-name">{{ vm.name }}</div>
|
<div class="vm-name">{{ vm.name }}</div>
|
||||||
<div class="vm-status" :class="getStatusClass(vm.state)">
|
<div class="vm-state" :class="getStateClass(vm.state)">
|
||||||
<i class="fas fa-circle status-indicator"></i>
|
<i class="fas fa-circle state-indicator"></i>
|
||||||
<span>{{ vm.state }}</span>
|
<span>{{ vm.state }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="vm.node" class="vm-node">
|
||||||
|
<i class="fas fa-server node-icon"></i>
|
||||||
|
<span>{{ vm.node }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -154,7 +159,8 @@ const emit = defineEmits([
|
|||||||
'toggle-list',
|
'toggle-list',
|
||||||
'select-vm',
|
'select-vm',
|
||||||
'toggle-filter',
|
'toggle-filter',
|
||||||
'reset-filters'
|
'reset-filters',
|
||||||
|
'clear-vm'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// UI state refs
|
// UI state refs
|
||||||
@ -175,30 +181,73 @@ const appliedFilters = ref({
|
|||||||
nodes: {}
|
nodes: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add a computed property to determine if the clear button should be shown
|
||||||
|
const shouldShowClearButton = computed(() => {
|
||||||
|
// Show when:
|
||||||
|
// 1. List is open and there's a search query
|
||||||
|
// 2. List is closed and there's a selected VM
|
||||||
|
return (props.showList && props.modelValue && props.showClearButton) ||
|
||||||
|
(!props.showList && (props.selectedVM || localStorage.getItem('selectedVMId')));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add a computed property to check if a VM is selected
|
||||||
|
const isVMSelected = (vmName) => {
|
||||||
|
return props.selectedVM === vmName ||
|
||||||
|
props.vmFromUrl === vmName ||
|
||||||
|
localStorage.getItem('selectedVMId') === vmName;
|
||||||
|
};
|
||||||
|
|
||||||
// Initialize the component
|
// Initialize the component
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// Set up click outside handler
|
// Set up click outside handler
|
||||||
document.addEventListener('click', handleClickOutside);
|
document.addEventListener('click', handleClickOutside);
|
||||||
|
|
||||||
|
// Get the selected VM from localStorage
|
||||||
|
const savedVMId = localStorage.getItem('selectedVMId');
|
||||||
|
|
||||||
// Restore search text from localStorage if available
|
// Restore search text from localStorage if available
|
||||||
const savedSearchText = localStorage.getItem('vmSearchText');
|
const savedSearchText = localStorage.getItem('vmSearchText');
|
||||||
|
|
||||||
|
// Initialize input value based on context
|
||||||
|
if (!props.showList) {
|
||||||
|
// If list is closed, show the selected VM name in the input
|
||||||
|
const effectiveVM = props.selectedVM || props.vmFromUrl || savedVMId;
|
||||||
|
if (effectiveVM) {
|
||||||
|
// Find the VM in the list to get its full name
|
||||||
|
const vm = props.vmList.find(v => v.name === effectiveVM);
|
||||||
|
if (vm) {
|
||||||
|
inputValue.value = vm.name;
|
||||||
|
} else {
|
||||||
|
inputValue.value = effectiveVM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (props.showList) {
|
||||||
|
// If list is open
|
||||||
|
if (props.modelValue) {
|
||||||
|
// If there's a model value, use it
|
||||||
|
inputValue.value = props.modelValue;
|
||||||
|
searchText.value = props.modelValue;
|
||||||
|
} else if (savedSearchText) {
|
||||||
|
// If there's saved search text, restore it
|
||||||
|
inputValue.value = savedSearchText;
|
||||||
|
searchText.value = savedSearchText;
|
||||||
|
emit('update:modelValue', savedSearchText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Always restore the search text ref from localStorage
|
||||||
if (savedSearchText) {
|
if (savedSearchText) {
|
||||||
searchText.value = savedSearchText;
|
searchText.value = savedSearchText;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize input value based on selected VM
|
// Load saved filters
|
||||||
if (!props.showList && (props.selectedVM || props.vmFromUrl)) {
|
loadFiltersFromLocalStorage();
|
||||||
inputValue.value = props.selectedVM || props.vmFromUrl;
|
|
||||||
} else if (props.showList && props.modelValue) {
|
|
||||||
inputValue.value = props.modelValue;
|
|
||||||
searchText.value = props.modelValue;
|
|
||||||
// Save to localStorage
|
|
||||||
localStorage.setItem('vmSearchText', props.modelValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the list is visible on mount, scroll to selected VM
|
// If the list is visible on mount, scroll to selected VM
|
||||||
if (props.showList && (props.selectedVM || props.vmFromUrl)) {
|
if (props.showList) {
|
||||||
scrollToSelectedVM();
|
nextTick(() => {
|
||||||
|
scrollToSelectedVM();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -210,14 +259,23 @@ onUnmounted(() => {
|
|||||||
const handleSearch = (event) => {
|
const handleSearch = (event) => {
|
||||||
const value = event.target.value;
|
const value = event.target.value;
|
||||||
inputValue.value = value;
|
inputValue.value = value;
|
||||||
|
|
||||||
|
// Update search text ref
|
||||||
searchText.value = value;
|
searchText.value = value;
|
||||||
isFilterActive.value = true;
|
|
||||||
|
|
||||||
// Save search text to localStorage
|
|
||||||
localStorage.setItem('vmSearchText', value);
|
|
||||||
|
|
||||||
|
// Update the model
|
||||||
emit('update:modelValue', value);
|
emit('update:modelValue', value);
|
||||||
emit('search', value);
|
emit('search', value);
|
||||||
|
|
||||||
|
// Save to localStorage for search history
|
||||||
|
if (value) {
|
||||||
|
localStorage.setItem('vmSearchText', value);
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('vmSearchText');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update filter state
|
||||||
|
isFilterActive.value = !!value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle focus on search input
|
// Handle focus on search input
|
||||||
@ -260,60 +318,32 @@ const handleSearchClick = () => {
|
|||||||
|
|
||||||
// Toggle the VM list
|
// Toggle the VM list
|
||||||
const toggleList = () => {
|
const toggleList = () => {
|
||||||
// If the list is already open, toggle filtering instead of closing
|
emit('toggle-list');
|
||||||
if (props.showList) {
|
|
||||||
// If we're in list mode (not filtering) and the button is clicked, close the drawer
|
// When toggling the list, ensure search text is preserved
|
||||||
if (!isFilterActive.value) {
|
const savedSearchText = localStorage.getItem('vmSearchText');
|
||||||
// Save the current search text before closing
|
|
||||||
if (props.modelValue) {
|
if (!props.showList) {
|
||||||
searchText.value = props.modelValue;
|
// When opening the list, restore search text if available
|
||||||
// Save to localStorage
|
if (savedSearchText && !inputValue.value) {
|
||||||
localStorage.setItem('vmSearchText', props.modelValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the drawer
|
|
||||||
emit('toggle-list');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle filtering mode
|
|
||||||
isFilterActive.value = !isFilterActive.value;
|
|
||||||
|
|
||||||
// If we're turning filtering on, make sure the search text is applied
|
|
||||||
if (isFilterActive.value && searchText.value) {
|
|
||||||
inputValue.value = searchText.value;
|
|
||||||
emit('update:modelValue', searchText.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're turning filtering off (switching to list mode), scroll to selected VM
|
|
||||||
if (!isFilterActive.value) {
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
scrollToSelectedVM();
|
inputValue.value = savedSearchText;
|
||||||
|
searchText.value = savedSearchText;
|
||||||
|
emit('update:modelValue', savedSearchText);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// No need to emit toggle-list since we're not closing the list
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
// If the list is closed, open it without filtering
|
|
||||||
if (!props.showList) {
|
// Handle clear button click
|
||||||
// If we're opening the list, deactivate filtering
|
const handleClearButton = () => {
|
||||||
isFilterActive.value = false;
|
if (props.showList) {
|
||||||
|
// If the list is open, clear the search
|
||||||
// Restore search text in the input, but don't apply filtering
|
clearSearch();
|
||||||
if (searchText.value) {
|
} else {
|
||||||
inputValue.value = searchText.value;
|
// If the list is closed, clear the selected VM
|
||||||
emit('update:modelValue', searchText.value);
|
clearSelectedVM();
|
||||||
}
|
|
||||||
|
|
||||||
// Schedule scrolling to selected VM after the list opens
|
|
||||||
nextTick(() => {
|
|
||||||
scrollToSelectedVM();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
emit('toggle-list');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear search
|
// Clear search
|
||||||
@ -328,8 +358,11 @@ const clearSearch = () => {
|
|||||||
emit('update:modelValue', '');
|
emit('update:modelValue', '');
|
||||||
emit('clear');
|
emit('clear');
|
||||||
|
|
||||||
// Focus the search input after clearing
|
// Scroll to selected VM after clearing search
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
scrollToSelectedVM();
|
||||||
|
|
||||||
|
// Focus the search input after clearing
|
||||||
const searchInput = document.querySelector('.search-input');
|
const searchInput = document.querySelector('.search-input');
|
||||||
if (searchInput) {
|
if (searchInput) {
|
||||||
searchInput.focus();
|
searchInput.focus();
|
||||||
@ -337,10 +370,36 @@ const clearSearch = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Clear selected VM
|
||||||
|
const clearSelectedVM = () => {
|
||||||
|
// Clear the input value
|
||||||
|
inputValue.value = '';
|
||||||
|
|
||||||
|
// Clear from localStorage
|
||||||
|
localStorage.removeItem('selectedVMId');
|
||||||
|
|
||||||
|
// Don't clear vmSearchText - that's for search history
|
||||||
|
// Only clear if the input value matches the selected VM
|
||||||
|
const savedVMId = localStorage.getItem('selectedVMId');
|
||||||
|
const savedSearchText = localStorage.getItem('vmSearchText');
|
||||||
|
if (savedSearchText === savedVMId) {
|
||||||
|
localStorage.removeItem('vmSearchText');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the VM list
|
||||||
|
emit('toggle-list');
|
||||||
|
|
||||||
|
// Emit event to parent component
|
||||||
|
emit('clear-vm');
|
||||||
|
};
|
||||||
|
|
||||||
// Select a VM
|
// Select a VM
|
||||||
const handleVMSelect = (vm) => {
|
const handleVMSelect = (vm) => {
|
||||||
console.log('Selecting VM:', vm);
|
console.log('Selecting VM:', vm);
|
||||||
|
|
||||||
|
// Update the input value to show the selected VM
|
||||||
|
inputValue.value = vm.name;
|
||||||
|
|
||||||
// Save the current search text before selecting a VM
|
// Save the current search text before selecting a VM
|
||||||
if (props.modelValue) {
|
if (props.modelValue) {
|
||||||
searchText.value = props.modelValue;
|
searchText.value = props.modelValue;
|
||||||
@ -348,6 +407,9 @@ const handleVMSelect = (vm) => {
|
|||||||
localStorage.setItem('vmSearchText', props.modelValue);
|
localStorage.setItem('vmSearchText', props.modelValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save selected VM to localStorage
|
||||||
|
localStorage.setItem('selectedVMId', vm.name);
|
||||||
|
|
||||||
emit('select-vm', vm);
|
emit('select-vm', vm);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -377,6 +439,7 @@ const toggleFilterMenu = () => {
|
|||||||
// Filter toggle
|
// Filter toggle
|
||||||
const handleFilterToggle = (type, value) => {
|
const handleFilterToggle = (type, value) => {
|
||||||
appliedFilters.value[type][value] = !appliedFilters.value[type][value];
|
appliedFilters.value[type][value] = !appliedFilters.value[type][value];
|
||||||
|
saveFiltersToLocalStorage();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reset filters
|
// Reset filters
|
||||||
@ -387,6 +450,7 @@ const handleResetFilters = () => {
|
|||||||
Object.keys(appliedFilters.value.nodes).forEach(node => {
|
Object.keys(appliedFilters.value.nodes).forEach(node => {
|
||||||
appliedFilters.value.nodes[node] = false;
|
appliedFilters.value.nodes[node] = false;
|
||||||
});
|
});
|
||||||
|
saveFiltersToLocalStorage();
|
||||||
showFilterMenu.value = false;
|
showFilterMenu.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -427,7 +491,24 @@ const availableStates = computed(() => {
|
|||||||
props.vmList.forEach(vm => {
|
props.vmList.forEach(vm => {
|
||||||
if (vm.state) states.add(vm.state);
|
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
|
// Calculate available nodes from vmList
|
||||||
@ -454,6 +535,9 @@ watch([availableStates, availableNodes], ([states, nodes]) => {
|
|||||||
appliedFilters.value.nodes[node] = false;
|
appliedFilters.value.nodes[node] = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Save updated filters
|
||||||
|
saveFiltersToLocalStorage();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Count active filters
|
// Count active filters
|
||||||
@ -468,22 +552,46 @@ const activeFiltersCount = computed(() => {
|
|||||||
return count;
|
return count;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Status class helper
|
// Update function name from getStatusClass to getStateClass
|
||||||
const getStatusClass = (state) => {
|
const getStateClass = (state) => {
|
||||||
if (!state) return 'status-unknown';
|
if (!state) return 'status-unknown';
|
||||||
switch(state.toLowerCase()) {
|
|
||||||
case 'start': return 'status-running';
|
const lowerState = state.toLowerCase();
|
||||||
case 'stop': return 'status-stopped';
|
|
||||||
case 'disable': return 'status-paused';
|
// Green for running VMs
|
||||||
default: return 'status-unknown';
|
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
|
// Watch for changes in showList
|
||||||
watch(() => props.showList, (isVisible) => {
|
watch(() => props.showList, (isVisible) => {
|
||||||
if (!isVisible) {
|
if (!isVisible) {
|
||||||
// When list is closed, show selected VM
|
// When list is closed, show selected VM
|
||||||
const effectiveVM = props.selectedVM || props.vmFromUrl;
|
const effectiveVM = props.selectedVM || props.vmFromUrl || localStorage.getItem('selectedVMId');
|
||||||
if (effectiveVM) {
|
if (effectiveVM) {
|
||||||
inputValue.value = effectiveVM;
|
inputValue.value = effectiveVM;
|
||||||
|
|
||||||
@ -513,7 +621,7 @@ watch(() => props.showList, (isVisible) => {
|
|||||||
// Watch for changes in selectedVM or vmFromUrl
|
// Watch for changes in selectedVM or vmFromUrl
|
||||||
watch([() => props.selectedVM, () => props.vmFromUrl], ([selectedVM, vmFromUrl]) => {
|
watch([() => props.selectedVM, () => props.vmFromUrl], ([selectedVM, vmFromUrl]) => {
|
||||||
if (!props.showList) {
|
if (!props.showList) {
|
||||||
const effectiveVM = selectedVM || vmFromUrl;
|
const effectiveVM = selectedVM || vmFromUrl || localStorage.getItem('selectedVMId');
|
||||||
if (effectiveVM) {
|
if (effectiveVM) {
|
||||||
inputValue.value = effectiveVM;
|
inputValue.value = effectiveVM;
|
||||||
}
|
}
|
||||||
@ -523,31 +631,56 @@ watch([() => props.selectedVM, () => props.vmFromUrl], ([selectedVM, vmFromUrl])
|
|||||||
// Add a function to scroll to the selected VM
|
// Add a function to scroll to the selected VM
|
||||||
const scrollToSelectedVM = () => {
|
const scrollToSelectedVM = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const selectedVMName = props.selectedVM || props.vmFromUrl;
|
// Find the first selected VM
|
||||||
|
const selectedVMName = props.selectedVM || props.vmFromUrl || localStorage.getItem('selectedVMId');
|
||||||
if (selectedVMName && vmListContainer.value) {
|
if (selectedVMName && vmListContainer.value) {
|
||||||
const activeElement = vmListContainer.value.querySelector(`[data-vm-name="${selectedVMName}"]`);
|
const activeElement = vmListContainer.value.querySelector(`[data-vm-name="${selectedVMName}"]`);
|
||||||
if (activeElement) {
|
if (activeElement) {
|
||||||
|
// Scroll the element into view
|
||||||
activeElement.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
activeElement.scrollIntoView({ block: 'center', behavior: 'smooth' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add localStorage persistence for filters
|
||||||
|
const saveFiltersToLocalStorage = () => {
|
||||||
|
localStorage.setItem('vmFilters', JSON.stringify(appliedFilters.value));
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadFiltersFromLocalStorage = () => {
|
||||||
|
const savedFilters = localStorage.getItem('vmFilters');
|
||||||
|
if (savedFilters) {
|
||||||
|
try {
|
||||||
|
const parsedFilters = JSON.parse(savedFilters);
|
||||||
|
// Merge saved filters with current filters to handle new states/nodes
|
||||||
|
appliedFilters.value = {
|
||||||
|
states: { ...appliedFilters.value.states, ...parsedFilters.states },
|
||||||
|
nodes: { ...appliedFilters.value.nodes, ...parsedFilters.nodes }
|
||||||
|
};
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Error parsing saved filters:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.controls-bar {
|
.vm-selector-bar {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
padding: 1rem;
|
padding-top: 0.25rem;
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
|
||||||
}
|
}
|
||||||
|
|
||||||
.controls-row {
|
.vm-selector-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
padding-bottom: 0.75rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-box {
|
.search-box {
|
||||||
@ -580,6 +713,12 @@ const scrollToSelectedVM = () => {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
|
transition: color 0.2s;
|
||||||
|
z-index: 5; /* Ensure it's above other elements */
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-clear:hover {
|
||||||
|
color: #dc3545; /* Red color on hover */
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-toggle-btn {
|
.list-toggle-btn {
|
||||||
@ -622,7 +761,8 @@ const scrollToSelectedVM = () => {
|
|||||||
background-color: white;
|
background-color: white;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-top: 0.5rem;
|
margin-top: -0.5rem;
|
||||||
|
padding-bottom: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vm-list {
|
.vm-list {
|
||||||
@ -631,6 +771,7 @@ const scrollToSelectedVM = () => {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: calc(100vh - 200px);
|
max-height: calc(100vh - 200px);
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
padding-bottom: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vm-list-item {
|
.vm-list-item {
|
||||||
@ -638,7 +779,6 @@ const scrollToSelectedVM = () => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.75rem 1rem;
|
padding: 0.75rem 1rem;
|
||||||
border: none !important;
|
border: none !important;
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
|
||||||
background-color: white;
|
background-color: white;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -648,6 +788,7 @@ const scrollToSelectedVM = () => {
|
|||||||
|
|
||||||
.vm-list-item:last-child {
|
.vm-list-item:last-child {
|
||||||
border-bottom: none !important;
|
border-bottom: none !important;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vm-list-item:hover {
|
.vm-list-item:hover {
|
||||||
@ -671,12 +812,12 @@ const scrollToSelectedVM = () => {
|
|||||||
z-index: 2 !important;
|
z-index: 2 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controls-bar .vm-list-container .vm-list .vm-list-item.active {
|
.vm-selector-bar .vm-list-container .vm-list .vm-list-item.active {
|
||||||
background-color: rgba(13, 110, 253, 0.15) !important;
|
background-color: rgba(13, 110, 253, 0.15) !important;
|
||||||
position: relative !important;
|
position: relative !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controls-bar .vm-list-container .vm-list .vm-list-item.active::before {
|
.vm-selector-bar .vm-list-container .vm-list .vm-list-item.active::before {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute !important;
|
position: absolute !important;
|
||||||
left: 0 !important;
|
left: 0 !important;
|
||||||
@ -688,45 +829,60 @@ const scrollToSelectedVM = () => {
|
|||||||
|
|
||||||
.vm-item-content {
|
.vm-item-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vm-name {
|
.vm-name {
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vm-status {
|
.vm-state {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
font-size: 0.875rem;
|
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;
|
font-size: 0.625rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Status colors */
|
/* Status colors - updated */
|
||||||
.status-running {
|
.status-running {
|
||||||
color: #28a745;
|
color: #28a745; /* Green */
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-stopped {
|
.status-stopped {
|
||||||
color: #6c757d;
|
color: #dc3545; /* Red */
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-paused {
|
.status-provisioning {
|
||||||
color: #ffc107;
|
color: #0d6efd; /* Blue */
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-error {
|
.status-mirror {
|
||||||
color: #dc3545;
|
color: #6f42c1; /* Purple */
|
||||||
}
|
}
|
||||||
|
|
||||||
.status-unknown {
|
.status-restarting {
|
||||||
color: #6c757d;
|
color: #ffc107; /* Yellow */
|
||||||
}
|
}
|
||||||
|
|
||||||
.no-vms-message {
|
.no-vms-message {
|
||||||
@ -741,7 +897,7 @@ const scrollToSelectedVM = () => {
|
|||||||
top: 100%;
|
top: 100%;
|
||||||
right: 0;
|
right: 0;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
min-width: 250px;
|
min-width: 350px;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
margin-top: 0.5rem;
|
margin-top: 0.5rem;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
@ -757,12 +913,11 @@ const scrollToSelectedVM = () => {
|
|||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: #495057;
|
color: #495057;
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
||||||
padding-bottom: 0.25rem;
|
padding-bottom: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-options-dropdown {
|
.filter-options-dropdown {
|
||||||
max-height: 150px;
|
max-height: 200px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
File diff suppressed because it is too large
Load Diff
156
pvc-vue/src/components/pages/nodes/NodeVMList.vue
Normal file
156
pvc-vue/src/components/pages/nodes/NodeVMList.vue
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
<template>
|
||||||
|
<div class="vms-container">
|
||||||
|
<div class="card-header">
|
||||||
|
<h6 class="card-title mb-0">
|
||||||
|
<span class="metric-label">Running VMs</span>
|
||||||
|
</h6>
|
||||||
|
</div>
|
||||||
|
<div v-if="!runningDomains || runningDomains.length === 0" class="no-vms">
|
||||||
|
No VMs running on this node
|
||||||
|
</div>
|
||||||
|
<div v-else class="vm-list" :style="{
|
||||||
|
'grid-template-columns': `repeat(auto-fill, minmax(150px, 1fr))`
|
||||||
|
}">
|
||||||
|
<div
|
||||||
|
v-for="vmName in runningDomains"
|
||||||
|
:key="vmName"
|
||||||
|
class="vm-item"
|
||||||
|
@click="selectVMAndNavigate(vmName)"
|
||||||
|
>
|
||||||
|
{{ vmName }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import { navigateToVM } from '../../../services/navigation';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
vmData: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
nodeData: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
nodeName: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
// Get the selected node data
|
||||||
|
const nodeData = computed(() => {
|
||||||
|
if (!props.nodeName || !props.nodeData || props.nodeData.length === 0) {
|
||||||
|
console.log('No node selected or no node data available');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const node = props.nodeData.find(node => node.name === props.nodeName);
|
||||||
|
console.log(`Node data for ${props.nodeName}:`, node);
|
||||||
|
return node;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Get running domains from the node data
|
||||||
|
const runningDomains = computed(() => {
|
||||||
|
if (!nodeData.value || !nodeData.value.running_domains) {
|
||||||
|
console.log('No running domains found for node:', props.nodeName);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Found ${nodeData.value.running_domains.length} running domains on node ${props.nodeName}:`, nodeData.value.running_domains);
|
||||||
|
return nodeData.value.running_domains;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Navigate to VM details using the navigation service
|
||||||
|
const selectVMAndNavigate = (vmName) => {
|
||||||
|
navigateToVM(vmName, router);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.vms-container {
|
||||||
|
min-width: 180px;
|
||||||
|
background: white;
|
||||||
|
border: 1px solid rgba(0,0,0,0.125);
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
background-color: rgba(0, 0, 0, 0.03);
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
|
||||||
|
height: 38px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header h6 {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-vms {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100px;
|
||||||
|
color: #6c757d;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vm-list {
|
||||||
|
display: grid;
|
||||||
|
gap: 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.5rem;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vm-item {
|
||||||
|
padding: 0.5rem;
|
||||||
|
background-color: rgba(0, 0, 0, 0.015);
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
cursor: pointer;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: 500;
|
||||||
|
color: #333;
|
||||||
|
transition: all 0.2s;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
position: relative;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vm-item:hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0.04);
|
||||||
|
border-color: rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vm-node {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
color: #6c757d;
|
||||||
|
margin-top: 0.25rem;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="overview-container">
|
<div class="content-container">
|
||||||
<!-- Information Cards Section -->
|
<!-- Information Cards Section -->
|
||||||
<CollapsibleSection title="Cluster Information" :initially-expanded="sections.info">
|
<CollapsibleSection title="Cluster Information" :initially-expanded="sections.info">
|
||||||
<div class="metrics-row">
|
<div class="metrics-row">
|
||||||
@ -870,11 +870,12 @@ const isMaintenanceMode = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.overview-container {
|
.content-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
padding-top: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.metrics-row {
|
.metrics-row {
|
||||||
|
@ -1,117 +1,116 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="overview-container">
|
<VMSearchBar
|
||||||
<VMSearchBar
|
:key="`vm-search-${selectedVM}`"
|
||||||
:key="`vm-search-${selectedVM}`"
|
v-model="searchQuery"
|
||||||
v-model="searchQuery"
|
:selected-vm="selectedVM"
|
||||||
:selected-vm="selectedVM"
|
:vm-from-url="route.query.vm"
|
||||||
:vm-from-url="route.query.vm"
|
:show-list="showVMList"
|
||||||
:show-list="showVMList"
|
:show-clear-button="true"
|
||||||
:show-clear-button="true"
|
:vm-list="props.vmData"
|
||||||
:vm-list="props.vmData"
|
@search="handleSearch"
|
||||||
@search="handleSearch"
|
@focus="handleSearchFocus"
|
||||||
@focus="handleSearchFocus"
|
@blur="handleSearchBlur"
|
||||||
@blur="handleSearchBlur"
|
@clear="clearSearch"
|
||||||
@clear="clearSearch"
|
@toggle-list="toggleVMList"
|
||||||
@toggle-list="toggleVMList"
|
@select-vm="selectVM"
|
||||||
@select-vm="selectVM"
|
@clear-vm="clearSelectedVM"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- VM Details -->
|
<!-- VM Details -->
|
||||||
<div v-if="selectedVMData && !showVMList" class="content-container">
|
<div v-if="selectedVMData && !showVMList" class="content-container">
|
||||||
<CollapsibleSection title="VM Information" :initially-expanded="sections.info">
|
<CollapsibleSection title="VM Information" :initially-expanded="sections.info">
|
||||||
<div class="info-grid">
|
<div class="info-grid-general">
|
||||||
<ValueCard
|
<ValueCard
|
||||||
title="State"
|
title="State"
|
||||||
:value="selectedVMData.state || 'Unknown'"
|
:value="selectedVMData.state || 'Unknown'"
|
||||||
:status="getStateColor(selectedVMData.state)"
|
:status="getStateColor(selectedVMData.state)"
|
||||||
/>
|
/>
|
||||||
<ValueCard
|
<ValueCard
|
||||||
title="Node"
|
title="Node"
|
||||||
:value="selectedVMData.node || 'N/A'"
|
:value="selectedVMData.node || 'N/A'"
|
||||||
/>
|
/>
|
||||||
<ValueCard
|
<ValueCard
|
||||||
title="CPUs"
|
title="CPUs"
|
||||||
:value="selectedVMData.vcpus || 0"
|
:value="selectedVMData.vcpus || 0"
|
||||||
/>
|
/>
|
||||||
<ValueCard
|
<ValueCard
|
||||||
title="Memory"
|
title="Memory"
|
||||||
:value="formatMemory(selectedVMData.memory)"
|
:value="formatMemory(selectedVMData.memory)"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
</CollapsibleSection>
|
|
||||||
|
|
||||||
<!-- Resources Section -->
|
|
||||||
<CollapsibleSection title="Resources" :initially-expanded="sections.resources">
|
|
||||||
<div class="info-grid-2">
|
|
||||||
<ValueCard
|
|
||||||
title="Disk Size"
|
|
||||||
:value="formatStorage(selectedVMData.disk_size)"
|
|
||||||
/>
|
|
||||||
<ValueCard
|
|
||||||
title="Network IPs"
|
|
||||||
:value="selectedVMData.ips?.join(', ') || 'None'"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</CollapsibleSection>
|
|
||||||
|
|
||||||
<!-- Networks Section -->
|
|
||||||
<CollapsibleSection
|
|
||||||
v-if="selectedVMData.networks?.length"
|
|
||||||
title="Network Interfaces"
|
|
||||||
:initially-expanded="sections.networks"
|
|
||||||
>
|
|
||||||
<div class="cards-stack">
|
|
||||||
<div v-for="network in selectedVMData.networks"
|
|
||||||
:key="network.vni"
|
|
||||||
class="detail-card"
|
|
||||||
>
|
|
||||||
<ValueCard title="Interface" :value="network.vni" />
|
|
||||||
<ValueCard title="Type" :value="network.type" />
|
|
||||||
<ValueCard title="MAC" :value="network.mac" />
|
|
||||||
<ValueCard title="Source" :value="network.source" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CollapsibleSection>
|
|
||||||
|
|
||||||
<!-- Storage Section -->
|
|
||||||
<CollapsibleSection
|
|
||||||
v-if="selectedVMData.disks?.length"
|
|
||||||
title="Storage"
|
|
||||||
:initially-expanded="sections.storage"
|
|
||||||
>
|
|
||||||
<div class="cards-stack">
|
|
||||||
<div v-for="disk in selectedVMData.disks"
|
|
||||||
:key="disk.dev"
|
|
||||||
class="detail-card"
|
|
||||||
>
|
|
||||||
<ValueCard title="Device" :value="disk.dev" />
|
|
||||||
<ValueCard title="Type" :value="disk.type" />
|
|
||||||
<ValueCard title="Bus" :value="disk.bus" />
|
|
||||||
<ValueCard title="Source" :value="disk.name" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</CollapsibleSection>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Loading and no-selection states -->
|
|
||||||
<div v-if="!selectedVMData && !showVMList" class="content-container">
|
|
||||||
<div v-if="isLoading" class="loading-container">
|
|
||||||
<div class="spinner-border text-primary" role="status">
|
|
||||||
<span class="visually-hidden">Loading...</span>
|
|
||||||
</div>
|
|
||||||
<p class="mt-2 text-muted">Loading VM details...</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="no-content-message">
|
</CollapsibleSection>
|
||||||
<div class="alert alert-info">
|
|
||||||
<i class="fas fa-info-circle me-2"></i>
|
<!-- Resources Section -->
|
||||||
<span v-if="invalidVMSelected">
|
<CollapsibleSection title="Resources" :initially-expanded="sections.resources">
|
||||||
Selected VM does not exist
|
<div class="info-grid-resources">
|
||||||
</span>
|
<ValueCard
|
||||||
<span v-else>
|
title="Disk Size"
|
||||||
Please select a VM from the list to view its details
|
:value="formatStorage(selectedVMData.disk_size)"
|
||||||
</span>
|
/>
|
||||||
|
<ValueCard
|
||||||
|
title="Network IPs"
|
||||||
|
:value="selectedVMData.ips?.join(', ') || 'None'"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CollapsibleSection>
|
||||||
|
|
||||||
|
<!-- Networks Section -->
|
||||||
|
<CollapsibleSection
|
||||||
|
v-if="selectedVMData.networks?.length"
|
||||||
|
title="Network Interfaces"
|
||||||
|
:initially-expanded="sections.networks"
|
||||||
|
>
|
||||||
|
<div class="cards-stack">
|
||||||
|
<div v-for="network in selectedVMData.networks"
|
||||||
|
:key="network.vni"
|
||||||
|
class="detail-card"
|
||||||
|
>
|
||||||
|
<ValueCard title="Interface" :value="network.vni" />
|
||||||
|
<ValueCard title="Type" :value="network.type" />
|
||||||
|
<ValueCard title="MAC" :value="network.mac" />
|
||||||
|
<ValueCard title="Source" :value="network.source" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</CollapsibleSection>
|
||||||
|
|
||||||
|
<!-- Storage Section -->
|
||||||
|
<CollapsibleSection
|
||||||
|
v-if="selectedVMData.disks?.length"
|
||||||
|
title="Storage"
|
||||||
|
:initially-expanded="sections.storage"
|
||||||
|
>
|
||||||
|
<div class="cards-stack">
|
||||||
|
<div v-for="disk in selectedVMData.disks"
|
||||||
|
:key="disk.dev"
|
||||||
|
class="detail-card"
|
||||||
|
>
|
||||||
|
<ValueCard title="Device" :value="disk.dev" />
|
||||||
|
<ValueCard title="Type" :value="disk.type" />
|
||||||
|
<ValueCard title="Bus" :value="disk.bus" />
|
||||||
|
<ValueCard title="Source" :value="disk.name" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CollapsibleSection>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Loading and no-selection states -->
|
||||||
|
<div v-if="!selectedVMData && !showVMList" class="content-container">
|
||||||
|
<div v-if="isLoading" class="loading-container">
|
||||||
|
<div class="spinner-border text-primary" role="status">
|
||||||
|
<span class="visually-hidden">Loading...</span>
|
||||||
|
</div>
|
||||||
|
<p class="mt-2 text-muted">Loading VM details...</p>
|
||||||
|
</div>
|
||||||
|
<div v-else class="no-content-message">
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<i class="fas fa-info-circle me-2"></i>
|
||||||
|
<span v-if="invalidVMSelected">
|
||||||
|
Selected VM does not exist
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
Please select a VM from the list to view its details
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -149,7 +148,7 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Use ref and sync with route
|
// Use ref and sync with route
|
||||||
const selectedVM = ref(route.query.vm || '');
|
const selectedVM = ref('');
|
||||||
const searchQuery = ref('');
|
const searchQuery = ref('');
|
||||||
const showVMList = ref(true);
|
const showVMList = ref(true);
|
||||||
const searchActive = ref(false);
|
const searchActive = ref(false);
|
||||||
@ -173,9 +172,15 @@ const selectedVMData = computed(() => {
|
|||||||
const handleSearch = (value) => {
|
const handleSearch = (value) => {
|
||||||
searchQuery.value = value;
|
searchQuery.value = value;
|
||||||
searchActive.value = true;
|
searchActive.value = true;
|
||||||
|
|
||||||
// Store the search query in localStorage for persistence
|
// Store the search query in localStorage for persistence
|
||||||
if (value) {
|
if (value) {
|
||||||
localStorage.setItem('vmSearchQuery', value);
|
localStorage.setItem('vmSearchQuery', value);
|
||||||
|
// Also save to vmSearchText for consistency
|
||||||
|
localStorage.setItem('vmSearchText', value);
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('vmSearchQuery');
|
||||||
|
// Don't remove vmSearchText here - it's used for search history
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -196,9 +201,17 @@ const handleSearchBlur = (event) => {
|
|||||||
// Toggle VM list visibility
|
// Toggle VM list visibility
|
||||||
const toggleVMList = () => {
|
const toggleVMList = () => {
|
||||||
showVMList.value = !showVMList.value;
|
showVMList.value = !showVMList.value;
|
||||||
|
|
||||||
if (showVMList.value) {
|
if (showVMList.value) {
|
||||||
|
// When opening the list
|
||||||
searchActive.value = false;
|
searchActive.value = false;
|
||||||
invalidVMSelected.value = false;
|
invalidVMSelected.value = false;
|
||||||
|
|
||||||
|
// Restore search text if available
|
||||||
|
const savedSearchText = localStorage.getItem('vmSearchText');
|
||||||
|
if (savedSearchText && !searchQuery.value) {
|
||||||
|
searchQuery.value = savedSearchText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -213,8 +226,10 @@ const selectVM = (vm) => {
|
|||||||
// Close the VM list
|
// Close the VM list
|
||||||
showVMList.value = false;
|
showVMList.value = false;
|
||||||
|
|
||||||
// Update the URL
|
// Save to localStorage
|
||||||
router.push({ query: { vm: vm.name } });
|
localStorage.setItem('selectedVMId', vm.name);
|
||||||
|
|
||||||
|
// No URL parameter update
|
||||||
};
|
};
|
||||||
|
|
||||||
// Clear search
|
// Clear search
|
||||||
@ -224,75 +239,124 @@ const clearSearch = () => {
|
|||||||
localStorage.removeItem('vmSearchQuery');
|
localStorage.removeItem('vmSearchQuery');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add a method to clear the selected VM
|
||||||
|
const clearSelectedVM = () => {
|
||||||
|
// Clear the selected VM
|
||||||
|
selectedVM.value = '';
|
||||||
|
invalidVMSelected.value = false;
|
||||||
|
|
||||||
|
// Clear the search query in this component
|
||||||
|
searchQuery.value = '';
|
||||||
|
|
||||||
|
// Show the VM list
|
||||||
|
showVMList.value = true;
|
||||||
|
|
||||||
|
// Clear VM selection from localStorage
|
||||||
|
localStorage.removeItem('selectedVMId');
|
||||||
|
|
||||||
|
// Don't clear vmSearchText unless it matches the VM name
|
||||||
|
const savedVMId = localStorage.getItem('selectedVMId');
|
||||||
|
const savedSearchText = localStorage.getItem('vmSearchText');
|
||||||
|
if (savedSearchText === savedVMId) {
|
||||||
|
localStorage.removeItem('vmSearchText');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear URL parameter if it exists
|
||||||
|
if (route.query.vm) {
|
||||||
|
router.replace({ path: '/vms' }, { replace: true });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Lifecycle hooks
|
// Lifecycle hooks
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log('VMOverview mounted, route.query.vm:', route.query.vm);
|
console.log('VMOverview mounted');
|
||||||
|
isLoading.value = true;
|
||||||
|
|
||||||
|
// Check sources in priority order:
|
||||||
|
// 1. localStorage (for returning to the page or navigating from other pages)
|
||||||
|
// 2. URL query parameter (for backward compatibility)
|
||||||
|
const savedVMId = localStorage.getItem('selectedVMId');
|
||||||
const vmFromQuery = route.query.vm;
|
const vmFromQuery = route.query.vm;
|
||||||
|
|
||||||
// Restore previous search query from localStorage if available
|
// Restore previous search query from localStorage
|
||||||
const savedSearch = localStorage.getItem('vmSearchQuery');
|
const savedSearch = localStorage.getItem('vmSearchQuery');
|
||||||
if (savedSearch) {
|
const savedSearchText = localStorage.getItem('vmSearchText');
|
||||||
searchQuery.value = savedSearch;
|
|
||||||
|
// If we have a VM to select
|
||||||
|
let vmToSelect = savedVMId || vmFromQuery;
|
||||||
|
|
||||||
|
if (vmToSelect && props.vmData.length > 0) {
|
||||||
|
// Check if the VM exists
|
||||||
|
const vmExists = props.vmData.some(v => v.name === vmToSelect);
|
||||||
|
|
||||||
|
if (vmExists) {
|
||||||
|
selectedVM.value = vmToSelect;
|
||||||
|
showVMList.value = false;
|
||||||
|
|
||||||
|
// Set the search query to the VM name for display in the search bar
|
||||||
|
searchQuery.value = vmToSelect;
|
||||||
|
|
||||||
|
// If from URL, save to localStorage for persistence
|
||||||
|
if (vmFromQuery && !savedVMId) {
|
||||||
|
localStorage.setItem('selectedVMId', vmFromQuery);
|
||||||
|
|
||||||
|
// Remove the VM ID from the URL without reloading the page
|
||||||
|
router.replace({ path: '/vms' }, { replace: true });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('Selected VM does not exist:', vmToSelect);
|
||||||
|
invalidVMSelected.value = true;
|
||||||
|
localStorage.removeItem('selectedVMId');
|
||||||
|
|
||||||
|
// Only clear search text if it matches the VM name
|
||||||
|
if (savedSearchText === vmToSelect) {
|
||||||
|
localStorage.removeItem('vmSearchText');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the VM list with any saved search
|
||||||
|
showVMList.value = true;
|
||||||
|
if (savedSearch) {
|
||||||
|
searchQuery.value = savedSearch;
|
||||||
|
} else if (savedSearchText) {
|
||||||
|
searchQuery.value = savedSearchText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No VM selected, show the list with any saved search
|
||||||
|
showVMList.value = true;
|
||||||
|
if (savedSearch) {
|
||||||
|
searchQuery.value = savedSearch;
|
||||||
|
} else if (savedSearchText) {
|
||||||
|
searchQuery.value = savedSearchText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vmFromQuery) {
|
isLoading.value = false;
|
||||||
console.log('Setting selectedVM to:', vmFromQuery);
|
});
|
||||||
selectedVM.value = vmFromQuery;
|
|
||||||
isLoading.value = true;
|
// Watch for changes in the selected VM
|
||||||
showVMList.value = false;
|
watch(selectedVM, (newValue) => {
|
||||||
|
if (newValue) {
|
||||||
// If we have data, verify the VM exists
|
// Save to localStorage whenever it changes
|
||||||
if (props.vmData.length) {
|
localStorage.setItem('selectedVMId', newValue);
|
||||||
const vmExists = props.vmData.some(v => v.name === vmFromQuery);
|
} else {
|
||||||
invalidVMSelected.value = !vmExists;
|
localStorage.removeItem('selectedVMId');
|
||||||
}
|
|
||||||
isLoading.value = false;
|
|
||||||
} else if (props.vmData.length > 0) {
|
|
||||||
showVMList.value = true;
|
|
||||||
invalidVMSelected.value = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
// Watch for changes in the VM data
|
||||||
// Remove event listeners and clean up resources
|
|
||||||
});
|
|
||||||
|
|
||||||
// Watch for route changes to update selectedVM
|
|
||||||
watch(() => route.query.vm, (newVm) => {
|
|
||||||
// Explicitly update the ref when route changes
|
|
||||||
selectedVM.value = newVm || '';
|
|
||||||
if (newVm) {
|
|
||||||
// Just update UI state, don't trigger another route change
|
|
||||||
invalidVMSelected.value = false;
|
|
||||||
showVMList.value = false;
|
|
||||||
} else if (props.vmData.length > 0) {
|
|
||||||
showVMList.value = true;
|
|
||||||
invalidVMSelected.value = false;
|
|
||||||
}
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
// Watch for changes in the VM list visibility
|
|
||||||
watch(() => showVMList.value, (isVisible) => {
|
|
||||||
if (isVisible && selectedVM.value) {
|
|
||||||
// Scroll to selected VM when the list becomes visible
|
|
||||||
nextTick(() => {
|
|
||||||
// Scroll to selected VM logic
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add watcher for vmData to handle loading state
|
|
||||||
watch(() => props.vmData, (newData) => {
|
watch(() => props.vmData, (newData) => {
|
||||||
if (selectedVM.value && newData.length) {
|
if (selectedVM.value && newData.length > 0) {
|
||||||
|
// Verify the VM still exists
|
||||||
const vmExists = newData.some(vm => vm.name === selectedVM.value);
|
const vmExists = newData.some(vm => vm.name === selectedVM.value);
|
||||||
invalidVMSelected.value = !vmExists;
|
invalidVMSelected.value = !vmExists;
|
||||||
|
|
||||||
|
if (!vmExists) {
|
||||||
|
// If VM no longer exists, clear localStorage
|
||||||
|
localStorage.removeItem('selectedVMId');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, { immediate: true });
|
}, { deep: true });
|
||||||
|
|
||||||
// Add debug watcher
|
|
||||||
watch(() => selectedVM.value, (newVal) => {
|
|
||||||
console.log('VMOverview selectedVM changed:', newVal);
|
|
||||||
}, { immediate: true });
|
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
const getStateColor = (state) => {
|
const getStateColor = (state) => {
|
||||||
@ -318,17 +382,12 @@ const formatStorage = (sizeGB) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.overview-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-container {
|
.content-container {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
width: 100%;
|
||||||
|
padding-top: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-container {
|
.loading-container {
|
||||||
@ -344,37 +403,33 @@ const formatStorage = (sizeGB) => {
|
|||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Keep only the styles needed for VM details display */
|
.info-grid-general {
|
||||||
.info-grid {
|
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 1rem;
|
gap: 0.5rem;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-grid-2 {
|
.info-grid-resources {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 1rem;
|
gap: 0.5rem;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
.cards-stack {
|
.cards-stack {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 1rem;
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-card {
|
.detail-card {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||||
gap: 1rem;
|
gap: 0.5rem;
|
||||||
padding: 1rem;
|
|
||||||
background-color: rgba(0, 0, 0, 0.02);
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.info-grid,
|
.info-grid-general,
|
||||||
.info-grid-2 {
|
.info-grid-resources {
|
||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
pvc-vue/src/services/navigation.js
Normal file
39
pvc-vue/src/services/navigation.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Navigate to a VM without using URL parameters
|
||||||
|
* @param {string} vmId - The ID of the VM to navigate to
|
||||||
|
* @param {import('vue-router').Router} router - Vue Router instance
|
||||||
|
*/
|
||||||
|
export function navigateToVM(vmId, router) {
|
||||||
|
// Save the VM ID to localStorage
|
||||||
|
localStorage.setItem('selectedVMId', vmId);
|
||||||
|
|
||||||
|
// Navigate to the VMs page
|
||||||
|
router.push('/vms');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Navigate to a node without using URL parameters
|
||||||
|
* @param {string} nodeId - The ID of the node to navigate to
|
||||||
|
* @param {import('vue-router').Router} router - Vue Router instance
|
||||||
|
*/
|
||||||
|
export function navigateToNode(nodeId, router) {
|
||||||
|
// Save the node ID to localStorage
|
||||||
|
localStorage.setItem('selectedNodeId', nodeId);
|
||||||
|
|
||||||
|
// Navigate to the Nodes page
|
||||||
|
router.push('/nodes');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the selected VM and return to the default VM page view
|
||||||
|
* @param {import('vue-router').Router} router - Vue Router instance
|
||||||
|
*/
|
||||||
|
export function clearSelectedVM(router) {
|
||||||
|
// Clear from localStorage
|
||||||
|
localStorage.removeItem('selectedVMId');
|
||||||
|
|
||||||
|
// Navigate to the VMs page without query parameters
|
||||||
|
router.push('/vms');
|
||||||
|
}
|
32
pvc-vue/src/utils/vmSelection.js
Normal file
32
pvc-vue/src/utils/vmSelection.js
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* Selects a VM and saves the selection to localStorage
|
||||||
|
* @param {string} vmId - The ID of the VM to select
|
||||||
|
* @param {import('vue-router').Router} router - Vue Router instance (optional)
|
||||||
|
*/
|
||||||
|
export function selectVM(vmId, router = null) {
|
||||||
|
// Save to localStorage
|
||||||
|
localStorage.setItem('selectedVMId', vmId);
|
||||||
|
|
||||||
|
// Optionally update URL if router is provided
|
||||||
|
if (router) {
|
||||||
|
router.push({
|
||||||
|
path: '/vms',
|
||||||
|
query: { vm: vmId }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the currently selected VM from localStorage
|
||||||
|
* @returns {string|null} The selected VM ID or null if none is selected
|
||||||
|
*/
|
||||||
|
export function getSelectedVM() {
|
||||||
|
return localStorage.getItem('selectedVMId');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the selected VM from localStorage
|
||||||
|
*/
|
||||||
|
export function clearSelectedVM() {
|
||||||
|
localStorage.removeItem('selectedVMId');
|
||||||
|
}
|
@ -10,10 +10,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref, onMounted, watch } from 'vue';
|
||||||
import PageTitle from '../components/general/PageTitle.vue';
|
import PageTitle from '../components/general/PageTitle.vue';
|
||||||
import NodeOverview from '../components/pages/nodes/NodeOverview.vue';
|
import NodeOverview from '../components/pages/nodes/NodeOverview.vue';
|
||||||
|
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
nodeData: {
|
nodeData: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
@ -30,6 +31,25 @@ defineProps({
|
|||||||
default: () => ({})
|
default: () => ({})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const selectedNode = ref(null);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// Restore selected node from localStorage if available
|
||||||
|
const savedNodeId = localStorage.getItem('selectedNodeId');
|
||||||
|
if (savedNodeId) {
|
||||||
|
selectedNode.value = savedNodeId;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(selectedNode, (newValue) => {
|
||||||
|
// Save selected node to localStorage whenever it changes
|
||||||
|
if (newValue) {
|
||||||
|
localStorage.setItem('selectedNodeId', newValue);
|
||||||
|
} else {
|
||||||
|
localStorage.removeItem('selectedNodeId');
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@ -39,9 +59,4 @@ defineProps({
|
|||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove top margin from first child (usually PageTitle) */
|
|
||||||
.content-grid > :first-child {
|
|
||||||
margin-top: 0 !important;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
@ -11,10 +11,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref, onMounted, watch } from 'vue';
|
||||||
|
import { useRouter, useRoute } from 'vue-router';
|
||||||
import PageTitle from '../components/general/PageTitle.vue';
|
import PageTitle from '../components/general/PageTitle.vue';
|
||||||
import VMOverview from '../components/pages/vms/VMOverview.vue';
|
import VMOverview from '../components/pages/vms/VMOverview.vue';
|
||||||
|
|
||||||
// Define props to receive data from App.vue
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
vmData: {
|
vmData: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@ -36,6 +40,9 @@ const props = defineProps({
|
|||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// We'll handle the VM selection in the VMOverview component
|
||||||
|
// This parent component just needs to pass the data
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@ -45,9 +52,4 @@ const props = defineProps({
|
|||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove top margin from first child (usually PageTitle) */
|
|
||||||
.content-grid > :first-child {
|
|
||||||
margin-top: 0 !important;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
Reference in New Issue
Block a user