Move everything to models and services #17

Merged
konrad merged 82 commits from refactor/models into master 2019-03-02 10:25:10 +00:00
Showing only changes of commit 2d4ee63e1f - Show all commits

View File

@ -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>