| 1 | <template> |
| 2 | <div ref="page" class="page"> |
| 3 | <n-tabs type="line" animated :tabs-padding="24"> |
| 4 | <n-tab-pane |
| 5 | name="ConfiguredSources" |
| 6 | :tab=" |
| 7 | showConfiguredSourcesListToolbar |
| 8 | ? 'Configured Sources' |
| 9 | : `Configured Sources (${configuredSourcesListTotal})` |
| 10 | " |
| 11 | display-directive="show" |
| 12 | > |
| 13 | <ConfiguredSourcesList |
| 14 | :show-toolbar="showConfiguredSourcesListToolbar" |
| 15 | @mounted="configuredSourcesListCTX = $event" |
| 16 | @loaded="configuredSourcesListTotal = $event" |
| 17 | /> |
| 18 | </n-tab-pane> |
| 19 | <n-tab-pane name="ExclusionRules" tab="Exclusion Rules" display-directive="show"> |
| 20 | <ExclusionRulesList |
| 21 | :show-creation-button="showExclusionRulesListCreationButton" |
| 22 | :show-info-popover="showExclusionRulesListInfoPopover" |
| 23 | @mounted="exclusionRulesListCTX = $event" |
| 24 | /> |
| 25 | </n-tab-pane> |
| 26 | |
| 27 | <template #suffix> |
| 28 | <div class="flex items-center gap-2"> |
| 29 | <NewConfiguredSourceButton |
| 30 | v-if="!showConfiguredSourcesListToolbar" |
| 31 | @success="reloadConfiguredSourcesList()" |
| 32 | /> |
| 33 | <NewExclusionRuleButton |
| 34 | v-if="!showExclusionRulesListCreationButton" |
| 35 | @success="reloadExclusionRulesList()" |
| 36 | /> |
| 37 | </div> |
| 38 | </template> |
| 39 | </n-tabs> |
| 40 | </div> |
| 41 | </template> |
| 42 | |
| 43 | <script setup lang="ts"> |
| 44 | import { useResizeObserver } from "@vueuse/core" |
| 45 | import { NTabPane, NTabs } from "naive-ui" |
| 46 | import { ref } from "vue" |
| 47 | import ExclusionRulesList from "@/components/incidentManagement/exclusionRules/ExclusionRulesList.vue" |
| 48 | |
| 49 | import NewExclusionRuleButton from "@/components/incidentManagement/exclusionRules/NewExclusionRuleButton.vue" |
| 50 | import ConfiguredSourcesList from "@/components/incidentManagement/sources/ConfiguredSourcesList.vue" |
| 51 | import NewConfiguredSourceButton from "@/components/incidentManagement/sources/NewConfiguredSourceButton.vue" |
| 52 | |
| 53 | const configuredSourcesListTotal = ref(0) |
| 54 | const configuredSourcesListCTX = ref<{ reload: () => void } | null>(null) |
| 55 | const exclusionRulesListCTX = ref<{ reload: () => void } | null>(null) |
| 56 | const page = ref() |
| 57 | |
| 58 | const showConfiguredSourcesListToolbar = ref(false) |
| 59 | const showExclusionRulesListCreationButton = ref(false) |
| 60 | const showExclusionRulesListInfoPopover = ref(false) |
| 61 | |
| 62 | function reloadConfiguredSourcesList() { |
| 63 | if (configuredSourcesListCTX.value) { |
| 64 | configuredSourcesListCTX.value.reload() |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | function reloadExclusionRulesList() { |
| 69 | if (exclusionRulesListCTX.value) { |
| 70 | exclusionRulesListCTX.value.reload() |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | useResizeObserver(page, entries => { |
| 75 | const entry = entries[0] |
| 76 | if (!entry) return |
| 77 | |
| 78 | const { width } = entry.contentRect |
| 79 | |
| 80 | showConfiguredSourcesListToolbar.value = width < 600 |
| 81 | showExclusionRulesListCreationButton.value = width < 800 |
| 82 | showExclusionRulesListInfoPopover.value = width > 600 |
| 83 | }) |
| 84 | </script> |