44 :headers =" headers"
55 :data =" filteredTables"
66 v-model:filter =" filter"
7- show_filter =" true" >
7+ show_filter =" true"
8+ @selectItem =" onSelectItem" >
89 </data-table >
910 </div >
1011</template >
@@ -21,34 +22,43 @@ const props = defineProps({
2122});
2223
2324const filter = ref (" " );
25+ const group = ref (null );
2426
2527const headers = computed (() => {
28+ let IdHeader = " ID" ;
29+ if (group .value ) {
30+ IdHeader = " Count" ;
31+ }
2632 return [
27- {name: " ID " , schema: [" table-id" ], get : (table ) => table .id },
33+ {name: IdHeader , schema: [" table-id" ], get : (table ) => table .id },
2834 {name: " Entities" , schema: [" int" ], totals: true , get : (table ) => table .count },
2935 {name: " Capacity" , schema: [" int" ], totals: true , get : (table ) => table .size },
3036 {name: " Columns" , schema: [" int" ], get : (table ) => table .type .length },
3137 {name: " Memory (KB)" , schema: [" float" ], totals: true , get : (table ) => {
3238 if (! table .memory ) {
3339 return 0 ;
3440 }
41+ if (typeof table .memory === " number" ) {
42+ return table .memory / 1000 ;
43+ }
3544 return ((explorer .calculateMemoryTotal (table .memory .table ) +
3645 explorer .calculateMemoryTotal (table .memory .components )) / 1000 );
3746 }},
38- {name: " Components" , schema : [ " table-type " ], get : (table ) => formatType (table .type )},
47+ {name: " Components" , list : true , get : (table ) => formatType (table .type )},
3948 ];
4049});
4150
4251const searchableType = computed (() => {
4352 return props .tables .map ((table ) => {
44- return formatType (table .type ).toLowerCase ( ).split (" " ).join (" " );
53+ return formatType (table .type ).join ( " " ).split (" " ).join (" " ). toLowerCase ( );
4554 });
4655});
4756
4857const filteredTables = computed (() => {
58+ let tables = props .tables ;
4959 if (filter .value && filter .value .length > 0 ) {
5060 const F = filter .value .toLowerCase ().split (" " ).join (" " ).split (" ," );
51- return props . tables .filter ((table , index ) => {
61+ tables = tables .filter ((table , index ) => {
5262 const v = searchableType .value [index];
5363 for (let f of F ) {
5464 if (! v .includes (f)) {
@@ -58,7 +68,37 @@ const filteredTables = computed(() => {
5868 return true ;
5969 });
6070 }
61- return props .tables ;
71+
72+ if (group .value ) {
73+ // create map for group strings
74+ let groups = {};
75+
76+ for (let table of tables) {
77+ for (let i = 0 ; i < table .type .length ; i++ ) {
78+ const id = table .type [i];
79+ if (id .includes (group .value )) {
80+ let copy = table .type .slice ();
81+ copy[i] = " (" + group .value + " ," + " *)" ;
82+
83+ const key = copy .join (" , " );
84+ let val = groups[key];
85+ if (! val) {
86+ val = groups[key] = {id: 0 , count: 0 , size: 0 , memory: 0 , type: copy};
87+ }
88+ val .id ++ ;
89+ val .count += table .count ;
90+ val .size += table .size ;
91+ val .memory += explorer .calculateMemoryTotal (table .memory .table );
92+ val .memory += explorer .calculateMemoryTotal (table .memory .components );
93+ break ;
94+ }
95+ }
96+ }
97+
98+ tables = Object .values (groups);
99+ }
100+
101+ return tables;
62102});
63103
64104function formatType (type ) {
@@ -69,7 +109,21 @@ function formatType(type) {
69109 result .push (str);
70110 }
71111
72- return result .join (" , " );;
112+ return result;
113+ }
114+
115+ function onSelectItem (evt ) {
116+ const pair = explorer .parsePair (evt .item );
117+ if (! pair) {
118+ return ;
119+ }
120+
121+ if (pair[1 ] === " *" ) {
122+ group .value = undefined ;
123+ return ;
124+ }
125+
126+ group .value = pair[0 ];
73127}
74128
75129 </script >
0 commit comments