Move everything to models and services #17
93
src/App.vue
93
src/App.vue
|
@ -116,58 +116,57 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import auth from './auth'
|
||||
import {HTTP} from './http-common'
|
||||
import auth from './auth'
|
||||
import message from './message'
|
||||
import router from './router'
|
||||
import NamespaceService from "./services/namespace";
|
||||
import router from './router'
|
||||
import NamespaceService from './services/namespace'
|
||||
|
||||
export default {
|
||||
name: 'app',
|
||||
export default {
|
||||
name: 'app',
|
||||
|
||||
data() {
|
||||
return {
|
||||
user: auth.user,
|
||||
loading: false,
|
||||
namespaces: [],
|
||||
data() {
|
||||
return {
|
||||
user: auth.user,
|
||||
loading: false,
|
||||
namespaces: [],
|
||||
mobileMenuActive: false,
|
||||
fullpage: false,
|
||||
currentDate: new Date(),
|
||||
namespaceService: NamespaceService,
|
||||
}
|
||||
},
|
||||
beforeMount() {
|
||||
// Password reset
|
||||
if(this.$route.query.userPasswordReset !== undefined) {
|
||||
localStorage.removeItem('passwordResetToken') // Delete an eventually preexisting old token
|
||||
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
|
||||
router.push({name: 'passwordReset'})
|
||||
}
|
||||
// Email verification
|
||||
if(this.$route.query.userEmailConfirm !== undefined) {
|
||||
localStorage.removeItem('emailConfirmToken') // Delete an eventually preexisting old token
|
||||
localStorage.setItem('emailConfirmToken', this.$route.query.userEmailConfirm)
|
||||
router.push({name: 'login'})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.user.authenticated) {
|
||||
this.namespaceService = new NamespaceService()
|
||||
this.loadNamespaces()
|
||||
beforeMount() {
|
||||
// Password reset
|
||||
if(this.$route.query.userPasswordReset !== undefined) {
|
||||
localStorage.removeItem('passwordResetToken') // Delete an eventually preexisting old token
|
||||
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
|
||||
router.push({name: 'passwordReset'})
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// call the method again if the route changes
|
||||
'$route': 'doStuffAfterRoute'
|
||||
},
|
||||
methods: {
|
||||
logout() {
|
||||
auth.logout()
|
||||
},
|
||||
gravatar() {
|
||||
return 'https://www.gravatar.com/avatar/' + this.user.infos.avatar + '?s=50'
|
||||
// Email verification
|
||||
if(this.$route.query.userEmailConfirm !== undefined) {
|
||||
localStorage.removeItem('emailConfirmToken') // Delete an eventually preexisting old token
|
||||
localStorage.setItem('emailConfirmToken', this.$route.query.userEmailConfirm)
|
||||
router.push({name: 'login'})
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.user.authenticated) {
|
||||
this.namespaceService = new NamespaceService()
|
||||
this.loadNamespaces()
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
// call the method again if the route changes
|
||||
'$route': 'doStuffAfterRoute'
|
||||
},
|
||||
methods: {
|
||||
logout() {
|
||||
auth.logout()
|
||||
},
|
||||
loadNamespaces() {
|
||||
gravatar() {
|
||||
return 'https://www.gravatar.com/avatar/' + this.user.infos.avatar + '?s=50'
|
||||
},
|
||||
loadNamespaces() {
|
||||
this.namespaceService.getAll()
|
||||
.then(r => {
|
||||
this.$set(this, 'namespaces', r)
|
||||
|
@ -175,11 +174,11 @@
|
|||
.catch(e => {
|
||||
message.error(e, this)
|
||||
})
|
||||
},
|
||||
},
|
||||
loadNamespacesIfNeeded(e){
|
||||
if (this.user.authenticated && e.name === 'home') {
|
||||
this.loadNamespaces()
|
||||
}
|
||||
if (this.user.authenticated && e.name === 'home') {
|
||||
this.loadNamespaces()
|
||||
}
|
||||
},
|
||||
doStuffAfterRoute(e) {
|
||||
this.fullpage = false;
|
||||
|
@ -189,6 +188,6 @@
|
|||
setFullPage() {
|
||||
this.fullpage = true;
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
Reference in New Issue
Block a user