diff --git a/.gitignore b/.gitignore
index 9322b8a6..f489a1e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ selenium-debug.log
*.sln
package-lock.json
+coverage/
diff --git a/package.json b/package.json
index 47e3eba2..a70ed1c0 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,7 @@
"driver.js": "0.8.1",
"dropzone": "5.2.0",
"echarts": "4.1.0",
- "element-ui": "2.4.11",
+ "element-ui": "^2.7.0",
"file-saver": "1.3.8",
"fuse.js": "3.4.2",
"js-cookie": "2.2.0",
@@ -50,6 +50,7 @@
"jszip": "3.1.5",
"lodash": "^4.17.11",
"lodash.debounce": "^4.0.8",
+ "moment": "^2.24.0",
"normalize.css": "7.0.0",
"nprogress": "0.2.0",
"numeral": "^2.0.6",
diff --git a/src/api/__mocks__/reports.js b/src/api/__mocks__/reports.js
new file mode 100644
index 00000000..43df97e7
--- /dev/null
+++ b/src/api/__mocks__/reports.js
@@ -0,0 +1,37 @@
+const reports = [
+ { created_at: '2019-05-21T21:35:33.000Z', account: { acct: 'benj', display_name: 'Benjamin Fame' }, actor: { acct: 'admin' }, state: 'open', id: '2', content: 'This is a report', statuses: [] },
+ { created_at: '2019-05-20T22:45:33.000Z', account: { acct: 'alice', display_name: 'Alice Pool' }, actor: { acct: 'admin2' }, state: 'resolved', id: '1', content: 'Please block this user', statuses: [] },
+ { created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '3', content: '', statuses: [] },
+ { created_at: '2019-05-21T21:35:33.000Z', account: { acct: 'benj', display_name: 'Benjamin Fame' }, actor: { acct: 'admin' }, state: 'open', id: '5', content: 'This is a report', statuses: [] },
+ { created_at: '2019-05-20T22:45:33.000Z', account: { acct: 'alice', display_name: 'Alice Pool' }, actor: { acct: 'admin2' }, state: 'resolved', id: '7', content: 'Please block this user', statuses: [
+ { account: { display_name: 'Alice Pool', avatar: '' }, visibility: 'public', sensitive: false, id: '11', content: 'Hey!', url: '', created_at: '2019-05-10T21:35:33.000Z' },
+ { account: { display_name: 'Alice Pool', avatar: '' }, visibility: 'unlisted', sensitive: true, id: '10', content: 'Bye!', url: '', created_at: '2019-05-10T21:00:33.000Z' }
+ ] },
+ { created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '6', content: '', statuses: [] },
+ { created_at: '2019-05-18T13:01:33.000Z', account: { acct: 'nick', display_name: 'Nick Keys' }, actor: { acct: 'admin' }, state: 'closed', id: '4', content: '', statuses: [] }
+]
+
+export async function fetchReports(limit, max_id, authHost, token) {
+ const paginatedReports = max_id.length > 0 ? reports.slice(5) : reports.slice(0, 5)
+ return Promise.resolve({ data: { reports: paginatedReports }})
+}
+
+export async function filterReports(filter, limit, max_id, authHost, token) {
+ const filteredReports = reports.filter(report => report.state === filter)
+ const paginatedReports = max_id.length > 0 ? filteredReports.slice(5) : filteredReports.slice(0, 5)
+ return Promise.resolve({ data: { reports: paginatedReports }})
+}
+
+export async function changeState(state, id, authHost, token) {
+ const report = reports.find(report => report.id === id)
+ return Promise.resolve({ data: { ...report, state }})
+}
+
+export async function changeStatusScope(id, sensitive, visibility, authHost, token) {
+ const status = reports[4].statuses[0]
+ return Promise.resolve({ data: { ...status, sensitive, visibility }})
+}
+
+export async function deleteStatus(statusId, authHost, token) {
+ return Promise.resolve()
+}
diff --git a/src/api/reports.js b/src/api/reports.js
new file mode 100644
index 00000000..c84a5bfd
--- /dev/null
+++ b/src/api/reports.js
@@ -0,0 +1,52 @@
+import request from '@/utils/request'
+import { getToken } from '@/utils/auth'
+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 changeStatusScope(id, sensitive, visibility, authHost, token) {
+ return await request({
+ baseURL: baseName(authHost),
+ url: `/api/pleroma/admin/statuses/${id}`,
+ method: 'put',
+ headers: authHeaders(token),
+ data: { sensitive, visibility }
+ })
+}
+
+export async function deleteStatus(id, authHost, token) {
+ return await request({
+ baseURL: baseName(authHost),
+ url: `/api/pleroma/admin/statuses/${id}`,
+ method: 'delete',
+ headers: authHeaders(token)
+ })
+}
+
+export async function fetchReports(limit, max_id, authHost, token) {
+ return await request({
+ baseURL: baseName(authHost),
+ url: `/api/pleroma/admin/reports?limit=${limit}&max_id=${max_id}`,
+ method: 'get',
+ headers: authHeaders(token)
+ })
+}
+
+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()}` } : {}
diff --git a/src/api/reportsData.js b/src/api/reportsData.js
new file mode 100644
index 00000000..36bc9b66
--- /dev/null
+++ b/src/api/reportsData.js
@@ -0,0 +1,218 @@
+export const reports = [
+ {
+ id: '1',
+ timestamp: '2019/4/12',
+ local: true,
+ from: 'John', // actor nickname
+ object: 'Bob', // user nickname
+ header: 'Report #1', // content
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Nick', text: 'Lorem ipsum', id: '1', timestamp: '2019/4/13' },
+ { author: 'Val', text: 'dolor sit amet', id: '2', timestamp: '2019/4/13' }
+ ]
+ },
+ {
+ id: '2',
+ timestamp: '2019/4/1',
+ local: true,
+ from: 'Max',
+ object: 'Vic',
+ header: 'Report #2',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Tony', text: 'consectetur adipiscing elit', id: '3', timestamp: '2019/4/2' },
+ { author: 'Zac', text: 'sed do eiusmod tempor incididunt', id: '4', timestamp: '2019/4/3' }
+ ]
+ },
+ {
+ id: '3',
+ timestamp: '2019/2/28',
+ local: true,
+ from: 'Tim',
+ object: 'Jen',
+ header: 'Report #3',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', id: '5', timestamp: '2019/3/1' }]
+ },
+ {
+ id: '4',
+ timestamp: '2019/4/12',
+ local: true,
+ from: 'John', // actor nickname
+ object: 'Bob', // user nickname
+ header: 'Report #4', // content
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Nick', text: 'Lorem ipsum', id: '6', timestamp: '2019/4/13' },
+ { author: 'Val', text: 'dolor sit amet', id: '7', timestamp: '2019/4/13' }
+ ]
+ },
+ {
+ id: '5',
+ timestamp: '2019/4/1',
+ local: true,
+ from: 'Max',
+ object: 'Vic',
+ header: 'Report #5',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Tony', text: 'consectetur adipiscing elit', id: '8', timestamp: '2019/4/2' },
+ { author: 'Zac', text: 'sed do eiusmod tempor incididunt', id: '9', timestamp: '2019/4/3' }
+ ]
+ },
+ {
+ id: '6',
+ timestamp: '2019/2/28',
+ local: true,
+ from: 'Tim',
+ object: 'Jen',
+ header: 'Report #6',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', id: '10', timestamp: '2019/3/1' }]
+ },
+ {
+ id: '7',
+ timestamp: '2019/4/12',
+ local: true,
+ from: 'John', // actor nickname
+ object: 'Bob', // user nickname
+ header: 'Report #7', // content
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Nick', text: 'Lorem ipsum', id: '11', timestamp: '2019/4/13' },
+ { author: 'Val', text: 'dolor sit amet', id: '12', timestamp: '2019/4/13' }
+ ]
+ },
+ {
+ id: '8',
+ timestamp: '2019/4/1',
+ local: true,
+ from: 'Max',
+ object: 'Vic',
+ header: 'Report #8',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Tony', text: 'consectetur adipiscing elit', id: '13', timestamp: '2019/4/2' },
+ { author: 'Zac', text: 'sed do eiusmod tempor incididunt', id: '14', timestamp: '2019/4/3' }
+ ]
+ },
+ {
+ id: '9',
+ timestamp: '2019/2/28',
+ local: true,
+ from: 'Tim',
+ object: 'Jen',
+ header: 'Report #9',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', id: '15', timestamp: '2019/3/1' }]
+ },
+ {
+ id: '10',
+ timestamp: '2019/4/12',
+ local: true,
+ from: 'John', // actor nickname
+ object: 'Bob', // user nickname
+ header: 'Report #10', // content
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Nick', text: 'Lorem ipsum', id: '16', timestamp: '2019/4/13' },
+ { author: 'Val', text: 'dolor sit amet', id: '17', timestamp: '2019/4/13' }
+ ]
+ },
+ {
+ id: '11',
+ timestamp: '2019/4/1',
+ local: true,
+ from: 'Max',
+ object: 'Vic',
+ header: 'Report #11',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Tony', text: 'consectetur adipiscing elit', id: '18', timestamp: '2019/4/2' },
+ { author: 'Zac', text: 'sed do eiusmod tempor incididunt', id: '19', timestamp: '2019/4/3' }
+ ]
+ },
+ {
+ id: '12',
+ timestamp: '2019/2/28',
+ local: true,
+ from: 'Tim',
+ object: 'Jen',
+ header: 'Report #12',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', id: '20', timestamp: '2019/3/1' }]
+ },
+ {
+ id: '13',
+ timestamp: '2019/4/12',
+ local: true,
+ from: 'John', // actor nickname
+ object: 'Bob', // user nickname
+ header: 'Report #13', // content
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Nick', text: 'Lorem ipsum', id: '21', timestamp: '2019/4/13' },
+ { author: 'Val', text: 'dolor sit amet', id: '22', timestamp: '2019/4/13' }
+ ]
+ },
+ {
+ id: '14',
+ timestamp: '2019/4/1',
+ local: true,
+ from: 'Max',
+ object: 'Vic',
+ header: 'Report #14',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Tony', text: 'consectetur adipiscing elit', id: '23', timestamp: '2019/4/2' },
+ { author: 'Zac', text: 'sed do eiusmod tempor incididunt', id: '24', timestamp: '2019/4/3' }
+ ]
+ },
+ {
+ id: '15',
+ timestamp: '2019/2/28',
+ local: true,
+ from: 'Tim',
+ object: 'Jen',
+ header: 'Report #15',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', id: '25', timestamp: '2019/3/1' }]
+ },
+ {
+ id: '16',
+ timestamp: '2019/4/12',
+ local: true,
+ from: 'John', // actor nickname
+ object: 'Bob', // user nickname
+ header: 'Report #16', // content
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Nick', text: 'Lorem ipsum', id: '26', timestamp: '2019/4/13' },
+ { author: 'Val', text: 'dolor sit amet', id: '27', timestamp: '2019/4/13' }
+ ]
+ },
+ {
+ id: '17',
+ timestamp: '2019/4/1',
+ local: true,
+ from: 'Max',
+ object: 'Vic',
+ header: 'Report #17',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [
+ { author: 'Tony', text: 'consectetur adipiscing elit', id: '28', timestamp: '2019/4/2' },
+ { author: 'Zac', text: 'sed do eiusmod tempor incididunt', id: '29', timestamp: '2019/4/3' }
+ ]
+ },
+ {
+ id: '18',
+ timestamp: '2019/2/28',
+ local: true,
+ from: 'Tim',
+ object: 'Jen',
+ header: 'Report #18',
+ content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ notes: [{ author: 'Bruce', text: 'ut labore et dolore magna aliqua', id: '30', timestamp: '2019/3/1' }]
+ }
+]
diff --git a/src/lang/en.js b/src/lang/en.js
index 4663a714..137426d4 100644
--- a/src/lang/en.js
+++ b/src/lang/en.js
@@ -64,7 +64,8 @@ export default {
clipboardDemo: 'Clipboard',
i18n: 'I18n',
externalLink: 'External Link',
- users: 'Users'
+ users: 'Users',
+ reports: 'Reports'
},
navbar: {
logOut: 'Log Out',
@@ -200,5 +201,37 @@ export default {
byStatus: 'By status',
active: 'Active',
deactivated: 'Deactivated'
+ },
+ reports: {
+ reports: 'Reports',
+ reply: 'Reply',
+ from: 'From',
+ showNotes: 'Show notes',
+ newNote: 'New note',
+ submit: 'Submit',
+ confirmMsg: 'Are you sure you want to delete this note?',
+ delete: 'Delete',
+ cancel: 'Cancel',
+ deleteCompleted: 'Delete comleted',
+ deleteCanceled: 'Delete canceled',
+ noNotes: 'No notes to display',
+ changeState: 'Change state',
+ changeScope: 'Change scope',
+ resolve: 'Resolve',
+ reopen: 'Reopen',
+ close: 'Close',
+ addSensitive: 'Add Sensitive flag',
+ removeSensitive: 'Remove Sensitive flag',
+ public: 'Make status public',
+ private: 'Make status private',
+ unlisted: 'Make status unlisted',
+ sensitive: 'Sensitive',
+ deleteStatus: 'Delete status'
+ },
+ reportsFilter: {
+ inputPlaceholder: 'Select filter',
+ open: 'Open',
+ closed: 'Closed',
+ resolved: 'Resolved'
}
}
diff --git a/src/router/index.js b/src/router/index.js
index 26877477..98f9e414 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -64,5 +64,17 @@ export const asyncRouterMap = [
}
]
},
+ {
+ path: '/reports',
+ component: Layout,
+ children: [
+ {
+ path: 'index',
+ component: () => import('@/views/reports/index'),
+ name: 'Reports',
+ meta: { title: 'reports', icon: 'documentation', noCache: true }
+ }
+ ]
+ },
{ path: '*', redirect: '/404', hidden: true }
]
diff --git a/src/store/index.js b/src/store/index.js
index 24dd7d66..119c4c97 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -3,6 +3,7 @@ import Vuex from 'vuex'
import app from './modules/app'
import errorLog from './modules/errorLog'
import permission from './modules/permission'
+import reports from './modules/reports'
import tagsView from './modules/tagsView'
import user from './modules/user'
import users from './modules/users'
@@ -15,6 +16,7 @@ const store = new Vuex.Store({
app,
errorLog,
permission,
+ reports,
tagsView,
user,
users
diff --git a/src/store/modules/reports.js b/src/store/modules/reports.js
new file mode 100644
index 00000000..a699a22a
--- /dev/null
+++ b/src/store/modules/reports.js
@@ -0,0 +1,79 @@
+import { changeState, changeStatusScope, deleteStatus, fetchReports, filterReports } from '@/api/reports'
+
+const reports = {
+ state: {
+ fetchedReports: [],
+ idOfLastReport: '',
+ page_limit: 5,
+ stateFilter: '',
+ loading: true
+ },
+ mutations: {
+ SET_LAST_REPORT_ID: (state, id) => {
+ state.idOfLastReport = id
+ },
+ SET_LOADING: (state, status) => {
+ state.loading = status
+ },
+ SET_REPORTS: (state, reports) => {
+ state.fetchedReports = reports
+ },
+ SET_REPORTS_FILTER: (state, filter) => {
+ state.stateFilter = filter
+ }
+ },
+ actions: {
+ async ChangeReportState({ commit, getters, state }, { reportState, reportId }) {
+ const { data } = await changeState(reportState, reportId, getters.authHost, getters.token)
+ const updatedReports = state.fetchedReports.map(report => report.id === reportId ? data : report)
+ commit('SET_REPORTS', updatedReports)
+ },
+ async ChangeStatusScope({ commit, getters, state }, { statusId, isSensitive, visibility, reportId }) {
+ const { data } = await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token)
+ const updatedReports = state.fetchedReports.map(report => {
+ if (report.id === reportId) {
+ const statuses = report.statuses.map(status => status.id === statusId ? data : status)
+ return { ...report, statuses }
+ } else {
+ return report
+ }
+ })
+ commit('SET_REPORTS', updatedReports)
+ },
+ ClearFetchedReports({ commit }) {
+ commit('SET_REPORTS', [])
+ commit('SET_LAST_REPORT_ID', '')
+ },
+ async DeleteStatus({ commit, getters, state }, { statusId, reportId }) {
+ deleteStatus(statusId, getters.authHost, getters.token)
+ const updatedReports = state.fetchedReports.map(report => {
+ if (report.id === reportId) {
+ const statuses = report.statuses.filter(status => status.id !== statusId)
+ return { ...report, statuses }
+ } else {
+ return report
+ }
+ })
+ commit('SET_REPORTS', updatedReports)
+ },
+ async FetchReports({ commit, getters, state }) {
+ commit('SET_LOADING', true)
+
+ const response = state.stateFilter.length === 0
+ ? await fetchReports(state.page_limit, state.idOfLastReport, getters.authHost, getters.token)
+ : 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)
+ },
+ SetFilter({ commit }, filter) {
+ commit('SET_REPORTS_FILTER', filter)
+ }
+ }
+}
+
+export default reports
diff --git a/src/store/modules/users.js b/src/store/modules/users.js
index ae021032..22c450d6 100644
--- a/src/store/modules/users.js
+++ b/src/store/modules/users.js
@@ -67,11 +67,11 @@ const users = {
commit('SWAP_USER', updatedUser)
},
async FetchUsers({ commit, state, getters }, { page }) {
+ commit('SET_LOADING', true)
+
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
const response = await fetchUsers(filters, getters.authHost, getters.token, page)
- commit('SET_LOADING', true)
-
loadUsers(commit, page, response.data)
},
async RemoveTag({ commit, getters }, { users, tag }) {
diff --git a/src/views/reports/components/ReportsFilter.vue b/src/views/reports/components/ReportsFilter.vue
new file mode 100644
index 00000000..263d2eca
--- /dev/null
+++ b/src/views/reports/components/ReportsFilter.vue
@@ -0,0 +1,43 @@
+
+ {{ status.account.display_name }}
+ Report on {{ report.account.display_name }}
+ ID: {{ report.id }}
+ {{ $t('reports.reports') }}
+