Skip to content

Commit

Permalink
feat(webui): update resource status in webui (#66)
Browse files Browse the repository at this point in the history
* fix(service): fix device discovery error handling during service starup (#59)

* refactor(cli): command usage and example string generation refactor and update (#57)

* refactor(cli): command usage and example string generation refactor and update

* doc(cli): add docker-specific note about service-related cli options

* feat(webui): device discovery in cfm webui (#58)

* feat: set the nodes width based on the device id dimensions

* feat: add ipaddress to the existed devices in dashboard

* feat: add new button to discover new devices and the related interfaces

* fix: fix the bug in addDiscoveredHosts interface

* fix: fix bug in addDiscoveredBlades interface

* feat: add function addDiscoveredDevices with output popup and waiting popup

* style:  separate lines for discovered blades and hosts

* feat: add waiting progress for device discovery

* feat: update the content after adding new discovered devices

* feat: distinguish node status by border color

* feat: prevent the user from manually adding blades to the CMA_Discovered_Blades appliance

* style: remove unnecessary stype setup

* fix(docker): update the docker running command to make D-bus available using privileged mode (#60)

* feat: update the docker running command to make D-bus available ay priviledged mode

* fix: update the docker running command to make D-bus available using privileged mode

* fix(service): fix error handling bugs during add blade\host (#61)

Found a couple bugs in appliance.AddBlade() and manager.AddHost().
(1) corner case where an empty bladeId is being allowed, when it shouldn't
(2) Not enough information is being saved to new blade objects during error handling.  This was causing a panic during the delete because the backendOps variable was a nil point being used to call a backend function.

* fix: fix the returning datatype issue in yaml

* feat: implement api bladesGetResourceStatus in webui

---------

Co-authored-by: Scott Howe <[email protected]>
  • Loading branch information
Meng-20 and scott-howe-1 authored Dec 11, 2024
1 parent 401c2c0 commit a0c0a1a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
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);
}

},
}
})

0 comments on commit a0c0a1a

Please sign in to comment.