| 1 | <template> |
| 2 | <n-tabs type="line" animated :tabs-padding="24" class="grow" pane-wrapper-class="flex grow flex-col"> |
| 3 | <n-tab-pane name="Overview" tab="Overview" display-directive="show:lazy" class="flex grow flex-col"> |
| 4 | <n-spin :show="loading" class="flex grow flex-col" content-class="flex grow flex-col"> |
| 5 | <div class="flex flex-col gap-4 p-5 pt-3"> |
| 6 | <div class="grid grid-cols-6 gap-4"> |
| 7 | <CardKV class="col-span-6 md:col-span-2"> |
| 8 | <template #key>name</template> |
| 9 | <template #value>{{ entity.name }}</template> |
| 10 | </CardKV> |
| 11 | <CardKV class="col-span-3 md:col-span-2"> |
| 12 | <template #key>creator</template> |
| 13 | <template #value> |
| 14 | <div class="flex flex-col gap-2 py-1"> |
| 15 | <div> |
| 16 | <span class="text-secondary">by:</span> |
| 17 | {{ entity.created_by }} |
| 18 | </div> |
| 19 | <div> |
| 20 | <span class="text-secondary">at:</span> |
| 21 | {{ formatDate(entity.created_at, dFormats.datetimesec) }} |
| 22 | </div> |
| 23 | </div> |
| 24 | </template> |
| 25 | </CardKV> |
| 26 | <CardKV class="col-span-3 md:col-span-2"> |
| 27 | <template #key>status</template> |
| 28 | <template #value> |
| 29 | <div class="flex h-full w-full items-center justify-center font-sans"> |
| 30 | <ExclusionRuleStatusToggler |
| 31 | :entity |
| 32 | @loading="updatingStatus = $event" |
| 33 | @updated="setStatus($event)" |
| 34 | /> |
| 35 | </div> |
| 36 | </template> |
| 37 | </CardKV> |
| 38 | </div> |
| 39 | |
| 40 | <div class="border-default bg-secondary flex flex-wrap items-center gap-3 rounded-lg border p-3"> |
| 41 | <Badge type="splitted"> |
| 42 | <template #label># ID</template> |
| 43 | <template #value>{{ entity.id }}</template> |
| 44 | </Badge> |
| 45 | |
| 46 | <Badge type="splitted" color="primary"> |
| 47 | <template #iconLeft> |
| 48 | <Icon :name="TargetIcon" /> |
| 49 | </template> |
| 50 | <template #label>Match count</template> |
| 51 | <template #value> |
| 52 | {{ entity.match_count }} |
| 53 | </template> |
| 54 | </Badge> |
| 55 | |
| 56 | <Badge v-if="entity.last_matched_at" type="splitted" color="primary"> |
| 57 | <template #iconLeft> |
| 58 | <Icon :name="TimeIcon" /> |
| 59 | </template> |
| 60 | <template #label>Last match</template> |
| 61 | <template #value> |
| 62 | {{ formatDate(entity.last_matched_at, dFormats.datetimesec) }} |
| 63 | </template> |
| 64 | </Badge> |
| 65 | |
| 66 | <Badge v-if="entity.customer_code" type="splitted"> |
| 67 | <template #label>Customer</template> |
| 68 | <template #value> |
| 69 | <code |
| 70 | class="text-primary cursor-pointer leading-none" |
| 71 | @click.stop="routeCustomer({ code: entity.customer_code }).navigate()" |
| 72 | > |
| 73 | #{{ entity.customer_code }} |
| 74 | <Icon :name="LinkIcon" :size="14" class="relative top-0.5" /> |
| 75 | </code> |
| 76 | </template> |
| 77 | </Badge> |
| 78 | </div> |
| 79 | |
| 80 | <CardKV v-for="(val, key) in properties" :key> |
| 81 | <template #key>{{ key }}</template> |
| 82 | <template #value>{{ val }}</template> |
| 83 | </CardKV> |
| 84 | </div> |
| 85 | </n-spin> |
| 86 | </n-tab-pane> |
| 87 | <n-tab-pane name="Fields" tab="Fields" display-directive="show:lazy"> |
| 88 | <div class="p-6 pt-3"> |
| 89 | <CardKV v-for="(val, key) in entity.field_matches" :key size="lg"> |
| 90 | <template #key>{{ key }}</template> |
| 91 | <template #value> |
| 92 | <CodeSource :code="val" lang="shell" /> |
| 93 | </template> |
| 94 | </CardKV> |
| 95 | </div> |
| 96 | </n-tab-pane> |
| 97 | </n-tabs> |
| 98 | </template> |
| 99 | |
| 100 | <script setup lang="ts"> |
| 101 | import type { ExclusionRule } from "@/types/incidentManagement/exclusionRules.d" |
| 102 | import _pick from "lodash/pick" |
| 103 | import { NSpin, NTabPane, NTabs } from "naive-ui" |
| 104 | import { computed, ref, toRefs } from "vue" |
| 105 | import Badge from "@/components/common/Badge.vue" |
| 106 | import CardKV from "@/components/common/cards/CardKV.vue" |
| 107 | import CodeSource from "@/components/common/CodeSource.vue" |
| 108 | import Icon from "@/components/common/Icon.vue" |
| 109 | import { useNavigation } from "@/composables/useNavigation" |
| 110 | import { useSettingsStore } from "@/stores/settings" |
| 111 | import { formatDate } from "@/utils/format" |
| 112 | import ExclusionRuleStatusToggler from "./ExclusionRuleStatusToggler.vue" |
| 113 | |
| 114 | const props = defineProps<{ |
| 115 | entity: ExclusionRule |
| 116 | }>() |
| 117 | |
| 118 | const { entity } = toRefs(props) |
| 119 | |
| 120 | const TimeIcon = "carbon:time" |
| 121 | const LinkIcon = "carbon:launch" |
| 122 | const TargetIcon = "zondicons:target" |
| 123 | const dFormats = useSettingsStore().dateFormat |
| 124 | const { routeCustomer } = useNavigation() |
| 125 | const updatingStatus = ref(false) |
| 126 | const loading = computed(() => updatingStatus.value) |
| 127 | const properties = computed(() => _pick(entity.value, ["description", "channel", "title"])) |
| 128 | |
| 129 | function setStatus(value: ExclusionRule) { |
| 130 | entity.value.enabled = value.enabled |
| 131 | } |
| 132 | </script> |