Browse Source

fix rest-client bug

pull/45/head
Doflatango 7 years ago
parent
commit
26face1b77
  1. 16
      web/ui/src/App.vue
  2. 9
      web/ui/src/libraries/rest-client.js

16
web/ui/src/App.vue

@ -2,10 +2,10 @@
<div id="app">
<div class="ui blue inverted menu fixed">
<div class="item">CRONSUN</div>
<router-link v-if="$store.getters.email" class="item" to="/" v-bind:class="{active: this.$route.path == '/'}"><i class="dashboard icon"></i> {{$L('dashboard')}}</router-link>
<router-link v-if="$store.getters.email" class="item" to="/log" v-bind:class="{active: this.$route.path.indexOf('/log') === 0}"><i class="file text icon"></i> {{$L('log')}}</router-link>
<router-link v-if="$store.getters.email" class="item" to="/job" v-bind:class="{active: this.$route.path.indexOf('/job') === 0}"><i class="calendar icon"></i> {{$L('job')}}</router-link>
<router-link v-if="$store.getters.email" class="item" to="/node" v-bind:class="{active: this.$route.path.indexOf('/node') === 0}"><i class="server icon"></i> {{$L('node')}}</router-link>
<router-link v-if="shouldOpen" class="item" to="/" v-bind:class="{active: this.$route.path == '/'}"><i class="dashboard icon"></i> {{$L('dashboard')}}</router-link>
<router-link v-if="shouldOpen" class="item" to="/log" v-bind:class="{active: this.$route.path.indexOf('/log') === 0}"><i class="file text icon"></i> {{$L('log')}}</router-link>
<router-link v-if="shouldOpen" class="item" to="/job" v-bind:class="{active: this.$route.path.indexOf('/job') === 0}"><i class="calendar icon"></i> {{$L('job')}}</router-link>
<router-link v-if="shouldOpen" class="item" to="/node" v-bind:class="{active: this.$route.path.indexOf('/node') === 0}"><i class="server icon"></i> {{$L('node')}}</router-link>
<router-link v-if="$store.getters.enabledAuth && $store.getters.role === 1" class="item" to="/admin/account/list" v-bind:class="{active: this.$route.path.indexOf('/admin/account') === 0}"><i class="user icon"></i> {{$L('account')}}</router-link>
<div class="right menu">
@ -52,6 +52,8 @@ export default {
}).onfailed((data, xhr) => {
if (xhr.status !== 401) {
vm.$bus.$emit('error', data);
} else {
vm.$store.commit('enabledAuth', true);
}
vm.$router.push('/login');
}).
@ -74,6 +76,12 @@ export default {
});
},
computed: {
shouldOpen() {
return !this.$store.getters.enabledAuth || (this.$store.getters.enabledAuth && this.$store.getters.email)
}
},
methods: {
getConfig() {
this.$rest.GET('configurations').

9
web/ui/src/libraries/rest-client.js

@ -28,15 +28,12 @@ var sendXHR = function(opt) {
data = xhr.response;
}
if (opt.specialHandlers && typeof opt.specialHandlers[xhr.status] === 'function') {
opt.specialHandlers[xhr.status](data, xhr);
return
}
if (xhr.status != opt.successCode) {
typeof opt.onfailed == 'function' && opt.onfailed(data, xhr);
} else if (typeof opt.onsucceed == 'function') {
} else if (xhr.status === opt.successCode && typeof opt.onsucceed == 'function') {
opt.onsucceed(data, xhr);
} else if (opt.specialHandlers && typeof opt.specialHandlers[xhr.status] === 'function') {
opt.specialHandlers[xhr.status](data, xhr);
}
typeof opt.onend == 'function' && opt.onend(xhr);

Loading…
Cancel
Save