diff --git a/api/cfm-openapi.yaml b/api/cfm-openapi.yaml index 2265266..a3e2c51 100644 --- a/api/cfm-openapi.yaml +++ b/api/cfm-openapi.yaml @@ -527,10 +527,8 @@ paths: description: OK content: application/json: - schema: - type: array - items: - $ref: '#/components/schemas/bladesResourceStatus' + schema: + $ref: '#/components/schemas/bladesMemoryResourceStatusCollection' "404": description: Not Found content: diff --git a/webui/src/components/Appliance/ComposeMemoryButton.vue b/webui/src/components/Appliance/ComposeMemoryButton.vue index aee07d5..2265976 100644 --- a/webui/src/components/Appliance/ComposeMemoryButton.vue +++ b/webui/src/components/Appliance/ComposeMemoryButton.vue @@ -363,7 +363,7 @@ export default { const bladeResourceStore = useBladeResourceStore(); const bladePortStore = useBladePortStore(); - await bladeResourceStore.fetchMemoryResources( + await bladeResourceStore.updateMemoryResourcesStatus( this.associatedApplianceId, this.bladeId ); diff --git a/webui/src/components/Appliance/Memory.vue b/webui/src/components/Appliance/Memory.vue index bff8bc8..835c6a9 100644 --- a/webui/src/components/Appliance/Memory.vue +++ b/webui/src/components/Appliance/Memory.vue @@ -434,7 +434,7 @@ export default { this.selectedMemoryRegion.memoryApplianceId, this.selectedMemoryRegion.memoryBladeId ); - await bladeResourceStore.fetchMemoryResources( + await bladeResourceStore.updateMemoryResourcesStatus( this.selectedMemoryRegion.memoryApplianceId, this.selectedMemoryRegion.memoryBladeId ); @@ -477,7 +477,7 @@ export default { const bladeResourceStore = useBladeResourceStore(); const bladePortStore = useBladePortStore(); - await bladeResourceStore.fetchMemoryResources( + await bladeResourceStore.updateMemoryResourcesStatus( this.selectedMemoryRegion.memoryApplianceId, this.selectedMemoryRegion.memoryBladeId ); diff --git a/webui/src/components/Stores/BladeResourceStore.ts b/webui/src/components/Stores/BladeResourceStore.ts index 1ca8937..d490b6b 100644 --- a/webui/src/components/Stores/BladeResourceStore.ts +++ b/webui/src/components/Stores/BladeResourceStore.ts @@ -21,7 +21,7 @@ export const useBladeResourceStore = defineStore('bladeResource', { applianceId, bladeId ); - + const resourcesCount = response.data.memberCount; for (let i = 0; i < resourcesCount; i++) { // Extract the id for each resources @@ -47,5 +47,34 @@ export const useBladeResourceStore = defineStore('bladeResource', { console.error("Error fetching resources:", error); } }, + + async updateMemoryResourcesStatus(applianceId: string, bladeId: string) { + try { + const defaultApi = new DefaultApi(undefined, API_BASE_PATH); + const updatedResource = await defaultApi.bladesGetResourceStatus( + applianceId, + bladeId, + ); + + if (updatedResource) { + // Create a map to quick look up the updatedResource + const resourceMap = new Map(); + updatedResource.data.resourceStatuses.forEach((resource) => { + resourceMap.set(resource.id, resource.compositionStatus.compositionState); + }); + + // Update the status in memoryResources based on the resource map + this.memoryResources.forEach(resource => { + if (resourceMap.has(resource.id)) { + resource.compositionStatus.compositionState = resourceMap.get(resource.id) + "" + } + }); + } + + } catch (error) { + console.error("Error updating resources:", error); + } + + }, } }) \ No newline at end of file