Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(webui): improve performance of resource status update in webui #66

Merged
merged 9 commits into from
Dec 11, 2024
6 changes: 2 additions & 4 deletions api/cfm-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
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);
}

},
}
})
Loading