Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
HUB Terra
SMS
Frontend
Commits
5d8993c4
Verified
Commit
5d8993c4
authored
3 years ago
by
Marc Hanisch
Browse files
Options
Downloads
Patches
Plain Diff
adds filter option for the search
parent
94db043f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!104
Load and save Generic Device Actions
,
!93
Actions UI for devices
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/cv/ActionTypeApi.ts
+36
-13
36 additions, 13 deletions
services/cv/ActionTypeApi.ts
with
36 additions
and
13 deletions
services/cv/ActionTypeApi.ts
+
36
−
13
View file @
5d8993c4
...
...
@@ -58,39 +58,58 @@ export class ActionTypeApi extends CVApi<ActionType> {
}
}
export
const
ACTION_TYPE_API_FILTER_DEVICE
=
'
Device
'
export
const
ACTION_TYPE_API_FILTER_PLATFORM
=
'
Platform
'
export
const
ACTION_TYPE_API_FILTER_CONFIGURATION
=
'
Configuration
'
export
type
ActionTypeApiFilterType
=
typeof
ACTION_TYPE_API_FILTER_DEVICE
|
typeof
ACTION_TYPE_API_FILTER_PLATFORM
|
typeof
ACTION_TYPE_API_FILTER_CONFIGURATION
export
class
ActionTypeSearchBuilder
{
private
axiosApi
:
AxiosInstance
private
serializer
:
ActionTypeSerializer
private
actionTypeFilter
:
ActionTypeApiFilterType
|
undefined
constructor
(
axiosApi
:
AxiosInstance
,
serializer
:
ActionTypeSerializer
)
{
this
.
axiosApi
=
axiosApi
this
.
serializer
=
serializer
}
onlyType
(
actionType
:
ActionTypeApiFilterType
):
ActionTypeSearchBuilder
{
this
.
actionTypeFilter
=
actionType
return
this
}
build
():
ActionTypeSearcher
{
return
new
ActionTypeSearcher
(
this
.
axiosApi
,
this
.
serializer
)
return
new
ActionTypeSearcher
(
this
.
axiosApi
,
this
.
serializer
,
this
.
actionTypeFilter
)
}
}
export
class
ActionTypeSearcher
{
private
axiosApi
:
AxiosInstance
private
serializer
:
ActionTypeSerializer
private
actionTypeFilter
:
ActionTypeApiFilterType
|
undefined
constructor
(
axiosApi
:
AxiosInstance
,
serializer
:
ActionTypeSerializer
)
{
constructor
(
axiosApi
:
AxiosInstance
,
serializer
:
ActionTypeSerializer
,
actionType
?:
ActionTypeApiFilterType
)
{
this
.
axiosApi
=
axiosApi
this
.
serializer
=
serializer
if
(
actionType
)
{
this
.
actionTypeFilter
=
actionType
}
}
private
findAllOnPage
(
page
:
number
,
pageSize
:
number
):
Promise
<
IPaginationLoader
<
ActionType
>>
{
const
params
:
{
[
idx
:
string
]:
any
}
=
{
'
page[size]
'
:
pageSize
,
'
page[number]
'
:
page
,
'
filter[status.iexact]
'
:
'
ACCEPTED
'
,
sort
:
'
term
'
}
if
(
this
.
actionTypeFilter
)
{
params
[
'
filter[action_category__term]
'
]
=
this
.
actionTypeFilter
}
return
this
.
axiosApi
.
get
(
''
,
{
params
:
{
'
page[size]
'
:
pageSize
,
'
page[number]
'
:
page
,
'
filter[status.iexact]
'
:
'
ACCEPTED
'
,
sort
:
'
term
'
}
params
}
).
then
((
rawResponse
)
=>
{
const
response
=
rawResponse
.
data
...
...
@@ -111,14 +130,18 @@ export class ActionTypeSearcher {
}
findMatchingAsList
():
Promise
<
ActionType
[]
>
{
const
params
:
{
[
idx
:
string
]:
any
}
=
{
'
page[size]
'
:
10000
,
'
filter[status.iexact]
'
:
'
ACCEPTED
'
,
sort
:
'
term
'
}
if
(
this
.
actionTypeFilter
)
{
params
[
'
filter[action_category__term]
'
]
=
this
.
actionTypeFilter
}
return
this
.
axiosApi
.
get
(
''
,
{
params
:
{
'
page[size]
'
:
10000
,
'
filter[status.iexact]
'
:
'
ACCEPTED
'
,
sort
:
'
term
'
}
params
}
).
then
((
rawResponse
)
=>
{
const
response
=
rawResponse
.
data
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment