forked from AkkomaGang/admin-fe
Add ability to change state of reports
This commit is contained in:
parent
b14805d889
commit
3657b49a5c
4 changed files with 34 additions and 7 deletions
|
@ -2,6 +2,16 @@ import request from '@/utils/request'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import { baseName } from './utils'
|
import { baseName } from './utils'
|
||||||
|
|
||||||
|
export async function changeState(state, id, authHost, token) {
|
||||||
|
return await request({
|
||||||
|
baseURL: baseName(authHost),
|
||||||
|
url: `/api/pleroma/admin/reports/${id}`,
|
||||||
|
method: 'put',
|
||||||
|
headers: authHeaders(token),
|
||||||
|
data: { state }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export async function fetchReports(limit, max_id, authHost, token) {
|
export async function fetchReports(limit, max_id, authHost, token) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
|
|
|
@ -212,7 +212,8 @@ export default {
|
||||||
cancel: 'Cancel',
|
cancel: 'Cancel',
|
||||||
deleteCompleted: 'Delete comleted',
|
deleteCompleted: 'Delete comleted',
|
||||||
deleteCanceled: 'Delete canceled',
|
deleteCanceled: 'Delete canceled',
|
||||||
noNotes: 'No notes to display'
|
noNotes: 'No notes to display',
|
||||||
|
changeState: 'Change state'
|
||||||
},
|
},
|
||||||
reportsFilter: {
|
reportsFilter: {
|
||||||
inputPlaceholder: 'Select filter',
|
inputPlaceholder: 'Select filter',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { fetchReports, filterReports } from '@/api/reports'
|
import { changeState, fetchReports, filterReports } from '@/api/reports'
|
||||||
|
|
||||||
const reports = {
|
const reports = {
|
||||||
state: {
|
state: {
|
||||||
|
@ -15,18 +15,23 @@ const reports = {
|
||||||
SET_LOADING: (state, status) => {
|
SET_LOADING: (state, status) => {
|
||||||
state.loading = status
|
state.loading = status
|
||||||
},
|
},
|
||||||
|
SET_REPORT: (state, { reportIndex, data }) => {
|
||||||
|
state.fetchedReports[reportIndex] = data
|
||||||
|
},
|
||||||
SET_REPORTS: (state, reports) => {
|
SET_REPORTS: (state, reports) => {
|
||||||
state.fetchedReports = reports
|
state.fetchedReports = reports
|
||||||
},
|
},
|
||||||
SET_REPORTS_FILTER: (state, filter) => {
|
SET_REPORTS_FILTER: (state, filter) => {
|
||||||
state.stateFilter = filter
|
state.stateFilter = filter
|
||||||
}
|
}
|
||||||
// SET_REPORT: (state, { index, report }) => {
|
|
||||||
// state.fetchedReports[index] = report
|
|
||||||
// },
|
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async FetchReports({ commit, state, getters }) {
|
async ChangeReportState({ commit, getters, state }, { reportState, reportId }) {
|
||||||
|
const { data } = await changeState(reportState, reportId, getters.authHost, getters.token)
|
||||||
|
const reportIndex = state.fetchedReports.findIndex(report => report.id === reportId)
|
||||||
|
commit('SET_REPORT', { reportIndex, data })
|
||||||
|
},
|
||||||
|
async FetchReports({ commit, getters, state }) {
|
||||||
commit('SET_LOADING', true)
|
commit('SET_LOADING', true)
|
||||||
const response = await fetchReports(state.page_limit, state.idOfLastReport, getters.authHost, getters.token)
|
const response = await fetchReports(state.page_limit, state.idOfLastReport, getters.authHost, getters.token)
|
||||||
const reports = state.fetchedReports.concat(response.data.reports)
|
const reports = state.fetchedReports.concat(response.data.reports)
|
||||||
|
|
|
@ -4,7 +4,15 @@
|
||||||
<div class="header-container">
|
<div class="header-container">
|
||||||
<h3 class="report-title">Report on {{ report.account.display_name }}</h3>
|
<h3 class="report-title">Report on {{ report.account.display_name }}</h3>
|
||||||
<div>
|
<div>
|
||||||
<el-tag :type="getStateType(report.state)" size="large">{{ capitalizeFirstLetter(report.state) }}</el-tag>
|
<el-tag :type="getStateType(report.state)" :key="report.state" size="large">{{ capitalizeFirstLetter(report.state) }}</el-tag>
|
||||||
|
<el-dropdown>
|
||||||
|
<el-button plain size="small" icon="el-icon-edit">{{ $t('reports.changeState') }}<i class="el-icon-arrow-down el-icon--right"/></el-button>
|
||||||
|
<el-dropdown-menu slot="dropdown">
|
||||||
|
<el-dropdown-item v-if="report.state !== 'resolved'" @click.native="changeReportState('resolved', report.id)">Resolve</el-dropdown-item>
|
||||||
|
<el-dropdown-item v-if="report.state !== 'open'" @click.native="changeReportState('open', report.id)">Open</el-dropdown-item>
|
||||||
|
<el-dropdown-item v-if="report.state !== 'closed'" @click.native="changeReportState('closed', report.id)">Close</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
<!-- <el-button plain size="small" @click="toggleNoteInput">{{ $t('reports.reply') }}</el-button> -->
|
<!-- <el-button plain size="small" @click="toggleNoteInput">{{ $t('reports.reply') }}</el-button> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -121,6 +129,9 @@ export default {
|
||||||
this.$data.note = ''
|
this.$data.note = ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
changeReportState(reportState, reportId) {
|
||||||
|
this.$store.dispatch('ChangeReportState', { reportState, reportId })
|
||||||
|
},
|
||||||
deleteNote(reportId, noteId) {
|
deleteNote(reportId, noteId) {
|
||||||
this.$confirm(i18n.t('reports.confirmMsg'), {
|
this.$confirm(i18n.t('reports.confirmMsg'), {
|
||||||
confirmButtonText: i18n.t('reports.delete'),
|
confirmButtonText: i18n.t('reports.delete'),
|
||||||
|
|
Loading…
Reference in a new issue