Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
7d6b8b3b
Unverified
Commit
7d6b8b3b
authored
Feb 03, 2021
by
Lijiaoa
Committed by
GitHub
Feb 03, 2021
Browse files
Support multiple selection for filter status (manage all experiments page) (#3351)
parent
8c8db374
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
62 deletions
+59
-62
ts/webui/src/components/managementExp/ExperimentManager.tsx
ts/webui/src/components/managementExp/ExperimentManager.tsx
+42
-58
ts/webui/src/components/managementExp/FilterBtns.tsx
ts/webui/src/components/managementExp/FilterBtns.tsx
+3
-2
ts/webui/src/components/managementExp/expFunction.ts
ts/webui/src/components/managementExp/expFunction.ts
+14
-2
No files found.
ts/webui/src/components/managementExp/ExperimentManager.tsx
View file @
7d6b8b3b
...
@@ -23,7 +23,7 @@ interface ExpListState {
...
@@ -23,7 +23,7 @@ interface ExpListState {
errorMessage
:
string
;
errorMessage
:
string
;
hideFilter
:
boolean
;
hideFilter
:
boolean
;
searchInputVal
:
string
;
searchInputVal
:
string
;
selectedStatus
:
string
;
selectedStatus
:
string
[]
;
selectedPlatform
:
string
;
selectedPlatform
:
string
;
selectedStartDate
?:
Date
;
selectedStartDate
?:
Date
;
selectedEndDate
?:
Date
;
selectedEndDate
?:
Date
;
...
@@ -42,7 +42,7 @@ class Experiment extends React.Component<{}, ExpListState> {
...
@@ -42,7 +42,7 @@ class Experiment extends React.Component<{}, ExpListState> {
errorMessage
:
''
,
errorMessage
:
''
,
hideFilter
:
true
,
hideFilter
:
true
,
searchInputVal
:
''
,
searchInputVal
:
''
,
selectedStatus
:
''
,
selectedStatus
:
[]
,
selectedPlatform
:
''
,
selectedPlatform
:
''
,
source
:
[],
// data in table
source
:
[],
// data in table
originExperimentList
:
[],
// api /experiments-info
originExperimentList
:
[],
// api /experiments-info
...
@@ -312,39 +312,28 @@ class Experiment extends React.Component<{}, ExpListState> {
...
@@ -312,39 +312,28 @@ class Experiment extends React.Component<{}, ExpListState> {
*/
*/
private
commonSelectString
=
(
data
:
AllExperimentList
[],
field
:
string
):
AllExperimentList
[]
=>
{
private
commonSelectString
=
(
data
:
AllExperimentList
[],
field
:
string
):
AllExperimentList
[]
=>
{
const
{
selectedStatus
,
selectedPlatform
,
selectedStartDate
,
selectedEndDate
}
=
this
.
state
;
const
{
selectedStatus
,
selectedPlatform
,
selectedStartDate
,
selectedEndDate
}
=
this
.
state
;
const
hasStatus
=
selectedStatus
===
''
?
false
:
true
;
const
hasPlatform
=
selectedPlatform
===
''
?
false
:
true
;
const
hasStartDate
=
selectedStartDate
===
undefined
?
false
:
true
;
const
hasEndDate
=
selectedEndDate
===
undefined
?
false
:
true
;
if
(
field
===
'
status
'
)
{
if
(
field
===
'
status
'
)
{
if
(
hasPlatform
)
{
data
=
filterByStatusOrPlatform
(
selectedPlatform
,
'
platform
'
,
data
);
data
=
filterByStatusOrPlatform
(
selectedPlatform
,
'
platform
'
,
data
);
}
}
}
if
(
field
===
'
platform
'
)
{
if
(
field
===
'
platform
'
)
{
if
(
hasStatus
)
{
data
=
filterByStatusOrPlatform
(
selectedStatus
,
'
status
'
,
data
);
data
=
filterByStatusOrPlatform
(
selectedStatus
,
'
status
'
,
data
);
}
}
}
if
(
field
===
''
)
{
if
(
field
===
''
)
{
if
(
hasPlatform
)
{
data
=
Array
.
from
(
data
=
filterByStatusOrPlatform
(
selectedPlatform
,
'
platform
'
,
data
);
new
Set
([
}
...
filterByStatusOrPlatform
(
selectedPlatform
,
'
platform
'
,
data
),
if
(
hasStatus
)
{
...
filterByStatusOrPlatform
(
selectedStatus
,
'
status
'
,
data
)
data
=
filterByStatusOrPlatform
(
selectedStatus
,
'
status
'
,
data
);
])
}
);
}
}
if
(
hasStartDate
)
{
data
=
data
.
filter
(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
item
=>
data
=
data
.
filter
(
temp
=>
compareDate
(
new
Date
(
temp
.
startTime
),
selectedStartDate
!
));
(
selectedStartDate
===
undefined
||
compareDate
(
new
Date
(
item
.
startTime
),
selectedStartDate
))
&&
}
(
selectedEndDate
===
undefined
||
compareDate
(
new
Date
(
item
.
endTime
),
selectedEndDate
))
if
(
hasEndDate
)
{
);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
data
=
data
.
filter
(
temp
=>
compareDate
(
new
Date
(
temp
.
endTime
),
selectedEndDate
!
));
}
return
data
;
return
data
;
};
};
...
@@ -352,10 +341,16 @@ class Experiment extends React.Component<{}, ExpListState> {
...
@@ -352,10 +341,16 @@ class Experiment extends React.Component<{}, ExpListState> {
// status platform startTime endTime
// status platform startTime endTime
private
selectStatus
=
(
_event
:
React
.
FormEvent
<
HTMLDivElement
>
,
item
:
any
):
void
=>
{
private
selectStatus
=
(
_event
:
React
.
FormEvent
<
HTMLDivElement
>
,
item
:
any
):
void
=>
{
if
(
item
!==
undefined
)
{
if
(
item
!==
undefined
)
{
const
{
searchSource
,
sortInfo
}
=
this
.
state
;
const
{
searchSource
,
sortInfo
,
selectedStatus
}
=
this
.
state
;
let
result
=
filterByStatusOrPlatform
(
item
.
key
,
'
status
'
,
searchSource
);
const
newSelectedStatus
=
item
.
selected
?
[...
selectedStatus
,
item
.
key
as
string
]
:
selectedStatus
.
filter
(
key
=>
key
!==
item
.
key
);
let
result
=
filterByStatusOrPlatform
(
newSelectedStatus
,
'
status
'
,
searchSource
);
result
=
this
.
commonSelectString
(
result
,
'
status
'
);
result
=
this
.
commonSelectString
(
result
,
'
status
'
);
this
.
setState
({
selectedStatus
:
item
.
key
,
source
:
getSortedSource
(
result
,
sortInfo
)
});
this
.
setState
({
selectedStatus
:
newSelectedStatus
,
source
:
getSortedSource
(
result
,
sortInfo
)
});
}
}
};
};
...
@@ -378,41 +373,30 @@ class Experiment extends React.Component<{}, ExpListState> {
...
@@ -378,41 +373,30 @@ class Experiment extends React.Component<{}, ExpListState> {
searchSource
,
searchSource
,
sortInfo
sortInfo
}
=
this
.
state
;
}
=
this
.
state
;
const
hasStatus
=
selectedStatus
===
''
?
false
:
true
;
const
hasPlatform
=
selectedPlatform
===
''
?
false
:
true
;
const
hasPlatform
=
selectedPlatform
===
''
?
false
:
true
;
const
hasStartDate
=
selectedStartDate
===
undefined
?
false
:
true
;
const
hasEndDate
=
selectedEndDate
===
undefined
?
false
:
true
;
// filter status, platform
let
result
;
let
result
=
filterByStatusOrPlatform
(
selectedStatus
,
'
status
'
,
searchSource
);
if
(
type
===
'
start
'
)
{
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
result
=
searchSource
.
filter
(
item
=>
compareDate
(
new
Date
(
item
.
startTime
),
date
));
if
(
hasStatus
)
{
result
=
result
.
filter
(
temp
=>
temp
.
status
===
selectedStatus
);
}
if
(
hasPlatform
)
{
if
(
hasPlatform
)
{
result
=
result
.
filter
(
temp
=>
temp
.
platform
===
selectedPlatform
);
result
=
result
.
filter
(
temp
=>
temp
.
platform
===
selectedPlatform
);
}
}
if
(
hasEndDate
)
{
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if
(
type
===
'
start
'
)
{
result
=
result
.
filter
(
temp
=>
compareDate
(
new
Date
(
temp
.
endTime
),
selectedEndDate
!
));
result
=
result
.
filter
(
}
item
=>
compareDate
(
new
Date
(
item
.
startTime
),
date
)
&&
(
selectedEndDate
===
undefined
||
compareDate
(
new
Date
(
item
.
endTime
),
selectedEndDate
))
);
this
.
setState
(()
=>
({
this
.
setState
(()
=>
({
source
:
getSortedSource
(
result
,
sortInfo
),
source
:
getSortedSource
(
result
,
sortInfo
),
selectedStartDate
:
date
selectedStartDate
:
date
}));
}));
}
else
{
}
else
{
result
=
searchSource
.
filter
(
item
=>
compareDate
(
new
Date
(
item
.
endTime
),
date
));
result
=
result
.
filter
(
item
=>
if
(
hasStatus
)
{
compareDate
(
new
Date
(
item
.
endTime
),
date
)
&&
result
=
result
.
filter
(
temp
=>
temp
.
status
===
selectedStatus
);
(
selectedStartDate
===
undefined
||
compareDate
(
new
Date
(
item
.
startTime
),
selectedStartDate
))
}
);
if
(
hasPlatform
)
{
result
=
result
.
filter
(
temp
=>
temp
.
platform
===
selectedPlatform
);
}
if
(
hasStartDate
)
{
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
result
=
result
.
filter
(
temp
=>
compareDate
(
new
Date
(
temp
.
startTime
),
selectedStartDate
!
));
}
this
.
setState
(()
=>
({
this
.
setState
(()
=>
({
source
:
getSortedSource
(
result
,
sortInfo
),
source
:
getSortedSource
(
result
,
sortInfo
),
selectedEndDate
:
date
selectedEndDate
:
date
...
@@ -434,7 +418,7 @@ class Experiment extends React.Component<{}, ExpListState> {
...
@@ -434,7 +418,7 @@ class Experiment extends React.Component<{}, ExpListState> {
);
);
this
.
setState
(()
=>
({
this
.
setState
(()
=>
({
source
:
getSortedSource
(
result
,
sortInfo
),
source
:
getSortedSource
(
result
,
sortInfo
),
selectedStatus
:
''
,
selectedStatus
:
[]
,
selectedPlatform
:
''
,
selectedPlatform
:
''
,
selectedStartDate
:
undefined
,
selectedStartDate
:
undefined
,
selectedEndDate
:
undefined
selectedEndDate
:
undefined
...
...
ts/webui/src/components/managementExp/FilterBtns.tsx
View file @
7d6b8b3b
...
@@ -5,7 +5,7 @@ import { fillOptions } from './expFunction';
...
@@ -5,7 +5,7 @@ import { fillOptions } from './expFunction';
interface
FilterBtnsProps
{
interface
FilterBtnsProps
{
platform
:
string
[];
platform
:
string
[];
selectedStatus
:
string
;
selectedStatus
:
string
[]
;
selectedPlatform
:
string
;
selectedPlatform
:
string
;
selectedStartDate
:
Date
;
selectedStartDate
:
Date
;
selectedEndDate
:
Date
;
selectedEndDate
:
Date
;
...
@@ -37,7 +37,8 @@ class FilterBtns extends React.Component<FilterBtnsProps, {}> {
...
@@ -37,7 +37,8 @@ class FilterBtns extends React.Component<FilterBtnsProps, {}> {
<
React
.
Fragment
>
<
React
.
Fragment
>
<
Dropdown
<
Dropdown
label
=
'Status'
label
=
'Status'
selectedKey
=
{
selectedStatus
}
selectedKeys
=
{
selectedStatus
}
multiSelect
onChange
=
{
selectStatus
.
bind
(
this
)
}
onChange
=
{
selectStatus
.
bind
(
this
)
}
placeholder
=
'Select an option'
placeholder
=
'Select an option'
options
=
{
fillOptions
(
EXPERIMENTSTATUS
)
}
options
=
{
fillOptions
(
EXPERIMENTSTATUS
)
}
...
...
ts/webui/src/components/managementExp/expFunction.ts
View file @
7d6b8b3b
...
@@ -15,8 +15,20 @@ function compareDate(date1: Date, date2: Date): boolean {
...
@@ -15,8 +15,20 @@ function compareDate(date1: Date, date2: Date): boolean {
return
false
;
return
false
;
}
}
const
filterByStatusOrPlatform
=
(
val
:
string
,
type
:
string
,
data
:
AllExperimentList
[]):
AllExperimentList
[]
=>
{
const
filterByStatusOrPlatform
=
(
val
:
string
|
string
[],
type
:
string
,
data
:
AllExperimentList
[]
):
AllExperimentList
[]
=>
{
if
(
typeof
val
===
'
string
'
&&
val
!==
''
)
{
return
data
.
filter
(
temp
=>
temp
[
type
]
===
val
);
return
data
.
filter
(
temp
=>
temp
[
type
]
===
val
);
}
if
(
Array
.
isArray
(
val
)
&&
val
.
length
!==
0
)
{
return
data
.
filter
(
temp
=>
val
.
includes
(
temp
[
type
]));
}
return
data
;
};
};
function
fillOptions
(
arr
:
string
[]):
any
{
function
fillOptions
(
arr
:
string
[]):
any
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment