3
3
<n-tabs type =" segment" animated @update:value =" refresh" >
4
4
<n-tab-pane name =" indices" tab =" INDICES" >
5
5
<n-data-table
6
- :columns =" indexTable.columns"
6
+ :columns =" indexTable.columns as any "
7
7
:data =" indexTable.data"
8
8
:bordered =" false"
9
9
max-height =" 400"
10
10
/>
11
11
</n-tab-pane >
12
12
<n-tab-pane name =" templates" tab =" TEMPLATES" >
13
13
<n-data-table
14
- :columns =" templateTable.columns"
14
+ :columns =" templateTable.columns as any "
15
15
:data =" templateTable.data"
16
16
:bordered =" false"
17
17
max-height =" 400"
@@ -99,7 +99,7 @@ const aliasDialogRef = ref();
99
99
const templateDialogRef = ref ();
100
100
const switchAliasDialogRef = ref ();
101
101
102
- const filtersRef = ref <{ [key : string ]: string }>({
102
+ const filterState = ref <{ [key : string ]: string }>({
103
103
index: ' ' ,
104
104
uuid: ' ' ,
105
105
health: ' ' ,
@@ -109,14 +109,14 @@ const filtersRef = ref<{ [key: string]: string }>({
109
109
});
110
110
111
111
const handleFilter = (key : string , value : string ) => {
112
- filtersRef .value [key ] = value ;
112
+ filterState .value [key ] = value ;
113
113
};
114
114
115
115
const filterProps = (key : string ) => ({
116
116
filter: true ,
117
117
renderFilterMenu(_ : { hide: () => void }) {
118
118
return h (NInput , {
119
- value: filtersRef .value [key ],
119
+ value: filterState .value [key ],
120
120
placeholder: ` type to filter ${key } ` ,
121
121
clearable: true ,
122
122
size: ' small' ,
@@ -125,7 +125,11 @@ const filterProps = (key: string) => ({
125
125
});
126
126
},
127
127
renderFilterIcon() {
128
- return h (NIcon , {}, { default : () => h (Search ) });
128
+ return h (
129
+ NIcon ,
130
+ { color: filterState .value [key ] ? ' var(--theme-color)' : ' var(--n-text-color)' },
131
+ { default : () => h (Search ) },
132
+ );
129
133
},
130
134
});
131
135
@@ -136,21 +140,54 @@ const indexTable = computed(() => {
136
140
dataIndex: ' index' ,
137
141
key: ' index' ,
138
142
... filterProps (' index' ),
143
+ sorter: ' default' ,
139
144
},
140
- { title: ' UUID' , dataIndex: ' uuid' , key: ' uuid' , ... filterProps (' uuid' ) },
145
+ { title: ' UUID' , dataIndex: ' uuid' , key: ' uuid' , ... filterProps (' uuid' ), sorter: ' default ' },
141
146
{
142
147
title: ' health' ,
143
148
dataIndex: ' health' ,
144
149
key: ' health' ,
145
150
... filterProps (' health' ),
151
+ sorter: ' default' ,
146
152
render({ health }: { health: IndexHealth }) {
147
153
return (
148
154
(health === IndexHealth .GREEN ? ' 🟢' : health === IndexHealth .YELLOW ? ' 🟡' : ' 🔴' ) +
149
155
` ${health } `
150
156
);
151
157
},
152
158
},
153
- { title: ' status' , dataIndex: ' status' , key: ' status' , ... filterProps (' status' ) },
159
+ {
160
+ title: ' status' ,
161
+ dataIndex: ' status' ,
162
+ key: ' status' ,
163
+ ... filterProps (' status' ),
164
+ sorter: ' default' ,
165
+ },
166
+ {
167
+ title: ' Docs' ,
168
+ dataIndex: ' docs' ,
169
+ key: ' docs' ,
170
+ sorter : (a : ClusterIndex , b : ClusterIndex ) => (a .docs ?.count ?? 0 ) - (b .docs ?.count ?? 0 ),
171
+ render({ docs }: ClusterIndex ) {
172
+ return docs .count ;
173
+ },
174
+ },
175
+ { title: ' Storage' , dataIndex: ' storage' , key: ' storage' , sorter: ' default' },
176
+ {
177
+ title: ' shards' ,
178
+ dataIndex: ' shards' ,
179
+ key: ' shards' ,
180
+ render({ shards }: ClusterIndex ) {
181
+ if (! shards || ! Array .isArray (shards )) {
182
+ return ' 0p/0r' ;
183
+ }
184
+
185
+ const primaryCount = shards .filter (shard => shard .prirep === ' p' ).length ;
186
+ const replicaCount = shards .filter (shard => shard .prirep === ' r' ).length ;
187
+
188
+ return ` ${primaryCount }p/${replicaCount }r ` ;
189
+ },
190
+ },
154
191
{
155
192
title: ' Aliases' ,
156
193
dataIndex: ' aliases' ,
@@ -195,30 +232,6 @@ const indexTable = computed(() => {
195
232
),
196
233
),
197
234
},
198
- {
199
- title: ' Docs' ,
200
- dataIndex: ' docs' ,
201
- key: ' docs' ,
202
- render({ docs }: ClusterIndex ) {
203
- return docs .count ;
204
- },
205
- },
206
- {
207
- title: ' shards' ,
208
- dataIndex: ' shards' ,
209
- key: ' shards' ,
210
- render({ shards }: ClusterIndex ) {
211
- if (! shards || ! Array .isArray (shards )) {
212
- return ' 0p/0r' ;
213
- }
214
-
215
- const primaryCount = shards .filter (shard => shard .prirep === ' p' ).length ;
216
- const replicaCount = shards .filter (shard => shard .prirep === ' r' ).length ;
217
-
218
- return ` ${primaryCount }p/${replicaCount }r ` ;
219
- },
220
- },
221
- { title: ' Storage' , dataIndex: ' storage' , key: ' storage' },
222
235
{
223
236
title: ' Actions' ,
224
237
dataIndex: ' actions' ,
@@ -260,23 +273,23 @@ const indexTable = computed(() => {
260
273
261
274
const data = indexWithAliases .value
262
275
.filter (item =>
263
- filtersRef .value .uuid
264
- ? get (item , ' uuid' , ' ' ).toLowerCase ().includes (filtersRef .value .uuid .toLowerCase ())
276
+ filterState .value .uuid
277
+ ? get (item , ' uuid' , ' ' ).toLowerCase ().includes (filterState .value .uuid .toLowerCase ())
265
278
: true ,
266
279
)
267
280
.filter (item =>
268
- filtersRef .value .index
269
- ? get (item , ' index' , ' ' ).toLowerCase ().includes (filtersRef .value .index .toLowerCase ())
281
+ filterState .value .index
282
+ ? get (item , ' index' , ' ' ).toLowerCase ().includes (filterState .value .index .toLowerCase ())
270
283
: true ,
271
284
)
272
285
.filter (item =>
273
- filtersRef .value .health
274
- ? get (item , ' health' , ' ' ).toLowerCase ().includes (filtersRef .value .health .toLowerCase ())
286
+ filterState .value .health
287
+ ? get (item , ' health' , ' ' ).toLowerCase ().includes (filterState .value .health .toLowerCase ())
275
288
: true ,
276
289
)
277
290
.filter (item =>
278
- filtersRef .value .status
279
- ? get (item , ' status' , ' ' ).toLowerCase ().includes (filtersRef .value .status .toLowerCase ())
291
+ filterState .value .status
292
+ ? get (item , ' status' , ' ' ).toLowerCase ().includes (filterState .value .status .toLowerCase ())
280
293
: true ,
281
294
);
282
295
@@ -285,12 +298,18 @@ const indexTable = computed(() => {
285
298
286
299
const templateTable = computed (() => {
287
300
const columns = [
288
- { title: ' Template Name' , dataIndex: ' name' , key: ' name' , ... filterProps (' name' ) },
289
- { title: ' Type' , dataIndex: ' type' , key: ' type' , ... filterProps (' type' ) },
290
- { title: ' Order' , dataIndex: ' order' , key: ' order' },
291
- { title: ' Version' , dataIndex: ' version' , key: ' version' },
292
- { title: ' Mappings' , dataIndex: ' mapping_count' , key: ' mapping_count' },
293
- { title: ' Settings' , dataIndex: ' settings_count' , key: ' settings_count' },
301
+ {
302
+ title: ' Template Name' ,
303
+ dataIndex: ' name' ,
304
+ key: ' name' ,
305
+ ... filterProps (' name' ),
306
+ sorter: ' default' ,
307
+ },
308
+ { title: ' Type' , dataIndex: ' type' , key: ' type' , ... filterProps (' type' ), sorter: ' default' },
309
+ { title: ' Order' , dataIndex: ' order' , key: ' order' , sorter: ' default' },
310
+ { title: ' Version' , dataIndex: ' version' , key: ' version' , sorter: ' default' },
311
+ { title: ' Mappings' , dataIndex: ' mapping_count' , key: ' mapping_count' , sorter: ' default' },
312
+ { title: ' Settings' , dataIndex: ' settings_count' , key: ' settings_count' , sorter: ' default' },
294
313
{ title: ' Aliases' , dataIndex: ' alias_count' , key: ' alias_count' },
295
314
{ title: ' Metadata' , dataIndex: ' metadata' , key: ' metadata' },
296
315
{
@@ -318,13 +337,13 @@ const templateTable = computed(() => {
318
337
319
338
const data = templates .value
320
339
.filter (item =>
321
- filtersRef .value .name
322
- ? get (item , ' name' , ' ' ).toLowerCase ().includes (filtersRef .value .name .toLowerCase ())
340
+ filterState .value .name
341
+ ? get (item , ' name' , ' ' ).toLowerCase ().includes (filterState .value .name .toLowerCase ())
323
342
: true ,
324
343
)
325
344
.filter (item =>
326
- filtersRef .value .type
327
- ? get (item , ' type' , ' ' ).toLowerCase ().includes (filtersRef .value .type .toLowerCase ())
345
+ filterState .value .type
346
+ ? get (item , ' type' , ' ' ).toLowerCase ().includes (filterState .value .type .toLowerCase ())
328
347
: true ,
329
348
);
330
349
0 commit comments