Update filters names and the way they are passed to api

This commit is contained in:
Angelina Filippova 2019-03-26 23:54:21 +05:00
parent ae1008d94f
commit 46f53b2405
3 changed files with 16 additions and 14 deletions

View file

@ -2,10 +2,10 @@ import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
export async function fetchUsers(showLocalUsersOnly, authHost, token, page = 1) {
export async function fetchUsers(filters, authHost, token, page = 1) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/users?page=${page}&local_only=${showLocalUsersOnly}`,
url: `/api/pleroma/admin/users?page=${page}&filters=${filters}`,
method: 'get',
headers: authHeaders(token)
})
@ -20,10 +20,10 @@ export async function toggleUserActivation(nickname, authHost, token) {
})
}
export async function searchUsers(query, showLocalUsersOnly, authHost, token, page = 1) {
export async function searchUsers(query, filters, authHost, token, page = 1) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/users?query=${query}&page=${page}&local_only=${showLocalUsersOnly}`,
url: `/api/pleroma/admin/users?query=${query}&page=${page}&filters=${filters}`,
method: 'get',
headers: authHeaders(token)
})

View file

@ -8,10 +8,10 @@ const users = {
totalUsersCount: 0,
currentPage: 1,
filters: {
localUsersOnly: false,
externalUsersOnly: false,
activeUsersOnly: false,
deactivatedUsersOnly: false
local: false,
external: false,
active: false,
deactivated: false
}
},
mutations: {
@ -48,7 +48,8 @@ const users = {
},
actions: {
async FetchUsers({ commit, state, getters }, { page }) {
const response = await fetchUsers(state.filters, getters.authHost, getters.token, page)
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)
@ -67,7 +68,8 @@ const users = {
commit('SET_LOADING', true)
commit('SET_SEARCH_QUERY', query)
const response = await searchUsers(query, state.filters, getters.authHost, getters.token, page)
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
const response = await searchUsers(query, filters, getters.authHost, getters.token, page)
loadUsers(commit, page, response.data)
}

View file

@ -28,19 +28,19 @@ export default {
label: this.$i18n.t('usersFilter.byUserType'),
options: [{
label: this.$i18n.t('usersFilter.local'),
value: 'localUsersOnly'
value: 'local'
}, {
label: this.$i18n.t('usersFilter.external'),
value: 'externalUsersOnly'
value: 'external'
}]
}, {
label: this.$i18n.t('usersFilter.byStatus'),
options: [{
label: this.$i18n.t('usersFilter.active'),
value: 'activeUsersOnly'
value: 'active'
}, {
label: this.$i18n.t('usersFilter.deactivated'),
value: 'deactivatedUsersOnly'
value: 'deactivated'
}]
}],
value: []