diff --git a/layouts/default.vue b/layouts/default.vue index 6d2ef419..3ab501e0 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -4,7 +4,7 @@ @@ -18,7 +18,7 @@ import { mapState } from 'vuex' export default { computed: { - ...mapState(['ErrorAlertMessage']), + ...mapState(['ErrorAlertMessage', 'variant']), showErrorAlert: { get () { diff --git a/pages/player.vue b/pages/player.vue index 211881dd..a6ea6b87 100644 --- a/pages/player.vue +++ b/pages/player.vue @@ -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 () { diff --git a/plugins/axios.js b/plugins/axios.js index f4690221..876c8bf8 100644 --- a/plugins/axios.js +++ b/plugins/axios.js @@ -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) } diff --git a/store/index.js b/store/index.js index f14132da..3004c386 100644 --- a/store/index.js +++ b/store/index.js @@ -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 }