main
vue 79 lines 2.09 KB
Raw
1 <template>
2 <div class="page">
3 <div class="mb-4">
4 <n-button secondary type="primary" @click="showRulesDrawer = true">
5 <template #icon>
6 <Icon :name="RulesIcon" :size="22" />
7 </template>
8 View All Rules
9 </n-button>
10 </div>
11
12 <PipeList @open-rule="openRule($event)" />
13
14 <n-modal
15 v-model:show="showDetails"
16 preset="card"
17 content-class="p-0!"
18 :style="{ maxWidth: 'min(600px, 90vw)', overflow: 'hidden' }"
19 :title="highlightPipe?.title"
20 :bordered="false"
21 segmented
22 >
23 <PipeInfo :pipeline="highlightPipe" />
24 </n-modal>
25
26 <n-drawer
27 v-model:show="showRulesDrawer"
28 :width="700"
29 style="max-width: 90vw"
30 :trap-focus="false"
31 display-directive="show"
32 >
33 <n-drawer-content closable body-content-style="padding:0">
34 <template #header>
35 <span>Rules list</span>
36 <span v-if="rulesTotal !== null" class="text-secondary ml-2 font-mono">{{ rulesTotal }}</span>
37 </template>
38 <RulesList :highlight="highlightRule" @loaded="rulesTotal = $event.total" />
39 </n-drawer-content>
40 </n-drawer>
41 </div>
42 </template>
43
44 <script setup lang="ts">
45 import type { PipelineFull } from "@/types/graylog/pipelines.d"
46 import { NButton, NDrawer, NDrawerContent, NModal } from "naive-ui"
47 import { onBeforeMount, ref, watch } from "vue"
48 import { useRoute } from "vue-router"
49 import Icon from "@/components/common/Icon.vue"
50 import PipeInfo from "@/components/graylog/Pipelines/PipeInfo.vue"
51 import PipeList from "@/components/graylog/Pipelines/PipeList.vue"
52 import RulesList from "@/components/graylog/Pipelines/RulesList.vue"
53
54 const RulesIcon = "ic:outline-swipe-right-alt"
55
56 const route = useRoute()
57 const showDetails = ref(false)
58 const highlightPipe = ref<PipelineFull | undefined>(undefined)
59 const highlightRule = ref<string | null>(null)
60 const showRulesDrawer = ref(false)
61 const rulesTotal = ref<null | number>(null)
62
63 function openRule(id: string) {
64 highlightRule.value = id
65 showRulesDrawer.value = true
66 }
67
68 watch(showRulesDrawer, val => {
69 if (!val) {
70 highlightRule.value = null
71 }
72 })
73
74 onBeforeMount(() => {
75 if (route.query?.rule) {
76 openRule(route.query.rule.toString())
77 }
78 })
79 </script>