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

View File

@ -563,13 +563,21 @@ export default {
const saveList = this.playlist.map(({ begin, ...item }) => item) const saveList = this.playlist.map(({ begin, ...item }) => item)
await this.$axios.post( const postSave = await this.$axios.post(
'api/player/playlist/', 'api/player/playlist/',
{ {
data: { channel: this.$store.state.config.configGui.channel, date: saveDate, program: saveList }, data: { channel: this.$store.state.config.configGui.channel, date: saveDate, program: saveList },
channel: this.configGui[this.configID].id 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) { async deletePlaylist (playlistDate) {
@ -577,7 +585,15 @@ export default {
const date = playlistDate.split('-') const date = playlistDate.split('-')
const playlistPath = `${this.configPlayout.playlist.path}/${date[0]}/${date[1]}/${playlistDate}.json` 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 () { showCopyModal () {

View File

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

View File

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