Skip to content

Commit

Permalink
fix rest-client bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Doflatango authored and miraclesu committed Jul 17, 2017
1 parent 99e2da5 commit 83006a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
16 changes: 12 additions & 4 deletions web/ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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');
}).
Expand All @@ -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').
Expand Down
9 changes: 3 additions & 6 deletions web/ui/src/libraries/rest-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 83006a5

Please sign in to comment.