From c64d47710bd53d269ba7bba7b114bf0aa6a8eee6 Mon Sep 17 00:00:00 2001 From: Mengling Ding Date: Fri, 20 Dec 2024 15:04:45 -0600 Subject: [PATCH] fix: fix the problem with status and memoryChart not updating correctly --- webui/src/components/Appliance/Appliances.vue | 25 ++++++++++++++++--- webui/src/components/CXL-Hosts/CXL-Hosts.vue | 17 +++++++++++++ webui/src/components/Stores/BladeStore.ts | 6 +++++ webui/src/components/Stores/HostStore.ts | 7 ++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/webui/src/components/Appliance/Appliances.vue b/webui/src/components/Appliance/Appliances.vue index a000e98..1117ac2 100644 --- a/webui/src/components/Appliance/Appliances.vue +++ b/webui/src/components/Appliance/Appliances.vue @@ -1978,6 +1978,27 @@ export default { async (newBladeId, oldBladeId) => { if (newBladeId !== null && newBladeId !== oldBladeId) { loading.value = true; + + await bladeStore.fetchBladeById( + applianceStore.selectedApplianceId, + newBladeId + ); + + const selectedBlade = bladeStore.blades.find( + (blade) => blade.id === newBladeId + ); + + if (selectedBlade) { + bladeStore.selectBlade( + selectedBlade.id, + selectedBlade.ipAddress, + selectedBlade.port, + Number(selectedBlade.totalMemoryAvailableMiB), + Number(selectedBlade.totalMemoryAllocatedMiB), + selectedBlade.status + ); + } + // Fetch resources and ports for the newly selected blade await Promise.all([ bladeResourceStore.fetchMemoryResources( @@ -1992,10 +2013,6 @@ export default { applianceStore.selectedApplianceId, newBladeId ), - bladeStore.fetchBladeById( - applianceStore.selectedApplianceId, - newBladeId - ), ]); // Update the URL with the new blade ID updateUrlWithBladeId(applianceStore.selectedApplianceId, newBladeId); diff --git a/webui/src/components/CXL-Hosts/CXL-Hosts.vue b/webui/src/components/CXL-Hosts/CXL-Hosts.vue index de78580..8162d07 100644 --- a/webui/src/components/CXL-Hosts/CXL-Hosts.vue +++ b/webui/src/components/CXL-Hosts/CXL-Hosts.vue @@ -1127,6 +1127,23 @@ export default { async (newHostId, oldHostId) => { if (newHostId !== null && newHostId !== oldHostId) { loading.value = true; + + await hostStore.fetchHostById(newHostId); + + const selectedHost = hostStore.hosts.find( + (host) => host.id === newHostId + ); + + if (selectedHost) { + hostStore.selectHost( + selectedHost.id, + selectedHost.ipAddress, + selectedHost.port, + selectedHost.localMemoryMiB, + selectedHost.status + ); + } + // Fetch resources and ports for the newly selected host await Promise.all([ hostPortStore.hostPortStore(newHostId), diff --git a/webui/src/components/Stores/BladeStore.ts b/webui/src/components/Stores/BladeStore.ts index 92e93c0..5ff77e4 100644 --- a/webui/src/components/Stores/BladeStore.ts +++ b/webui/src/components/Stores/BladeStore.ts @@ -65,6 +65,12 @@ export const useBladeStore = defineStore('blade', { this.updateSelectedBladeStatus(blade.status) + // Update blades in case this blade changes + if (blade) { + this.blades = this.blades.map((b) => + b.id === bladeId ? detailsResponseOfBlade.data : b + ); + } return blade; } catch (error) { console.error("Error fetching blade by id:", error); diff --git a/webui/src/components/Stores/HostStore.ts b/webui/src/components/Stores/HostStore.ts index 3f96b9f..94ddc11 100644 --- a/webui/src/components/Stores/HostStore.ts +++ b/webui/src/components/Stores/HostStore.ts @@ -95,6 +95,13 @@ export const useHostStore = defineStore("host", { const host = detailsResponseOfHost.data; this.updateSelectHostStatus(host.status); + // Update hosts in case this host changes + if (host) { + this.hosts = this.hosts.map((h) => + h.id === hostId ? detailsResponseOfHost.data : h + ); + } + return host; } catch (error) { console.error("Error fetching host by id:", error);