Exclude page size handling from frontend

This commit is contained in:
Angelina Filippova 2019-03-04 00:25:25 +03:00
parent 3adcd048a1
commit 8a698398d5
3 changed files with 13 additions and 14 deletions

View file

@ -1,8 +1,8 @@
import request from '@/utils/request'
export async function fetchUsers(page = 1, page_size) {
export async function fetchUsers(page = 1) {
return await request({
url: `/api/pleroma/admin/users?page=${page}&page_size=${page_size}`,
url: `/api/pleroma/admin/users?page=${page}`,
method: 'get'
})
}
@ -14,9 +14,9 @@ export async function toggleUserActivation(nickname) {
})
}
export async function searchUsers(query, page = 1, page_size) {
export async function searchUsers(query, page = 1) {
return await request({
url: `/api/pleroma/admin/users/search?query=${query}&page=${page}&page_size=${page_size}`,
url: `/api/pleroma/admin/users/search?query=${query}&page=${page}`,
method: 'get'
})
}

View file

@ -6,7 +6,6 @@ const user = {
loading: true,
searchQuery: '',
totalUsersCount: 0,
pageSize: 2,
currentPage: 1
},
mutations: {
@ -39,8 +38,8 @@ const user = {
}
},
actions: {
async FetchUsers({ commit }, { page, page_size }) {
const response = await fetchUsers(page, page_size)
async FetchUsers({ commit }, { page }) {
const response = await fetchUsers(page)
commit('SET_LOADING', true)
@ -51,15 +50,15 @@ const user = {
commit('SWAP_USER', response.data)
},
async SearchUsers({ commit, dispatch }, { query, page, page_size }) {
async SearchUsers({ commit, dispatch }, { query, page }) {
if (query.length === 0) {
commit('SET_SEARCH_QUERY', query)
dispatch('FetchUsers', { page, page_size: 2 })
dispatch('FetchUsers', page)
} else {
commit('SET_LOADING', true)
commit('SET_SEARCH_QUERY', query)
const response = await searchUsers(query, page, page_size)
const response = await searchUsers(query, page)
loadUsers(commit, page, response.data)
}

View file

@ -60,11 +60,11 @@ export default {
},
created() {
this.handleDebounceSearchInput = debounce((query) => {
this.$store.dispatch('SearchUsers', { query, page: 1, page_size: 2 })
this.$store.dispatch('SearchUsers', { query, page: 1 })
}, 500)
},
mounted: function() {
this.$store.dispatch('FetchUsers', { page: 1, page_size: 2 })
this.$store.dispatch('FetchUsers', { page: 1 })
},
methods: {
handleDeactivate({ nickname }) {
@ -73,9 +73,9 @@ export default {
handlePageChange(page) {
const searchQuery = this.$store.state.users.searchQuery
if (searchQuery === '') {
this.$store.dispatch('FetchUsers', { page, page_size: 2 })
this.$store.dispatch('FetchUsers', { page })
} else {
this.$store.dispatch('SearchUsers', { query: searchQuery, page, page_size: 2 })
this.$store.dispatch('SearchUsers', { query: searchQuery, page })
}
},
showDeactivatedButton(id) {