-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(xo-web): add host status to xo6 dashboard (#7799)
- Loading branch information
Showing
6 changed files
with
95 additions
and
5 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
@xen-orchestra/web/src/components/site/dashboard/HostsStatus.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<template> | ||
<UiCard> | ||
<CardTitle>{{ $t('hosts-status') }}</CardTitle> | ||
<LoadingHero :disabled="isReady" type="card"> | ||
<DonutChartWithLegend :icon="faServer" :segments /> | ||
<CardNumbers :label="t('total')" :value="hosts.length" class="total" size="small" /> | ||
</LoadingHero> | ||
</UiCard> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { useHostStore } from '@/stores/xo-rest-api/host.store' | ||
import { HOST_POWER_STATE } from '@/types/host.type' | ||
import type { DonutChartWithLegendProps } from '@core/components/donut-chart-with-legend/DonutChartWithLegend.vue' | ||
import CardTitle from '@core/components/card/CardTitle.vue' | ||
import CardNumbers from '@core/components/CardNumbers.vue' | ||
import DonutChartWithLegend from '@core/components/donut-chart-with-legend/DonutChartWithLegend.vue' | ||
import LoadingHero from '@core/components/state-hero/LoadingHero.vue' | ||
import UiCard from '@core/components/UiCard.vue' | ||
import { faServer } from '@fortawesome/free-solid-svg-icons' | ||
import { computed } from 'vue' | ||
import { useI18n } from 'vue-i18n' | ||
const { t } = useI18n() | ||
const { records: hosts, isReady } = useHostStore().subscribe() | ||
const hostsCount = computed(() => { | ||
return hosts.value.reduce( | ||
(acc, host) => { | ||
if (host.power_state === HOST_POWER_STATE.RUNNING) { | ||
acc.running++ | ||
} else if (host.power_state === HOST_POWER_STATE.HALTED) { | ||
acc.halted++ | ||
} else { | ||
acc.unknown++ | ||
} | ||
return acc | ||
}, | ||
{ running: 0, halted: 0, unknown: 0 } | ||
) | ||
}) | ||
const segments = computed<DonutChartWithLegendProps['segments']>(() => [ | ||
{ | ||
label: t('hosts-status.running'), | ||
value: hostsCount.value.running, | ||
color: 'success', | ||
}, | ||
{ | ||
label: t('hosts-status.halted'), | ||
value: hostsCount.value.halted, | ||
color: 'warning', | ||
}, | ||
{ | ||
label: t('hosts-status.unknown'), | ||
value: hostsCount.value.unknown, | ||
color: 'disabled', | ||
tooltip: t('hosts-status.unknown.tooltip'), | ||
}, | ||
]) | ||
</script> | ||
|
||
<style lang="postcss" scoped> | ||
.total { | ||
margin-left: auto; | ||
} | ||
</style> |
4 changes: 2 additions & 2 deletions
4
@xen-orchestra/web/src/components/site/dashboard/VmsStatus.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters