show save/delete success message

This commit is contained in:
jb-alvarado 2021-10-31 15:49:21 +01:00
parent a5b1357b3d
commit 6083aae383
4 changed files with 25 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<b-alert
:show="showErrorAlert"
dismissible
variant="danger"
:variant="variant"
class="status-alert"
@dismissed="showErrorAlert=!showErrorAlert"
>
@ -18,7 +18,7 @@ import { mapState } from 'vuex'
export default {
computed: {
...mapState(['ErrorAlertMessage']),
...mapState(['ErrorAlertMessage', 'variant']),
showErrorAlert: {
get () {

View File

@ -563,13 +563,21 @@ export default {
const saveList = this.playlist.map(({ begin, ...item }) => item)
await this.$axios.post(
const postSave = await this.$axios.post(
'api/player/playlist/',
{
data: { channel: this.$store.state.config.configGui.channel, date: saveDate, program: saveList },
channel: this.configGui[this.configID].id
}
)
if (postSave.status === 200 || postSave.status === 201) {
this.$store.commit('UPDATE_VARIANT', 'success')
this.$store.commit('UPDATE_SHOW_ERROR_ALERT', true)
this.$store.commit('UPDATE_ERROR_AERT_MESSAGE', 'Playlist saved...')
setTimeout(() => { this.$store.commit('UPDATE_SHOW_ERROR_ALERT', false) }, 2000)
}
},
async deletePlaylist (playlistDate) {
@ -577,7 +585,15 @@ export default {
const date = playlistDate.split('-')
const playlistPath = `${this.configPlayout.playlist.path}/${date[0]}/${date[1]}/${playlistDate}.json`
await this.$axios.post('api/player/playlist/', { data: { delete: playlistPath } })
const postDelete = await this.$axios.post('api/player/playlist/', { data: { delete: playlistPath } })
if (postDelete.status === 200 || postDelete.status === 201) {
this.$store.commit('UPDATE_VARIANT', 'success')
this.$store.commit('UPDATE_SHOW_ERROR_ALERT', true)
this.$store.commit('UPDATE_ERROR_AERT_MESSAGE', 'Playlist deleted...')
setTimeout(() => { this.$store.commit('UPDATE_SHOW_ERROR_ALERT', false) }, 2000)
}
},
showCopyModal () {

View File

@ -53,6 +53,7 @@ export default function ({ $axios, store, redirect, route }) {
if (code === 401 && route.path !== '/') {
redirect('/')
} else if (code !== 401) {
store.commit('UPDATE_VARIANT', 'danger')
store.commit('UPDATE_SHOW_ERROR_ALERT', true)
store.commit('UPDATE_ERROR_AERT_MESSAGE', error)
}

View File

@ -2,6 +2,7 @@ export const strict = false
export const state = () => ({
showErrorAlert: false,
variant: 'danger',
ErrorAlertMessage: ''
})
@ -9,6 +10,9 @@ export const mutations = {
UPDATE_SHOW_ERROR_ALERT (state, show) {
state.showErrorAlert = show
},
UPDATE_VARIANT (state, variant) {
state.variant = variant
},
UPDATE_ERROR_AERT_MESSAGE (state, message) {
state.ErrorAlertMessage = message
}