| 1 | <template> |
| 2 | <div class="flex flex-col gap-3"> |
| 3 | <div v-for="item of itemsPaginated" :key="item.id"> |
| 4 | <TacticCard :id="item.id" :entity="item.entity" @loaded="item.entity = $event" /> |
| 5 | </div> |
| 6 | <div v-if="list.length" class="flex justify-end"> |
| 7 | <n-pagination |
| 8 | v-model:page="currentPage" |
| 9 | v-model:page-size="pageSize" |
| 10 | :item-count="list.length" |
| 11 | :page-slot="6" |
| 12 | /> |
| 13 | </div> |
| 14 | <n-empty v-else description="No items found" class="h-48 justify-center" /> |
| 15 | </div> |
| 16 | </template> |
| 17 | |
| 18 | <script setup lang="ts"> |
| 19 | import type { MitreTacticDetails } from "@/types/mitre.d" |
| 20 | import { NEmpty, NPagination } from "naive-ui" |
| 21 | import { computed, onMounted, ref } from "vue" |
| 22 | import TacticCard from "./TacticCard.vue" |
| 23 | |
| 24 | const { list } = defineProps<{ |
| 25 | list: string[] |
| 26 | }>() |
| 27 | |
| 28 | const pageSize = ref(5) |
| 29 | const currentPage = ref(1) |
| 30 | const tactics = ref<{ id: string; entity?: MitreTacticDetails }[]>([]) |
| 31 | |
| 32 | const itemsPaginated = computed(() => { |
| 33 | const from = (currentPage.value - 1) * pageSize.value |
| 34 | const to = currentPage.value * pageSize.value |
| 35 | |
| 36 | return tactics.value.slice(from, to) |
| 37 | }) |
| 38 | |
| 39 | onMounted(() => { |
| 40 | tactics.value = list.map(o => ({ id: o, entity: undefined })) |
| 41 | }) |
| 42 | </script> |