@@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
2
2
import {
3
3
Heading ,
4
4
Section ,
5
+ Form ,
5
6
Button ,
6
7
Tile ,
7
8
Notification ,
@@ -31,6 +32,11 @@ export default function ContainerItem({
31
32
page : 0 ,
32
33
objects : 0 ,
33
34
} ) ;
35
+ const [ filters , setFilters ] = useState ( [ {
36
+ key : '' ,
37
+ match : 'MatchStringEqual' ,
38
+ value : '' ,
39
+ } ] ) ;
34
40
const [ objects , setObjects ] = useState ( null ) ;
35
41
const [ isLoadingObjects , setLoadingObjects ] = useState ( false ) ;
36
42
const [ isLoadingEACL , setLoadingEACL ] = useState ( false ) ;
@@ -84,7 +90,7 @@ export default function ContainerItem({
84
90
setPagination ( { ...pagination , page : pageTemp } ) ;
85
91
setLoadingObjects ( true ) ;
86
92
api ( 'POST' , `/objects/${ containerId } /search?limit=${ ObjectsPerPage } &offset=${ pageTemp * ObjectsPerPage } ` , {
87
- " filters" : [ ] ,
93
+ filters : filters . every ( ( item ) => item . key !== '' && item . value !== '' ) ? filters : [ ] ,
88
94
} , {
89
95
"Authorization" : `Bearer ${ walletData . tokens . object . bearer } ` ,
90
96
} ) . then ( ( e ) => {
@@ -292,7 +298,7 @@ export default function ContainerItem({
292
298
/>
293
299
Objects
294
300
</ div >
295
- { activePanel === 'objects' && ! isLoadingObjects && (
301
+ { activePanel === 'objects' && (
296
302
< Button
297
303
size = "small"
298
304
color = "primary"
@@ -307,6 +313,127 @@ export default function ContainerItem({
307
313
</ Heading >
308
314
{ activePanel === 'objects' && (
309
315
< >
316
+ { objects && ( objects . length !== 0 || ( objects . length === 0 && filters !== null ) ) && (
317
+ < div className = "filters_block" >
318
+ < Heading
319
+ align = "center"
320
+ weight = "normal"
321
+ size = { 6 }
322
+ style = { {
323
+ display : 'flex' ,
324
+ alignItems : 'center' ,
325
+ justifyContent : 'space-between' ,
326
+ margin : 0 ,
327
+ } }
328
+ >
329
+ < span style = { { position : 'relative' } } >
330
+ Filter
331
+ < div className = "tooltip_block" >
332
+ < img
333
+ className = "input_icon"
334
+ src = "/img/icons/info_circle.svg"
335
+ height = { 18 }
336
+ width = { 18 }
337
+ alt = "info"
338
+ />
339
+ < div className = "tooltip" > Flexible search allows you to use any attributes to search through the attribute-operation-value formula, you can use parameters such as FilePath, FileName, etc.</ div >
340
+ </ div >
341
+ </ span >
342
+ < Button
343
+ color = "primary"
344
+ size = "small"
345
+ onClick = { ( ) => {
346
+ let filtersTemp = [ ...filters ] ;
347
+ filtersTemp . push ( {
348
+ key : '' ,
349
+ match : 'MatchStringEqual' ,
350
+ value : '' ,
351
+ } ) ;
352
+ setFilters ( filtersTemp ) ;
353
+ } }
354
+ disabled = { isLoadingObjects }
355
+ >
356
+ Add filter
357
+ </ Button >
358
+ </ Heading >
359
+ { filters . map ( ( filterItem , indexFilter ) => (
360
+ < div className = "filter_item" key = { indexFilter } >
361
+ < Form . Control >
362
+ < Form . Input
363
+ size = 'small'
364
+ placeholder = "Attribute"
365
+ value = { filterItem . key }
366
+ onChange = { ( e ) => {
367
+ let filtersTemp = [ ...filters ] ;
368
+ filtersTemp [ indexFilter ] . key = e . target . value ;
369
+ setFilters ( filtersTemp ) ;
370
+ } }
371
+ disabled = { isLoadingObjects }
372
+ />
373
+ </ Form . Control >
374
+ < Form . Control className = "select_wrapper" >
375
+ < Form . Select
376
+ size = 'small'
377
+ value = { filterItem . match }
378
+ onChange = { ( e ) => {
379
+ let filtersTemp = [ ...filters ] ;
380
+ filtersTemp [ indexFilter ] . match = e . target . value ;
381
+ setFilters ( filtersTemp ) ;
382
+ } }
383
+ disabled = { isLoadingObjects }
384
+ >
385
+ { [
386
+ { value : 'MatchStringEqual' , title : '=' } ,
387
+ { value : 'MatchStringNotEqual' , title : '≠' } ,
388
+ { value : 'MatchNumGT' , title : '>' } ,
389
+ { value : 'MatchNumGE' , title : '≥' } ,
390
+ { value : 'MatchNumLT' , title : '<' } ,
391
+ { value : 'MatchNumLE' , title : '≤' } ,
392
+ ] . map ( ( item ) => (
393
+ < option value = { item . value } key = { item . title } > { item . title } </ option >
394
+ ) ) }
395
+ </ Form . Select >
396
+ </ Form . Control >
397
+ < Form . Control >
398
+ < Form . Input
399
+ size = 'small'
400
+ placeholder = "Value"
401
+ value = { filterItem . value }
402
+ onChange = { ( e ) => {
403
+ let filtersTemp = [ ...filters ] ;
404
+ filtersTemp [ indexFilter ] . value = e . target . value ;
405
+ setFilters ( filtersTemp ) ;
406
+ } }
407
+ disabled = { isLoadingObjects }
408
+ />
409
+ </ Form . Control >
410
+ < img
411
+ src = "/img/icons/trashbin.svg"
412
+ width = { 14 }
413
+ height = { 14 }
414
+ fill = "#f14668"
415
+ alt = "delete"
416
+ style = { { cursor : 'pointer' , marginLeft : 8 } }
417
+ onClick = { ( ) => {
418
+ let filtersTemp = [ ...filters ] ;
419
+ filtersTemp . splice ( indexFilter , 1 ) ;
420
+ setFilters ( filtersTemp ) ;
421
+ } }
422
+ />
423
+ </ div >
424
+ ) ) }
425
+ < Button
426
+ fullwidth
427
+ color = "primary"
428
+ size = "small"
429
+ style = { { marginTop : 8 } }
430
+ onClick = { ( ) => onGetObjects ( containerItem . containerId , 0 ) }
431
+ disabled = { isLoadingObjects || filters . some ( ( item ) => item . key === '' || item . value === '' ) }
432
+ >
433
+ Search
434
+ </ Button >
435
+ </ div >
436
+ ) }
310
437
{ ! isLoadingObjects ? (
311
438
< >
312
439
{ objects && objects . length === 0 && (
0 commit comments