Skip to content

Commit

Permalink
fix: make the failed host not affect others display in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Meng-20 committed Dec 17, 2024
1 parent 36e75ef commit d529bb2
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions webui/src/components/Stores/HostStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,31 @@ export const useHostStore = defineStore("host", {
.pop()
?.slice(0, -2) as string;
// Get host by id
const detailsResponseOfHost = await defaultApi.hostsGetById(hostId);
if (hostId) {
try {
const detailsResponseOfHost = await defaultApi.hostsGetById(hostId);

// Store host in hosts
if (detailsResponseOfHost) {
this.hosts.push(detailsResponseOfHost.data);
const host = {
id: detailsResponseOfHost.data.id,
ipAddress: detailsResponseOfHost.data.ipAddress,
status: detailsResponseOfHost.data.status,
};
this.hostIds.push(host);
// Store host in hosts
if (detailsResponseOfHost) {
this.hosts.push(detailsResponseOfHost.data);
const host = {
id: detailsResponseOfHost.data.id,
ipAddress: detailsResponseOfHost.data.ipAddress,
status: detailsResponseOfHost.data.status,
};
this.hostIds.push(host);
}
}
catch (hostError) {
console.error(`Error fetching host ${hostId}:`, hostError);
// Push the failed host with an empty status
// TODO: Get the status for the failed host from cfm-service
this.hostIds.push({
id: hostId,
ipAddress: "",
status: "",
});
}
}
}
} catch (error) {
Expand Down

0 comments on commit d529bb2

Please sign in to comment.