main
vue 40 lines 1.11 KB
Raw
1 <template>
2 <n-card
3 title="Recent Alerts"
4 segmented
5 :content-class="`flex flex-col gap-4 overflow-hidden ${!recentAlerts.length ? 'items-center justify-center' : 'p-0!'}`"
6 >
7 <n-empty v-if="!recentAlerts.length" description="No recent alerts" />
8
9 <n-scrollbar v-else class="flex grow" trigger="none">
10 <div class="flex flex-col gap-4 p-4">
11 <RecentAlertCard v-for="alert in recentAlerts" :key="alert.id" embedded :alert />
12 </div>
13 </n-scrollbar>
14
15 <n-button :text="!!recentAlerts.length" class="mb-4!" @click="goToAlerts()">
16 <template #icon>
17 <Icon name="carbon:launch" />
18 </template>
19 View all alerts
20 </n-button>
21 </n-card>
22 </template>
23
24 <script setup lang="ts">
25 import type { DashboardAlert } from "./types"
26 import { NButton, NCard, NEmpty, NScrollbar } from "naive-ui"
27 import Icon from "@/components/common/Icon.vue"
28 import { useNavigation } from "@/composables/common/useNavigation"
29 import RecentAlertCard from "./RecentAlertCard.vue"
30
31 defineProps<{
32 recentAlerts: DashboardAlert[]
33 }>()
34
35 const { routeAlertsList } = useNavigation()
36
37 function goToAlerts() {
38 routeAlertsList().navigate()
39 }
40 </script>