main
vue 75 lines 1.98 KB
Raw
1 <template>
2 <CardEntity :embedded hoverable>
3 <template #default>
4 <div class="flex flex-wrap gap-2">
5 <strong>{{ ioc.type }}</strong>
6 <span>{{ ioc.value }}</span>
7 </div>
8 <p class="mt-2">{{ ioc.description }}</p>
9 </template>
10 <template #footerExtra>
11 <div class="flex items-center justify-end gap-3">
12 <VirusTotalEnrichmentButton :ioc-value="ioc.value" />
13
14 <n-popconfirm
15 v-model:show="showDeleteConfirm"
16 trigger="manual"
17 to="body"
18 @positive-click="deleteIoc()"
19 @clickoutside="showDeleteConfirm = false"
20 >
21 <template #trigger>
22 <n-button quaternary size="tiny" :loading="canceling" @click.stop="showDeleteConfirm = true">
23 Delete
24 </n-button>
25 </template>
26 Are you sure you want to delete this IoC?
27 </n-popconfirm>
28 </div>
29 </template>
30 </CardEntity>
31 </template>
32
33 <script setup lang="ts">
34 import type { AlertIOC } from "@/types/incidentManagement/alerts"
35 import { NButton, NPopconfirm, useMessage } from "naive-ui"
36 import { ref } from "vue"
37 import Api from "@/api"
38 import CardEntity from "@/components/common/cards/CardEntity.vue"
39 import VirusTotalEnrichmentButton from "@/components/threatIntel/VirusTotalEnrichmentButton.vue"
40
41 const { ioc, embedded, alertId } = defineProps<{
42 ioc: AlertIOC
43 alertId: number
44 embedded?: boolean
45 }>()
46
47 const emit = defineEmits<{
48 (e: "deleted"): void
49 }>()
50
51 const message = useMessage()
52 const canceling = ref(false)
53 const showDeleteConfirm = ref(false)
54
55 function deleteIoc() {
56 canceling.value = true
57
58 Api.incidentManagement.alerts
59 .deleteAlertIoc(alertId, ioc.id)
60 .then(res => {
61 if (res.data.success) {
62 message.success(res.data?.message || "Case Data Store File deleted successfully")
63 emit("deleted")
64 } else {
65 message.warning(res.data?.message || "An error occurred. Please try again later.")
66 }
67 })
68 .catch(err => {
69 message.error(err.response?.data?.message || "An error occurred. Please try again later.")
70 })
71 .finally(() => {
72 canceling.value = false
73 })
74 }
75 </script>