Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sean King
admin-fe
Commits
63bf0ecb
Commit
63bf0ecb
authored
5 years ago
by
Angelina Filippova
Browse files
Options
Downloads
Patches
Plain Diff
Add ability to filter reports
parent
1494f7fd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/api/reports.js
+7
-1
7 additions, 1 deletion
src/api/reports.js
src/store/modules/reports.js
+31
-12
31 additions, 12 deletions
src/store/modules/reports.js
src/views/reports/components/ReportsFilter.vue
+4
-11
4 additions, 11 deletions
src/views/reports/components/ReportsFilter.vue
with
42 additions
and
24 deletions
src/api/reports.js
+
7
−
1
View file @
63bf0ecb
...
...
@@ -11,7 +11,13 @@ export async function fetchReports(limit, max_id, authHost, token) {
})
}
export
async
function
toggleReportsFilter
(
authHost
,
token
,
filters
)
{
export
async
function
filterReports
(
filter
,
limit
,
max_id
,
authHost
,
token
)
{
return
await
request
({
baseURL
:
baseName
(
authHost
),
url
:
`/api/pleroma/admin/reports?state=
${
filter
}
&limit=
${
limit
}
&max_id=
${
max_id
}
`
,
method
:
'
get
'
,
headers
:
authHeaders
(
token
)
})
}
const
authHeaders
=
(
token
)
=>
token
?
{
'
Authorization
'
:
`Bearer
${
getToken
()}
`
}
:
{}
This diff is collapsed.
Click to expand it.
src/store/modules/reports.js
+
31
−
12
View file @
63bf0ecb
import
{
fetchReports
,
toggle
Reports
Filter
}
from
'
@/api/reports
'
import
{
fetchReports
,
filter
Reports
}
from
'
@/api/reports
'
const
reports
=
{
state
:
{
fetchedReports
:
[],
idOfLastReport
:
''
,
page_limit
:
5
,
stateFilter
:
''
,
loading
:
true
},
mutations
:
{
SET_REPORTS
:
(
state
,
reports
)
=>
{
state
.
fetchedReports
=
state
.
fetchedReports
.
concat
(
reports
)
},
SET_REPORT
:
(
state
,
{
index
,
report
})
=>
{
state
.
fetchedReports
[
index
]
=
report
SET_LAST_REPORT_ID
:
(
state
,
id
)
=>
{
state
.
idOfLastReport
=
id
},
SET_LOADING
:
(
state
,
status
)
=>
{
state
.
loading
=
status
},
SET_LAST_REPORT_ID
:
(
state
,
id
)
=>
{
state
.
idOfLastReport
=
id
SET_REPORTS
:
(
state
,
reports
)
=>
{
state
.
fetchedReports
=
reports
},
SET_REPORTS_FILTER
:
(
state
,
filter
)
=>
{
state
.
stateFilter
=
filter
}
// SET_REPORT: (state, { index, report }) => {
// state.fetchedReports[index] = report
// },
},
actions
:
{
async
FetchReports
({
commit
,
state
,
getters
})
{
commit
(
'
SET_LOADING
'
,
true
)
const
response
=
await
fetchReports
(
state
.
page_limit
,
state
.
idOfLastReport
,
getters
.
authHost
,
getters
.
token
)
const
reports
=
response
.
data
.
reports
const
reports
=
state
.
fetchedReports
.
concat
(
response
.
data
.
reports
)
const
id
=
reports
.
length
>
0
?
reports
[
reports
.
length
-
1
].
id
:
state
.
idOfLastReport
commit
(
'
SET_REPORTS
'
,
reports
)
commit
(
'
SET_LAST_REPORT_ID
'
,
id
)
commit
(
'
SET_LOADING
'
,
false
)
},
async
ToggleReportsFilter
({
getters
},
filters
)
{
const
response
=
await
toggleReportsFilter
(
getters
.
authHost
,
getters
.
token
,
filters
)
return
response
.
data
async
ToggleReportsFilter
({
commit
,
dispatch
,
getters
,
state
},
filter
)
{
commit
(
'
SET_REPORTS
'
,
[])
commit
(
'
SET_LAST_REPORT_ID
'
,
''
)
if
(
filter
.
length
===
0
)
{
dispatch
(
'
FetchReports
'
)
}
else
{
commit
(
'
SET_REPORTS_FILTER
'
,
filter
)
commit
(
'
SET_LOADING
'
,
true
)
const
response
=
await
filterReports
(
state
.
stateFilter
,
state
.
page_limit
,
state
.
idOfLastReport
,
getters
.
authHost
,
getters
.
token
)
const
reports
=
state
.
fetchedReports
.
concat
(
response
.
data
.
reports
)
const
id
=
reports
.
length
>
0
?
reports
[
reports
.
length
-
1
].
id
:
state
.
idOfLastReport
commit
(
'
SET_REPORTS
'
,
reports
)
commit
(
'
SET_LAST_REPORT_ID
'
,
id
)
commit
(
'
SET_LOADING
'
,
false
)
}
}
// async AddNote({ commit, state, getters }, { reportId, note }) {
// const report = state.fetchedReports.find(report => report.id === reportId)
...
...
This diff is collapsed.
Click to expand it.
src/views/reports/components/ReportsFilter.vue
+
4
−
11
View file @
63bf0ecb
<
template
>
<el-select
v-model=
"value"
:clearable=
"isDesktop"
v-model=
"filter"
:placeholder=
"$t('reportsFilter.inputPlaceholder')"
multip
le
clearab
le
class=
"select-field"
@
change=
"toggleFilters"
>
<el-option
value=
"open"
>
{{
$t
(
'
reportsFilter.open
'
)
}}
</el-option>
...
...
@@ -16,18 +15,12 @@
export
default
{
data
()
{
return
{
value
:
[]
}
},
computed
:
{
isDesktop
()
{
return
this
.
$store
.
state
.
app
.
device
===
'
desktop
'
filter
:
[]
}
},
methods
:
{
toggleFilters
()
{
const
currentFilters
=
this
.
$data
.
value
.
reduce
((
acc
,
filter
)
=>
({
...
acc
,
[
filter
]:
true
}),
{})
this
.
$store
.
dispatch
(
'
ToggleReportsFilter
'
,
currentFilters
)
this
.
$store
.
dispatch
(
'
ToggleReportsFilter
'
,
this
.
$data
.
filter
)
}
}
}
...
...
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