Merge branch 'v2.1' into master
This commit is contained in:
commit
2d3fc613ec
44 changed files with 923 additions and 392 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 }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
import { APP } from '../_helpers/APP'
|
||||
import { getTotal } from './utils'
|
||||
|
||||
const apiBase = '/tcp'
|
||||
|
||||
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.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 }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
8
webui/src/_services/utils.js
Normal file
8
webui/src/_services/utils.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
export const getTotal = (headers, params) => {
|
||||
const nextPage = parseInt(headers['x-next-page'], 10) || 1
|
||||
const hasNextPage = nextPage > 1
|
||||
|
||||
return hasNextPage
|
||||
? (params.page + 1) * params.limit
|
||||
: params.page * params.limit
|
||||
}
|
|
@ -55,11 +55,11 @@ export default {
|
|||
methods: {
|
||||
getProvider (service) {
|
||||
const words = service.name.split('@')
|
||||
if (words.length !== 2) {
|
||||
return this.provider
|
||||
if (words.length === 2) {
|
||||
return words[1]
|
||||
}
|
||||
|
||||
return words[1]
|
||||
return this.data.provider
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
</div>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section v-if="data.loadBalancer.terminationDelay">
|
||||
<q-card-section v-if="data.loadBalancer && data.loadBalancer.terminationDelay">
|
||||
<div class="row items-start no-wrap">
|
||||
<div class="col">
|
||||
<div class="text-subtitle2">Termination Delay</div>
|
||||
|
|
|
@ -55,11 +55,11 @@ export default {
|
|||
methods: {
|
||||
getProvider (service) {
|
||||
const words = service.name.split('@')
|
||||
if (words.length !== 2) {
|
||||
return this.provider
|
||||
if (words.length === 2) {
|
||||
return words[1]
|
||||
}
|
||||
|
||||
return words[1]
|
||||
return this.data.provider
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue