Newer
Older
ref="modalEmissionManagerEdit"
:title="$t('scheduleEditor.titleEdit', { show: selectedShow.name })"
size="lg"
<server-errors :errors="serverErrors" />
<p
class="tw-mb-0"
v-html="$t('scheduleEditor.timeslotRuns', {
firstDate: prettyDate(timeslot.start),
startTime: prettyTime(timeslot.start),
endTime: prettyTime(timeslot.end),
{{ $t('scheduleEditor.singleEmission') }}
src="/assets/radio.gif"
:alt="$t('loading')"
<span
v-if="scheduleTimeslots.length > 1"
v-html="'<br>' + $t('scheduleEditor.coexistingTimeslot', {
firstDate: timeslot.start === scheduleTimeslots[0].start ? prettyDate(scheduleTimeslots[1].start) : prettyDate(scheduleTimeslots[0].start),
startTime: timeslot.start === scheduleTimeslots[0].start ? prettyTime(scheduleTimeslots[1].start) : prettyTime(scheduleTimeslots[0].start),
endTime: timeslot.start === scheduleTimeslots[0].start ? prettyTime(scheduleTimeslots[1].end) : prettyTime(scheduleTimeslots[0].end),
<p
v-html="$t('scheduleEditor.recurringSchedule', {
rrule: rruleRender(schedule.rrule),
lastDate: prettyDate(schedule.last_date),
id="emission-table"
striped
:per-page="perPage"
:current-page="currentPage"
:fields="[
{ key: 'start', label: $t('scheduleEditor.start') },
{ key: 'end', label: $t('scheduleEditor.end') }
]"
:items="scheduleTimeslots"
:busy="!loaded.scheduleTimeslots"
:tbody-tr-class="trClass"
{{ prettyDateTime(data.item.start) }}
</template>
{{ prettyDateTime(data.item.end) }}
</template>
</b-table>
<div class="tw-w-full tw-flex tw-justify-end">
<b-pagination
v-model="currentPage"
:total-rows="scheduleTimeslots.length"
:per-page="perPage"
aria-controls="emission-table"
/>
</div>
</div>
</div>
<div v-else>
<img
src="/assets/radio.gif"
:alt="$t('loading')"
<h4>{{ $t('scheduleEditor.addRepetition') }}</h4>
<b-row>
<b-col cols="6">
<label class="tw-leading-loose">
{{ $t('scheduleEditor.whenToRepeat') }}
v-model="repetitionRule"
:options="repetitionOptions"
<b-checkbox
v-if="repetitionRule !== 4"
v-model="useSameTime"
{{ $t('scheduleEditor.useSameTime') }}
<b-form-input
v-model="repetitionTime"
type="time"
/>
</label>
</b-col>
</b-row>
<b-row
v-if="repetitionRule === 3"
class="tw-mt-4"
<b-col cols="6">
<label class="tw-leading-loose">
{{ $t('scheduleEditor.addNoOfDays') }}
/>
</label>
<b-checkbox v-model="onlyBusinessDays">
{{ $t('scheduleEditor.onlyBusinessDays') }}
variant="primary"
size="sm"
@click="createRepetitionSchedule"
{{ $t('scheduleEditor.addRepetition') }}
<hr>
<h4>Fallback für Ausstrahlungs-Schema hinzufügen</h4>
<b-row class="tw-px-4">
<strong>Momentan hinterlegte Playlist:</strong> (keine)
<div class="tw-w-full tw-block">
<b-button variant="primary">
v-if="loaded.scheduleTimeslots"
class="tw-w-full tw-flex tw-justify-between tw-items-center"

Richard Blechinger
committed
<template v-if="isInTheFuture(timeslot)">
<b-button
variant="danger"
size="sm"
@click="deleteFullSchedule(schedule.id)"

Richard Blechinger
committed
>
<span v-if="scheduleTimeslots.length === 1">{{ $t('scheduleEditor.delete.delete') }}</span>
<span v-else-if="schedule.rrule === 1">{{ $t('scheduleEditor.delete.both') }}</span>
<span v-else>{{ $t('scheduleEditor.delete.scheduleTimeslots') }}</span>
</b-button>

Richard Blechinger
committed
<b-button
v-if="schedule.rrule > 1 && scheduleTimeslots.length > 1"
variant="danger"
size="sm"
@click="deleteSingleTimeslot(schedule.id, timeslot.id)"

Richard Blechinger
committed
>
{{ $t('scheduleEditor.delete.timeslot') }}
</b-button>
</template>
v-if="schedule.rrule > 1 && scheduleTimeslots.length > 1"
variant="danger"
size="sm"
@click="deleteAllFutureTimeslots(schedule.id, timeslot.id)"
{{ $t('scheduleEditor.delete.allTimeslots') }}
</b-button>
</div>
</div>
<div v-else>
<img
src="/assets/radio.gif"
:alt="$t('loading')"
>
</div>
</template>
</b-modal>
<b-modal
ref="modalEmissionManagerDeleteTimeslots"
:title="$t('scheduleEditor.delete.timeslotsTitle')"
size="lg"
centered
hide-footer
no-close-on-esc
no-close-on-backdrop
src="/assets/radio.gif"
:alt="$t('loading')"
:value="deletion.count"
:max="deletion.amount"
variant="primary"
animated
</template>
<script>
import {mapGetters} from 'vuex'
import prettyDate from '../../mixins/prettyDate'
import rrules from '../../mixins/rrules'
import ServerErrors from '@/components/ServerErrors.vue'
components: {ServerErrors},
mixins: [prettyDate, rrules],
data() {
return {
currentPage: 1,
perPage: 5,
timeslot: null,
deletion: {
amount: 0,
count: 0,
},
useSameTime: true,
onlyBusinessDays: false,
addNoOfDays: 1,
repetitionRule: 1,
serverErrors: [],
},
computed: {
loaded() {
return {
shows: this.$store.state.shows.loaded.shows,
schedule: this.$store.state.shows.loaded.schedule,
scheduleTimeslots: this.$store.state.shows.loaded.scheduleTimeslots,
}
},
repetitionOptions() {
return [
{value: 1, text: this.$t("scheduleEditor.repetition.followingDay")},
{value: 2, text: this.$t("scheduleEditor.repetition.followingBusinessDay")},
{value: 3, text: this.$t("scheduleEditor.repetition.numberOfDaysLater")},
},
...mapGetters({
selectedShow: 'shows/selectedShow',
schedule: 'shows/schedule',
scheduleTimeslots: 'shows/scheduleTimeslots',
})
},
methods: {
trClass(item, type) {
if (!item || type !== 'row') {

Richard Blechinger
committed
return item.id === this.timeslot.id
? 'table-info'
: ''
},

Richard Blechinger
committed
isInTheFuture(timeslot) {
const start = new Date(timeslot.start)
const now = new Date()

Richard Blechinger
committed
},
async createRepetitionSchedule() {
const {onlyBusinessDays, addNoOfDays} = this.getRepetitionParameters()
let {first_date, time_start, time_end, rrule, last_date, default_playlist_id, automation_id, by_weekday} = this.schedule
if (this.repetitionTime.length > 0) {
const newStartTime = `${this.repetitionTime}:00`
const newStartTimeNs = this.hmsToNanoseconds(newStartTime)
const oldStartTimeNs = this.hmsToNanoseconds(time_start)
const oldEndTimeNs = this.hmsToNanoseconds(time_end)
time_start = newStartTime
time_end = this.prettyNanoseconds(newStartTimeNs + (oldEndTimeNs - oldStartTimeNs))
first_date,
time_start,
time_end,

Richard Blechinger
committed
default_playlist_id,
is_repetition: true,
add_business_days_only: onlyBusinessDays,
add_days_no: parseInt(addNoOfDays, 10),
this.serverErrors = []
try {
await this.$store.dispatch('shows/submitSchedule', {
showId: this.selectedShow.id,
schedule: newSchedule,
})
this.$parent.renderView(null)
} catch (e) {
if (e.response?.status === 409) {
this.$log.debug('Timeslot conflict. Switching to resolve mode.')
this.$parent.resolve(e.response.data)
} else {
this.serverErrors = e.errors ?? []
}
} finally {
this.$refs.modalEmissionManagerEdit.hide()
}
},
deleteFullSchedule(id) {
this.$store.dispatch('shows/deleteSchedule', {
show: this.selectedShow.id,
schedule: id,
callback: () => {
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
this.$parent.renderView(null)
}
})
},
deleteSingleTimeslot(scheduleId, timeslotId) {
this.$store.dispatch('shows/deleteTimeslot', {
show: this.selectedShow.id,
schedule: scheduleId,
timeslot: timeslotId,
callback: () => {
this.$refs.modalEmissionManagerEdit.hide()
this.$parent.renderView(null)
}
})
},
deleteAllFutureTimeslots(scheduleId) {
let startDate = new Date(this.timeslot.start)
let toDelete = []
for (let slot of this.scheduleTimeslots) {
if (new Date(slot.start) >= startDate) {
toDelete.push(slot.id)
}
}
if (toDelete.length === this.scheduleTimeslots.length) {
this.$log.debug('deleting full schedule')
this.deleteFullSchedule(scheduleId)
} else {
this.deletion.amount = toDelete.length
this.deletion.count = 0
this.$refs.modalEmissionManagerDeleteTimeslots.show()
for (let i in toDelete) {
this.$log.debug('Deleting timeslot', toDelete[i])
this.$store.dispatch('shows/deleteTimeslot', {
show: this.selectedShow.id,
schedule: scheduleId,
timeslot: toDelete[i],
callback: () => {
this.deletion.count++
this.$log.debug('deleted ' + this.deletion.count + ' timeslots')
if (this.deletion.count === this.deletion.amount) {
this.$parent.renderView(null)
this.$refs.modalEmissionManagerDeleteTimeslots.hide()
this.$refs.modalEmissionManagerEdit.hide()
}
}
})
}
}
},
loadSchedule(scheduleId) {
this.$store.dispatch('shows/fetchSchedule', {
show: this.selectedShow.id,
schedule: scheduleId,
callback: () => {
this.loadScheduleTimeslots(scheduleId)
}
})
},
loadScheduleTimeslots(scheduleId) {
this.$store.dispatch('shows/fetchTimeslots', {
id: this.selectedShow.id,
schedule: scheduleId,
start: this.schedule.first_date,
end: this.schedule.last_date,
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
})
},
getRepetitionParameters() {
if (this.repetitionRule == 1) {
return {
onlyBusinessDays: false,
addNoOfDays: 1,
}
}
if (this.repetitionRule == 2) {
return {
onlyBusinessDays: true,
addNoOfDays: 1,
}
}
return {
onlyBusinessDays: this.onlyBusinessDays,
addNoOfDays: this.addNoOfDays,
}
},
// initialise a new schedule and open the modal
open(timeslot) {
const timeslotIndex = this.scheduleTimeslots.findIndex(item => item.id === timeslot.id)
let timeslotPage = Math.ceil(timeslotIndex / this.perPage)
const timeslotIsFirstEntryOnPage = timeslotIndex === ((timeslotPage) * this.perPage)
// The math above is slightly off for every first entry on the page
// So we add 1 to adjust the page to the correct one
if (timeslotIsFirstEntryOnPage) {
}
this.$refs.modalEmissionManagerEdit.show()
this.loadSchedule(timeslot.schedule)
},
</script>
<style scoped>
</style>