From ac9428a41b2b496fcc8ec56e33ae3aa1a1d1752b Mon Sep 17 00:00:00 2001 From: Joshua Boniface Date: Sun, 2 Mar 2025 01:11:42 -0500 Subject: [PATCH] Refactor collapsable section into reusable component --- pvc-vue/src/components/ClusterOverview.vue | 388 +++++++---------- pvc-vue/src/components/CollapsibleSection.vue | 140 ++++++ pvc-vue/src/components/NodeOverview.vue | 411 +++++++----------- pvc-vue/src/components/VMOverview.vue | 43 +- 4 files changed, 463 insertions(+), 519 deletions(-) create mode 100644 pvc-vue/src/components/CollapsibleSection.vue diff --git a/pvc-vue/src/components/ClusterOverview.vue b/pvc-vue/src/components/ClusterOverview.vue index 5929ff9..3381be1 100644 --- a/pvc-vue/src/components/ClusterOverview.vue +++ b/pvc-vue/src/components/ClusterOverview.vue @@ -1,269 +1,181 @@ @@ -287,6 +199,7 @@ import MemoryChart from './charts/MemoryChart.vue'; import StorageChart from './charts/StorageChart.vue'; import HealthChart from './charts/HealthChart.vue'; import ValueCard from './ValueCard.vue'; +import CollapsibleSection from './CollapsibleSection.vue'; // Register Chart.js components ChartJS.register( @@ -912,11 +825,6 @@ const sections = ref({ states: true }); -// Toggle section visibility -const toggleSection = (section) => { - sections.value[section] = !sections.value[section]; -}; - // Add a new function to determine if we should show the health delta const showHealthDelta = (msg) => { // Don't show delta for "No issues detected" or similar messages diff --git a/pvc-vue/src/components/CollapsibleSection.vue b/pvc-vue/src/components/CollapsibleSection.vue new file mode 100644 index 0000000..95f4411 --- /dev/null +++ b/pvc-vue/src/components/CollapsibleSection.vue @@ -0,0 +1,140 @@ + + + + + \ No newline at end of file diff --git a/pvc-vue/src/components/NodeOverview.vue b/pvc-vue/src/components/NodeOverview.vue index a9ae24b..fc1a34d 100644 --- a/pvc-vue/src/components/NodeOverview.vue +++ b/pvc-vue/src/components/NodeOverview.vue @@ -25,286 +25,171 @@
-
- -
-
-
-
Node Information
-
-
-
- -
+ +
+ + + + + + + + + + + + + + + + +
- -
-
-
- - - - - - - - - - - - - - - - - -
-
-
- -
-
-
+ -
- -
-
-
-
Health & Utilization Graphs
-
-
-
- -
+ +
+ + + + + + + + + + +
- -
-
-
- - - - - - - - - - - -
-
-
- -
-
-
+ -
- -
-
-
-
CPU Resources
-
-
-
- -
-
- -
-
-
- - + +
+ + - - + + - - -
-
-
- -
+ +
-
+ -
- -
-
-
-
Memory Resources
-
-
-
- -
+ +
+ + + + + + + + + + + + + +
- -
-
-
- - - - - - - - - - - - - - -
-
-
- -
-
-
+ -
- -
-
-
-
Running VMs
+ +
+
+
+
+ Running VMs +
-
-
- -
-
- -
-
-
-
-
-
- Running VMs -
-
-
-
-

No VMs running on this node

-
-
-
- {{ vm }} -
-
+
+
+

No VMs running on this node

+
+
+
+ {{ vm }}
-
- -
-
+
@@ -322,6 +207,7 @@ import MemoryChart from './charts/MemoryChart.vue'; import StorageChart from './charts/StorageChart.vue'; import HealthChart from './charts/HealthChart.vue'; import ValueCard from './ValueCard.vue'; +import CollapsibleSection from './CollapsibleSection.vue'; // Move all the props, refs, computed properties, and functions from Nodes.vue const props = defineProps({ @@ -351,11 +237,6 @@ const sections = ref({ vms: true }); -// Toggle section visibility -const toggleSection = (section) => { - sections.value[section] = !sections.value[section]; -}; - // State for selected node and tab scrolling const selectedNode = ref(''); const tabsContainer = ref(null); diff --git a/pvc-vue/src/components/VMOverview.vue b/pvc-vue/src/components/VMOverview.vue index 750f027..8882494 100644 --- a/pvc-vue/src/components/VMOverview.vue +++ b/pvc-vue/src/components/VMOverview.vue @@ -110,7 +110,33 @@
- + + +
+ +
+
+ + + +
+ +
+
+ + + +
+ +
+
+ + + +
+ +
+
@@ -126,6 +152,7 @@ import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'; import { useRouter, useRoute } from 'vue-router'; import VMDetail from './VMDetail.vue'; +import CollapsibleSection from './CollapsibleSection.vue'; const router = useRouter(); const route = useRoute(); @@ -160,7 +187,7 @@ const appliedFilters = ref({ }); const selectedVMRef = ref(null); -// Section visibility state +// Section visibility state - simplified since expansion is handled by CollapsibleSection const sections = ref({ info: true, graphs: true, @@ -191,18 +218,6 @@ const toggleFilterMenu = () => { showFilterMenu.value = !showFilterMenu.value; }; -// Toggle section visibility -const toggleSection = (section) => { - sections.value[section] = !sections.value[section]; -}; - -// Clear search -const clearSearch = () => { - searchQuery.value = ''; - searchActive.value = false; - filterVMs(); -}; - // Toggle a filter on/off const toggleFilter = (type, value) => { appliedFilters.value[type][value] = !appliedFilters.value[type][value];