| 1 | <template> |
| 2 | <n-card class="unhealthy-indices" segmented content-class="pr-1!"> |
| 3 | <template #header> |
| 4 | <div class="align-center flex justify-between"> |
| 5 | <span>Unhealthy Indices</span> |
| 6 | <span class="text-secondary font-mono">{{ unhealthyIndices.length }}</span> |
| 7 | </div> |
| 8 | </template> |
| 9 | <n-spin :show="loading"> |
| 10 | <div class="min-h-14"> |
| 11 | <n-scrollbar class="max-h-125" trigger="none" content-class="pr-5!"> |
| 12 | <template v-if="unhealthyIndices && unhealthyIndices.length"> |
| 13 | <div |
| 14 | v-for="item of unhealthyIndices" |
| 15 | :key="item.index" |
| 16 | class="item" |
| 17 | :class="item.health" |
| 18 | title="Click for details" |
| 19 | @click="emit('click', item)" |
| 20 | > |
| 21 | <IndexCard :index="item" /> |
| 22 | </div> |
| 23 | </template> |
| 24 | <n-empty v-else description="No Unhealthy Indices found"> |
| 25 | <template #icon> |
| 26 | <Icon :name="ShieldIcon" /> |
| 27 | </template> |
| 28 | <template #extra>Great, all indices are healthy!</template> |
| 29 | </n-empty> |
| 30 | </n-scrollbar> |
| 31 | </div> |
| 32 | </n-spin> |
| 33 | </n-card> |
| 34 | </template> |
| 35 | |
| 36 | <script setup lang="ts"> |
| 37 | import type { IndexStats } from "@/types/indices.d" |
| 38 | import { NCard, NEmpty, NScrollbar, NSpin } from "naive-ui" |
| 39 | import { computed, toRefs } from "vue" |
| 40 | import Icon from "@/components/common/Icon.vue" |
| 41 | import IndexCard from "@/components/indices/IndexCard.vue" |
| 42 | import { IndexHealth } from "@/types/indices.d" |
| 43 | |
| 44 | const props = defineProps<{ |
| 45 | indices: IndexStats[] | null |
| 46 | }>() |
| 47 | |
| 48 | const emit = defineEmits<{ |
| 49 | (e: "click", value: IndexStats): void |
| 50 | }>() |
| 51 | |
| 52 | const ShieldIcon = "fluent:shield-task-20-regular" |
| 53 | |
| 54 | const { indices } = toRefs(props) |
| 55 | |
| 56 | const loading = computed(() => !indices?.value || indices.value === null) |
| 57 | |
| 58 | const unhealthyIndices = computed(() => |
| 59 | (indices.value || []).filter( |
| 60 | (index: IndexStats) => index.health === IndexHealth.YELLOW || index.health === IndexHealth.RED |
| 61 | ) |
| 62 | ) |
| 63 | </script> |
| 64 | |
| 65 | <style lang="scss" scoped> |
| 66 | .unhealthy-indices { |
| 67 | .item { |
| 68 | cursor: pointer; |
| 69 | |
| 70 | &:not(:last-child) { |
| 71 | margin-bottom: calc(var(--spacing) * 3); |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | </style> |