Delay loading animation (#8)
This commit is contained in:
parent
12f58bc1c6
commit
74455b058a
15 changed files with 112 additions and 58 deletions
|
@ -57,14 +57,17 @@
|
||||||
auth.logout()
|
auth.logout()
|
||||||
},
|
},
|
||||||
loadPendingTasks() {
|
loadPendingTasks() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
HTTP.get(`tasks`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.get(`tasks`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.tasks = response.data
|
this.tasks = response.data
|
||||||
this.tasks.sort(this.sortyByDeadline)
|
this.tasks.sort(this.sortyByDeadline)
|
||||||
|
cancel()
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
cancel()
|
||||||
|
this.loading = false
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -78,7 +81,6 @@
|
||||||
router.push({name: 'showList', params: {id: lid}})
|
router.push({name: 'showList', params: {id: lid}})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadList() {
|
loadList() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.get(`lists/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.get(`lists/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -105,14 +105,14 @@
|
||||||
if (response.data.owner.id === this.user.infos.id) {
|
if (response.data.owner.id === this.user.infos.id) {
|
||||||
this.userIsAdmin = true
|
this.userIsAdmin = true
|
||||||
}
|
}
|
||||||
this.loading = false
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.post(`lists/` + this.$route.params.id, this.list, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.post(`lists/` + this.$route.params.id, this.list, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -126,27 +126,30 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.handleSuccess({message: 'The list was successfully updated.'})
|
this.handleSuccess({message: 'The list was successfully updated.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteList() {
|
deleteList() {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
HTTP.delete(`lists/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.delete(`lists/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.handleSuccess({message: 'The list was successfully deleted.'})
|
this.handleSuccess({message: 'The list was successfully deleted.'})
|
||||||
|
cancel()
|
||||||
router.push({name: 'home'})
|
router.push({name: 'home'})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,23 +45,23 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
newList() {
|
newList() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.put(`namespaces/` + this.$route.params.id + `/lists`, this.list, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.put(`namespaces/` + this.$route.params.id + `/lists`, this.list, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$parent.loadNamespaces()
|
this.$parent.loadNamespaces()
|
||||||
this.handleSuccess({message: 'The list was successfully created.'})
|
this.handleSuccess({message: 'The list was successfully created.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,12 +190,10 @@
|
||||||
methods: {
|
methods: {
|
||||||
loadList() {
|
loadList() {
|
||||||
this.isTaskEdit = false
|
this.isTaskEdit = false
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.get(`lists/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.get(`lists/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.loading = false
|
|
||||||
|
|
||||||
// Make date objects from timestamps
|
// Make date objects from timestamps
|
||||||
for (const t in response.data.tasks) {
|
for (const t in response.data.tasks) {
|
||||||
let dueDate = new Date(response.data.tasks[t].dueDate * 1000)
|
let dueDate = new Date(response.data.tasks[t].dueDate * 1000)
|
||||||
|
@ -215,36 +213,41 @@
|
||||||
if (this.list.tasks === null) {
|
if (this.list.tasks === null) {
|
||||||
this.list.tasks = []
|
this.list.tasks = []
|
||||||
}
|
}
|
||||||
|
cancel() // cancel the timer
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addTask() {
|
addTask() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.put(`lists/` + this.$route.params.id, {text: this.newTask}, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.put(`lists/` + this.$route.params.id, {text: this.newTask}, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.list.tasks.push(response.data)
|
this.list.tasks.push(response.data)
|
||||||
this.handleSuccess({message: 'The task was successfully created.'})
|
this.handleSuccess({message: 'The task was successfully created.'})
|
||||||
|
cancel() // cancel the timer
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.newTask = ''
|
this.newTask = ''
|
||||||
},
|
},
|
||||||
markAsDone(e) {
|
markAsDone(e) {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
this.loading = true
|
|
||||||
|
|
||||||
HTTP.post(`tasks/` + e.target.id, {done: e.target.checked}, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.post(`tasks/` + e.target.id, {done: e.target.checked}, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.updateTaskByID(parseInt(e.target.id), response.data)
|
this.updateTaskByID(parseInt(e.target.id), response.data)
|
||||||
this.handleSuccess({message: 'The task was successfully ' + (e.target.checked ? 'un-' :'') + 'marked as done.'})
|
this.handleSuccess({message: 'The task was successfully ' + (e.target.checked ? 'un-' :'') + 'marked as done.'})
|
||||||
|
cancel() // To not set the spinner to loading when the request is made in less than 100ms, would lead to loading infinitly.
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
editTask(id) {
|
editTask(id) {
|
||||||
|
@ -288,7 +291,7 @@
|
||||||
this.isTaskEdit = true
|
this.isTaskEdit = true
|
||||||
},
|
},
|
||||||
editTaskSubmit() {
|
editTaskSubmit() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
// Convert the date in a unix timestamp
|
// Convert the date in a unix timestamp
|
||||||
let duedate = (+ new Date(this.taskEditTask.dueDate)) / 1000
|
let duedate = (+ new Date(this.taskEditTask.dueDate)) / 1000
|
||||||
|
@ -335,9 +338,11 @@
|
||||||
// Also update the current taskedit object so the ui changes
|
// Also update the current taskedit object so the ui changes
|
||||||
this.$set(this, 'taskEditTask', response.data)
|
this.$set(this, 'taskEditTask', response.data)
|
||||||
this.handleSuccess({message: 'The task was successfully updated.'})
|
this.handleSuccess({message: 'The task was successfully updated.'})
|
||||||
|
cancel() // cancel the timers
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateTaskByID(id, updatedTask) {
|
updateTaskByID(id, updatedTask) {
|
||||||
|
@ -395,11 +400,9 @@
|
||||||
return dates
|
return dates
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadNamespace() {
|
loadNamespace() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.get(`namespaces/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.get(`namespaces/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -105,14 +105,15 @@
|
||||||
if (response.data.owner.id === this.user.infos.id) {
|
if (response.data.owner.id === this.user.infos.id) {
|
||||||
this.userIsAdmin = true
|
this.userIsAdmin = true
|
||||||
}
|
}
|
||||||
this.loading = false
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.post(`namespaces/` + this.$route.params.id, this.namespace, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.post(`namespaces/` + this.$route.params.id, this.namespace, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -124,27 +125,30 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.handleSuccess({message: 'The namespace was successfully updated.'})
|
this.handleSuccess({message: 'The namespace was successfully updated.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteNamespace() {
|
deleteNamespace() {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
HTTP.delete(`namespaces/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.delete(`namespaces/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.handleSuccess({message: 'The namespace was successfully deleted.'})
|
this.handleSuccess({message: 'The namespace was successfully deleted.'})
|
||||||
|
cancel()
|
||||||
router.push({name: 'home'})
|
router.push({name: 'home'})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,23 +45,23 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
newNamespace() {
|
newNamespace() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.put(`namespaces`, this.namespace, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.put(`namespaces`, this.namespace, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.$parent.loadNamespaces()
|
this.$parent.loadNamespaces()
|
||||||
this.handleSuccess({message: 'The namespace was successfully created.'})
|
this.handleSuccess({message: 'The namespace was successfully created.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,27 +121,33 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadTeams() {
|
loadTeams() {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
HTTP.get(this.typeString + `s/` + this.id + `/teams`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.get(this.typeString + `s/` + this.id + `/teams`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$set(this, 'listTeams', response.data)
|
this.$set(this, 'listTeams', response.data)
|
||||||
this.loading = false
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteTeam() {
|
deleteTeam() {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
HTTP.delete(this.typeString + `s/` + this.id + `/teams/` + this.teamToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.delete(this.typeString + `s/` + this.id + `/teams/` + this.teamToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.showTeamDeleteModal = false;
|
this.showTeamDeleteModal = false;
|
||||||
this.handleSuccess({message: 'The team was successfully deleted from the ' + this.typeString + '.'})
|
this.handleSuccess({message: 'The team was successfully deleted from the ' + this.typeString + '.'})
|
||||||
this.loadTeams()
|
this.loadTeams()
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addTeam(admin) {
|
addTeam(admin) {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
if(admin === null) {
|
if(admin === null) {
|
||||||
admin = false
|
admin = false
|
||||||
}
|
}
|
||||||
|
@ -154,12 +160,15 @@
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loadTeams()
|
this.loadTeams()
|
||||||
this.handleSuccess({message: 'The team was successfully added.'})
|
this.handleSuccess({message: 'The team was successfully added.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toggleTeamType(teamid, current) {
|
toggleTeamType(teamid, current) {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
let right = 0
|
let right = 0
|
||||||
if (!current) {
|
if (!current) {
|
||||||
right = 2
|
right = 2
|
||||||
|
@ -169,17 +178,17 @@
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loadTeams()
|
this.loadTeams()
|
||||||
this.handleSuccess({message: 'The team right was successfully updated.'})
|
this.handleSuccess({message: 'The team right was successfully updated.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -142,28 +142,34 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadUsers() {
|
loadUsers() {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
HTTP.get(this.typeString + `s/` + this.id + `/users`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.get(this.typeString + `s/` + this.id + `/users`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
//response.data.push(this.list.owner)
|
//response.data.push(this.list.owner)
|
||||||
this.$set(this, 'users', response.data)
|
this.$set(this, 'users', response.data)
|
||||||
this.loading = false
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteUser() {
|
deleteUser() {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
HTTP.delete(this.typeString + `s/` + this.id + `/users/` + this.userToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.delete(this.typeString + `s/` + this.id + `/users/` + this.userToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.showUserDeleteModal = false;
|
this.showUserDeleteModal = false;
|
||||||
this.handleSuccess({message: 'The user was successfully deleted from the ' + this.typeString + '.'})
|
this.handleSuccess({message: 'The user was successfully deleted from the ' + this.typeString + '.'})
|
||||||
this.loadUsers()
|
this.loadUsers()
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addUser(admin) {
|
addUser(admin) {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
if(admin === null) {
|
if(admin === null) {
|
||||||
admin = false
|
admin = false
|
||||||
}
|
}
|
||||||
|
@ -179,12 +185,15 @@
|
||||||
this.loadUsers()
|
this.loadUsers()
|
||||||
this.newUser = {}
|
this.newUser = {}
|
||||||
this.handleSuccess({message: 'The user was successfully added.'})
|
this.handleSuccess({message: 'The user was successfully added.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toggleUserType(userid, current) {
|
toggleUserType(userid, current) {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
let right = 0
|
let right = 0
|
||||||
if (!current) {
|
if (!current) {
|
||||||
right = 2
|
right = 2
|
||||||
|
@ -194,16 +203,18 @@
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loadUsers()
|
this.loadUsers()
|
||||||
this.handleSuccess({message: 'The user right was successfully updated.'})
|
this.handleSuccess({message: 'The user right was successfully updated.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
findUsers(query) {
|
findUsers(query) {
|
||||||
this.loading = true;
|
const cancel = message.setLoading(this)
|
||||||
if(query === '') {
|
if(query === '') {
|
||||||
this.$set(this, 'foundUsers', [])
|
this.$set(this, 'foundUsers', [])
|
||||||
this.loading = false
|
cancel()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,10 +231,11 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loading = false
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
clearAll () {
|
clearAll () {
|
||||||
|
@ -233,11 +245,9 @@
|
||||||
return `and ${count} others`
|
return `and ${count} others`
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -170,7 +170,7 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadTeam() {
|
loadTeam() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.get(`teams/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.get(`teams/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -181,14 +181,14 @@
|
||||||
this.userIsAdmin = true
|
this.userIsAdmin = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.loading = false
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.post(`teams/` + this.$route.params.id, this.team, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.post(`teams/` + this.$route.params.id, this.team, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -200,33 +200,42 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.handleSuccess({message: 'The team was successfully updated.'})
|
this.handleSuccess({message: 'The team was successfully updated.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteTeam() {
|
deleteTeam() {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
HTTP.delete(`teams/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.delete(`teams/` + this.$route.params.id, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.handleSuccess({message: 'The team was successfully deleted.'})
|
this.handleSuccess({message: 'The team was successfully deleted.'})
|
||||||
|
cancel()
|
||||||
router.push({name: 'home'})
|
router.push({name: 'home'})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
cancel()
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteUser() {
|
deleteUser() {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
HTTP.delete(`teams/` + this.$route.params.id + `/members/` + this.userToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.delete(`teams/` + this.$route.params.id + `/members/` + this.userToDelete, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.showUserDeleteModal = false;
|
this.showUserDeleteModal = false;
|
||||||
this.handleSuccess({message: 'The user was successfully deleted from the team.'})
|
this.handleSuccess({message: 'The user was successfully deleted from the team.'})
|
||||||
this.loadTeam()
|
this.loadTeam()
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
cancel()
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addUser(admin) {
|
addUser(admin) {
|
||||||
|
const cancel = message.setLoading(this)
|
||||||
if(admin === null) {
|
if(admin === null) {
|
||||||
admin = false
|
admin = false
|
||||||
}
|
}
|
||||||
|
@ -234,9 +243,11 @@
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loadTeam()
|
this.loadTeam()
|
||||||
this.handleSuccess({message: 'The team member was successfully added.'})
|
this.handleSuccess({message: 'The team member was successfully added.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toggleUserType(userid, current) {
|
toggleUserType(userid, current) {
|
||||||
|
@ -246,11 +257,9 @@
|
||||||
this.addUser(!current)
|
this.addUser(!current)
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,19 +40,18 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadTeams() {
|
loadTeams() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.get(`teams`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.get(`teams`, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$set(this, 'teams', response.data)
|
this.$set(this, 'teams', response.data)
|
||||||
this.loading = false
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,23 +45,23 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
newTeam() {
|
newTeam() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
|
|
||||||
HTTP.put(`teams`, this.team, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.put(`teams`, this.team, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
router.push({name:'editTeam', params:{id: response.data.id}})
|
router.push({name:'editTeam', params:{id: response.data.id}})
|
||||||
this.handleSuccess({message: 'The team was successfully created.'})
|
this.handleSuccess({message: 'The team was successfully created.'})
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
cancel()
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
message.error(e, this)
|
message.error(e, this)
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
message.success(e, this)
|
message.success(e, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
import auth from '../../auth'
|
import auth from '../../auth'
|
||||||
import router from '../../router'
|
import router from '../../router'
|
||||||
import {HTTP} from '../../http-common'
|
import {HTTP} from '../../http-common'
|
||||||
|
import message from '../../message'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -53,15 +54,15 @@
|
||||||
// Try to verify the email
|
// Try to verify the email
|
||||||
let emailVerifyToken = localStorage.getItem('emailConfirmToken')
|
let emailVerifyToken = localStorage.getItem('emailConfirmToken')
|
||||||
if (emailVerifyToken) {
|
if (emailVerifyToken) {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
HTTP.post(`user/confirm`, {token: emailVerifyToken})
|
HTTP.post(`user/confirm`, {token: emailVerifyToken})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
localStorage.removeItem('emailConfirmToken')
|
localStorage.removeItem('emailConfirmToken')
|
||||||
this.loading = false
|
|
||||||
this.confirmedEmailSuccess = true
|
this.confirmedEmailSuccess = true
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.loading = false
|
cancel()
|
||||||
this.error = e.response.data.message
|
this.error = e.response.data.message
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {HTTP} from '../../http-common'
|
import {HTTP} from '../../http-common'
|
||||||
|
import message from '../../message'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -53,11 +54,11 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit() {
|
submit() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
this.error = ''
|
this.error = ''
|
||||||
|
|
||||||
if (this.credentials.password2 !== this.credentials.password) {
|
if (this.credentials.password2 !== this.credentials.password) {
|
||||||
this.loading = false
|
cancel()
|
||||||
this.error = 'Passwords don\'t match'
|
this.error = 'Passwords don\'t match'
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -71,17 +72,17 @@
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.handleSuccess(response)
|
this.handleSuccess(response)
|
||||||
localStorage.removeItem('passwordResetToken')
|
localStorage.removeItem('passwordResetToken')
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e.response.data.message
|
this.error = e.response.data.message
|
||||||
|
cancel()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
this.error = e.response.data.message
|
this.error = e.response.data.message
|
||||||
},
|
},
|
||||||
handleSuccess(e) {
|
handleSuccess(e) {
|
||||||
this.loading = false
|
|
||||||
this.successMessage = e.data.message
|
this.successMessage = e.data.message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {HTTP} from '../../http-common'
|
import {HTTP} from '../../http-common'
|
||||||
|
import message from '../../message'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -43,7 +44,7 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submit() {
|
submit() {
|
||||||
this.loading = true
|
const cancel = message.setLoading(this)
|
||||||
this.error = ''
|
this.error = ''
|
||||||
let credentials = {
|
let credentials = {
|
||||||
user_name: this.username,
|
user_name: this.username,
|
||||||
|
@ -51,15 +52,15 @@
|
||||||
|
|
||||||
HTTP.post(`user/password/token`, credentials)
|
HTTP.post(`user/password/token`, credentials)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.loading = false
|
cancel()
|
||||||
this.isSuccess = true
|
this.isSuccess = true
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
cancel()
|
||||||
this.handleError(e)
|
this.handleError(e)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleError(e) {
|
handleError(e) {
|
||||||
this.loading = false
|
|
||||||
this.error = e.response.data.message
|
this.error = e.response.data.message
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
export default {
|
export default {
|
||||||
|
setLoading(context) {
|
||||||
|
const timeout = setTimeout(function () {
|
||||||
|
context.loading = true
|
||||||
|
}, 100);
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
};
|
||||||
|
},
|
||||||
error(e, context) {
|
error(e, context) {
|
||||||
// Build the notification text from error response
|
// Build the notification text from error response
|
||||||
let err = e.message
|
let err = e.message
|
||||||
|
@ -12,6 +20,8 @@ export default {
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
text: err
|
text: err
|
||||||
})
|
})
|
||||||
|
|
||||||
|
context.loading = false
|
||||||
},
|
},
|
||||||
success(e, context) {
|
success(e, context) {
|
||||||
// Build the notification text from error response
|
// Build the notification text from error response
|
||||||
|
@ -26,6 +36,8 @@ export default {
|
||||||
title: 'Success',
|
title: 'Success',
|
||||||
text: err
|
text: err
|
||||||
})
|
})
|
||||||
|
|
||||||
|
context.loading = false
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue