Web UI: Table infinite scroll
This commit is contained in:
parent
bd75eddc8e
commit
c4a38de007
15 changed files with 2965 additions and 1049 deletions
|
@ -4,7 +4,7 @@ export function getAllRouters ({ commit }, params) {
|
|||
commit('getAllRoutersRequest')
|
||||
return TcpService.getAllRouters(params)
|
||||
.then(body => {
|
||||
commit('getAllRoutersSuccess', body)
|
||||
commit('getAllRoutersSuccess', { body, ...params })
|
||||
return body
|
||||
})
|
||||
.catch(error => {
|
||||
|
@ -30,7 +30,7 @@ export function getAllServices ({ commit }, params) {
|
|||
commit('getAllServicesRequest')
|
||||
return TcpService.getAllServices(params)
|
||||
.then(body => {
|
||||
commit('getAllServicesSuccess', body)
|
||||
commit('getAllServicesSuccess', { body, ...params })
|
||||
return body
|
||||
})
|
||||
.catch(error => {
|
||||
|
|
|
@ -5,12 +5,33 @@ export function getAllRoutersRequest (state) {
|
|||
state.allRouters.loading = true
|
||||
}
|
||||
|
||||
export function getAllRoutersSuccess (state, body) {
|
||||
state.allRouters = { items: body.data, total: body.total, loading: false }
|
||||
export function getAllRoutersSuccess (state, data) {
|
||||
const { body, query = '', status = '', page } = data
|
||||
const currentState = state.allRouters
|
||||
|
||||
const isSameContext = currentState.currentQuery === query && currentState.currentStatus === status
|
||||
|
||||
state.allRouters = {
|
||||
...state.allRouters,
|
||||
items: [
|
||||
...(isSameContext && currentState.items && page !== 1 ? currentState.items : []),
|
||||
...(body.data || [])
|
||||
],
|
||||
currentPage: page,
|
||||
total: body.total,
|
||||
loading: false,
|
||||
currentQuery: query,
|
||||
currentStatus: status
|
||||
}
|
||||
}
|
||||
|
||||
export function getAllRoutersFailure (state, error) {
|
||||
state.allRouters = { error }
|
||||
state.allRouters = {
|
||||
...state.allRouters,
|
||||
loading: false,
|
||||
error,
|
||||
endReached: error.message.includes('invalid request: page:')
|
||||
}
|
||||
}
|
||||
|
||||
export function getAllRoutersClear (state) {
|
||||
|
@ -43,12 +64,33 @@ export function getAllServicesRequest (state) {
|
|||
state.allServices.loading = true
|
||||
}
|
||||
|
||||
export function getAllServicesSuccess (state, body) {
|
||||
state.allServices = { items: body.data, total: body.total, loading: false }
|
||||
export function getAllServicesSuccess (state, data) {
|
||||
const { body, query = '', status = '', page } = data
|
||||
const currentState = state.allServices
|
||||
|
||||
const isSameContext = currentState.currentQuery === query && currentState.currentStatus === status
|
||||
|
||||
state.allServices = {
|
||||
...state.allServices,
|
||||
items: [
|
||||
...(isSameContext && currentState.items && page !== 1 ? currentState.items : []),
|
||||
...(body.data || [])
|
||||
],
|
||||
currentPage: page,
|
||||
total: body.total,
|
||||
loading: false,
|
||||
currentQuery: query,
|
||||
currentStatus: status
|
||||
}
|
||||
}
|
||||
|
||||
export function getAllServicesFailure (state, error) {
|
||||
state.allServices = { error }
|
||||
state.allServices = {
|
||||
...state.allServices,
|
||||
loading: false,
|
||||
error,
|
||||
endReached: error.message.includes('invalid request: page:')
|
||||
}
|
||||
}
|
||||
|
||||
export function getAllServicesClear (state) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue