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