diff --git a/package.json b/package.json index 3a0efe10..9f17f9f1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ffplayout-frontend", - "version": "5.1.2", + "version": "5.2.0", "description": "Web GUI for ffplayout", "author": "Jonathan Baecker", "private": true, diff --git a/pages/configure.vue b/pages/configure.vue index 27604663..e8e85341 100644 --- a/pages/configure.vue +++ b/pages/configure.vue @@ -22,7 +22,7 @@
Ad + + Edit + Delete @@ -287,6 +290,11 @@ unchecked-value="" /> + + + + + @@ -357,7 +365,7 @@
@@ -376,6 +384,9 @@ + + + timeInSec) { - this.listDate = this.$dayjs(this.listDate).tz(this.timezone).subtract(1, 'day').format('YYYY-MM-DD') + this.listDate = this.$dayjs(this.listDate).utcOffset(this.utcOffset).subtract(1, 'day').format('YYYY-MM-DD') } await this.getPlaylist() @@ -707,12 +723,11 @@ export default { async savePlaylist (saveDate) { this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, this.playlist)) - const saveList = this.playlist.map(({ begin, ...item }) => item) const postSave = await this.$axios.post( `api/playlist/${this.configGui[this.configID].id}/`, - { channel: this.$store.state.config.configGui.channel, date: saveDate, program: saveList } + { channel: this.configGui[this.configID].name, date: saveDate, program: saveList } ) if (postSave.status === 200 || postSave.status === 201) { @@ -765,9 +780,14 @@ export default { }, addSource () { - const list = this.playlist - list.push(this.newSource) - this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, list)) + if (this.editId === undefined) { + const list = this.playlist + list.push(this.newSource) + this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, list)) + } else { + this.playlist[this.editId] = this.newSource + this.editId = undefined + } this.newSource = { begin: 0, @@ -775,12 +795,29 @@ export default { out: 0, duration: 0, category: '', + custom_filter: '', source: '' } this.$nextTick(() => { this.$bvModal.hide('add-source-modal') }) + }, + + editItem (i) { + this.editId = i + + this.newSource = { + begin: this.playlist[i].begin, + in: this.playlist[i].in, + out: this.playlist[i].out, + duration: this.playlist[i].duration, + category: this.playlist[i].category, + custom_filter: this.playlist[i].custom_filter, + source: this.playlist[i].source + } + + this.$bvModal.show('add-source-modal') } } } diff --git a/plugins/helpers.js b/plugins/helpers.js index d0d04dfb..1022b2e3 100644 --- a/plugins/helpers.js +++ b/plugins/helpers.js @@ -9,8 +9,16 @@ export default ({ app }, inject) => { for (const item of list) { item.begin = begin + if (!item.audio) { + delete item.audio + } + if (!item.category) { - item.category = '' + delete item.category + } + + if (!item.custom_filter) { + delete item.custom_filter } begin += (item.out - item.in) diff --git a/store/auth.js b/store/auth.js index 8cdd101e..8cfef072 100644 --- a/store/auth.js +++ b/store/auth.js @@ -26,7 +26,7 @@ export const mutations = { } export const actions = { - async obtainToken ({ commit, state }, { username, password }) { + async obtainToken ({ commit }, { username, password }) { const payload = { username, password @@ -45,7 +45,7 @@ export const actions = { return code }, - inspectToken ({ commit, dispatch, state }) { + inspectToken ({ commit, state }) { const token = this.$cookies.get('token') if (token) { diff --git a/store/config.js b/store/config.js index 34da7dab..1c080602 100644 --- a/store/config.js +++ b/store/config.js @@ -10,7 +10,7 @@ export const state = () => ({ configPlayout: {}, currentUser: null, configUser: null, - timezone: 'UTC' + utcOffset: 0 }) export const mutations = { @@ -41,13 +41,13 @@ export const mutations = { UPDATE_USER_CONFIG (state, config) { state.configUser = config }, - UPDATE_TIMEZONE (state, zone) { - state.timezone = zone + UPDATE_UTC_OFFSET (state, offset) { + state.utcOffset = offset } } export const actions = { - async nuxtClientInit ({ commit, dispatch, rootState }) { + async nuxtClientInit ({ dispatch, rootState }) { await dispatch('auth/inspectToken', null, { root: true }) if (rootState.auth.isLogin) { await dispatch('getGuiConfig') @@ -56,7 +56,7 @@ export const actions = { } }, - async getGuiConfig ({ commit, state }) { + async getGuiConfig ({ commit }) { const response = await this.$axios.get('api/channels') if (response.data) { @@ -68,7 +68,7 @@ export const actions = { } } - commit('UPDATE_TIMEZONE', response.data[0].timezone) + commit('UPDATE_UTC_OFFSET', response.data[0].utc_offset) commit('UPDATE_GUI_CONFIG', response.data) commit('UPDATE_GUI_CONFIG_RAW', _.cloneDeep(response.data)) commit('UPDATE_CONFIG_COUNT', response.data.length) @@ -78,7 +78,8 @@ export const actions = { channel: '', preview_url: '', playout_config: '', - extra_extensions: [] + extra_extensions: [], + utc_offset: 0 }]) } }, @@ -133,13 +134,13 @@ export const actions = { } }, - async setPlayoutConfig ({ commit, state }, obj) { + async setPlayoutConfig ({ state }, obj) { const channel = state.configGui[state.configID].id const update = await this.$axios.put(`api/playout/config/${channel}`, obj) return update }, - async getUserConfig ({ commit, state }) { + async getUserConfig ({ commit }) { const user = await this.$axios.get('api/user') if (user.data) { @@ -150,7 +151,7 @@ export const actions = { } }, - async setUserConfig ({ commit, state }, obj) { + async setUserConfig (obj) { const update = await this.$axios.put(`api/user/${obj.id}`, obj) return update } diff --git a/store/media.js b/store/media.js index b91ac1e4..c4e2e36a 100644 --- a/store/media.js +++ b/store/media.js @@ -17,7 +17,7 @@ export const mutations = { } export const actions = { - async getTree ({ commit, dispatch, state, rootState }, { path }) { + async getTree ({ commit, rootState }, { path }) { const crumbs = [] let root = '/' const channel = rootState.config.configGui[rootState.config.configID].id diff --git a/store/playlist.js b/store/playlist.js index 2b8b7b17..c837b6a5 100644 --- a/store/playlist.js +++ b/store/playlist.js @@ -51,13 +51,13 @@ export const mutations = { } export const actions = { - async getPlaylist ({ commit, dispatch, state, rootState }, { date }) { - const timeInSec = this.$timeToSeconds(this.$dayjs().tz(rootState.config.timezone).format('HH:mm:ss')) + async getPlaylist ({ commit, rootState }, { date }) { + const timeInSec = this.$timeToSeconds(this.$dayjs().utcOffset(rootState.config.utcOffset).format('HH:mm:ss')) const channel = rootState.config.configGui[rootState.config.configID].id - let dateToday = this.$dayjs().tz(this.timezone).format('YYYY-MM-DD') + let dateToday = this.$dayjs().utcOffset(rootState.config.utcOffset).format('YYYY-MM-DD') if (rootState.config.startInSec > timeInSec) { - dateToday = this.$dayjs(dateToday).tz(rootState.config.timezone).subtract(1, 'day').format('YYYY-MM-DD') + dateToday = this.$dayjs(dateToday).utcOffset(rootState.config.utcOffset).subtract(1, 'day').format('YYYY-MM-DD') } const response = await this.$axios.get(`api/playlist/${channel}?date=${date}`) @@ -75,9 +75,9 @@ export const actions = { } }, - async playoutStat ({ commit, dispatch, state, rootState }) { + async playoutStat ({ commit, state, rootState }) { const channel = rootState.config.configGui[rootState.config.configID].id - const time = this.$dayjs().tz(rootState.config.timezone).format('HH:mm:ss') + const time = this.$dayjs().utcOffset(rootState.config.utcOffset).format('HH:mm:ss') let timeSec = this.$timeToSeconds(time) commit('SET_TIME', time)