66 let tableComponent: HTMLDivElement ;
77 let table: Tabulator ;
88 let printData: any [] = [];
9+ let originalData: any [] = []; // Keep original
910
10- onMount (() => {
11- printData = allResults .map ((r ) => ({ ... r }));
11+ // Update when allResults changes
12+ $ : if (allResults ) {
13+ originalData = allResults .map (r => ({ ... r }));
14+ printData = originalData ;
15+ if (table ) table .setData (originalData );
16+ }
1217
18+ onMount (() => {
1319 table = new Tabulator (tableComponent , {
14- data: allResults ,
15- reactiveData: true ,
20+ data: [] ,
21+ reactiveData: false ,
1622 layout: " fitColumns" ,
1723 groupBy: [" ruleLabel" ],
1824 groupHeader : (value , count , data ) => {
2127 },
2228 columns: [
2329 { title: " #" , formatter: " rownum" , width: 75 },
24- { title: " Name" , field: " name" , minWidth: 150 },
25- { title: " Severity" , field: " severity" , minWidth: 150 },
26- { title: " Type" , field: " type" , width: 150 },
27- {
28- title: " Flow name" ,
29- field: " flowName" ,
30- minWidth: 150 ,
31- headerFilter: true ,
32- headerFilterPlaceholder: " " ,
30+ {
31+ title: " Name" , field: " name" , minWidth: 150 ,
32+ headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " "
33+ },
34+ {
35+ title: " Severity" , field: " severity" , minWidth: 150 ,
36+ headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " "
3337 },
34- { title: " X" , field: " locationX" , width: 75 },
35- { title: " Y" , field: " locationY" , width: 75 },
36- { title: " Connects to" , field: " connectsTo" , minWidth: 150 },
37- { title: " Expression" , field: " expression" , minWidth: 150 },
38- { title: " DataType" , field: " dataType" , width: 150 },
38+ {
39+ title: " Type" , field: " type" , width: 150 ,
40+ headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " "
41+ },
42+ {
43+ title: " Flow name" , field: " flowName" , minWidth: 150 ,
44+ headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " "
45+ },
46+ { title: " X" , field: " locationX" , width: 75 , headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " " },
47+ { title: " Y" , field: " locationY" , width: 75 , headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " " },
48+ { title: " Connects to" , field: " connectsTo" , minWidth: 150 , headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " " },
49+ { title: " Expression" , field: " expression" , minWidth: 150 , headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " " },
50+ { title: " DataType" , field: " dataType" , width: 150 , headerFilter: " input" , headerFilterFunc: " like" , headerFilterPlaceholder: " " },
3951 ],
4052 });
4153 });
4658
4759 function onMessage(e : MessageEvent ) {
4860 const msg = e .data ;
61+
4962 if (msg .type === " applySearchFlowName" ) {
50- const term = (msg .value ?? " " ).trim ();
51- if (! term ) {
52- table ?.clearHeaderFilter ();
53- return ;
54- }
55- table ?.setHeaderFilterValue (" flowName" , term );
63+ const term = (msg .value ?? " " ).toString ().trim ();
64+ applyFlowFilter (term );
65+ return ;
5666 }
67+
5768 if (msg .type === " applySearchAttributes" ) {
58- const term = (msg .value ?? " " ).trim ();
69+ const term = (msg .value ?? " " ).toString ().trim ();
70+ applyAttributeFilter (term );
71+ }
72+ }
5973
60- if (! term ) {
61- table ?.clearHeaderFilter ([" resultCount" , " type" ]);
62- return ;
63- }
74+ // === FLOW NAME FILTER ===
75+ function applyFlowFilter(term : string ) {
76+ if (! term ) {
77+ table ?.setData (originalData );
78+ return ;
79+ }
80+ const filtered = originalData .filter (row =>
81+ row .flowName ?.toString ().toLowerCase ().includes (term .toLowerCase ())
82+ );
83+ table ?.setData (filtered );
84+ }
6485
65- // Option 1: Use built-in OR via custom filter
66- table ?.setFilter (
67- [
68- { field: " resultCount" , type: " like" , value: term },
69- { field: " type" , type: " like" , value: term },
70- ],
71- " or"
72- );
86+ // === ATTRIBUTES FILTER ===
87+ function applyAttributeFilter(term : string ) {
88+ if (! term ) {
89+ table ?.setData (originalData );
7390 return ;
7491 }
92+ const filtered = originalData .filter (row => {
93+ return [
94+ row .name , row .severity , row .type ,
95+ row .locationX , row .locationY ,
96+ row .connectsTo , row .expression , row .dataType
97+ ].some (val => val ?.toString ().toLowerCase ().includes (term .toLowerCase ()));
98+ });
99+ table ?.setData (filtered );
75100 }
76101 </script >
77102
78103<svelte:window on:message ={onMessage } />
79- <div bind:this ={tableComponent } class =" tabulator-table" />
104+ <div bind:this ={tableComponent } class =" tabulator-table" />
0 commit comments