| 1 | <template> |
| 2 | <CardEntity :loading="canceling" hoverable clickable @click.stop="openReport()"> |
| 3 | <template #default> |
| 4 | {{ report }} |
| 5 | </template> |
| 6 | <template #footerExtra> |
| 7 | <n-popconfirm |
| 8 | v-model:show="showConfirm" |
| 9 | trigger="manual" |
| 10 | @positive-click="deleteScoutSuiteReport()" |
| 11 | @clickoutside="showConfirm = false" |
| 12 | > |
| 13 | <template #trigger> |
| 14 | <n-button quaternary size="tiny" @click.stop="showConfirm = true">delete</n-button> |
| 15 | </template> |
| 16 | Are you sure you want to delete the report? |
| 17 | </n-popconfirm> |
| 18 | </template> |
| 19 | </CardEntity> |
| 20 | </template> |
| 21 | |
| 22 | <script setup lang="ts"> |
| 23 | import type { ScoutSuiteReport } from "@/types/cloudSecurityAssessment.d" |
| 24 | import { NButton, NPopconfirm, useMessage } from "naive-ui" |
| 25 | import { ref } from "vue" |
| 26 | import Api from "@/api" |
| 27 | import CardEntity from "@/components/common/cards/CardEntity.vue" |
| 28 | import { getBaseUrl } from "@/utils" |
| 29 | |
| 30 | const { report } = defineProps<{ report: ScoutSuiteReport }>() |
| 31 | |
| 32 | const emit = defineEmits<{ |
| 33 | (e: "deleted"): void |
| 34 | }>() |
| 35 | |
| 36 | const message = useMessage() |
| 37 | const canceling = ref(false) |
| 38 | const showConfirm = ref(false) |
| 39 | |
| 40 | function deleteScoutSuiteReport() { |
| 41 | canceling.value = true |
| 42 | |
| 43 | Api.cloudSecurityAssessment |
| 44 | .deleteScoutSuiteReport(report) |
| 45 | .then(res => { |
| 46 | if (res.data.success) { |
| 47 | message.success(res.data?.message || "Report deleted successfully") |
| 48 | emit("deleted") |
| 49 | } else { |
| 50 | message.warning(res.data?.message || "An error occurred. Please try again later.") |
| 51 | } |
| 52 | }) |
| 53 | .catch(err => { |
| 54 | message.error(err.response?.data?.message || "An error occurred. Please try again later.") |
| 55 | }) |
| 56 | .finally(() => { |
| 57 | canceling.value = false |
| 58 | }) |
| 59 | } |
| 60 | |
| 61 | function openReport() { |
| 62 | window.open(`${getBaseUrl()}/scoutsuite-report/${report}`, "_blank") |
| 63 | } |
| 64 | </script> |