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

@ -170,7 +170,7 @@
},
methods: {
loadTeam() {
this.loading = true
const cancel = message.setLoading(this)
HTTP.get(`teams/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => {
@ -181,14 +181,14 @@
this.userIsAdmin = true
}
}
this.loading = false
cancel()
})
.catch(e => {
this.handleError(e)
})
},
submit() {
this.loading = true
const cancel = message.setLoading(this)
HTTP.post(`teams/` + this.$route.params.id, this.team, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => {
@ -200,33 +200,42 @@
}
}
this.handleSuccess({message: 'The team was successfully updated.'})
cancel()
})
.catch(e => {
this.handleError(e)
cancel()
})
},
deleteTeam() {
const cancel = message.setLoading(this)
HTTP.delete(`teams/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(() => {
this.handleSuccess({message: 'The team was successfully deleted.'})
cancel()
router.push({name: 'home'})
})
.catch(e => {
cancel()
this.handleError(e)
})
},
deleteUser() {
const cancel = message.setLoading(this)
HTTP.delete(`teams/` + this.$route.params.id + `/members/` + this.userToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(() => {
this.showUserDeleteModal = false;
this.handleSuccess({message: 'The user was successfully deleted from the team.'})
this.loadTeam()
cancel()
})
.catch(e => {
cancel()
this.handleError(e)
})
},
addUser(admin) {
const cancel = message.setLoading(this)
if(admin === null) {
admin = false
}
@ -234,9 +243,11 @@
.then(() => {
this.loadTeam()
this.handleSuccess({message: 'The team member was successfully added.'})
cancel()
})
.catch(e => {
this.handleError(e)
cancel()
})
},
toggleUserType(userid, current) {
@ -246,11 +257,9 @@
this.addUser(!current)
},
handleError(e) {
this.loading = false
message.error(e, this)
},
handleSuccess(e) {
this.loading = false
message.success(e, this)
}
}

View File

@ -40,19 +40,18 @@
},
methods: {
loadTeams() {
this.loading = true
const cancel = message.setLoading(this)
HTTP.get(`teams`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => {
this.$set(this, 'teams', response.data)
this.loading = false
cancel()
})
.catch(e => {
this.handleError(e)
})
},
handleError(e) {
this.loading = false
message.error(e, this)
},
}

View File

@ -45,23 +45,23 @@
},
methods: {
newTeam() {
this.loading = true
const cancel = message.setLoading(this)
HTTP.put(`teams`, this.team, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => {
router.push({name:'editTeam', params:{id: response.data.id}})
this.handleSuccess({message: 'The team was successfully created.'})
cancel()
})
.catch(e => {
cancel()
this.handleError(e)
})
},
handleError(e) {
this.loading = false
message.error(e, this)
},
handleSuccess(e) {
this.loading = false
message.success(e, this)
}
}