|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import { ofetch } from "ofetch"; |
3 | | -import { URL_MERGE_DIFF, MergeKaniColumns, multiSort, type VecMergeHashKaniList } from "~/shared/utils/merged_list"; |
| 3 | +import { URL_MERGE_DIFF, MergeKaniColumns, multiSort, type VecMergeHashKaniList, FILTERS, ProofKind } from "~/shared/utils/kani"; |
| 4 | +import { useStyleStore } from "~/stores/style"; |
4 | 5 |
|
5 | | -const vec = ref<VecMergeHashKaniList>([]); |
| 6 | +const { viewportHeight } = storeToRefs(useStyleStore()); |
| 7 | +const colStyle = (ratio: number) => { |
| 8 | + const style = { |
| 9 | + "width": `${Math.round(viewportHeight.value * ratio)}px`, |
| 10 | + "white-space": "normal", "word-break": "break-word", |
| 11 | + }; |
| 12 | + console.log(style); |
| 13 | + return style; |
| 14 | +}; |
| 15 | +
|
| 16 | +const raw = ref<VecMergeHashKaniList>([]); |
6 | 17 | // Download JSON |
7 | 18 | ofetch<VecMergeHashKaniList>( |
8 | 19 | URL_MERGE_DIFF, |
9 | 20 | { parseResponse: JSON.parse } |
10 | | -).then(val => vec.value = val); |
| 21 | +).then(val => raw.value = val); |
| 22 | +
|
| 23 | +// fitler rows |
| 24 | +const filters = ref(FILTERS.filters); |
| 25 | +// stats |
| 26 | +const counts = computed<{ total: number, standard: number, contract: number }>(() => ({ |
| 27 | + total: raw.value.length, |
| 28 | + standard: raw.value.filter(ele => ele.proof_kind === ProofKind.Standard).length, |
| 29 | + contract: |
| 30 | + raw.value.filter(ele => ele.proof_kind === ProofKind.Contract).length, |
| 31 | +})); |
| 32 | +
|
11 | 33 |
|
12 | 34 | // Set title |
13 | 35 | useHead({ title: "Verify Rust Std - Kani" }); |
14 | 36 | </script> |
15 | 37 |
|
16 | 38 | <template> |
17 | | - <div>len = {{ vec.length }}</div> |
| 39 | + <DataTable :value="raw" paginator :rows="5" :rowsPerPageOptions="[5, 10, 20, 50]" sortMode="multiple" removableSort |
| 40 | + v-model:multi-sort-meta="multiSort" stripedRows tableStyle="min-width: 20rem" v-model:filters="filters" |
| 41 | + :globalFilterFields="FILTERS.fields" currentPageReportTemplate="{first} to {last} of {totalRecords}"> |
18 | 42 |
|
19 | | - <DataTable :value="vec" paginator :rows="5" :rowsPerPageOptions="[5, 10, 20, 50]" sortMode="multiple" removableSort |
20 | | - v-model:multi-sort-meta="multiSort" stripedRows tableStyle="min-width: 50rem"> |
21 | | - <!-- :virtual-scroller-options="{ itemSize: 5, lazy: true, }"> It's slow to render the table, so partial render. --> |
22 | 43 | <template #header> |
23 | | - <div class="flex flex-wrap items-center justify-between gap-2"> |
24 | | - <span class="text-xl font-bold">Products</span> |
25 | | - <Button icon="pi pi-refresh" rounded raised /> |
| 44 | + <div class="flex justify-between items-center"> |
| 45 | + <div> |
| 46 | + </div> |
| 47 | + <div> |
| 48 | + <IconField> |
| 49 | + <InputIcon> |
| 50 | + <i class="pi pi-search" /> |
| 51 | + </InputIcon> |
| 52 | + <InputText v-model="filters.global.value" placeholder="filepath or function" /> |
| 53 | + </IconField> |
| 54 | + </div> |
26 | 55 | </div> |
27 | 56 | </template> |
28 | 57 |
|
| 58 | + <!-- Passing ratio to maxWidth seems not working. Pass bodyStyle to wrap long paths while bodyClass not working. --> |
29 | 59 | <Column v-for="col of MergeKaniColumns" :key="col.key" :field="col.col.field" :header="col.col.header" |
30 | | - :style="{ width: col.col.width }" :sortable="col.col.sortable"></Column> |
| 60 | + :style="{ width: col.col.width }" bodyStyle="white-space: normal; word-break: break-word" |
| 61 | + :sortable="col.col.sortable"> |
| 62 | + </Column> |
| 63 | + |
| 64 | + <template #paginatorstart> |
| 65 | + <span>Total: {{ counts.total }}</span> |
| 66 | + </template> |
| 67 | + <template #paginatorend> |
| 68 | + <div class="grid grid-cols-2 grid-rows-2 place-items-center"> |
| 69 | + <span>Standard:</span> |
| 70 | + <span>{{ counts.standard }}</span> |
| 71 | + <span>Contract:</span> |
| 72 | + <span>{{ counts.contract }}</span> |
| 73 | + </div> |
| 74 | + </template> |
31 | 75 | </DataTable> |
32 | 76 | </template> |
0 commit comments