Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Kruse
aura-engine
Commits
22a079ee
Commit
22a079ee
authored
5 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Display current and next schedule.
parent
2796761f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/aura-clock/src/StudioClock.svelte
+86
-34
86 additions, 34 deletions
contrib/aura-clock/src/StudioClock.svelte
with
86 additions
and
34 deletions
contrib/aura-clock/src/StudioClock.svelte
+
86
−
34
View file @
22a079ee
...
...
@@ -4,7 +4,7 @@
let
time
=
new
Date
();
let
queryCurrent
=
"
/
trackservice/current
"
;
let
queryCurrent
=
"
/
clock
"
;
let
data
;
let
currentTrack
=
null
;
...
...
@@ -17,12 +17,15 @@
$
:
minutes
=
time
.
getMinutes
();
$
:
seconds
=
time
.
getSeconds
();
data
=
fetchApi
(
queryCurrent
);
onMount
(()
=>
{
const
interval
=
setInterval
(()
=>
{
time
=
new
Date
();
timeLeft
-=
1
;
if
(
timeLeft
=
=
0
)
{
if
(
timeLeft
<
=
0
||
data
==
null
)
{
currentTrack
=
null
;
data
=
null
;
data
=
fetchApi
(
queryCurrent
);
...
...
@@ -55,25 +58,24 @@
}
}
function
setCurrentTrack
(
track
)
{
if
(
currentTrack
==
null
&&
track
!=
null
&&
track
.
track
!=
null
)
{
currentTrack
=
track
;
function
setCurrentTrack
(
info
)
{
if
(
currentTrack
==
null
&&
info
!=
null
&&
info
.
track
!=
null
)
{
currentTrack
=
info
;
let
t
=
time
-
Date
.
parse
(
track
.
track_start
);
let
t
=
time
-
Date
.
parse
(
info
.
track_start
);
t
=
parseInt
(
t
/
1000
);
timeLeft
=
track
.
track
.
duration
-
t
;
console
.
log
(
"
TIMELEFT:
"
+
timeLeft
);
timeLeft
=
info
.
track
.
duration
-
t
-
4
;
}
return
""
;
}
function
displayTitle
(
track
)
{
if
(
track
!=
null
&&
track
.
track
!=
null
)
{
function
displayTitle
(
info
)
{
if
(
info
!=
null
&&
info
.
track
!=
null
)
{
let
artist
=
""
;
if
(
track
.
track
.
artist
!=
""
)
artist
=
track
.
track
.
artist
+
"
-
"
;
return
artist
+
track
.
track
.
title
;
if
(
info
.
track
.
artist
!=
""
)
artist
=
info
.
track
.
artist
+
"
-
"
;
return
artist
+
info
.
track
.
title
;
}
return
""
;
}
...
...
@@ -93,25 +95,48 @@
return
""
;
}
function
displayShowSchedule
(
track
)
{
if
(
track
.
schedule
!=
null
)
{
let
scheduleStart
=
Date
.
parse
(
track
.
schedule_start
);
let
scheduleEnd
=
Date
.
parse
(
track
.
schedule_end
);
scheduleStart
=
date
.
toLocaleTimeString
(
navigator
.
language
,
{
hour
:
'
2-digit
'
,
minute
:
'
2-digit
'
});
scheduleEnd
=
date
.
toLocaleTimeString
(
navigator
.
language
,
{
hour
:
'
2-digit
'
,
minute
:
'
2-digit
'
});
return
"
(
"
+
scheduleStart
+
"
-
"
+
scheduleEnd
+
"
)
"
;
function
displayShowName
(
show
)
{
let
name
=
""
if
(
show
==
null
||
show
.
name
==
null
)
{
name
=
'
<span class="error">No show scheduled!</span>
'
;
}
else
{
name
=
show
.
name
;
}
return
""
;
return
name
;
}
function
displayShowSchedule
(
schedule
)
{
let
str
=
""
;
if
(
schedule
!=
null
&&
schedule
.
schedule_start
!=
null
)
{
let
scheduleStart
=
""
let
scheduleEnd
=
""
;
if
(
schedule
.
schedule_start
!=
null
)
{
let
scheduleStart
=
new
Date
(
Date
.
parse
(
schedule
.
schedule_start
));
scheduleStart
=
scheduleStart
.
toLocaleTimeString
(
navigator
.
language
,
{
hour
:
'
2-digit
'
,
minute
:
'
2-digit
'
});
str
=
"
(
"
+
scheduleStart
;
}
if
(
schedule
.
schedule_end
!=
null
)
{
scheduleEnd
=
new
Date
(
Date
.
parse
(
schedule
.
schedule_end
));
scheduleEnd
=
scheduleEnd
.
toLocaleTimeString
(
navigator
.
language
,
{
hour
:
'
2-digit
'
,
minute
:
'
2-digit
'
});
str
=
str
+
"
-
"
+
scheduleEnd
+
"
)
"
;
}
else
{
str
+=
"
)
"
;
}
}
return
str
;
}
data
=
fetchApi
(
queryCurrent
);
</script>
...
...
@@ -136,6 +161,22 @@
padding
:
25px
;
}
#current-schedule
,
#next-schedule
{
margin
:
0
0
40px
20px
;
}
#track-list
{
border
:
2px
solid
#333
;
margin
:
20px
20px
40px
20px
;
padding
:
10px
;
}
.play-icon
,
.track-time-left
{
margin
:
12px
;
}
.active
{
color
:
green
;
}
...
...
@@ -241,20 +282,31 @@
{
:then
value
}
{
setCurrentTrack
(
value
)
}
<!-- <h2>▶ Playing</h2> -->
<h2>
{
value
.
show
.
name
}
{
displayShowSchedule
(
value
)
}
</h2>
<div
id=
"current-schedule"
><b>
Type:
</b>
{
value
.
show
.
type
}
,
<b>
Host:
</b>
{
value
.
show
.
host
}
</div>
{
#if
value
.
current
.
show
}
<div
id=
"current-schedule"
>
<h1
class=
"schedule-title"
>
{
@html
displayShowName
(
value
.
current
.
show
)
}
{
displayShowSchedule
(
value
.
current
)
}
</h1>
<div
class=
"schedule-details"
>
<b>
Type:
</b>
{
value
.
current
.
type
}
,
<b>
Host:
</b>
{
value
.
current
.
host
}
</div>
</div>
<div
id=
"track-list"
>
<div
id=
"current-track"
>
<h
1
>
<span
class=
"play-icon
s
"
>
▶
</span>
<h
2
>
<span
class=
"play-icon"
>
▶
</span>
<span
class=
"active track-title"
>
{
displayTitle
(
value
)
}
</span>
<span
class=
"track-time-left"
>
(
{
formatTime
(
timeLeft
)
}
)
</span>
</h
1
>
</h
2
>
</div>
</div>
<div
id=
"next-schedule"
>
<h2
class=
"schedule-title"
>
Next:
{
@html
displayShowName
(
value
.
next
.
show
)
}
{
displayShowSchedule
(
value
)
}
</h2>
<div
class=
"schedule-details"
>
<b>
Type:
</b>
{
value
.
next
.
type
}
,
<b>
Host:
</b>
{
value
.
next
.
host
}
</div>
</div>
{
/if
}
{
:catch
error
}
<p
style=
"color:red"
>
{
error
}
</p>
{
/await
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment