forked from AkkomaGang/admin-fe
Add actor_type filter
This commit is contained in:
parent
6b58b4f545
commit
05b6992dd4
2 changed files with 14 additions and 6 deletions
|
@ -110,10 +110,10 @@ export async function fetchUser(id, authHost, token) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchUsers(filters, authHost, token, page = 1) {
|
export async function fetchUsers(filters, actorTypeFilters, authHost, token, page = 1) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
url: `/api/pleroma/admin/users?page=${page}&filters=${filters}`,
|
url: `/api/pleroma/admin/users?page=${page}&filters=${filters}&actor_types=${actorTypeFilters}`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers: authHeaders(token)
|
headers: authHeaders(token)
|
||||||
})
|
})
|
||||||
|
@ -175,10 +175,10 @@ export async function resendConfirmationEmail(nicknames, authHost, token) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function searchUsers(query, filters, authHost, token, page = 1) {
|
export async function searchUsers(query, filters, actorTypeFilters, authHost, token, page = 1) {
|
||||||
return await request({
|
return await request({
|
||||||
baseURL: baseName(authHost),
|
baseURL: baseName(authHost),
|
||||||
url: `/api/pleroma/admin/users?query=${query}&page=${page}&filters=${filters}`,
|
url: `/api/pleroma/admin/users?query=${query}&page=${page}&filters=${filters}&actor_types=${actorTypeFilters}`,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers: authHeaders(token)
|
headers: authHeaders(token)
|
||||||
})
|
})
|
||||||
|
|
|
@ -31,6 +31,7 @@ const users = {
|
||||||
totalUsersCount: 0,
|
totalUsersCount: 0,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
|
actorTypeFilters: [],
|
||||||
filters: {
|
filters: {
|
||||||
local: false,
|
local: false,
|
||||||
external: false,
|
external: false,
|
||||||
|
@ -46,6 +47,9 @@ const users = {
|
||||||
tags: []
|
tags: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
SET_ACTOR_TYPE_FILTERS: (state, actorTypeFilters) => {
|
||||||
|
state.actorTypeFilters = actorTypeFilters
|
||||||
|
},
|
||||||
SET_USERS: (state, users) => {
|
SET_USERS: (state, users) => {
|
||||||
state.fetchedUsers = users
|
state.fetchedUsers = users
|
||||||
},
|
},
|
||||||
|
@ -248,7 +252,7 @@ const users = {
|
||||||
async FetchUsers({ commit, dispatch, getters, state }, { page }) {
|
async FetchUsers({ commit, dispatch, getters, state }, { page }) {
|
||||||
commit('SET_LOADING', true)
|
commit('SET_LOADING', true)
|
||||||
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
|
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
|
||||||
const response = await fetchUsers(filters, getters.authHost, getters.token, page)
|
const response = await fetchUsers(filters, state.actorTypeFilters, getters.authHost, getters.token, page)
|
||||||
await dispatch('GetNodeInfo')
|
await dispatch('GetNodeInfo')
|
||||||
loadUsers(commit, page, response.data)
|
loadUsers(commit, page, response.data)
|
||||||
},
|
},
|
||||||
|
@ -299,7 +303,7 @@ const users = {
|
||||||
commit('SET_SEARCH_QUERY', query)
|
commit('SET_SEARCH_QUERY', query)
|
||||||
|
|
||||||
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
|
const filters = Object.keys(state.filters).filter(filter => state.filters[filter]).join()
|
||||||
const response = await searchUsers(query, filters, getters.authHost, getters.token, page)
|
const response = await searchUsers(query, filters, state.actorTypeFilters, getters.authHost, getters.token, page)
|
||||||
|
|
||||||
loadUsers(commit, page, response.data)
|
loadUsers(commit, page, response.data)
|
||||||
}
|
}
|
||||||
|
@ -310,6 +314,10 @@ const users = {
|
||||||
duration: 5 * 1000
|
duration: 5 * 1000
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
async ToggleActorTypeFilter({ commit, dispatch, state }, actorTypeFilters) {
|
||||||
|
commit('SET_ACTOR_TYPE_FILTERS', actorTypeFilters)
|
||||||
|
dispatch('SearchUsers', { query: state.searchQuery, page: 1 })
|
||||||
|
},
|
||||||
async ToggleUsersFilter({ commit, dispatch, state }, filters) {
|
async ToggleUsersFilter({ commit, dispatch, state }, filters) {
|
||||||
const defaultFilters = {
|
const defaultFilters = {
|
||||||
local: false,
|
local: false,
|
||||||
|
|
Loading…
Reference in a new issue