| 1 | <template> |
| 2 | <div :id="`rule-${rule.id}`"> |
| 3 | <CardEntity :highlighted="!!highlight" :embedded hoverable clickable @click.stop="showDetails = true"> |
| 4 | <template #headerMain>#{{ rule.id }}</template> |
| 5 | <template #headerExtra> |
| 6 | <n-popover overlap placement="top-end"> |
| 7 | <template #trigger> |
| 8 | <div class="hover:text-primary flex cursor-help items-center gap-2"> |
| 9 | {{ formatDateTime(rule.modified_at) }} |
| 10 | |
| 11 | <Icon :name="TimeIcon" :size="16" /> |
| 12 | </div> |
| 13 | </template> |
| 14 | <div class="flex flex-col px-1 py-2"> |
| 15 | <n-timeline> |
| 16 | <n-timeline-item type="success" title="Created" :time="formatDateTime(rule.created_at)" /> |
| 17 | <n-timeline-item |
| 18 | v-if="rule.modified_at" |
| 19 | title="Modified" |
| 20 | :time="formatDateTime(rule.modified_at)" |
| 21 | /> |
| 22 | </n-timeline> |
| 23 | </div> |
| 24 | </n-popover> |
| 25 | </template> |
| 26 | <template #default> |
| 27 | <div class="flex flex-col gap-1"> |
| 28 | {{ rule.title }} |
| 29 | |
| 30 | <p v-if="rule.description && rule.description !== rule.title"> |
| 31 | {{ rule.description }} |
| 32 | </p> |
| 33 | </div> |
| 34 | </template> |
| 35 | </CardEntity> |
| 36 | |
| 37 | <n-modal |
| 38 | v-model:show="showDetails" |
| 39 | preset="card" |
| 40 | content-class="p-0!" |
| 41 | :style="{ maxWidth: 'min(600px, 90vw)', overflow: 'hidden' }" |
| 42 | :title="rule.title" |
| 43 | :bordered="false" |
| 44 | segmented |
| 45 | > |
| 46 | <div class="p-6 pt-3"> |
| 47 | <div class="mb-2"> |
| 48 | Created: |
| 49 | <code>{{ formatDateTime(rule.created_at) }}</code> |
| 50 | </div> |
| 51 | <div class="mb-2"> |
| 52 | Modified: |
| 53 | <code>{{ formatDateTime(rule.modified_at) }}</code> |
| 54 | </div> |
| 55 | <div class="mb-2"> |
| 56 | Errors : |
| 57 | <code>{{ rule.errors || "-" }}</code> |
| 58 | </div> |
| 59 | <div class="mb-1">Source :</div> |
| 60 | <n-input |
| 61 | :value="rule.source" |
| 62 | type="textarea" |
| 63 | readonly |
| 64 | placeholder="Empty" |
| 65 | size="large" |
| 66 | :autosize="{ |
| 67 | minRows: 3, |
| 68 | maxRows: 10 |
| 69 | }" |
| 70 | /> |
| 71 | </div> |
| 72 | </n-modal> |
| 73 | </div> |
| 74 | </template> |
| 75 | |
| 76 | <script setup lang="ts"> |
| 77 | import type { PipelineRule } from "@/types/graylog/pipelines.d" |
| 78 | import { NInput, NModal, NPopover, NTimeline, NTimelineItem } from "naive-ui" |
| 79 | import { ref, toRefs } from "vue" |
| 80 | import CardEntity from "@/components/common/cards/CardEntity.vue" |
| 81 | import Icon from "@/components/common/Icon.vue" |
| 82 | import { useSettingsStore } from "@/stores/settings" |
| 83 | import { formatDate } from "@/utils/format" |
| 84 | |
| 85 | const props = defineProps<{ rule: PipelineRule; embedded?: boolean; highlight: boolean | null | undefined }>() |
| 86 | const { rule, highlight, embedded } = toRefs(props) |
| 87 | |
| 88 | const TimeIcon = "carbon:time" |
| 89 | |
| 90 | const showDetails = ref(false) |
| 91 | const dFormats = useSettingsStore().dateFormat |
| 92 | |
| 93 | function formatDateTime(timestamp: string): string { |
| 94 | return formatDate(timestamp, dFormats.datetimesec).toString() |
| 95 | } |
| 96 | </script> |