Web UI: Avoid unnecessary duplicated api calls
This commit is contained in:
parent
5b1dc0bfbd
commit
407eda0ba0
2 changed files with 20 additions and 35 deletions
|
@ -3,16 +3,13 @@ import { APP } from '../_helpers/APP'
|
||||||
const apiBase = '/http'
|
const apiBase = '/http'
|
||||||
|
|
||||||
function getAllRouters (params) {
|
function getAllRouters (params) {
|
||||||
return APP.api.get(`${apiBase}/routers?search=${params.query}&status=${params.status}`)
|
|
||||||
.then(body => {
|
|
||||||
const total = body.data ? body.data.length : 0
|
|
||||||
return APP.api.get(`${apiBase}/routers?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
return APP.api.get(`${apiBase}/routers?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
||||||
.then(body => {
|
.then(body => {
|
||||||
|
const total = body.data ? body.data.length : 0
|
||||||
console.log('Success -> HttpService -> getAllRouters', body.data)
|
console.log('Success -> HttpService -> getAllRouters', body.data)
|
||||||
// TODO - suggestion: add the total-pages in api response to optimize the query
|
// TODO - suggestion: add the total-pages in api response to optimize the query
|
||||||
return { data: body.data || [], total }
|
return { data: body.data || [], total }
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRouterByName (name) {
|
function getRouterByName (name) {
|
||||||
|
@ -24,16 +21,13 @@ function getRouterByName (name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllServices (params) {
|
function getAllServices (params) {
|
||||||
return APP.api.get(`${apiBase}/services?search=${params.query}&status=${params.status}`)
|
|
||||||
.then(body => {
|
|
||||||
const total = body.data ? body.data.length : 0
|
|
||||||
return APP.api.get(`${apiBase}/services?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
return APP.api.get(`${apiBase}/services?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
||||||
.then(body => {
|
.then(body => {
|
||||||
|
const total = body.data ? body.data.length : 0
|
||||||
console.log('Success -> HttpService -> getAllServices', body.data)
|
console.log('Success -> HttpService -> getAllServices', body.data)
|
||||||
// TODO - suggestion: add the total-pages in api response to optimize the query
|
// TODO - suggestion: add the total-pages in api response to optimize the query
|
||||||
return { data: body.data || [], total }
|
return { data: body.data || [], total }
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getServiceByName (name) {
|
function getServiceByName (name) {
|
||||||
|
@ -45,16 +39,13 @@ function getServiceByName (name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllMiddlewares (params) {
|
function getAllMiddlewares (params) {
|
||||||
return APP.api.get(`${apiBase}/middlewares?search=${params.query}&status=${params.status}`)
|
|
||||||
.then(body => {
|
|
||||||
const total = body.data ? body.data.length : 0
|
|
||||||
return APP.api.get(`${apiBase}/middlewares?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
return APP.api.get(`${apiBase}/middlewares?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
||||||
.then(body => {
|
.then(body => {
|
||||||
|
const total = body.data ? body.data.length : 0
|
||||||
console.log('Success -> HttpService -> getAllMiddlewares', body.data)
|
console.log('Success -> HttpService -> getAllMiddlewares', body.data)
|
||||||
// TODO - suggestion: add the total-pages in api response to optimize the query
|
// TODO - suggestion: add the total-pages in api response to optimize the query
|
||||||
return { data: body.data || [], total }
|
return { data: body.data || [], total }
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMiddlewareByName (name) {
|
function getMiddlewareByName (name) {
|
||||||
|
|
|
@ -3,16 +3,13 @@ import { APP } from '../_helpers/APP'
|
||||||
const apiBase = '/tcp'
|
const apiBase = '/tcp'
|
||||||
|
|
||||||
function getAllRouters (params) {
|
function getAllRouters (params) {
|
||||||
return APP.api.get(`${apiBase}/routers?search=${params.query}&status=${params.status}`)
|
|
||||||
.then(body => {
|
|
||||||
const total = body.data ? body.data.length : 0
|
|
||||||
return APP.api.get(`${apiBase}/routers?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
return APP.api.get(`${apiBase}/routers?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
||||||
.then(body => {
|
.then(body => {
|
||||||
|
const total = body.data ? body.data.length : 0
|
||||||
console.log('Success -> HttpService -> getAllRouters', body.data)
|
console.log('Success -> HttpService -> getAllRouters', body.data)
|
||||||
// TODO - suggestion: add the total-pages in api response to optimize the query
|
// TODO - suggestion: add the total-pages in api response to optimize the query
|
||||||
return { data: body.data || [], total }
|
return { data: body.data || [], total }
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRouterByName (name) {
|
function getRouterByName (name) {
|
||||||
|
@ -24,16 +21,13 @@ function getRouterByName (name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllServices (params) {
|
function getAllServices (params) {
|
||||||
return APP.api.get(`${apiBase}/services?search=${params.query}&status=${params.status}`)
|
|
||||||
.then(body => {
|
|
||||||
const total = body.data ? body.data.length : 0
|
|
||||||
return APP.api.get(`${apiBase}/services?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
return APP.api.get(`${apiBase}/services?search=${params.query}&status=${params.status}&per_page=${params.limit}&page=${params.page}`)
|
||||||
.then(body => {
|
.then(body => {
|
||||||
|
const total = body.data ? body.data.length : 0
|
||||||
console.log('Success -> HttpService -> getAllServices', body.data)
|
console.log('Success -> HttpService -> getAllServices', body.data)
|
||||||
// TODO - suggestion: add the total-pages in api response to optimize the query
|
// TODO - suggestion: add the total-pages in api response to optimize the query
|
||||||
return { data: body.data || [], total }
|
return { data: body.data || [], total }
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getServiceByName (name) {
|
function getServiceByName (name) {
|
||||||
|
|
Loading…
Reference in a new issue