Skip to content

Commit 65ae29a

Browse files
committed
feat(info): 按 categories 筛选
ref: #96
1 parent 28f55e8 commit 65ae29a

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

os-checks/pages/info.vue

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<template>
22
<div>
3-
<DataTable :value="summaryTable" tableStyle="min-width: 50rem;" scrollable scrollHeight="800px" showGridlines
3+
<DataTable :value="data" tableStyle="min-width: 50rem;" scrollable scrollHeight="800px" showGridlines
44
selectionMode="single" v-model:selection="selectedPkg" v-model:filters="filters"
55
:globalFilterFields="['user', 'repo', 'pkg', 'description', 'categories', 'os_categories']" removableSort
66
sortMode="multiple" paginator :rows="10" :rowsPerPageOptions="[5, 10, 20, 50, 100, 200, 1000]">
77

88
<template #header>
9-
<div style="display: flex; justify-content: center; ">
10-
<div style="width: 50%">
9+
<div style="display: flex; justify-content: space-between;">
10+
<div>
11+
<MultiSelect v-model="selectedCategories" display="chip" :options="categories" filter :maxSelectedLabels="4"
12+
placeholder="Select Categories" />
13+
</div>
14+
15+
<div style="width: 40%">
1116
<IconField>
1217
<InputIcon>
1318
<i class="pi pi-search" />
1419
</InputIcon>
1520
<InputText style="width: 100%" v-model="filters['global'].value" placeholder="Global Search" />
1621
</IconField>
1722
</div>
23+
1824
</div>
1925
</template>
2026

@@ -26,7 +32,7 @@
2632
<Column sortable field="version" header="Version" style="text-align: center;" />
2733
<Column sortable field="dependencies" header="Depen-dencies" style="text-align: center;" />
2834

29-
<Column sortable field="testcases" header="TestCases" style="text-align: center;" />
35+
<Column sortable field="testcases" header="Test Cases" style="text-align: center;" />
3036

3137
<Column sortable field="tests" header="Tests" style="text-align: center;" />
3238
<Column sortable field="examples" header="Examples" style="text-align: center;" />
@@ -103,6 +109,7 @@
103109
<script setup lang="ts">
104110
import type { Pkg, PkgInfo, Test } from '~/shared/info';
105111
import { FilterMatchMode } from '@primevue/core/api';
112+
import type { Summary } from '~/shared/workflows';
106113
107114
// interactive filter/search inputs
108115
const filters = ref<any>({
@@ -134,7 +141,7 @@ const summaryColumns = [
134141
// { field: "os_categories", header: "OS Categories" },
135142
];
136143
137-
const summaryTable = computed(() => {
144+
const summaryTable = computed<SummaryTable[]>(() => {
138145
const value = summaries.value.map(val => {
139146
return Object.entries(val.pkgs).map(([name, pkg]) => {
140147
return {
@@ -183,7 +190,20 @@ const summaryTable = computed(() => {
183190
});
184191
});
185192
193+
type SummaryTable = { idx: number; user: string; repo: string; pkg: string; version: string; dependencies: number | null; testcases: number | null; tests: number | null; examples: number | null; benches: number | null; author: string[] | null; description: string[]; categories: string[] | null; os_categories: string[] | null; };
194+
const data = ref<SummaryTable[]>([]);
195+
watch(summaryTable, (val) => data.value = val);
196+
197+
const categories = computed(() => [...new Set(summaryTable.value.map(val => val.categories).flat().filter(c => c))].sort());
198+
const selectedCategories = ref<string[]>([]);
199+
watch(selectedCategories, cat => {
200+
if (cat.length === 0) {
201+
data.value = summaryTable.value;
202+
return;
203+
}
186204
205+
data.value = summaryTable.value.filter(val => cat.find(c => val.categories?.find(vc => vc === c)));
206+
});
187207
188208
const dialogShow = ref(false);
189209
const dialogHeader = ref<{ repo: string, repo_url: string, pkg_name: string, pkg: Pkg } | null>();

0 commit comments

Comments
 (0)