diff --git a/app.js b/app.js index 1ecfd873bf3c2349519c049d42a1761b5a1c91cf..97f67106ea55764d3b1dbbb98c0a6fb9c38af93b 100644 --- a/app.js +++ b/app.js @@ -36,7 +36,6 @@ if (DOCKER_DB) { } var db = monk(MONGO_DB); -var fs = require('fs'); var expressValidator = require('express-validator'); /* jslint nomen: true */ @@ -197,7 +196,7 @@ app.get('/auth/github/callback', global.tokenAuthentication = function (req, res, next) { tracer.log('>> Check token'); let token; - if (req.params.token) { + if (req.params.token) token = req.params.token; if(req.query.token) token = req.query.token; diff --git a/controller/project/project.controller.js b/controller/project/project.controller.js index 731bc531799bad882888a691cc1bd937e07ed28a..627c38bcf9133f74611a1f56f6ccf92fe439e4a1 100644 --- a/controller/project/project.controller.js +++ b/controller/project/project.controller.js @@ -1,9 +1,3 @@ -var async = require("async"); -var url = require('url'); -var crypto = require('crypto'); -var dateFormat = require('dateformat'); -var validatorNPM = require('validator'); -var async = require('async'); const url = require('url'); const crypto = require('crypto'); const dateFormat = require('dateformat'); diff --git a/package.json b/package.json index 6f3835680ae1acbd930182187f1c65188bf048b0..288583bb8fdf48a8d723a0c0c8649ab49830bb83 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "style-loader": "^0.23.0", "url-loader": "^1.1.1", "webpack": "^4.20.0", - "webpack-cli": "^3.1.1", + "webpack-cli": "^3.1.2", "webpack-shell-plugin": "^0.5.0" } } diff --git a/view/atlasMaker/src/atlasmaker-ws.js b/view/atlasMaker/src/atlasmaker-ws.js index c90ef63a6f3f4c6d19ce418fc8b88abbdaba1ad1..d754691efbab0ec3e99f835f1fd4c68eb987e71c 100644 --- a/view/atlasMaker/src/atlasmaker-ws.js +++ b/view/atlasMaker/src/atlasmaker-ws.js @@ -6,17 +6,10 @@ import * as pako from '../../downloads/pako.min.js'; /** * @page AtlasMaker: WebSockets */ -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js export var AtlasMakerWS = { //==================================================================================== // Web sockets //==================================================================================== -======= -var AtlasMakerWS = { - //==================================================================================== - // Web sockets - //==================================================================================== ->>>>>>> master:public/js/atlasMaker-ws.js /** * @function createSocket * @desc Create a WebSocket connection using the WebSocket object or the MozWebSocket @@ -24,7 +17,6 @@ var AtlasMakerWS = { * @param {string} host Websocket host * @returns {object} Websocket */ -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js createSocket: function createSocket(host) { var ws; @@ -93,87 +85,6 @@ var AtlasMakerWS = { var timeout = me.reconnectionTimeout; $("#chat").text("Disconnected. Try to reconnect in " + (timeout--) + " s..."); if (me.timer) { -======= - createSocket: function createSocket(host) { - var me=AtlasMakerWidget; - var l=me.traceLog(createSocket,0,"#aca");if(l)console.log.apply(undefined,l); - - var ws; - - if (window.WebSocket) { - ws=new WebSocket(host); - } else if (window.MozWebSocket) { - ws=new MozWebSocket(host); - } else { - console.log("ERROR: browser does not support WebSockets"); - } - - return ws; - }, - /** - * @function initSocketConnection - */ - initSocketConnection: function initSocketConnection() { - var me=AtlasMakerWidget; - var l=me.traceLog(initSocketConnection,0,"#aca");if(l)console.log.apply(undefined,l); - - var def=$.Deferred(); - - // WS connection - var host = "ws://" + window.location.hostname + ":8080/"; - - if(me.debug) - console.log("[initSocketConnection] host:",host); - if (me.progress) - me.progress.html("Connecting..."); - - try { - me.socket = me.createSocket(host); - - me.socket.onopen = function(msg) { - if(me.debug) - console.log("[initSocketConnection] connection open",msg); - me.progress.html("MRI"); - $("#chat").text("Chat (1 connected)"); - me.flagConnected=1; - me.reconnectionTimeout = 5; - def.resolve(); - }; - - me.receiveFunctions["saveMetadata"]=me.receiveMetadata; - me.receiveFunctions["userData"]=me.receiveUserDataMessage; - me.receiveFunctions["volInfo"]=function(data){console.log("volInfo",data)}; - me.receiveFunctions["chat"]=me.receiveChatMessage; - me.receiveFunctions["show"]=me.receiveShowMessage; - me.receiveFunctions["paint"]=me.receivePaintMessage; - me.receiveFunctions["paintvol"]=me.receivePaintVolumeMessage; - me.receiveFunctions["disconnect"]=me.receiveDisconnectMessage; - me.receiveFunctions["serverMessage"]=me.receiveServerMessage; - - me.receiveFunctions["requestSlice"]=function(data){console.log("requestSlice",data)}; - me.receiveFunctions["requestSlice2"]=function(data){console.log("requestSlice2",data)}; - - me.socket.onmessage = me.receiveSocketMessage; - - me.socket.onclose = function(msg) { - me.flagConnected=0; - - // Try to reconnect - // wait a random initial time, to prevent an avalanche - // of reconnections in case of server crash - var rand = 1000+5000*Math.random(); - console.log("Initial random time:",rand); - setTimeout(function() { - var timeout = me.reconnectionTimeout; - $("#chat").text("Disconnected. Try to reconnect in "+(timeout--)+" s..."); - if(me.timer) { - clearInterval(me.timer); - } - me.timer = setInterval(function() { - if(timeout < 0) { - $("#chat").text("Reconnecting..."); - me.socket = null; ->>>>>>> master:public/js/atlasMaker-ws.js clearInterval(me.timer); setTimeout(function() { me.reconnectionTimeout *= 2; @@ -191,7 +102,6 @@ var AtlasMakerWS = { } else { $("#chat").text("Disconnected. Try to reconnect in "+(timeout--)+" s..."); } -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js me.timer = setInterval(function () { if (timeout < 0) { $("#chat").text("Reconnecting..."); @@ -284,80 +194,11 @@ var AtlasMakerWS = { var ext = String.fromCharCode(data[sz - 8], data[sz - 7], data[sz - 6]); if (me.debug > 1) { console.log("type: " + ext); } -======= - }, 1000); - }, rand); - }; - - window.onbeforeunload = function() { - me.socket.onclose = function () {}; // disable onclose handler first - me.socket.close() - }; - } - catch (ex) { - $("#chat").text("Chat (not connected - connection error)"); - } - - return def.promise(); - }, - /** - * @function receiveSocketMessage - */ - receiveSocketMessage: function receiveSocketMessage(msg) { - var me=AtlasMakerWidget; - var l=me.traceLog(receiveSocketMessage,1,"#aca");if(l)console.log.apply(undefined,l); - - // Message: atlas data initialisation - if(msg.data instanceof Blob) { - me.receiveBinaryMessage(msg.data); - return; - } - - // Message: interaction message - var data=JSON.parse(msg.data); - me.receiveFunctions[data.type](data); - }, - /** - * @function sendUserDataMessage - */ - sendUserDataMessage: function sendUserDataMessage(description) { - var me=AtlasMakerWidget; - var l=me.traceLog(sendUserDataMessage,1,"#aca");if(l)console.log.apply(undefined,l); - - if(me.flagConnected==0) - return; - - if(me.debug>1) console.log("message: "+description); - - if(description === "allUserData") - var msg={"type":"userData","user":me.User,"description":description}; - else - var msg={"type":"userData","description":description}; - try { - me.socket.send(JSON.stringify(msg)); - } catch (ex) { - console.log("ERROR: Unable to sendUserDataMessage",ex); - } - }, - /** - * @function receiveBinaryMessage - */ - receiveBinaryMessage: function receiveBinaryMessage(msgData) { - var me=AtlasMakerWidget; - var l=me.traceLog(receiveBinaryMessage,1,"#aca");if(l)console.log.apply(undefined,l); - - var fileReader = new FileReader(); - fileReader.onload = function from_receiveSocketMessage() { - var data=new Uint8Array(this.result); - var sz=data.length; - var ext=String.fromCharCode(data[sz-8],data[sz-7],data[sz-6]); ->>>>>>> master:public/js/atlasMaker-ws.js if(me.debug>1) console.log("type: "+ext); switch(ext) { case 'nii': { -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js var inflate = new pako.Inflate(); inflate.push(data, true); var atlas = {}; @@ -366,16 +207,6 @@ var AtlasMakerWS = { atlas.dim = me.brain_dim; me.atlas = atlas; -======= - var inflate=new pako.Inflate(); - inflate.push(data,true); - var atlas=new Object(); - atlas.data=inflate.result; - atlas.name=me.atlasFilename; - atlas.dim=me.brain_dim; - - me.atlas=atlas; ->>>>>>> master:public/js/atlasMaker-ws.js me.configureBrainImage(); me.configureAtlasImage(); @@ -389,17 +220,12 @@ var AtlasMakerWS = { me.info.volume=parseInt(vol)+" mm3"; // setup download link -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js var link = me.container.find("span#download_atlas"); link.html([ "", "", "" + atlas.name ].join('')); -======= - var link=me.container.find("span#download_atlas"); - link.html(""+atlas.name); ->>>>>>> master:public/js/atlasMaker-ws.js break; } @@ -407,7 +233,6 @@ var AtlasMakerWS = { var urlCreator = window.URL || window.webkitURL; var imageUrl = urlCreator.createObjectURL(msgData); var img = new Image(); -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js me.isMRILoaded = true; // receiving a jpg is proof of a loaded MRI @@ -416,47 +241,27 @@ var AtlasMakerWS = { me.brain_img.img = img; me.brain_img.view = me.flagLoadingImg.view; me.brain_img.slice = me.flagLoadingImg.slice; -======= - - me.isMRILoaded=true; // receiving a jpg is proof of a loaded MRI - - img.onload=function from_initSocketConnection(){ - var flagFirstImage=(me.brain_img.img==null); - me.brain_img.img=img; - me.brain_img.view=me.flagLoadingImg.view; - me.brain_img.slice=me.flagLoadingImg.slice; ->>>>>>> master:public/js/atlasMaker-ws.js me.drawImages(); me.flagLoadingImg.loading=false; -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js me.flagLoadingImg.loading = false; if (flagFirstImage || me.flagLoadingImg.view !== me.User.view || me.flagLoadingImg.slice !== me.User.slice) { -======= - if(flagFirstImage || me.flagLoadingImg.view!=me.User.view ||me.flagLoadingImg.slice!=me.User.slice) { ->>>>>>> master:public/js/atlasMaker-ws.js me.sendRequestSliceMessage(); } // remove loading indicator $("#loadingIndicator").hide(); -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js }; img.src = imageUrl; -======= - } - img.src=imageUrl; ->>>>>>> master:public/js/atlasMaker-ws.js break; } } }; fileReader.readAsArrayBuffer(msgData); -<<<<<<< HEAD:view/atlasMaker/src/atlasmaker-ws.js }, /** @@ -871,395 +676,3 @@ var AtlasMakerWS = { }); } }; -======= - }, - /** - * @function receiveUserDataMessage - */ - receiveUserDataMessage: function receiveUserDataMessage(data) { - var me=AtlasMakerWidget; - var l=me.traceLog(receiveUserDataMessage,0,"#aca");if(l)console.log.apply(undefined,l); - - if(me.debug>1) console.log("description: "+data.description,data); - - var u=data.uid; - - // First time the user is observed - if(me.Collab[u]===undefined) { - try { - //var msg=""+data.user.username+" entered atlas "+data.user.specimenName+"/"+data.user.atlasFilename+"
" - var msg; - if(data.user === undefined || data.user.username === "Anonymous") { - msg=""+data.uid+" entered
"; - } else { - msg=""+data.user.username+" entered
"; - } - $("#log").append(msg); - $("#log").scrollTop($("#log")[0].scrollHeight); - } catch (e) { - console.log("data:",data); - console.log(e); - } - } - - if(data.description === "allUserData") - me.Collab[u]=data.user; - else { - try { - var changes = JSON.parse(data.description); - var i; - for(i in changes) - me.Collab[u][i] = changes[i]; - } catch (e) { - console.log(e); - } - } - - var v,nusers=1; - for(v in me.Collab) - nusers++; - $("#chat").text("Chat ("+nusers+" connected)"); - }, - /** - * @function sendChatMessage - */ - sendChatMessage: function sendChatMessage() { - var me=AtlasMakerWidget; - var l=me.traceLog(sendChatMessage,0,"#aca");if(l)console.log.apply(undefined,l); - - if(me.flagConnected==0) - return; - var msg = DOMPurify.sanitize($('input#msg')[0].value); - try { - me.socket.send(JSON.stringify({"type":"chat","msg":msg,"username":me.User.username})); - var msg="me: "+msg+"
"; - $("#log").append(msg); - $("#log").scrollTop($("#log")[0].scrollHeight); - $('input#msg').val(""); - } catch (ex) { - console.log("ERROR: Unable to sendChatMessage",ex); - } - }, - /** - * @function receiveChatMessage - */ - receiveChatMessage: function receiveChatMessage(data) { - var me=AtlasMakerWidget; - var l=me.traceLog(receiveChatMessage,0,"#aca");if(l)console.log.apply(undefined,l); - console.log(data); - - var theSource=me.Collab[data.uid].source; - var theView=me.Collab[data.uid].view; - var theSlice=me.Collab[data.uid].slice; - var link = "/mri?url="+theSource+"&view="+theView+"&slice="+theSlice; - var theUsername=data.username; - var msg=""+theUsername+": "+data.msg+"
" - $("#log").append(msg); - $("#log").scrollTop($("#log")[0].scrollHeight); - }, - /** - * @function sendPaintMessage - * @desc On user painting, this function broadcasts the painting event to all other connected users - * @param {Object} msg Painting event object: {"c":c,"x":x,"y":y}, where "c" is the command (l,e,lf,ef) and x and y are the coordinates in slice space - */ - sendPaintMessage: function sendPaintMessage(msg) { - var me=AtlasMakerWidget; - var l=me.traceLog(sendPaintMessage,1,"#aca");if(l)console.log.apply(undefined,l); - - if(me.flagConnected==0) - return; - try { - me.socket.send(JSON.stringify({type:"paint",data:msg})); - } catch (ex) { - console.log("ERROR: Unable to sendPaintMessage",ex); - } - }, - /** - * @function receivePaintMessage - * @desc Receive paint events from other connected users - */ - receivePaintMessage: function receivePaintMessage(data) { - var me=AtlasMakerWidget; - var l=me.traceLog(receivePaintMessage,3,"#aca");if(l)console.log.apply(undefined,l); - - var msg=data.data; - var u=data.uid; // user - var c=msg.c; // command - var x=parseInt(msg.x); // x coordinate - var y=parseInt(msg.y); // y coordinate - - if(me.Collab[u]) - me.paintxy(u,c,x,y,me.Collab[u]); - }, - /** - * @function sendShowMessage - * @desc On user showing, this function broadcasts the showing event to all other connected users - * @param {Object} msg Showing event object: {"x":x,"y":y}, where x and y are the coordinates in slice space - */ - sendShowMessage: function sendShowMessage(msg) { - var me=AtlasMakerWidget; - var l=me.traceLog(sendShowMessage,1,"#aca");if(l)console.log.apply(undefined,l); - - if(me.flagConnected==0) - return; - try { - me.socket.send(JSON.stringify({type:"show",data:msg})); - } catch (ex) { - console.log("ERROR: Unable to sendShowMessage",ex); - } - }, - /** - * @function receiveShowMessage - * @desc Receive show events from other connected users - */ - receiveShowMessage: function receiveShowMessage(data) { - var me=AtlasMakerWidget; - var l=me.traceLog(receiveShowMessage,3,"#aca");if(l)console.log.apply(undefined,l); - - var msg=data.data; - var u=data.uid; // user - var c=msg.c; // command - var x=parseInt(msg.x); // x coordinate - var y=parseInt(msg.y); // y coordinate - - if(me.Collab[u]) - me.showxy(u,c,x,y,me.Collab[u]); - }, - /** - * @function receivePaintVolumeMessage - */ - receivePaintVolumeMessage: function receivePaintVolumeMessage(data) { - var me=AtlasMakerWidget; - var l=me.traceLog(receivePaintVolumeMessage,0,"#aca");if(l)console.log.apply(undefined,l); - - var i,ind,val,voxels; - - voxels=data.data; - me.paintvol(voxels.data); - - /* - TEST - */ - me.sendRequestSliceMessage(); - }, - /** - * @function sendUndoMessage - */ - sendUndoMessage: function sendUndoMessage() { - var me=AtlasMakerWidget; - var l=me.traceLog(sendUndoMessage,0,"#aca");if(l)console.log.apply(undefined,l); - - if(me.flagConnected==0) - return; - try { - me.socket.send(JSON.stringify({type:"paint",data:{c:"u"}})); - } catch (ex) { - console.log("ERROR: Unable to sendUndoMessage",ex); - } - }, - /** - * @function sendSaveMessage - */ - sendSaveMessage: function sendSaveMessage() { - var me=AtlasMakerWidget; - var l=me.traceLog(sendSaveMessage,0,"#aca");if(l)console.log.apply(undefined,l); - - if(me.flagConnected==0) - return; - try { - me.socket.send(JSON.stringify({type:"save"})); - } catch (ex) { - console.log("ERROR: Unable to sendSaveMessage",ex); - } - }, - /** - * @function sendRequestMRIMessage - */ - sendRequestMRIMessage: function sendRequestMRIMessage(source) { - var me=AtlasMakerWidget; - var l=me.traceLog(sendRequestMRIMessage,1,"#aca");if(l)console.log.apply(undefined,l); - - if(me.flagConnected==0) - return; - - try { - me.socket.send(JSON.stringify({ - type:"requestMRI", - source:"sendRequestMRIMessage" - })); - } catch (ex) { - console.log("ERROR: Unable to sendRequestMRIMessage",ex); - } - }, - /** - * @function sendRequestSliceMessage - */ - sendRequestSliceMessage: function sendRequestSliceMessage() { - var me=AtlasMakerWidget; - var l=me.traceLog(sendRequestSliceMessage,1,"#aca");if(l)console.log.apply(undefined,l); - - if(me.flagConnected==0) - return; - if(me.flagLoadingImg.loading==true) - return; - try { - me.socket.send(JSON.stringify({ - - type:"requestSlice", - /* - TEST - */ - //type:"requestSlice2", - - view:me.User.view, - slice:me.User.slice - })); - me.flagLoadingImg.loading=true; - me.flagLoadingImg.view=me.User.view; - me.flagLoadingImg.slice=me.User.slice; - - } catch (ex) { - console.log("ERROR: Unable to sendRequestSliceMessage",ex); - } - }, - /** - * @todo This is really not the place for some of this code. The receiveMetadata - * function is ok, but the direct references to projectInfo -- a structure - * exclusively used by project.mustache -- should go to that file. Now, the - * mechanism for uncoupling the 2 pieces of code is not clear. It could be - * a subscription, for example. - */ - receiveMetadata: function receiveMetadata(data) { - var me=AtlasMakerWidget; - var l=me.traceLog(receiveMetadata,1,"#aca");if(l)console.log.apply(undefined,l); - var projShortname = projectInfo.shortname; - for (var i in projectInfo.files.list) { - if (projectInfo.files.list[i].source == data.metadata.source) { - for (var key in projectInfo.files.list[i].mri.annotations[projShortname]) { - info_proxy["files.list." + i + ".mri.annotations." + projShortname + "." + key] = data.metadata.mri.annotations[projShortname][key]; - } - info_proxy["files.list." + i + ".name"] = data.metadata.name; - break; - } - } - }, - /** - * @function sendSaveMetadataMessage - */ - sendSaveMetadataMessage: function sendSaveMetadataMessage(info, method, patch) { - var me=AtlasMakerWidget; - var l=me.traceLog(sendSaveMetadataMessage,1,"#aca");if(l)console.log.apply(undefined,l); - - var def = $.Deferred(); - if(me.flagConnected==0) { - console.log("WARNING: Not connected: will not save metadata"); - return def.reject().promise(); - } - - try { - var rnd = Math.random().toString(36).slice(20); - var met = method || "append"; - if(method == "patch") { - me.socket.send(JSON.stringify({ - type:"saveMetadata", - metadata: info, - method: met, - patch: patch, - rnd: rnd - })); - } else { - me.socket.send(JSON.stringify({ - type:"saveMetadata", - metadata: info, - method: met, - rnd: rnd - })); - } - if(me.debug>1) { - console.log(rnd); - console.log(info); - } - def.resolve(); - - } catch (ex) { - console.log("ERROR: Unable to sendSaveMetadataMessage",ex); - def.reject(); - } - return def.promise(); - }, - /** - * @function receiveDisconnectMessage - */ - receiveDisconnectMessage: function receiveDisconnectMessage(data) { - var me=AtlasMakerWidget; - var l=me.traceLog(receiveDisconnectMessage,0,"#aca");if(l)console.log.apply(undefined,l); - - var u=data.uid; // user - if(me.Collab[u]) { - var msg; - if(me.Collab[u].username === undefined || me.Collab[u].username === "Anonymous") - msg = ""+me.Collab[u].uid+" left
"; - else - msg = ""+me.Collab[u].username+" left
"; - } - else - var msg=""+u+" left
"; - delete me.Collab[u]; - var v,nusers=1; for(v in me.Collab) nusers++; - $("#chat").text("Chat ("+nusers+" connected)"); - $("#log").append(msg); - $("#log").scrollTop($("#log")[0].scrollHeight); - }, - /** - * @function receiveServerMessage - */ - receiveServerMessage: function receiveServerMessage(data) { - var me=AtlasMakerWidget; - var l=me.traceLog(receiveServerMessage,0,"#aca");if(l)console.log.apply(undefined,l); - - var msg=data.msg; - var prevMsg=$("#chat").text(); - $("#chat").text(msg); - setTimeout(function(){$("#chat").text(prevMsg)},5000); - }, - /** - * @function replayWSTraffic - * @desc Replays websocket traffic recorded at the served. Used for debugging - * @param Array recorded An array of websocket messages recorded in the server - */ - replayWSTraffic: function replayWSTraffic(recorded) { - var me=AtlasMakerWidget; - var l=me.traceLog(replayWSTraffic,0,"#aca");if(l)console.log.apply(undefined,l); - var i; - for(i=0;i>>>>>> master:public/js/atlasMaker-ws.js diff --git a/view/brainbox/src/pages/mri-page.js b/view/brainbox/src/pages/mri-page.js index e0f27cafa816935435afd5b7d846f98f58a0e10e..24483cfa469b4d8ba811ba739bdb6876ee284c14 100644 --- a/view/brainbox/src/pages/mri-page.js +++ b/view/brainbox/src/pages/mri-page.js @@ -1,4 +1,3 @@ -<<<<<<< HEAD:view/brainbox/src/pages/mri-page.js /*global AtlasMakerWidget BrainBox info_proxy mriInfo params*/ import $ from 'jquery'; import 'jquery-ui/themes/base/core.css'; @@ -19,162 +18,6 @@ import '../style/mri-style.css'; import '../style/access-style.css'; import '../style/dropdown-style.css'; -======= - - - - - - - {{title}} - - - - - - - - - - - - - -
- - -
- - - - -
- - - -
-
- - -
- - -
- -
- -
-
- - - - - - - - - - - - - - - -
Name
Data source
Inclusion date
- -
- - Volume Annotations
- - - - - - - - - - - -
NameValueProjectModifiedAccess
-
- - - -
- - Text Annotations
- - - - - - - - - - - -
NameValueProjectModifiedAccess
-
- - - -
- -
-
- - - -
- -
-
- -
-
- -
- - -
- - - -
-
- - -
-

- - - - group de neuroanatomie appliquée et théorique - -

-
-
- - - - - - - - - - - - - -