Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tv_panel
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hermod
tv_panel
Commits
498cd7e8
Commit
498cd7e8
authored
Feb 20, 2018
by
Aymeric Bernard
Browse files
Options
Downloads
Plain Diff
Merge branch 'real-api' into 'master'
Real api See merge request hermod/tv_panel!2
parents
a6366815
0fea11ab
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
front/display.js
+12
-3
12 additions, 3 deletions
front/display.js
front/index.html
+6
-3
6 additions, 3 deletions
front/index.html
front/socket.js
+2
-0
2 additions, 0 deletions
front/socket.js
front/style.css
+1
-1
1 addition, 1 deletion
front/style.css
server/index.js
+6
-38
6 additions, 38 deletions
server/index.js
with
27 additions
and
45 deletions
front/display.js
+
12
−
3
View file @
498cd7e8
...
...
@@ -12,13 +12,19 @@ const concatTextParts = textParts =>
const
jsonTextToHtml
=
data
=>
<
div
className
=
"
text-bloc
"
>
{
concatTextParts
(
data
.
text
)}
<
/div>
;
const
jsonImageToHtml
=
data
=>
<
div
className
=
"
image-bloc
"
>
{
data
.
image
}
<
/div>
;
const
jsonImageToHtml
=
data
=>
<
div
className
=
"
image-bloc
"
>
<
img
src
=
"
https://people.via.ecp.fr/~bebert/chatenay.jpg
"
alt
-
src
=
{
data
.
image
}
style
=
"
height: 80px; margin-right: 10px; border: solid 1px #A0A0A0
"
/>
<
/div>
;
const
jsonImageTextToHtml
=
data
=>
(
<
div
className
=
"
image-text-bloc
"
style
=
"
display: flex
"
>
<
img
src
=
"
https://people.via.ecp.fr/~
stook/perso/ancien_public_html/stickerFlat.pn
g
"
style
=
"
height:
4
0px; margin-right: 10px
"
src
=
"
https://people.via.ecp.fr/~
bebert/toddy.jp
g
"
style
=
"
height:
8
0px; margin-right: 10px
; border: solid 1px #A0A0A0
"
/>
<
div
style
=
"
width: 100%; display: flex; justify-content: space-between
"
>
{
concatTextParts
(
data
.
text
)}
...
...
@@ -30,6 +36,9 @@ export default (data) => {
const
head
=
<
div
style
=
"
background-color:#F2F2FF; padding:10px
"
/>
;
data
.
rows
.
map
((
row
)
=>
{
if
(
!
row
)
{
return
''
;
}
switch
(
row
.
type
)
{
case
0
:
return
jsonTextToHtml
(
row
);
...
...
This diff is collapsed.
Click to expand it.
front/index.html
+
6
−
3
View file @
498cd7e8
...
...
@@ -2,12 +2,12 @@
<html>
<head>
<title>
Socket IO test
</title>
<title>
Hermod TV Panel
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"style.css"
>
</head>
<body>
<p>
Date:
<p
style=
"color: #DDDDDD"
>
Date:
<span
id=
"date"
>
Not connected
</span>
...
...
@@ -15,6 +15,9 @@
<div
id=
"panel_data"
></div>
<style
type=
"text/css"
id=
"root"
>
</style>
<script
type=
"text/javascript"
src=
"https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.slim.js"
></script>
<script
type=
"text/javascript"
src=
"./setup.js"
defer
></script>
<script
type=
"text/javascript"
src=
"./socket.js"
defer
></script>
...
...
This diff is collapsed.
Click to expand it.
front/socket.js
+
2
−
0
View file @
498cd7e8
...
...
@@ -18,11 +18,13 @@ socketIO.on('date', (data) => {
socketIO
.
on
(
'
panel_data
'
,
(
data
)
=>
{
console
.
log
(
data
);
// data.ttl = 500000;
setTimeout
(()
=>
{
socketIO
.
emit
(
'
panel_data
'
);
console
.
log
(
`Next call in
${
data
.
ttl
}
milliseconds.`
);
},
data
.
ttl
);
const
panelData
=
document
.
getElementById
(
'
panel_data
'
);
document
.
getElementById
(
'
root
'
).
innerHTML
=
'
html {--size: 80px;}
'
;
diffNodes
(
panelData
,
jsonToHtmlArray
(
data
));
});
...
...
This diff is collapsed.
Click to expand it.
front/style.css
+
1
−
1
View file @
498cd7e8
.text-element
{
font-size
:
40px
;
font-size
:
var
(
--size
)
;
}
.text-bloc
{
...
...
This diff is collapsed.
Click to expand it.
server/index.js
+
6
−
38
View file @
498cd7e8
const
fetch
=
require
(
'
node-fetch
'
);
const
io
=
require
(
'
socket.io
'
)(
3000
);
let
incr
=
0
;
io
.
of
(
'
/
'
).
on
(
'
connection
'
,
(
socket
)
=>
{
fetch
(
'
http://hermod.cs-campus.fr/api/v1/screen/1
'
)
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
socket
.
emit
(
'
message
'
,
res
));
// Respond to date message with the date
socket
.
on
(
'
date
'
,
()
=>
{
socket
.
emit
(
'
date
'
,
{
date
:
Date
.
now
()
});
});
// Respond to panel_data message by fetching the info from the server
socket
.
on
(
'
panel_data
'
,
()
=>
{
socket
.
emit
(
'
panel_data
'
,
// Pour les tests, json en dur
{
version
:
'
0.0.3
'
,
ttl
:
2000
,
rows
:
[
{
type
:
1
,
// 0 for "text", 1 for "text + image", 2 for "image"...
image
:
'
base_url
'
,
text
:
[
{
text
:
'
What I want to display
'
,
style
:
{
color
:
'
#440044
'
}
},
{
text
:
incr
.
toString
(),
style
:
{
color
:
'
#BB8800
'
,
fontWeight
:
'
bold
'
}
},
],
},
{
type
:
0
,
text
:
[
{
text
:
'
Some text
'
,
style
:
{
color
:
'
#440044
'
}
},
{
text
:
incr
.
toString
(),
style
:
{
color
:
'
#BB8800
'
,
fontWeight
:
'
bold
'
}
},
],
},
{
type
:
2
,
image
:
'
base_url
'
,
text
:
[{
text
:
'
Nope
'
}],
},
],
},
);
// Truc qui change juste pour voir si ça refresh
incr
+=
1
;
fetch
(
'
http://hermod.cs-campus.fr/api/v1/screen/10
'
)
// TODO get the uid from a config
.
then
(
rawRes
=>
rawRes
.
json
())
.
then
(
res
=>
socket
.
emit
(
'
panel_data
'
,
res
))
.
catch
(
console
.
log
);
});
});
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