main
vue 71 lines 2.39 KB
Raw
1 <template>
2 <div>
3 <CardEntity :embedded hoverable clickable @click="showDetails = true">
4 {{ timelineData._source.rule_description }}
5 </CardEntity>
6
7 <n-modal
8 v-model:show="showDetails"
9 preset="card"
10 content-class="p-0!"
11 :style="{ maxWidth: 'min(700px, 90vw)', minHeight: 'min(550px, 90vh)', overflow: 'hidden' }"
12 :bordered="false"
13 title="Timeline Details"
14 segmented
15 >
16 <n-tabs type="line" animated :tabs-padding="24">
17 <n-tab-pane name="Info" tab="Info" display-directive="show">
18 <div class="grid-auto-fit-200 grid gap-2 p-6 pt-3">
19 <CardKV v-for="(value, key) of timelineDetailsInfo" :key>
20 <template #key>
21 {{ key }}
22 </template>
23 <template #value>
24 <div v-if="key === '_index'">
25 <code
26 class="text-primary cursor-pointer"
27 @click.stop="routeIndex(timelineDetailsInfo._index).navigate()"
28 >
29 {{ timelineDetailsInfo._index }}
30 <Icon :name="LinkIcon" :size="14" class="relative top-0.5" />
31 </code>
32 </div>
33 <div v-else>
34 {{ value === "" ? "-" : (value ?? "-") }}
35 </div>
36 </template>
37 </CardKV>
38 </div>
39 </n-tab-pane>
40 <n-tab-pane name="Source" tab="Source" display-directive="show">
41 <div v-if="timelineDetailsSource" class="p-6 pt-3">
42 <CodeSource :code="timelineDetailsSource" lang="json" />
43 </div>
44 </n-tab-pane>
45 </n-tabs>
46 </n-modal>
47 </div>
48 </template>
49
50 <script setup lang="ts">
51 import type { AlertTimeline } from "@/types/incidentManagement/alerts.d"
52 import _omit from "lodash/omit"
53 import { NModal, NTabPane, NTabs } from "naive-ui"
54 import { computed, defineAsyncComponent, ref, toRefs } from "vue"
55 import CardEntity from "@/components/common/cards/CardEntity.vue"
56 import CardKV from "@/components/common/cards/CardKV.vue"
57 import Icon from "@/components/common/Icon.vue"
58 import { useNavigation } from "@/composables/useNavigation"
59
60 const props = defineProps<{ timelineData: AlertTimeline; embedded?: boolean }>()
61
62 const CodeSource = defineAsyncComponent(() => import("@/components/common/CodeSource.vue"))
63
64 const { timelineData, embedded } = toRefs(props)
65
66 const LinkIcon = "carbon:launch"
67 const { routeIndex } = useNavigation()
68 const showDetails = ref(false)
69 const timelineDetailsInfo = computed(() => _omit(timelineData.value, ["_source"]))
70 const timelineDetailsSource = computed(() => timelineData.value?._source)
71 </script>