Skip to content

Commit

Permalink
fix: fix the problem with status and memoryChart not updating correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Meng-20 committed Dec 20, 2024
1 parent 8fceb5e commit c64d477
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
25 changes: 21 additions & 4 deletions webui/src/components/Appliance/Appliances.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions webui/src/components/CXL-Hosts/CXL-Hosts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 6 additions & 0 deletions webui/src/components/Stores/BladeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions webui/src/components/Stores/HostStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c64d477

Please sign in to comment.