@@ -11,11 +11,10 @@ const DEFAULT_PIVOT_CONFIG: PivotConfig = {
1111 selectedColumnFields : [ "$.input_metadata.completion_params.model" ] ,
1212 selectedValueField : "$.evaluation_result.score" ,
1313 selectedAggregator : "avg" ,
14- filters : [ ] ,
1514} ;
1615
17- // Default table filter configuration
18- const DEFAULT_TABLE_FILTER_CONFIG : FilterGroup [ ] = [ ] ;
16+ // Default filter configuration
17+ const DEFAULT_FILTER_CONFIG : FilterGroup [ ] = [ ] ;
1918
2019// Default pagination configuration
2120const DEFAULT_PAGINATION_CONFIG = {
@@ -31,10 +30,10 @@ export class GlobalState {
3130 expandedRows : Record < string , boolean > = { } ;
3231 // Pivot configuration
3332 pivotConfig : PivotConfig ;
34- // Table filter configuration
35- tableFilterConfig : FilterGroup [ ] ;
36- // Debounced, actually applied table filter configuration (for performance while typing)
37- appliedTableFilterConfig : FilterGroup [ ] ;
33+ // Unified filter configuration for both pivot and table views
34+ filterConfig : FilterGroup [ ] ;
35+ // Debounced, actually applied filter configuration (for performance while typing)
36+ appliedFilterConfig : FilterGroup [ ] ;
3837 // Pagination configuration
3938 currentPage : number ;
4039 pageSize : number ;
@@ -49,19 +48,18 @@ export class GlobalState {
4948
5049 // Debounce timers for localStorage saves and filter application
5150 private savePivotConfigTimer : ReturnType < typeof setTimeout > | null = null ;
52- private saveTableFilterConfigTimer : ReturnType < typeof setTimeout > | null =
53- null ;
51+ private saveFilterConfigTimer : ReturnType < typeof setTimeout > | null = null ;
5452 private savePaginationConfigTimer : ReturnType < typeof setTimeout > | null =
5553 null ;
56- private applyTableFilterTimer : ReturnType < typeof setTimeout > | null = null ;
54+ private applyFilterTimer : ReturnType < typeof setTimeout > | null = null ;
5755
5856 constructor ( ) {
5957 // Load pivot config from localStorage or use defaults
6058 this . pivotConfig = this . loadPivotConfig ( ) ;
61- // Load table filter config from localStorage or use defaults
62- this . tableFilterConfig = this . loadTableFilterConfig ( ) ;
59+ // Load filter config from localStorage or use defaults
60+ this . filterConfig = this . loadFilterConfig ( ) ;
6361 // Initialize applied filter config with current value
64- this . appliedTableFilterConfig = this . tableFilterConfig . slice ( ) ;
62+ this . appliedFilterConfig = this . filterConfig . slice ( ) ;
6563 // Load pagination config from localStorage or use defaults
6664 const paginationConfig = this . loadPaginationConfig ( ) ;
6765 this . currentPage = paginationConfig . currentPage ;
@@ -84,21 +82,18 @@ export class GlobalState {
8482 return { ...DEFAULT_PIVOT_CONFIG } ;
8583 }
8684
87- // Load table filter configuration from localStorage
88- private loadTableFilterConfig ( ) : FilterGroup [ ] {
85+ // Load filter configuration from localStorage
86+ private loadFilterConfig ( ) : FilterGroup [ ] {
8987 try {
90- const stored = localStorage . getItem ( "tableFilterConfig " ) ;
88+ const stored = localStorage . getItem ( "filterConfig " ) ;
9189 if ( stored ) {
9290 const parsed = JSON . parse ( stored ) ;
93- return Array . isArray ( parsed ) ? parsed : DEFAULT_TABLE_FILTER_CONFIG ;
91+ return Array . isArray ( parsed ) ? parsed : DEFAULT_FILTER_CONFIG ;
9492 }
9593 } catch ( error ) {
96- console . warn (
97- "Failed to load table filter config from localStorage:" ,
98- error
99- ) ;
94+ console . warn ( "Failed to load filter config from localStorage:" , error ) ;
10095 }
101- return DEFAULT_TABLE_FILTER_CONFIG ;
96+ return DEFAULT_FILTER_CONFIG ;
10297 }
10398
10499 // Load pagination configuration from localStorage
@@ -116,7 +111,7 @@ export class GlobalState {
116111 error
117112 ) ;
118113 }
119- return { ... DEFAULT_PAGINATION_CONFIG } ;
114+ return DEFAULT_PAGINATION_CONFIG ;
120115 }
121116
122117 // Save pivot configuration to localStorage
@@ -131,21 +126,14 @@ export class GlobalState {
131126 } , 200 ) ;
132127 }
133128
134- // Save table filter configuration to localStorage
135- private saveTableFilterConfig ( ) {
136- if ( this . saveTableFilterConfigTimer )
137- clearTimeout ( this . saveTableFilterConfigTimer ) ;
138- this . saveTableFilterConfigTimer = setTimeout ( ( ) => {
129+ // Save filter configuration to localStorage
130+ private saveFilterConfig ( ) {
131+ if ( this . saveFilterConfigTimer ) clearTimeout ( this . saveFilterConfigTimer ) ;
132+ this . saveFilterConfigTimer = setTimeout ( ( ) => {
139133 try {
140- localStorage . setItem (
141- "tableFilterConfig" ,
142- JSON . stringify ( this . tableFilterConfig )
143- ) ;
134+ localStorage . setItem ( "filterConfig" , JSON . stringify ( this . filterConfig ) ) ;
144135 } catch ( error ) {
145- console . warn (
146- "Failed to save table filter config to localStorage:" ,
147- error
148- ) ;
136+ console . warn ( "Failed to save filter config to localStorage:" , error ) ;
149137 }
150138 } , 200 ) ;
151139 }
@@ -178,15 +166,15 @@ export class GlobalState {
178166 this . savePivotConfig ( ) ;
179167 }
180168
181- // Update table filter configuration and save to localStorage
182- updateTableFilterConfig ( filters : FilterGroup [ ] ) {
183- this . tableFilterConfig = filters ;
184- this . saveTableFilterConfig ( ) ;
169+ // Update filter configuration and save to localStorage
170+ updateFilterConfig ( filters : FilterGroup [ ] ) {
171+ this . filterConfig = filters ;
172+ this . saveFilterConfig ( ) ;
185173
186174 // Debounce application of filters to avoid re-filtering on every keystroke
187- if ( this . applyTableFilterTimer ) clearTimeout ( this . applyTableFilterTimer ) ;
188- this . applyTableFilterTimer = setTimeout ( ( ) => {
189- this . appliedTableFilterConfig = this . tableFilterConfig . slice ( ) ;
175+ if ( this . applyFilterTimer ) clearTimeout ( this . applyFilterTimer ) ;
176+ this . applyFilterTimer = setTimeout ( ( ) => {
177+ this . appliedFilterConfig = this . filterConfig . slice ( ) ;
190178 } , 150 ) ;
191179 }
192180
@@ -205,18 +193,15 @@ export class GlobalState {
205193
206194 // Reset pivot configuration to defaults
207195 resetPivotConfig ( ) {
208- this . pivotConfig = {
209- ...DEFAULT_PIVOT_CONFIG ,
210- filters : [ ] , // Ensure filters is an empty array of FilterGroups
211- } ;
196+ this . pivotConfig = { ...DEFAULT_PIVOT_CONFIG } ;
212197 this . savePivotConfig ( ) ;
213198 }
214199
215- // Reset table filter configuration to defaults
216- resetTableFilterConfig ( ) {
217- this . tableFilterConfig = [ ...DEFAULT_TABLE_FILTER_CONFIG ] ;
218- this . appliedTableFilterConfig = [ ...DEFAULT_TABLE_FILTER_CONFIG ] ;
219- this . saveTableFilterConfig ( ) ;
200+ // Reset filter configuration to defaults
201+ resetFilterConfig ( ) {
202+ this . filterConfig = [ ...DEFAULT_FILTER_CONFIG ] ;
203+ this . appliedFilterConfig = [ ...DEFAULT_FILTER_CONFIG ] ;
204+ this . saveFilterConfig ( ) ;
220205 }
221206
222207 // Reset pagination configuration to defaults
@@ -315,20 +300,20 @@ export class GlobalState {
315300 }
316301
317302 get filteredFlattenedDataset ( ) {
318- if ( this . appliedTableFilterConfig . length === 0 ) {
303+ if ( this . appliedFilterConfig . length === 0 ) {
319304 return this . flattenedDataset ;
320305 }
321306
322- const filterFunction = createFilterFunction ( this . appliedTableFilterConfig ) ! ;
307+ const filterFunction = createFilterFunction ( this . appliedFilterConfig ) ! ;
323308 return this . flattenedDataset . filter ( filterFunction ) ;
324309 }
325310
326311 get filteredOriginalDataset ( ) {
327- if ( this . appliedTableFilterConfig . length === 0 ) {
312+ if ( this . appliedFilterConfig . length === 0 ) {
328313 return this . sortedDataset ;
329314 }
330315
331- const filterFunction = createFilterFunction ( this . appliedTableFilterConfig ) ! ;
316+ const filterFunction = createFilterFunction ( this . appliedFilterConfig ) ! ;
332317 return this . sortedIds
333318 . filter ( ( id ) => filterFunction ( this . flattenedById [ id ] ) )
334319 . map ( ( id ) => this . dataset [ id ] ) ;
0 commit comments