2121 <MultiSelect v-model =" selected.kinds" display =" chip" :options =" kinds" filter :maxSelectedLabels =" 4"
2222 placeholder =" Select Crate Kinds" />
2323
24- <MultiSelect v-model =" selected.displays " display =" chip" :options =" displays " filter :maxSelectedLabels = " 4 "
25- placeholder =" Select Columns" />
24+ <MultiSelect v-model =" selected.columns " display =" chip" :options =" columns " :optionLabel = " o => C.option(o) " filter
25+ :maxSelectedLabels = " 4 " placeholder =" Select Columns" />
2626 </div >
2727
2828 <div >
4848
4949 <Column frozen sortable field =" pkg" header =" Package" style =" min-width : 200px ;" />
5050
51- <Column sortable field =" version" header =" Version " style = " text-align : center ; " />
52- < Column sortable v-if = " display.digits " field = " lib " header = " Lib " style =" text-align : center ;" />
53- < Column sortable v-if = " display.digits " field = " bin " header = " Bin " style = " text-align : center ; " />
54- <Column sortable v-if =" display.digits " field =" dependencies " header =" Depen-dencies " style = " text-align : center ; " />
55- < Column sortable field = " release_count " header = " crates.io Releases " style =" text-align : center ;" >
51+ <Column v-if = " C.display('version') " sortable field =" version" : header =" C.name('version') "
52+ style =" text-align : center ;" />
53+
54+ <Column v-if =" C.display('release_count') " sortable field =" release_count " : header =" C.name('release_count') "
55+ style =" text-align : center ;" >
5656 <template #body =" { data } " >
5757 <NuxtLink :to =" `https://crates.io/crates/${data.pkg}`" target =" _blank" class =" nav-link" >
5858 {{ data.release_count }}
5959 </NuxtLink >
6060 </template >
6161 </Column >
6262
63- <Column sortable field =" diag_total_count" header =" Diag-nostics" style =" text-align : center ;" >
63+ <Column v-if =" C.display('diag_total_count')" sortable field =" diag_total_count"
64+ :header =" C.name('diag_total_count')" style =" text-align : center ;" >
6465 <template #body =" { data } " >
6566 <NuxtLink :to =" `/${data.user}/${data.repo}`" target =" _blank" class =" nav-link" >
6667 {{ data.diag_total_count }}
6768 </NuxtLink >
6869 </template >
6970 </Column >
7071
71-
72- <Column sortable v-if =" display.digits" field =" testcases" header =" Test Cases"
72+ <Column v-if =" C.display('testcases')" sortable field =" testcases" :header =" C.name('testcases')"
7373 style =" text-align : center ; font-weight : bold " >
7474 <template #body =" { data } " >
7575 <span :style =" { color: data.testcases_color }" >
7878 </template >
7979 </Column >
8080
81- <Column sortable v-if =" display.digits" field =" tests" header =" Tests" style =" text-align : center ;" />
82- <Column sortable v-if =" display.digits" field =" examples" header =" Examples" style =" text-align : center ;" />
83- <Column sortable v-if =" display.digits" field =" benches" header =" Benches" style =" text-align : center ;" />
81+ <Column v-if =" C.display('lib')" sortable field =" lib" :header =" C.name('lib')" style =" text-align : center ;" />
82+ <Column v-if =" C.display('bin')" sortable field =" bin" :header =" C.name('bin')" style =" text-align : center ;" />
83+ <Column v-if =" C.display('dependencies')" sortable field =" dependencies" :header =" C.name('dependencies')"
84+ style =" text-align : center ;" />
85+
86+ <Column v-if =" C.display('tests')" sortable field =" tests" :header =" C.name('tests')" style =" text-align : center ;" />
87+ <Column v-if =" C.display('examples')" sortable field =" examples" :header =" C.name('examples')"
88+ style =" text-align : center ;" />
89+ <Column v-if =" C.display('benches')" sortable field =" benches" :header =" C.name('benches')"
90+ style =" text-align : center ;" />
8491
85- <Column v-if =" display.links" field =" documentation" header =" Doc" style =" text-align : center ;" >
92+ <Column v-if =" C.display('documentation')" field =" documentation" :header =" C.name('documentation')"
93+ style =" text-align : center ;" >
8694 <template #body =" { data } " >
8795 <NuxtLink v-if =" data.documentation" :to =" data.documentation" target =" _blank" class =" nav-link" >
88- <Button icon =" pi pi-external-link" link />
96+ link
97+ <!-- <Button icon="pi pi-external-link" link /> -->
8998 </NuxtLink >
9099 </template >
91100 </Column >
92101
93- <Column v-if =" display.links" field =" latest_doc" header =" Latest Doc" style =" text-align : center ;" >
102+ <Column v-if =" C.display('latest_doc')" field =" latest_doc" :header =" C.name('latest_doc')"
103+ style =" text-align : center ;" >
94104 <template #body =" { data } " >
95105 <NuxtLink v-if =" data.latest_doc" :to =" data.latest_doc" target =" _blank" class =" nav-link" >
96- <Button icon =" pi pi-external-link" link />
106+ link
107+ <!-- <Button icon="pi pi-external-link" link /> -->
97108 </NuxtLink >
98109 </template >
99110 </Column >
100111
101- <Column v-if =" display.links " field =" homepage" header =" Home Page " style =" text-align : center ;" >
112+ <Column v-if =" C.display('homepage') " field =" homepage" : header =" C.name('homepage') " style =" text-align : center ;" >
102113 <template #body =" { data } " >
103114 <NuxtLink v-if =" data.homepage" :to =" data.homepage" target =" _blank" class =" nav-link" >
104- <Button icon =" pi pi-external-link" link />
115+ link
116+ <!-- <Button icon="pi pi-external-link" link /> -->
105117 </NuxtLink >
106118 </template >
107119 </Column >
108120
109- <Column v-if =" display.texts" sortable field =" categories" header =" Categories" style =" min-width : 200px ;" >
121+ <Column v-if =" C.display('categories')" sortable field =" categories" :header =" C.name('categories')"
122+ style =" min-width : 200px ;" >
110123 <template #body =" { data: { categories } } " >
111124 <div v-for =" tag of categories" >
112125 <Tag severity =" warn" :value =" tag" style =" margin-bottom : 5px ;" ></Tag >
113126 </div >
114127 </template >
115128 </Column >
116129
117- <Column v-if =" display.texts" sortable field =" keywords" header =" KeyWords" style =" min-width : 150px ;" >
130+ <Column v-if =" C.display('keywords')" sortable field =" keywords" :header =" C.name('keywords')"
131+ style =" min-width : 150px ;" >
118132 <template #body =" { data: { keywords } } " >
119133 <div v-for =" tag of keywords" >
120134 <Tag severity =" warn" :value =" tag" style =" margin-bottom : 5px ;" ></Tag >
121135 </div >
122136 </template >
123137 </Column >
124138
125- <Column v-if =" display.texts" field =" description" header =" Description" style =" min-width : 280px ;" />
139+ <Column v-if =" C.display('description')" field =" description" :header =" C.name('description')"
140+ style =" min-width : 280px ;" />
126141
127- <Column v-if =" display.texts" sortable field =" authors" header =" Authors" style =" min-width : 300px ;" >
142+ <Column v-if =" C.display('authors')" sortable field =" authors" :header =" C.name('authors')"
143+ style =" min-width : 300px ;" >
128144 <template #body =" { data: { authors } } " >
129145 <div v-for =" tag of authors" >
130146 <Tag severity =" info" :value =" tag" style =" margin-bottom : 5px ;" ></Tag >
212228
213229<script setup lang="ts">
214230import type { Pkg , PkgInfo , Test } from ' ~/shared/info' ;
215- import { unique_field , unique_field_bool } from ' ~/shared/info' ;
231+ import { unique_field , unique_field_bool , InfoCols } from ' ~/shared/info' ;
216232import { FilterMatchMode } from ' @primevue/core/api' ;
217233import type { DataTableSortMeta } from ' primevue/datatable' ;
218234
@@ -221,8 +237,6 @@ const tableHeight = computed(() => `${Math.round(viewportHeight.value * 0.8)}px`
221237
222238const summaries = ref <PkgInfo []>([]);
223239
224- const display = reactive <{ digits: boolean , links: boolean , texts: boolean }>({ digits: true , links: false , texts: false });
225-
226240githubFetch <PkgInfo []>({
227241 path: " plugin/cargo/info/summaries.json"
228242}).then (val => {
@@ -256,25 +270,24 @@ const summaryTable = computed<SummaryTable[]>(() => {
256270 repo: val .repo ,
257271 pkg: name ,
258272 version: pkg .version ,
273+ release_count: pkg .release_count ,
274+ diag_total_count: pkg .diag_total_count ,
275+ testcases: pkg .testcases ?.pkg_tests_count ?? null ,
276+ testcases_color ,
259277 lib: pkg .lib ? " ✅" : null ,
260278 bin: pkg .bin ? " ✅" : null ,
261279 dependencies: pkg .dependencies || null ,
262- testcases: pkg .testcases ?.pkg_tests_count ?? null ,
263- testcases_color ,
264280 tests: pkg .tests || null ,
265281 examples: pkg .examples || null ,
266282 benches: pkg .benches || null ,
267- authors: pkg .authors .length === 0 ? null : pkg .authors ,
268- description: pkg .description ,
269- keywords: pkg .keywords .length === 0 ? null : pkg .keywords ,
270- categories: pkg .categories .length === 0 ? null : pkg .categories ,
271- // os_categories: pkg.os_categories.length === 0 ? null : pkg.os_categories,
272283 documentation: pkg .documentation ,
284+ latest_doc: docs .value ?.[val .user ]?.[val .repo ]?.[name ] ?? null ,
273285 readme: pkg .readme ,
274286 homepage: pkg .homepage ,
275- latest_doc: docs .value ?.[val .user ]?.[val .repo ]?.[name ] ?? null ,
276- diag_total_count: pkg .diag_total_count ,
277- release_count: pkg .release_count ,
287+ categories: pkg .categories .length === 0 ? null : pkg .categories ,
288+ keywords: pkg .keywords .length === 0 ? null : pkg .keywords ,
289+ description: pkg .description ,
290+ authors: pkg .authors .length === 0 ? null : pkg .authors ,
278291 }
279292 })
280293 }).flat ();
@@ -338,38 +351,30 @@ const kinds = computed(() => {
338351 if (is_benches ) { arr .push (" Benches" ); }
339352 return arr ;
340353});
341- const displays = computed (() => Object .keys (display ));
354+
355+ const C = reactive (InfoCols .init ());
356+ C .setDefaultColumns ();
357+ const columns = C .options ();
342358
343359const selected = reactive <{
344360 categories: string [],
345361 keywords: string [],
346362 authors: string [],
347363 kinds: string [],
348364 text: any ,
349- displays : string [],
365+ columns : string [],
350366 sorts: DataTableSortMeta [],
351367}>({
352368 categories: [], keywords: [], authors: [], kinds: [],
353369 // interactive filter/search inputs
354370 text: { global: { value: null , matchMode: FilterMatchMode .CONTAINS }, },
355371 // columns to be displayed
356- displays : [],
372+ columns : [],
357373 sorts: [],
358374});
359375
360- watch (() => selected .displays , (disp ) => {
361- if (disp .length === 0 ) {
362- // @ts-ignore
363- // Object.keys(display).map(k => display[k] = true);
364- display .digits = true ;
365- display .links = false ;
366- display .texts = false ;
367- return ;
368- }
369-
370- const set = new Set (disp );
371- // @ts-ignore
372- Object .keys (display ).map (k => display [k ] = set .has (k ));
376+ watch (() => selected .columns , (cols ) => {
377+ C .setDisplay (cols );
373378});
374379
375380watchEffect (() => {
@@ -462,31 +467,27 @@ function updateFilter(query: {
462467 authors? : string ,
463468 kinds? : string ,
464469 text? : string ,
465- displays ? : string ,
470+ columns ? : string ,
466471 sorts? : string ,
467472}) {
468- if (query .categories ) { selected .categories = decodeURIComponent (query .categories ).split (" ," ); }
469- if (query .keywords ) { selected .keywords = decodeURIComponent (query .keywords ).split (" ," ); }
470- if (query .authors ) { selected .authors = decodeURIComponent (query .authors ).split (" ," ); }
473+ const { categories, keywords, authors, kinds, text, columns, sorts } = query ;
474+
475+ if (categories ) { selected .categories = decodeURIComponent (categories ).split (" ," ); }
476+ if (keywords ) { selected .keywords = decodeURIComponent (keywords ).split (" ," ); }
477+ if (authors ) { selected .authors = decodeURIComponent (authors ).split (" ," ); }
471478
472- if (query . kinds ) {
479+ if (kinds ) {
473480 const filter = new Set ([
474481 " Lib" , " Bin" , " TestCases" , " Tests" , " Examples" , " Benches"
475482 ]);
476- selected .kinds = decodeURIComponent (query . kinds ).split (" ," ).filter (k => filter .has (k ));
483+ selected .kinds = decodeURIComponent (kinds ).split (" ," ).filter (k => filter .has (k ));
477484 }
478485
479- if (query .text ) {
480- selected .text .global .value = decodeURIComponent (query .text );
481- }
486+ if (text ) { selected .text .global .value = decodeURIComponent (text ); }
487+ if (columns ) { selected .columns = decodeURIComponent (columns ).split (" ," ); }
482488
483- if (query .displays ) {
484- const filter = new Set (displays .value );
485- selected .displays = decodeURIComponent (query .displays ).split (" ," ).filter (k => filter .has (k ));
486- }
487-
488- if (query .sorts ) {
489- const args = decodeURIComponent (query .sorts ).split (" ," );
489+ if (sorts ) {
490+ const args = decodeURIComponent (sorts ).split (" ," );
490491 // @ts-ignore
491492 selected .sorts = args .map (arg => {
492493 let [field, order] = arg .split (" =" );
@@ -498,29 +499,22 @@ updateFilter(route.query);
498499
499500const router = useRouter ();
500501watchEffect (() => {
501- const { categories, keywords, authors, kinds, text, displays , sorts } = selected ;
502+ const { categories, keywords, authors, kinds, text, columns , sorts } = selected ;
502503
503504 let query: any = {};
504505
505- if (categories .length !== 0 ) {
506- query .categories = encodeURIComponent (categories .join (" ," ));
507- }
508- if (keywords .length !== 0 ) {
509- query .keywords = encodeURIComponent (keywords .join (" ," ));
510- }
506+ if (categories .length !== 0 ) { query .categories = encodeURIComponent (categories .join (" ," )); }
507+ if (keywords .length !== 0 ) { query .keywords = encodeURIComponent (keywords .join (" ," )); }
508+
511509 if (authors .length !== 0 ) {
512510 // FIXME: what if author string contains `,`
513511 query .authors = encodeURIComponent (authors .join (" ," ));
514512 }
515- if (kinds .length !== 0 ) {
516- query .kinds = encodeURIComponent (kinds .join (" ," ));
517- }
518- if (text .global .value ) {
519- query .text = encodeURIComponent (text .global .value );
520- }
521- if (displays .length !== 0 ) {
522- query .displays = encodeURIComponent (displays .join (" ," ));
523- }
513+
514+ if (kinds .length !== 0 ) { query .kinds = encodeURIComponent (kinds .join (" ," )); }
515+ if (text .global .value ) { query .text = encodeURIComponent (text .global .value ); }
516+ if (columns .length !== 0 ) { query .columns = encodeURIComponent (columns .join (" ," )); }
517+
524518 if (sorts .length !== 0 ) {
525519 const args = sorts .map (({ field , order }) => order ? ` ${field }=${order } ` : null );
526520 query .sorts = encodeURIComponent (args .filter (x => x ).join (" ," ));
0 commit comments