From de13254f0a4860268b105a2745cd7a0f5d23a059 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Tue, 5 Mar 2019 02:13:04 +0300 Subject: [PATCH 1/3] Add filtration for local users --- src/api/users.js | 10 ++++++++-- src/store/modules/users.js | 18 ++++++++++++++++-- src/views/users/index.vue | 17 ++++++++++++++++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/api/users.js b/src/api/users.js index bfbfd9f4..4d309194 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -16,9 +16,15 @@ export async function toggleUserActivation(nickname) { export async function searchUsers(query, page = 1) { return await request({ - url: `/api/pleroma/admin/users/search?query=${query}&page=${page}`, + url: `/api/pleroma/admin/users?query=${query}&page=${page}`, + method: 'get' + }) +} + +export async function fetchLocalUsers(page = 1) { + return await request({ + url: `/api/pleroma/admin/users?page=${page}&local_only=true`, method: 'get' }) } -export default { fetchUsers, toggleUserActivation } diff --git a/src/store/modules/users.js b/src/store/modules/users.js index 3997165a..402bde8d 100644 --- a/src/store/modules/users.js +++ b/src/store/modules/users.js @@ -1,4 +1,4 @@ -import { fetchUsers, toggleUserActivation, searchUsers } from '@/api/users' +import { fetchUsers, toggleUserActivation, searchUsers, fetchLocalUsers } from '@/api/users' const user = { state: { @@ -6,7 +6,8 @@ const user = { loading: true, searchQuery: '', totalUsersCount: 0, - currentPage: 1 + currentPage: 1, + showLocalUsers: false }, mutations: { SET_USERS: (state, users) => { @@ -35,6 +36,9 @@ const user = { }, SET_SEARCH_QUERY: (state, query) => { state.searchQuery = query + }, + SET_LOCAL_USERS_FILTER: (state, value) => { + state.showLocalUsers = value } }, actions: { @@ -62,6 +66,16 @@ const user = { loadUsers(commit, page, response.data) } + }, + async ToggleLocalUsersFilter({ commit, dispatch }, value) { + commit('SET_LOCAL_USERS_FILTER', value) + + if (value) { + const response = await fetchLocalUsers() + loadUsers(commit, 1, response.data) + } else { + dispatch('FetchUsers', 1) + } } } } diff --git a/src/views/users/index.vue b/src/views/users/index.vue index 5dfabdd5..fbd167aa 100644 --- a/src/views/users/index.vue +++ b/src/views/users/index.vue @@ -1,7 +1,10 @@