mirror of
https://github.com/vx3r/wg-gen-web.git
synced 2025-09-11 12:24:27 +00:00
update readme, some improvements in error handling
This commit is contained in:
@ -80,7 +80,8 @@
|
||||
<v-card-title>
|
||||
No stats available...
|
||||
</v-card-title>
|
||||
<v-card-text>{{ error }}</v-card-text>
|
||||
<v-card-text v-if="enabled">{{ error }}</v-card-text>
|
||||
<v-card-text v-else>Status API integration not configured.</v-card-text>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@ -109,26 +110,32 @@
|
||||
...mapGetters({
|
||||
interface: 'status/interfaceStatus',
|
||||
clients: 'status/clientStatus',
|
||||
enabled: 'status/enabled',
|
||||
error: 'status/error',
|
||||
}),
|
||||
dataLoaded: function () {
|
||||
return this.interface != null && this.interface.name !== "";
|
||||
return this.enabled && this.interface != null && this.interface.name !== "";
|
||||
}
|
||||
},
|
||||
|
||||
mounted () {
|
||||
this.readStatus()
|
||||
this.readEnabled()
|
||||
if(this.enabled) {
|
||||
this.readStatus()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapActions('status', {
|
||||
readStatus: 'read',
|
||||
readEnabled: 'isEnabled',
|
||||
}),
|
||||
|
||||
reload() {
|
||||
this.readStatus()
|
||||
},
|
||||
|
||||
// https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string
|
||||
humanFileSize(bytes, si=false, dp=1) {
|
||||
const thresh = si ? 1000 : 1024;
|
||||
|
||||
|
@ -10,9 +10,13 @@ const ApiService = {
|
||||
get(resource) {
|
||||
return Vue.axios.get(resource)
|
||||
.then(response => response.data)
|
||||
.catch(error => {
|
||||
throw new Error(`ApiService: ${error}`)
|
||||
});
|
||||
.catch(error => {
|
||||
if(typeof error.response !== 'undefined') {
|
||||
throw new Error(`${error.response.status} - ${error.response.statusText}: ${error.response.data}`)
|
||||
} else {
|
||||
throw new Error(`ApiService: ${error}`)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
post(resource, params) {
|
||||
|
@ -2,6 +2,7 @@ import ApiService from "../../services/api.service";
|
||||
|
||||
const state = {
|
||||
error: null,
|
||||
enabled: false,
|
||||
interfaceStatus: null,
|
||||
clientStatus: [],
|
||||
version: '_ci_build_not_run_properly_',
|
||||
@ -12,6 +13,10 @@ const getters = {
|
||||
return state.error;
|
||||
},
|
||||
|
||||
enabled(state) {
|
||||
return state.enabled;
|
||||
},
|
||||
|
||||
interfaceStatus(state) {
|
||||
return state.interfaceStatus;
|
||||
},
|
||||
@ -48,6 +53,17 @@ const actions = {
|
||||
commit('error', err)
|
||||
});
|
||||
},
|
||||
|
||||
isEnabled({ commit }){
|
||||
ApiService.get("/status/enabled")
|
||||
.then(resp => {
|
||||
commit('enabled', resp)
|
||||
})
|
||||
.catch(err => {
|
||||
commit('enabled', false);
|
||||
commit('error', err.response.data)
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
@ -55,6 +71,10 @@ const mutations = {
|
||||
state.error = error;
|
||||
},
|
||||
|
||||
enabled(state, enabled) {
|
||||
state.enabled = enabled;
|
||||
},
|
||||
|
||||
interfaceStatus(state, interfaceStatus){
|
||||
state.interfaceStatus = interfaceStatus
|
||||
},
|
||||
|
Reference in New Issue
Block a user