Skip to content
Snippets Groups Projects
Commit 5b51b961 authored by Aymeric Bernard's avatar Aymeric Bernard
Browse files

Get data from hermod.cs-campus.fr

parent a6366815
Branches
No related tags found
No related merge requests found
...@@ -30,6 +30,9 @@ export default (data) => { ...@@ -30,6 +30,9 @@ export default (data) => {
const head = <div style="background-color:#F2F2FF; padding:10px" />; const head = <div style="background-color:#F2F2FF; padding:10px" />;
data.rows data.rows
.map((row) => { .map((row) => {
if (!row) {
return '';
}
switch (row.type) { switch (row.type) {
case 0: case 0:
return jsonTextToHtml(row); return jsonTextToHtml(row);
......
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
<html> <html>
<head> <head>
<title>Socket IO test</title> <title>Hermod TV Panel</title>
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
</head> </head>
<body> <body>
<p>Date: <p style="color: #DDDDDD">Date:
<span id="date"> <span id="date">
Not connected Not connected
</span> </span>
......
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const io = require('socket.io')(3000); const io = require('socket.io')(3000);
let incr = 0;
io.of('/').on('connection', (socket) => { io.of('/').on('connection', (socket) => {
fetch('http://hermod.cs-campus.fr/api/v1/screen/1') // Respond to date message with the date
.then(res => res.json())
.then(res => socket.emit('message', res));
socket.on('date', () => { socket.on('date', () => {
socket.emit('date', { date: Date.now() }); socket.emit('date', { date: Date.now() });
}); });
// Respond to panel_data message by fetching the info from the server
socket.on('panel_data', () => { socket.on('panel_data', () => {
socket.emit( fetch('http://hermod.cs-campus.fr/api/v1/screen/10') // TODO get the uid from a config
'panel_data', .then(rawRes => rawRes.json())
// Pour les tests, json en dur .then(res => socket.emit('panel_data', res))
{ .catch(console.log);
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;
}); });
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment