-
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.
update HostsStatus component. Fix HOST_POWER_STATE enum.
- Loading branch information
Showing
8 changed files
with
82 additions
and
160 deletions.
There are no files selected for viewing
76 changes: 0 additions & 76 deletions
76
@xen-orchestra/web-core/lib/components/DonutWithLegends.vue
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
@xen-orchestra/web/src/components/pool/dashboard/HostStatus.vue
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
@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,65 @@ | ||
<template v-if="isReady"> | ||
<UiCard> | ||
<CardTitle>{{ $t('hosts-status') }}</CardTitle> | ||
<DonutChartWithLegend :icon="faServer" :segments /> | ||
<CardNumbers :value="hosts.length" class="total" label="Total" size="small" /> | ||
</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 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 } = 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> |
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