1
0

Delay loading animation (#8)

This commit is contained in:
konrad
2018-11-27 10:23:50 +00:00
committed by Gitea
parent 12f58bc1c6
commit 74455b058a
15 changed files with 112 additions and 58 deletions

View File

@ -97,7 +97,7 @@
},
methods: {
loadNamespace() {
this.loading = true
const cancel = message.setLoading(this)
HTTP.get(`namespaces/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => {
@ -105,14 +105,15 @@
if (response.data.owner.id === this.user.infos.id) {
this.userIsAdmin = true
}
this.loading = false
cancel()
})
.catch(e => {
this.handleError(e)
cancel()
})
},
submit() {
this.loading = true
const cancel = message.setLoading(this)
HTTP.post(`namespaces/` + this.$route.params.id, this.namespace, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => {
@ -124,27 +125,30 @@
}
}
this.handleSuccess({message: 'The namespace was successfully updated.'})
cancel()
})
.catch(e => {
this.handleError(e)
cancel()
})
},
deleteNamespace() {
const cancel = message.setLoading(this)
HTTP.delete(`namespaces/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(() => {
this.handleSuccess({message: 'The namespace was successfully deleted.'})
router.push({name: 'home'})
cancel()
router.push({name: 'home'})
})
.catch(e => {
this.handleError(e)
cancel()
})
},
handleError(e) {
this.loading = false
message.error(e, this)
},
handleSuccess(e) {
this.loading = false
message.success(e, this)
}
}

View File

@ -45,23 +45,23 @@
},
methods: {
newNamespace() {
this.loading = true
const cancel = message.setLoading(this)
HTTP.put(`namespaces`, this.namespace, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(() => {
this.$parent.loadNamespaces()
this.handleSuccess({message: 'The namespace was successfully created.'})
cancel()
})
.catch(e => {
this.handleError(e)
cancel()
})
},
handleError(e) {
this.loading = false
message.error(e, this)
},
handleSuccess(e) {
this.loading = false
message.success(e, this)
}
}