Skip to content

Commit

Permalink
Merge pull request #157 from camicroscope/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
birm authored Jun 16, 2023
2 parents 945e448 + 9488299 commit 94c085f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM node:14-alpine
RUN apk add --no-cache git
RUN apk add --no-cache openssl
RUN mkdir /src
COPY . /src
WORKDIR /src
RUN npm install
ARG viewer
ARG fork
RUN apk add --no-cache git
RUN git clone https://github.com/${fork:-camicroscope}/camicroscope.git --branch=${viewer:-master}
EXPOSE 4010

Expand Down
7 changes: 6 additions & 1 deletion caracal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const permissionHandler = require('./handlers/permssionHandler.js');
const dataHandlers = require('./handlers/dataHandlers.js');
const fileHandlers = require('./handlers/fileHandlers.js');
const sanitizeBody = require('./handlers/sanitizeHandler.js');
const envEcho = require("./handlers/envEcho.js");
const DataTransformationHandler = require('./handlers/dataTransformationHandler.js');


Expand All @@ -34,7 +35,7 @@ var MONGO_URI = process.env.MONGO_URI || 'mongodb://localhost';

var DISABLE_CSP = process.env.DISABLE_CSP || false;

var RUN_INDEXER = process.env.RUN_INDEXER || true;
var RUN_INDEXER = process.env.RUN_INDEXER || false;

const app = express();
app.use(cookieParser());
Expand Down Expand Up @@ -82,6 +83,7 @@ var HANDLERS = {
"permissionHandler": permissionHandler,
"editHandler": auth.editHandler,
"proxyHandler": proxyHandler,
"envEcho": envEcho,
"writeFile": fileHandlers.writeFile,
"iipHandler": function() {
return iipHandlers.iipHandler;
Expand All @@ -98,6 +100,9 @@ var HANDLERS = {
"markSpatial": function() {
return dataHandlers.Mark.spatial;
},
"markSegmentationCount": function() {
return dataHandlers.Mark.segmentationCountByExecid;
},
"findMarkTypes": function() {
return dataHandlers.Mark.findMarkTypes;
},
Expand Down
2 changes: 1 addition & 1 deletion handlers/authHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function tokenTrade(checkKey, signKey, userFunction) {
'err': 'User Unauthorized',
});
} else {
data = x;
let data = x;
delete data['exp'];
// sign using the mounted key
var token = jwt.sign(data, signKey, {
Expand Down
36 changes: 35 additions & 1 deletion handlers/dataHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,42 @@ Mark.spatial = function(req, res, next) {
next();
}).catch((e) => next(e));
};
Mark.segmentationCountByExecid = async function(req, res, next) {
var query = req.query;
delete query.token;

// handle x0, y0, x1, y1
if (req.query.x0 && req.query.x1) {
query.x = {
'$gt': parseFloat(req.query.x0),
'$lt': parseFloat(req.query.x1),
};
}
delete query.x0;
delete query.x1;
if (req.query.y0 && req.query.y1) {
query.y = {
'$gt': parseFloat(req.query.y0),
'$lt': parseFloat(req.query.y1),
};
}
delete query.y0;
delete query.y1;
try {
// {"$match": {"provenance.image.slide": {"$in": sids}}},
const data = await mongoDB.aggregate('camic', 'mark',
[
{"$match": query},
{"$group": {_id: "$provenance.analysis.execution_id", count: {$sum: 1}}},
]);
console.log(data);
req.data = data;
next();
} catch (error) {
req.data = {error};
next();
}
};
Mark.multi = function(req, res, next) {
var query = {};

Expand Down Expand Up @@ -211,7 +246,6 @@ Mark.multi = function(req, res, next) {
'$gt': parseFloat(postQuery.footprint),
};
}

mongoDB.find('camic', 'mark', query).then((x) => {
req.data = x;
next();
Expand Down
10 changes: 10 additions & 0 deletions handlers/envEcho.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// echo enviornment variables
function envEcho() {
return function(req, res, next) {
req.data = process.env;
next();
};
}


module.exports = envEcho;
2 changes: 1 addition & 1 deletion idx_mongo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mongodb = require("./service/database");

function quietMongoAdd(db, collection, data, x) {
try {
mongodb.add(db, collection, data, x);
mongodb.add(db, collection, data, x).catch((e)=>console.error(e));
} catch (err) {
console.error(err);
}
Expand Down

0 comments on commit 94c085f

Please sign in to comment.