From 44834771d426e6924c45827c8e954d5f26ca2e4c Mon Sep 17 00:00:00 2001 From: Soichi Hayashi Date: Fri, 26 Jun 2020 15:00:28 -0400 Subject: [PATCH 1/3] updated the way opened rooms are kept up. --- assets/css/room.css | 8 ++++++++ assets/js/main.js | 45 ++++----------------------------------------- room.html | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 assets/css/room.css create mode 100644 room.html diff --git a/assets/css/room.css b/assets/css/room.css new file mode 100644 index 00000000..b146ecc2 --- /dev/null +++ b/assets/css/room.css @@ -0,0 +1,8 @@ +body, html { + margin: 0; + padding: 0; + height: 100%; +} +#meet { + height: 100%; +} diff --git a/assets/js/main.js b/assets/js/main.js index 8051c851..9e618881 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -217,17 +217,10 @@ function directory(jQuery) { { targets: 4,//video render(data, type, row) { - /* return ` - - ` - */ - return ` - jitsi:ohbm2020-${row.number} - + + jitsi:ohbm2020-${row.number} + ` }, }, @@ -244,8 +237,6 @@ function directory(jQuery) { return '[ADD]'; } else { return 'PDF'; - //return 'PDF'; - //return 'PDF'; } }, } @@ -271,7 +262,6 @@ function directory(jQuery) { let msg = JSON.parse(e.data); if(msg.dump) { for(let key in msg.dump) { - $("#jit_users_"+key).text(msg.dump[key]); let row = table.row("#p"+key); if(row.length == 1) { table.cell(row, 5).data(msg.dump[key]); @@ -280,7 +270,6 @@ function directory(jQuery) { table.draw(); } if(msg.update) { - $("#jit_users_"+msg.update.id).text(msg.update.count); let row = table.row("#p"+msg.update.id); table.cell(row, 5).data(msg.update.count).draw(); } @@ -291,33 +280,7 @@ function directory(jQuery) { return table; } -let openJits = new Set(); - -window.addEventListener("beforeunload", function(evt) { - openJits.forEach(id=>{ - wss.send(JSON.stringify({action: "jitclose", id})); - }); -}); - function openJit(url, number) { - wss.send(JSON.stringify({action: "jit", id: number})); - openJits.add(number); - let child = window.open(url, "jit"+number); - let timer = setInterval(()=>{ - console.log(openJits); - if(child.closed) { - wss.send(JSON.stringify({action: "jitclose", id: number})); - openJits.delete(number); - clearInterval(timer); - } else { - //still open.. let's let the server know that we are still here - wss.send(JSON.stringify({action: "jit", id: number})); - } - }, 1000*3); -} - -function openPdf(url, number) { - window.open(pdf, "pdf"+number); + window.open("room.html#"+number); } - diff --git a/room.html b/room.html new file mode 100644 index 00000000..84b011c9 --- /dev/null +++ b/room.html @@ -0,0 +1,32 @@ + + + + + + + + +
+ + + From 3852768d7a82ad3c2bd1f8ad7c1b08af3c4d3b00 Mon Sep 17 00:00:00 2001 From: Soichi Hayashi Date: Fri, 26 Jun 2020 19:02:12 +0000 Subject: [PATCH 2/3] added cid to the ip address key --- backend/server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/server.js b/backend/server.js index 0746a45b..df27fb6d 100644 --- a/backend/server.js +++ b/backend/server.js @@ -30,7 +30,7 @@ app.ws('/', function(ws, req) { try { //console.debug(data); let msg = JSON.parse(data); - let ip = req.headers["x-real-ip"]; + let ip = req.headers["x-real-ip"]+"."+msg.cid; let entry; switch(msg.action) { From 6abdae9d0a5ea174b683ad440f4fb83952193c62 Mon Sep 17 00:00:00 2001 From: Soichi Hayashi Date: Fri, 26 Jun 2020 16:07:08 -0400 Subject: [PATCH 3/3] fixed overrides mechanism to allow custom videochat url as well as custom jitsi room name --- assets/js/main.js | 87 ++++++++++++++++++++++++++---------------- posters-overrides.json | 12 +++--- room.html | 9 +++-- 3 files changed, 65 insertions(+), 43 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 9e618881..2f5dfd8e 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -182,7 +182,7 @@ function getNodeType(jQuery, md5, url) { * @param {object} md5 md5 library object * @return {object} returns the rendered DataTable object */ -function directory(jQuery) { +async function directory(jQuery) { // Embed the table placeholder jQuery('#content').prepend('
'); @@ -217,11 +217,22 @@ function directory(jQuery) { { targets: 4,//video render(data, type, row) { - return ` - - jitsi:ohbm2020-${row.number} - - ` + let name = "ohbm2020-"+row.number; //default + if(row.videochat) name = row.videochat; //user can override it to another jitsi name + if(row.videochat && row.videochat.startsWith("http")) { + //or use custom url + return ` + + custom url + + `; + } else { + return ` + + jitsi://${name} + + `; + } }, }, { @@ -245,42 +256,52 @@ function directory(jQuery) { }); //end of DataTable //load posters - fetch("posters.json").then(res=>res.json()).then(data=>{ - data.posters.forEach(p=>{ - p.id = 'p'+p.number; //cannot be number (or string of number) - p.people = 0; - }); - table.rows.add(data.posters).draw(); + let res = await fetch("posters.json"); + let data = await res.json(); + data.posters.forEach(p=>{ + p.id = 'p'+p.number; //cannot be number (or string of number) + p.people = 0; + p.videochat = null; //let's ignore this now (override only) + }); - wss = new ReconnectingWebSocket("wss://dev1.soichi.us/ohbm2020/"); + //load override and apply + res = await fetch("posters-overrides.json"); + let override = await res.json(); + override.posters.forEach(o=>{ + let p = data.posters.find(p=>p.number == o.number); + Object.assign(p, o); + }); - //connect to backend - wss.onopen = () => { - wss.send(JSON.stringify({action: "dump"})); - } - wss.onmessage = e => { - let msg = JSON.parse(e.data); - if(msg.dump) { - for(let key in msg.dump) { - let row = table.row("#p"+key); - if(row.length == 1) { - table.cell(row, 5).data(msg.dump[key]); - } + table.rows.add(data.posters).draw(); + + wss = new ReconnectingWebSocket("wss://dev1.soichi.us/ohbm2020/"); + + //connect to backend + wss.onopen = () => { + wss.send(JSON.stringify({action: "dump"})); + } + wss.onmessage = e => { + let msg = JSON.parse(e.data); + if(msg.dump) { + for(let key in msg.dump) { + let row = table.row("#p"+key); + if(row.length == 1) { + table.cell(row, 5).data(msg.dump[key]); } - table.draw(); - } - if(msg.update) { - let row = table.row("#p"+msg.update.id); - table.cell(row, 5).data(msg.update.count).draw(); } + table.draw(); } - }); + if(msg.update) { + let row = table.row("#p"+msg.update.id); + table.cell(row, 5).data(msg.update.count).draw(); + } + } localStorage['ntCache'] = JSON.stringify(ntCache); return table; } -function openJit(url, number) { - window.open("room.html#"+number); +function openJit(id, name) { + window.open("room.html#"+id+"."+name); } diff --git a/posters-overrides.json b/posters-overrides.json index 3900c130..ece0e29c 100644 --- a/posters-overrides.json +++ b/posters-overrides.json @@ -3082,7 +3082,7 @@ }, { "number": 1098, - "videochat": "jitsi:cobidas_checklist", + "videochat": "cobidas_checklist", "pdf": "https://drive.google.com/file/d/1CirkGPplmrbqilPOq7OdKQJYZzwc0AKc/view?usp=sharing" }, { @@ -3674,7 +3674,7 @@ }, { "number": 1302, - "videochat": "jitsi:ohbm2020-412", + "videochat": "ohbm2020-412", "pdf": "https://cdn-akamai.6connex.com//645/1827//TaskCCA_poster_1__15922324225571065.pdf" }, { @@ -4583,7 +4583,7 @@ }, { "number": 1621, - "videochat": "zoom:9545579483 (password: \"visualqc\")", + "videochat": "https://zoom.us/j/9545579483?pwd=QUM3Um55MWV2RmFuWTJkb3ZKV2xQdz09", "pdf": "https://crossinvalidation.com/2020/06/22/evaluating-visual-qc-protocols-for-freesurfer-parcellations-error-detection-rate-inter-rater-reliability-and-site-differences/" }, { @@ -5290,7 +5290,7 @@ }, { "number": 1860, - "videochat": "jitsi:DeepPrimateBrainShapes", + "videochat": "DeepPrimateBrainShapes", "pdf": "https://github.com/katjaq/brainscapes/blob/master/img/Heuer-Toro_BrainScapes_OHBM_2020.pdf" }, { @@ -5395,7 +5395,7 @@ }, { "number": 1895, - "videochat": "jitsi:bids-derivatives", + "videochat": "bids-derivatives", "pdf": "https://cdn-akamai.6connex.com/645/1827/poster_15922429379118925.pdf" }, { @@ -5503,7 +5503,7 @@ }, { "number": 1929, - "videochat": "jitsi:rsHRF_toolbox", + "videochat": "rsHRF_toolbox", "pdf": "https://github.com/sofievdbos/OHBM2020/blob/master/OHBM20_SVDB_interactive.pdf" }, { diff --git a/room.html b/room.html index 84b011c9..7b4c94dc 100644 --- a/room.html +++ b/room.html @@ -8,13 +8,14 @@