@@ -7,7 +7,11 @@ import {
7
7
Switch ,
8
8
TextField ,
9
9
} from "@suid/material" ;
10
- import useViewModel , { SearchTerm , FiltersProps } from "./useViewModel" ;
10
+ import useViewModel , {
11
+ SearchTerm ,
12
+ FiltersProps ,
13
+ GridsRefs ,
14
+ } from "./useViewModel" ;
11
15
import { AgGridSolidRef } from "ag-grid-solid" ;
12
16
import { GridOptions } from "ag-grid-community" ;
13
17
import { Accessor , For , Show } from "solid-js" ;
@@ -26,14 +30,31 @@ const texts = {
26
30
notContains : "Not Contains" ,
27
31
} ;
28
32
33
+ interface GridsOptions {
34
+ msgs : GridOptions < GroupedMsg > ;
35
+ httpCodes : GridOptions < GroupedMsg > ;
36
+ jobs : GridOptions < GroupedMsg > ;
37
+ plugins : GridOptions < GroupedMsg > ;
38
+ added : GridOptions < GroupedMsg > ;
39
+ removed : GridOptions < GroupedMsg > ;
40
+ }
41
+
29
42
function Filters ( props : FiltersProps ) {
30
- let topLogsGridRef = { } as AgGridSolidRef ;
31
- let addedLogsGridRef = { } as AgGridSolidRef ;
32
- let removedLogsGridRef = { } as AgGridSolidRef ;
43
+ const gridsRefs : GridsRefs = {
44
+ msgs : { } as AgGridSolidRef ,
45
+ httpCodes : { } as AgGridSolidRef ,
46
+ jobs : { } as AgGridSolidRef ,
47
+ plugins : { } as AgGridSolidRef ,
48
+ added : { } as AgGridSolidRef ,
49
+ removed : { } as AgGridSolidRef ,
50
+ } ;
33
51
34
- let {
52
+ const {
35
53
filters,
36
- topLogs,
54
+ msgs,
55
+ httpCodes,
56
+ jobs,
57
+ plugins,
37
58
addedLogs,
38
59
removedLogs,
39
60
setFilters,
@@ -63,30 +84,34 @@ function Filters(props: FiltersProps) {
63
84
] ,
64
85
rowSelection : "multiple" ,
65
86
suppressRowClickSelection : true ,
66
- onSelectionChanged : handleLogsSelectionChanged ,
87
+ onSelectionChanged : ( ) => handleLogsSelectionChanged ( gridsRefs ) ,
67
88
getRowStyle : ( params ) =>
68
89
params . data ?. hasErrors ? { background : "#FFBFBF" } : undefined ,
69
90
} ;
70
91
71
- const topLogsGridOptions : GridOptions < GroupedMsg > = {
72
- ...commonGridOptions ,
73
- rowData : topLogs ( ) ,
74
- } ;
75
-
76
- const addedLogsGridOptions : GridOptions < GroupedMsg > = {
77
- ...commonGridOptions ,
78
- rowData : addedLogs ( ) ,
79
- } ;
80
-
81
- const removedLogsGridOptions : GridOptions < GroupedMsg > = {
82
- ...commonGridOptions ,
83
- rowData : removedLogs ( ) ,
84
- columnDefs : [
85
- { ...commonGridOptions . columnDefs ! [ 0 ] , checkboxSelection : undefined } ,
86
- { ...commonGridOptions . columnDefs ! [ 1 ] } ,
87
- ] ,
88
- rowSelection : undefined ,
89
- onSelectionChanged : undefined ,
92
+ const gridsOptions : GridsOptions = {
93
+ msgs : { ...commonGridOptions , rowData : msgs ( ) } ,
94
+ jobs : { ...commonGridOptions , rowData : jobs ( ) } ,
95
+ plugins : { ...commonGridOptions , rowData : plugins ( ) } ,
96
+ added : { ...commonGridOptions , rowData : addedLogs ( ) } ,
97
+ httpCodes : {
98
+ ...commonGridOptions ,
99
+ rowData : httpCodes ( ) ,
100
+ columnDefs : [
101
+ { ...commonGridOptions . columnDefs ! [ 0 ] , flex : 1 } ,
102
+ { ...commonGridOptions . columnDefs ! [ 1 ] , flex : 1 } ,
103
+ ] ,
104
+ } ,
105
+ removed : {
106
+ ...commonGridOptions ,
107
+ rowData : removedLogs ( ) ,
108
+ columnDefs : [
109
+ { ...commonGridOptions . columnDefs ! [ 0 ] , checkboxSelection : undefined } ,
110
+ { ...commonGridOptions . columnDefs ! [ 1 ] } ,
111
+ ] ,
112
+ rowSelection : undefined ,
113
+ onSelectionChanged : undefined ,
114
+ } ,
90
115
} ;
91
116
92
117
function handleEnterKey ( e : KeyboardEvent ) {
@@ -113,7 +138,7 @@ function Filters(props: FiltersProps) {
113
138
}
114
139
/>
115
140
< TextField
116
- label = "value "
141
+ label = "text "
117
142
value = { term . value }
118
143
onChange = { ( _ , val ) => setFilters ( "terms" , i ( ) , "value" , val ) }
119
144
onKeyDown = { handleEnterKey }
@@ -164,7 +189,7 @@ function Filters(props: FiltersProps) {
164
189
< Divider orientation = "vertical" flexItem > </ Divider >
165
190
< Button
166
191
variant = "outlined"
167
- onClick = { ( ) => handleResetClick ( topLogsGridRef , addedLogsGridRef ) }
192
+ onClick = { ( ) => handleResetClick ( gridsRefs ) }
168
193
>
169
194
Reset
170
195
</ Button >
@@ -185,30 +210,51 @@ function Filters(props: FiltersProps) {
185
210
< Grid item xs = { 12 } container spacing = { 2 } >
186
211
< Grid item xs = { 4 } >
187
212
< GroupedMsgGrid
188
- ref = { topLogsGridRef }
213
+ ref = { gridsRefs . msgs }
189
214
name = "Top Logs"
190
- options = { topLogsGridOptions }
215
+ options = { gridsOptions . msgs }
216
+ > </ GroupedMsgGrid >
217
+ </ Grid >
218
+ < Grid item xs = { 2 } >
219
+ < GroupedMsgGrid
220
+ ref = { gridsRefs . httpCodes }
221
+ name = "HTTP Codes"
222
+ options = { gridsOptions . httpCodes }
223
+ > </ GroupedMsgGrid >
224
+ </ Grid >
225
+ < Grid item xs = { 3 } >
226
+ < GroupedMsgGrid
227
+ ref = { gridsRefs . jobs }
228
+ name = "Jobs"
229
+ options = { gridsOptions . jobs }
230
+ > </ GroupedMsgGrid >
231
+ </ Grid >
232
+ < Grid item xs = { 3 } >
233
+ < GroupedMsgGrid
234
+ ref = { gridsRefs . plugins }
235
+ name = "Plugins"
236
+ options = { gridsOptions . plugins }
191
237
> </ GroupedMsgGrid >
192
238
</ Grid >
193
- < Show when = { comparer . isOn ( ) } >
194
- < Grid item xs = { 8 } container spacing = { 2 } >
195
- < Grid item xs = { 6 } >
196
- < GroupedMsgGrid
197
- ref = { addedLogsGridRef }
198
- name = "Added Logs"
199
- options = { addedLogsGridOptions }
200
- > </ GroupedMsgGrid >
201
- </ Grid >
202
- < Grid item xs = { 6 } >
203
- < GroupedMsgGrid
204
- ref = { removedLogsGridRef }
205
- name = "Removed Logs"
206
- options = { removedLogsGridOptions }
207
- > </ GroupedMsgGrid >
208
- </ Grid >
209
- </ Grid >
210
- </ Show >
211
239
</ Grid >
240
+ < Show when = { comparer . isOn ( ) } >
241
+ < Grid item xs = { 12 } container spacing = { 2 } >
242
+ < Grid item xs = { 6 } >
243
+ < GroupedMsgGrid
244
+ ref = { gridsRefs . added }
245
+ name = "Added Logs"
246
+ options = { gridsOptions . added }
247
+ > </ GroupedMsgGrid >
248
+ </ Grid >
249
+ < Grid item xs = { 6 } >
250
+ < GroupedMsgGrid
251
+ ref = { gridsRefs . removed }
252
+ name = "Removed Logs"
253
+ options = { gridsOptions . removed }
254
+ > </ GroupedMsgGrid >
255
+ </ Grid >
256
+ </ Grid >
257
+ </ Show >
212
258
</ Grid >
213
259
) ;
214
260
}
0 commit comments