Fix http/tcp resources pagination
This commit is contained in:
parent
aac3e2d4fb
commit
1d4f10bead
4 changed files with 36 additions and 26 deletions
|
@ -1,14 +1,15 @@
|
|||
import { APP } from '../_helpers/APP'
|
||||
import { getTotal } from './utils'
|
||||
|
||||
const apiBase = '/http'
|
||||
|
||||
function getAllRouters (params) {
|
||||
return APP.api.get(`${apiBase}/routers?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
||||
.then(body => {
|
||||
const total = body.data ? body.data.length : 0
|
||||
console.log('Success -> HttpService -> getAllRouters', body.data)
|
||||
// TODO - suggestion: add the total-pages in api response to optimize the query
|
||||
return { data: body.data || [], total }
|
||||
.then(response => {
|
||||
const { data = [], headers } = response
|
||||
const total = getTotal(headers, params)
|
||||
console.log('Success -> HttpService -> getAllRouters', response, response.data)
|
||||
return { data, total }
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -22,11 +23,11 @@ function getRouterByName (name) {
|
|||
|
||||
function getAllServices (params) {
|
||||
return APP.api.get(`${apiBase}/services?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
||||
.then(body => {
|
||||
const total = body.data ? body.data.length : 0
|
||||
console.log('Success -> HttpService -> getAllServices', body.data)
|
||||
// TODO - suggestion: add the total-pages in api response to optimize the query
|
||||
return { data: body.data || [], total }
|
||||
.then(response => {
|
||||
const { data = [], headers } = response
|
||||
const total = getTotal(headers, params)
|
||||
console.log('Success -> HttpService -> getAllServices', response.data)
|
||||
return { data, total }
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -40,11 +41,11 @@ function getServiceByName (name) {
|
|||
|
||||
function getAllMiddlewares (params) {
|
||||
return APP.api.get(`${apiBase}/middlewares?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
||||
.then(body => {
|
||||
const total = body.data ? body.data.length : 0
|
||||
console.log('Success -> HttpService -> getAllMiddlewares', body.data)
|
||||
// TODO - suggestion: add the total-pages in api response to optimize the query
|
||||
return { data: body.data || [], total }
|
||||
.then(response => {
|
||||
const { data = [], headers } = response
|
||||
const total = getTotal(headers, params)
|
||||
console.log('Success -> HttpService -> getAllMiddlewares', response.data)
|
||||
return { data, total }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue