| 1 | <template> |
| 2 | <div class="active-response-details"> |
| 3 | <n-spin :show="loading" class="min-h-48"> |
| 4 | <template v-if="content"> |
| 5 | <Markdown :source="content" /> |
| 6 | </template> |
| 7 | <template v-else> |
| 8 | <n-empty v-if="!loading" description="No description found" class="h-48 justify-center" /> |
| 9 | </template> |
| 10 | </n-spin> |
| 11 | </div> |
| 12 | </template> |
| 13 | |
| 14 | <script setup lang="ts"> |
| 15 | import { NEmpty, NSpin, useMessage } from "naive-ui" |
| 16 | import { defineAsyncComponent, onBeforeMount, ref } from "vue" |
| 17 | import Api from "@/api" |
| 18 | |
| 19 | const { techniqueId } = defineProps<{ |
| 20 | techniqueId: string |
| 21 | }>() |
| 22 | |
| 23 | const Markdown = defineAsyncComponent(() => import("@/components/common/Markdown.vue")) |
| 24 | |
| 25 | const message = useMessage() |
| 26 | const loading = ref(false) |
| 27 | const content = ref<string>() |
| 28 | |
| 29 | function getContent() { |
| 30 | loading.value = true |
| 31 | |
| 32 | Api.wazuh.mitre |
| 33 | .getMitreAtomicTestContent(techniqueId) |
| 34 | .then(res => { |
| 35 | if (res.data.success) { |
| 36 | content.value = res.data?.markdown_content |
| 37 | } else { |
| 38 | message.warning(res.data?.message || "An error occurred. Please try again later.") |
| 39 | } |
| 40 | }) |
| 41 | .catch(err => { |
| 42 | message.error(err.response?.data?.message || "An error occurred. Please try again later.") |
| 43 | }) |
| 44 | .finally(() => { |
| 45 | loading.value = false |
| 46 | }) |
| 47 | } |
| 48 | |
| 49 | onBeforeMount(() => { |
| 50 | getContent() |
| 51 | }) |
| 52 | </script> |