Commit c5f2906f authored by David Trattnig's avatar David Trattnig
Browse files

Replaced schedule with timeslot. engine-api#14

parent ea70dd52
......@@ -35,8 +35,8 @@ LOGO="https://gitlab.servus.at/aura/meta/-/raw/master/images/aura-logo.png"
LOGO_SIZE="100px"
API_URL="http://localhost:8008/api/v1/"
UNKNOWN_TITLE="Unknown Title"
NO_CURRENT_SCHEDULE="Right now, there's no show playing"
NO_NEXT_SCHEDULE="Nothing scheduled next"
NO_CURRENT_TIMESLOT="Right now, there's no show playing"
NO_NEXT_TIMESLOT="Nothing scheduled next"
PLAY_OFFSET=3
CSS=""
```
......@@ -54,8 +54,8 @@ able to override any configurations already performed during the build.
api="http://localhost:8008/api/v1/"
css="/css/o94.css"
unknowntitle="Unbekannter Titel"
nocurrentschedule="Derzeit keine Sendung"
nonextschedule="Keine weiteren Sendungen"
nocurrenttimeslot="Derzeit keine Sendung"
nonexttimeslot="Keine weiteren Sendungen"
playoffset=3>
</aura-clock>
```
......
......@@ -3,8 +3,8 @@ LOGO="https://gitlab.servus.at/aura/meta/-/raw/master/images/aura-logo.png"
LOGO_SIZE="100px"
API_URL="http://localhost:8008/api/v1/"
UNKNOWN_TITLE="Unknown Title"
NO_CURRENT_SCHEDULE="No show playing"
NO_NEXT_SCHEDULE="Nothing scheduled next"
NO_CURRENT_TIMESLOT="No show playing"
NO_NEXT_TIMESLOT="Nothing scheduled next"
PLAY_OFFSET=3
CSS=""
FALLBACK_TEXT="FALLBACK"
\ No newline at end of file
......@@ -3,8 +3,8 @@ LOGO="https://o94.at/themes/custom/radio_orange/logo1.png"
LOGO_SIZE=180px
API_URL="http://localhost:8008/api/v1/"
UNKNOWN_TITLE="Unbekannter Titel"
NO_CURRENT_SCHEDULE="Derzeit keine Sendung"
NO_NEXT_SCHEDULE="Keine weiteren Sendungen"
NO_CURRENT_TIMESLOT="Derzeit keine Sendung"
NO_NEXT_TIMESLOT="Keine weiteren Sendungen"
PLAY_OFFSET=3
CSS="/css/o94.css"
FALLBACK_TEXT="Notfallprogramm"
\ No newline at end of file
......@@ -8,8 +8,8 @@
export let name = globalConfig.NAME;
export let logo = globalConfig.LOGO;
export let logosize = globalConfig.LOGO_SIZE;
export let nocurrentschedule = globalConfig.NO_CURRENT_SCHEDULE;
export let nonextschedule = globalConfig.NO_NEXT_SCHEDULE;
export let nocurrenttimeslot = globalConfig.NO_CURRENT_TIMESLOT;
export let nonexttimeslot = globalConfig.NO_NEXT_TIMESLOT;
export let unknowntitle = globalConfig.UNKNOWN_TITLE;
export let playoffset = globalConfig.PLAY_OFFSET;
export let fallbacktext = globalConfig.FALLBACK_TEXT;
......@@ -23,7 +23,7 @@
let clockData = null;
let currentTrackElement = null;
let timeLeft;
let scheduleTimeLeft = 0;
let timeslotTimeLeft = 0;
let reloadTime = 10;
let reloadWait = 0;
......@@ -41,12 +41,12 @@
const interval = setInterval(() => {
time = new Date();
timeLeft -= 1;
scheduleTimeLeft -= 1;
timeslotTimeLeft -= 1;
/* End of track or end of schedule - load new data */
if (timeLeft <= 0 || scheduleTimeLeft <= 0) {
/* End of track or end of timeslot - load new data */
if (timeLeft <= 0 || timeslotTimeLeft <= 0) {
/* For some seconds refresh every second, to work around API timing delays */
if (timeLeft <= 0 && timeLeft >= -3 || scheduleTimeLeft <= 0 && scheduleTimeLeft >= -3 || reloadWait == 0) {
if (timeLeft <= 0 && timeLeft >= -3 || timeslotTimeLeft <= 0 && timeslotTimeLeft >= -3 || reloadWait == 0) {
promise = fetchApi(queryCurrent);
reloadWait = reloadTime;
}
......@@ -112,25 +112,25 @@
timeLeft = value.current_track.track_duration - t - playoffset;
}
if (value.current_schedule != null) {
let schedule_end = Date.parse(value.current_schedule.schedule_end);
schedule_end = parseInt(schedule_end/1000);
scheduleTimeLeft = schedule_end - time;
if (value.current_timeslot != null) {
let timeslot_end = Date.parse(value.current_timeslot.timeslot_end);
timeslot_end = parseInt(timeslot_end/1000);
timeslotTimeLeft = timeslot_end - time;
} else {
/* Decrease time left in any case to avoid reloading too often */
scheduleTimeLeft -= 1;
timeslotTimeLeft -= 1;
}
}
return "";
}
/* Checks if there's an existing, valid schedule */
function hasValidSchedule(value) {
if (value.current_schedule != null) {
if (value.current_schedule.schedule_end != null) {
let schedule_end = Date.parse(value.current_schedule.schedule_end);
let diff = schedule_end - time;
/* Checks if there's an existing, valid timeslot */
function hasValidTimeslot(value) {
if (value.current_timeslot != null) {
if (value.current_timeslot.timeslot_end != null) {
let timeslot_end = Date.parse(value.current_timeslot.timeslot_end);
let diff = timeslot_end - time;
if (diff >= 0)
return true;
}
......@@ -141,7 +141,7 @@
/* Checks if there is an existing valid playlist */
function hasValidPlaylist(value) {
if (hasValidSchedule(value))
if (hasValidTimeslot(value))
if (value.current_playlist != null)
return true;
return false;
......@@ -194,40 +194,40 @@
/* Display the name of a show */
function displayShowName(schedule, defaultText) {
function displayShowName(timeslot, defaultText) {
let name = ""
if (schedule == null || schedule.show_name == null || schedule.show_name == "") {
if (timeslot == null || timeslot.show_name == null || timeslot.show_name == "") {
name = '<span class="error">'+defaultText+'</span>';
} else {
name = schedule.show_name;
name = timeslot.show_name;
}
return name;
}
/* Display the schedule of a show */
function displayShowSchedule(schedule) {
/* Display the timeslot of a show */
function displayShowTimeslot(timeslot) {
let str = "";
if (schedule != null && schedule.schedule_start != null && schedule.show_name != "") {
let scheduleStart = ""
let scheduleEnd = "";
if (timeslot != null && timeslot.timeslot_start != null && timeslot.show_name != "") {
let timeslotStart = ""
let timeslotEnd = "";
if (schedule.schedule_start != null) {
let scheduleStart = new Date(Date.parse(schedule.schedule_start));
scheduleStart = scheduleStart.toLocaleTimeString(navigator.language, {
if (timeslot.timeslot_start != null) {
let timeslotStart = new Date(Date.parse(timeslot.timeslot_start));
timeslotStart = timeslotStart.toLocaleTimeString(navigator.language, {
hour: '2-digit',
minute:'2-digit'
});
str = scheduleStart;
str = timeslotStart;
}
if (schedule.schedule_end != null) {
scheduleEnd = new Date(Date.parse(schedule.schedule_end));
scheduleEnd = scheduleEnd.toLocaleTimeString(navigator.language, {
if (timeslot.timeslot_end != null) {
timeslotEnd = new Date(Date.parse(timeslot.timeslot_end));
timeslotEnd = timeslotEnd.toLocaleTimeString(navigator.language, {
hour: '2-digit',
minute:'2-digit'
});
str = str + " - " + scheduleEnd + "";
str = str + " - " + timeslotEnd + "";
} else {
str += "";
}
......@@ -239,9 +239,9 @@
/* Indicates if some fallback is playing */
function isFallback(value) {
if ("current_schedule" in value)
if ("current_timeslot" in value)
return true;
if (current_schedule.fallback_type > 0)
if (current_timeslot.fallback_type > 0)
return true;
return false;
}
......@@ -327,32 +327,32 @@
filter: invert(100%);
}
#current-schedule {
#current-timeslot {
border: 2px solid #333;
margin: 20px 20px 40px 20px;
background-color: #111;
height: 700px;
}
#current-schedule,
#next-schedule {
#current-timeslot,
#next-timeslot {
margin: 0 0 40px 20px;
}
#next-schedule {
#next-timeslot {
background-color:rgb(24, 24, 24);
margin-right: 20px;
padding: 12px;
text-align: center;
}
#current-schedule .schedule-title {
#current-timeslot .timeslot-title {
text-align: center;
height: 100px;
overflow: revert;
}
#current-schedule .schedule-title h1 {
#current-timeslot .timeslot-title h1 {
color: #ccc;
font-size: 2.8em;
position: relative;
......@@ -360,7 +360,7 @@
transform: translateY(-50%);
}
#next-schedule .schedule-title {
#next-timeslot .timeslot-title {
color: gray !important;
font-size: 2em;
}
......@@ -585,13 +585,13 @@
{initComponent(value)}
<div id="current-schedule">
<div class="schedule-title">
<div id="current-timeslot">
<div class="timeslot-title">
<h1>
{#if hasValidSchedule(value)}
{@html displayShowName(value.current_schedule, nocurrentschedule)} {displayShowSchedule(value.current_schedule)}
{#if hasValidTimeslot(value)}
{@html displayShowName(value.current_timeslot, nocurrenttimeslot)} {displayShowTimeslot(value.current_timeslot)}
{:else}
<span class="error">{nocurrentschedule}</span>
<span class="error">{nocurrenttimeslot}</span>
{/if}
{#if isFallback(value)}
<span class="fallback-indicator">{fallbacktext}</span>
......@@ -643,9 +643,9 @@
{#if value.current_schedule}
<div id="next-schedule">
<h3 class="schedule-title">{@html displayShowName(value.next_schedule, nonextschedule)} {displayShowSchedule(value)}</h3>
{#if value.current_timeslot}
<div id="next-timeslot">
<h3 class="timeslot-title">{@html displayShowName(value.next_timeslot, nonexttimeslot)} {displayShowTimeslot(value)}</h3>
</div>
{/if}
{:catch error}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment