get values from rootState, process playlist with day start as seconds

This commit is contained in:
jb-alvarado 2021-03-23 21:47:15 +01:00
parent d7ad26eb90
commit 51b42abf53
2 changed files with 15 additions and 24 deletions

View File

@ -369,20 +369,21 @@ export default {
computed: {
...mapState('config', ['configID', 'configGui', 'configPlayout', 'timezone']),
...mapState('media', ['crumbs', 'folderTree']),
...mapState('playlist', ['timeStr', 'timeLeft', 'currentClip', 'progressValue', 'currentClipIndex', 'currentClipDuration', 'currentClipIn', 'currentClipOut']),
...mapState('playlist', [
'timeStr', 'timeLeft', 'currentClip', 'progressValue', 'currentClipIndex',
'currentClipDuration', 'currentClipIn', 'currentClipOut', 'startInSec']),
playlist: {
get () {
return this.$store.state.playlist.playlist
},
set (list) {
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(
this.configPlayout.playlist.day_start, list))
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, list))
}
}
},
watch: {
listDate (date) {
listDate () {
this.getPlaylist()
setTimeout(() => { scrollTo(this) }, 5000)
},
@ -465,11 +466,7 @@ export default {
},
async getPlaylist () {
await this.$store.dispatch('playlist/getPlaylist', {
dayStart: this.configPlayout.playlist.day_start,
date: this.listDate,
configPath: this.configGui[this.configID].playout_config
})
await this.$store.dispatch('playlist/getPlaylist', { date: this.listDate })
},
showPreviewModal (src) {
@ -519,24 +516,18 @@ export default {
this.playlist[index].out = sec
}
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(
this.configPlayout.playlist.day_start, this.playlist))
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, this.playlist))
}
},
removeItemFromPlaylist (index) {
this.playlist.splice(index, 1)
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(
this.configPlayout.playlist.day_start, this.playlist))
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, this.playlist))
},
async resetPlaylist () {
await this.$store.dispatch('playlist/getPlaylist', {
dayStart: this.configPlayout.playlist.day_start,
date: this.listDate,
configPath: this.configGui[this.configID].playout_config
})
await this.$store.dispatch('playlist/getPlaylist', { date: this.listDate })
},
loopClips () {
@ -554,13 +545,11 @@ export default {
}
}
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(
this.configPlayout.playlist.day_start, tempList))
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, tempList))
},
async savePlaylist (saveDate) {
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(
this.configPlayout.playlist.day_start, this.playlist))
this.$store.commit('playlist/UPDATE_PLAYLIST', this.$processPlaylist(this.startInSec, this.playlist))
const saveList = this.playlist.map(({ begin, ...item }) => item)

View File

@ -51,8 +51,9 @@ export const mutations = {
}
export const actions = {
async getPlaylist ({ commit, dispatch, state, rootState }, { dayStart, date, configPath }) {
async getPlaylist ({ commit, dispatch, state, rootState }, { date }) {
const timeInSec = this.$timeToSeconds(this.$dayjs().tz(rootState.config.timezone).format('HH:mm:ss'))
const configPath = rootState.config.configGui[rootState.config.configID].playout_config
let dateToday = this.$dayjs().tz(this.timezone).format('YYYY-MM-DD')
if (rootState.config.startInSec > timeInSec) {
@ -60,9 +61,10 @@ export const actions = {
}
const response = await this.$axios.get(`api/player/playlist/?date=${date}&config_path=${configPath}`)
console.log(rootState.config.configPlayout.playlist.day_start)
if (response.data && response.data.program) {
commit('UPDATE_PLAYLIST', this.$processPlaylist(dayStart, response.data.program))
commit('UPDATE_PLAYLIST', this.$processPlaylist(rootState.config.startInSec, response.data.program))
if (date === dateToday) {
commit('UPDATE_TODAYS_PLAYLIST', _.cloneDeep(response.data.program))