main
vue 88 lines 2.66 KB
Raw
1 <template>
2 <div class="flex flex-col gap-4">
3 <div class="grid grid-cols-1 gap-4 @xl:grid-cols-2">
4 <CardEntity size="small">
5 <template #header>
6 <div class="text-secondary text-sm">Alert Name</div>
7 </template>
8 {{ alert.alert_name }}
9 </CardEntity>
10 <CardEntity size="small">
11 <template #header-main>
12 <div class="text-secondary text-sm">Status</div>
13 </template>
14 <template #header-extra>
15 <Chip v-if="alert.escalated" type="error" value="Escalated" size="tiny" round :bordered="false" />
16 </template>
17 <AlertStatusSelect :alert-id="alert.id" :status="alert.status" @success="handleStatusUpdateSuccess" />
18 </CardEntity>
19 <CardEntity size="small">
20 <template #header>
21 <div class="text-secondary text-sm">Source</div>
22 </template>
23 {{ alert.source }}
24 </CardEntity>
25
26 <CardEntity size="small">
27 <template #header>
28 <div class="text-secondary text-sm">Customer</div>
29 </template>
30 {{ alert.customer_code }}
31 </CardEntity>
32
33 <CardEntity size="small">
34 <template #header>
35 <div class="text-secondary text-sm">Created</div>
36 </template>
37 {{ formatDate(alert.alert_creation_time, dFormats.datetime) }}
38 </CardEntity>
39
40 <CardEntity v-if="alert.assigned_to" size="small">
41 <template #header>
42 <div class="text-secondary text-sm">Assigned To</div>
43 </template>
44 {{ alert.assigned_to }}
45 </CardEntity>
46
47 <CardEntity v-if="alert.alert_description" size="small" class="@xl:col-span-2">
48 <template #header>
49 <div class="text-secondary text-sm">Description</div>
50 </template>
51 {{ alert.alert_description }}
52 </CardEntity>
53 </div>
54
55 <div v-if="tags.length > 0" class="flex flex-wrap gap-2">
56 <code v-for="tag in tags" :key="tag">#{{ tag }}</code>
57 </div>
58 </div>
59 </template>
60
61 <script setup lang="ts">
62 import type { AlertStatusUpdateSuccessPayload } from "@/components/alerts/AlertStatusSelect.vue"
63 import type { Alert } from "@/types/alerts"
64 import { computed } from "vue"
65 import AlertStatusSelect from "@/components/alerts/AlertStatusSelect.vue"
66 import CardEntity from "@/components/common/cards/CardEntity.vue"
67 import Chip from "@/components/common/Chip.vue"
68 import { useSettingsStore } from "@/stores/settings"
69 import { formatDate } from "@/utils/format"
70
71 const props = defineProps<{
72 alert: Alert
73 }>()
74
75 const emit = defineEmits<{
76 (e: "statusUpdated", value: AlertStatusUpdateSuccessPayload): void
77 }>()
78
79 const dFormats = useSettingsStore().dateFormat
80
81 const tags = computed(() => {
82 return [...(props.alert.tags?.map(tag => tag.tag) || []), ...(props.alert.tag || [])]
83 })
84
85 function handleStatusUpdateSuccess(payload: AlertStatusUpdateSuccessPayload) {
86 emit("statusUpdated", payload)
87 }
88 </script>