Skip to content

Commit

Permalink
feat: implement api bladesGetResourceStatus in webui
Browse files Browse the repository at this point in the history
  • Loading branch information
Meng-20 committed Dec 10, 2024
1 parent a9c46ad commit 7b203f1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion webui/src/components/Appliance/ComposeMemoryButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ export default {
const bladeResourceStore = useBladeResourceStore();
const bladePortStore = useBladePortStore();

await bladeResourceStore.fetchMemoryResources(
await bladeResourceStore.updateMemoryResourcesStatus(
this.associatedApplianceId,
this.bladeId
);
Expand Down
4 changes: 2 additions & 2 deletions webui/src/components/Appliance/Memory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export default {
this.selectedMemoryRegion.memoryApplianceId,
this.selectedMemoryRegion.memoryBladeId
);
await bladeResourceStore.fetchMemoryResources(
await bladeResourceStore.updateMemoryResourcesStatus(
this.selectedMemoryRegion.memoryApplianceId,
this.selectedMemoryRegion.memoryBladeId
);
Expand Down Expand Up @@ -477,7 +477,7 @@ export default {
const bladeResourceStore = useBladeResourceStore();
const bladePortStore = useBladePortStore();

await bladeResourceStore.fetchMemoryResources(
await bladeResourceStore.updateMemoryResourcesStatus(
this.selectedMemoryRegion.memoryApplianceId,
this.selectedMemoryRegion.memoryBladeId
);
Expand Down
31 changes: 30 additions & 1 deletion webui/src/components/Stores/BladeResourceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<string, string>();
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);
}

},
}
})

0 comments on commit 7b203f1

Please sign in to comment.