4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-15 05:36:37 +00:00
AzuraCast/frontend/vue/components/Common/ScheduleView.vue

79 lines
1.9 KiB
Vue
Raw Normal View History

<template>
2022-12-29 21:15:05 +00:00
<full-calendar
ref="calendar"
:options="calendarOptions"
/>
</template>
2022-12-13 07:52:35 +00:00
<script setup>
import '@fullcalendar/core/vdom';
2022-12-10 17:55:09 +00:00
import FullCalendar from '@fullcalendar/vue3';
import allLocales from '@fullcalendar/core/locales-all';
2022-03-18 00:04:46 +00:00
import luxon2Plugin from '@fullcalendar/luxon2';
import timeGridPlugin from '@fullcalendar/timegrid';
2022-12-13 07:52:35 +00:00
import {shallowRef} from "vue";
2022-12-23 09:04:34 +00:00
import {useAzuraCast} from "~/vendor/azuracast";
2022-12-13 07:52:35 +00:00
const props = defineProps({
2022-12-30 14:38:34 +00:00
scheduleUrl: {
type: String,
required: true
},
stationTimeZone: {
type: String,
required: true
}
2022-12-13 07:52:35 +00:00
});
2022-12-13 07:52:35 +00:00
const emit = defineEmits(['click']);
const onEventDidMount = (info) => {
let desc = info?.event?.extendedProps?.description || null;
if (desc !== null) {
2022-12-30 16:44:47 +00:00
/* eslint-disable no-undef */
2022-12-13 07:52:35 +00:00
$(info.el).tooltip({
title: desc,
placement: 'top',
trigger: 'hover',
container: 'body',
offset: 0
});
2022-12-30 16:44:47 +00:00
/* eslint-enable */
}
};
2022-12-13 07:52:35 +00:00
const onEventClick = (arg) => {
emit('click', arg.event);
};
const {localeShort, timeConfig} = useAzuraCast();
2022-12-13 07:52:35 +00:00
const calendarOptions = shallowRef({
locale: localeShort,
2022-12-13 07:52:35 +00:00
locales: allLocales,
plugins: [luxon2Plugin, timeGridPlugin],
initialView: 'timeGridWeek',
timeZone: props.stationTimeZone,
themeSystem: 'bootstrap',
nowIndicator: true,
defaultTimedEventDuration: '00:20',
headerToolbar: false,
footerToolbar: false,
height: 'auto',
events: props.scheduleUrl,
eventClick: onEventClick,
eventDidMount: onEventDidMount,
views: {
timeGridWeek: {
slotLabelFormat: {
...timeConfig,
2022-12-13 07:52:35 +00:00
hour: 'numeric',
minute: '2-digit',
omitZeroMinute: true,
meridiem: 'short'
}
}
}
});
</script>