su2a / frontend /src /components /user /monitor /MonitorAvailabilityRow.vue
cjovs's picture
PG local + bucket backup/restore, DB: su2adb
126ef31 verified
Raw
History Blame Contribute Delete
1.24 kB
<template>
<div class="mt-3 flex items-end justify-between">
<div class="text-[11px] uppercase tracking-widest text-gray-400">
{{ windowLabel }}
</div>
<div class="flex items-baseline gap-0.5">
<span
class="text-3xl font-bold tabular-nums leading-none"
:style="colorStyle"
>
{{ displayValue }}
</span>
<span
class="text-base font-semibold leading-none"
:style="colorStyle"
>%</span>
</div>
</div>
<div
v-if="samplesLabel"
class="mt-1 text-[11px] text-gray-400 text-right"
>
{{ samplesLabel }}
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { hslForPct } from '@/composables/useChannelMonitorFormat'
const props = defineProps<{
windowLabel: string
value: number | null
samplesLabel?: string
}>()
const { t } = useI18n()
const displayValue = computed(() => {
if (props.value === null || Number.isNaN(props.value)) return t('monitorCommon.latencyEmpty')
return props.value.toFixed(2)
})
const colorStyle = computed(() => {
const colour = hslForPct(props.value)
return colour ? { color: colour } : { color: 'rgb(156 163 175)' }
})
</script>