1
0
Fork 0

Merge branch 'v2.1' into master

This commit is contained in:
Fernandez Ludovic 2019-12-11 22:14:26 +01:00
commit 2d3fc613ec
44 changed files with 923 additions and 392 deletions

View file

@ -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 }
})
}

View file

@ -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 }
})
}

View 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
}

View file

@ -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
}
}
}

View file

@ -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>

View file

@ -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
}
}
}