| 1 | <template> |
| 2 | <CardEntity> |
| 3 | <template #headerMain> |
| 4 | <n-popover overlap placement="bottom-start"> |
| 5 | <template #trigger> |
| 6 | <div class="hover:text-primary flex cursor-help items-center gap-2"> |
| 7 | <span>#{{ alertsEvent.event.id }}</span> |
| 8 | <Icon :name="InfoIcon" :size="16" /> |
| 9 | </div> |
| 10 | </template> |
| 11 | <div class="flex flex-col gap-1"> |
| 12 | <div class="box"> |
| 13 | event_definition_id: |
| 14 | <code |
| 15 | class="text-primary cursor-pointer" |
| 16 | @click="gotoEventsPage(alertsEvent.event.event_definition_id)" |
| 17 | > |
| 18 | {{ alertsEvent.event.event_definition_id }} |
| 19 | <Icon :name="LinkIcon" :size="13" class="relative top-0.5" /> |
| 20 | </code> |
| 21 | </div> |
| 22 | <div class="box"> |
| 23 | event_definition_type: |
| 24 | <code>{{ alertsEvent.event.event_definition_type }}</code> |
| 25 | </div> |
| 26 | <div class="box"> |
| 27 | source: |
| 28 | <code>{{ alertsEvent.event.source }}</code> |
| 29 | </div> |
| 30 | <div class="box"> |
| 31 | index_name: |
| 32 | <code |
| 33 | class="text-primary cursor-pointer" |
| 34 | @click="routeIndex(alertsEvent.index_name).navigate()" |
| 35 | > |
| 36 | {{ alertsEvent.index_name }} |
| 37 | <Icon :name="LinkIcon" :size="13" class="relative top-0.5" /> |
| 38 | </code> |
| 39 | </div> |
| 40 | <div class="box"> |
| 41 | index_type: |
| 42 | <code>{{ alertsEvent.index_type }}</code> |
| 43 | </div> |
| 44 | <div class="box"> |
| 45 | timestamp: |
| 46 | <code>{{ formatDateTime(alertsEvent.event.timestamp) }}</code> |
| 47 | </div> |
| 48 | <div class="box"> |
| 49 | timestamp processing: |
| 50 | <code>{{ formatDateTime(alertsEvent.event.timestamp_processing) }}</code> |
| 51 | </div> |
| 52 | </div> |
| 53 | </n-popover> |
| 54 | </template> |
| 55 | <template #headerExtra> |
| 56 | <n-popover overlap placement="top-end"> |
| 57 | <template #trigger> |
| 58 | <div class="hover:text-primary flex cursor-help items-center gap-2"> |
| 59 | <span>{{ formatDateTime(alertsEvent.event.timestamp) }}</span> |
| 60 | <Icon :name="TimeIcon" :size="16" /> |
| 61 | </div> |
| 62 | </template> |
| 63 | <div class="flex flex-col px-1 py-2"> |
| 64 | <n-timeline> |
| 65 | <n-timeline-item |
| 66 | type="success" |
| 67 | title="Timestamp" |
| 68 | :time="formatDateTime(alertsEvent.event.timestamp)" |
| 69 | /> |
| 70 | <n-timeline-item |
| 71 | v-if="alertsEvent.event.timestamp_processing" |
| 72 | title="Processing" |
| 73 | :time="formatDateTime(alertsEvent.event.timestamp_processing)" |
| 74 | /> |
| 75 | </n-timeline> |
| 76 | </div> |
| 77 | </n-popover> |
| 78 | </template> |
| 79 | <template #default>{{ alertsEvent.event.message }}</template> |
| 80 | </CardEntity> |
| 81 | </template> |
| 82 | |
| 83 | <script setup lang="ts"> |
| 84 | import type { AlertsEventElement } from "@/types/graylog/alerts.d" |
| 85 | import { NPopover, NTimeline, NTimelineItem } from "naive-ui" |
| 86 | import CardEntity from "@/components/common/cards/CardEntity.vue" |
| 87 | import Icon from "@/components/common/Icon.vue" |
| 88 | import { useNavigation } from "@/composables/useNavigation" |
| 89 | import { useSettingsStore } from "@/stores/settings" |
| 90 | import { formatDate } from "@/utils/format" |
| 91 | |
| 92 | const { alertsEvent } = defineProps<{ alertsEvent: AlertsEventElement }>() |
| 93 | |
| 94 | const emit = defineEmits<{ |
| 95 | (e: "clickEvent", value: string): void |
| 96 | }>() |
| 97 | |
| 98 | const InfoIcon = "carbon:information" |
| 99 | const TimeIcon = "carbon:time" |
| 100 | const LinkIcon = "carbon:launch" |
| 101 | |
| 102 | const dFormats = useSettingsStore().dateFormat |
| 103 | const { routeIndex } = useNavigation() |
| 104 | |
| 105 | function formatDateTime(timestamp: string): string { |
| 106 | return formatDate(timestamp, dFormats.datetimesec).toString() |
| 107 | } |
| 108 | |
| 109 | function gotoEventsPage(event_definition_id: string) { |
| 110 | emit("clickEvent", event_definition_id) |
| 111 | } |
| 112 | </script> |