2018-09-08 19:43:16 +00:00
|
|
|
export default {
|
2018-11-27 10:23:50 +00:00
|
|
|
setLoading(context) {
|
|
|
|
const timeout = setTimeout(function () {
|
|
|
|
context.loading = true
|
2020-09-05 20:35:52 +00:00
|
|
|
}, 100)
|
2018-11-27 10:23:50 +00:00
|
|
|
return () => {
|
2018-12-19 11:27:03 +00:00
|
|
|
clearTimeout(timeout)
|
|
|
|
context.loading = false
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
2018-11-27 10:23:50 +00:00
|
|
|
},
|
2020-03-02 20:19:26 +00:00
|
|
|
error(e, context, actions = []) {
|
|
|
|
// Build the notification text from error response
|
|
|
|
let err = e.message
|
|
|
|
if (e.response && e.response.data && e.response.data.message) {
|
|
|
|
err += '<br/>' + e.response.data.message
|
|
|
|
}
|
2018-09-08 19:43:16 +00:00
|
|
|
|
2020-03-02 20:19:26 +00:00
|
|
|
// Fire a notification
|
|
|
|
context.$notify({
|
|
|
|
type: 'error',
|
|
|
|
title: 'Error',
|
|
|
|
text: err,
|
|
|
|
actions: actions,
|
|
|
|
})
|
2018-11-27 10:23:50 +00:00
|
|
|
|
|
|
|
context.loading = false
|
2020-03-02 20:19:26 +00:00
|
|
|
},
|
|
|
|
success(e, context, actions = []) {
|
|
|
|
// Build the notification text from error response
|
|
|
|
let err = e.message
|
|
|
|
if (e.response && e.response.data && e.response.data.message) {
|
|
|
|
err += '<br/>' + e.response.data.message
|
|
|
|
}
|
2018-09-09 19:28:07 +00:00
|
|
|
|
2020-03-02 20:19:26 +00:00
|
|
|
// Fire a notification
|
|
|
|
context.$notify({
|
|
|
|
type: 'success',
|
|
|
|
title: 'Success',
|
|
|
|
text: err,
|
|
|
|
data: {
|
|
|
|
actions: actions,
|
|
|
|
},
|
|
|
|
})
|
2018-11-27 10:23:50 +00:00
|
|
|
|
|
|
|
context.loading = false
|
2020-03-02 20:19:26 +00:00
|
|
|
},
|
2018-09-08 19:43:16 +00:00
|
|
|
}
|