From d3232d4af3d92471ad512516aae084a54cb7ec71 Mon Sep 17 00:00:00 2001 From: Nan Li Date: Wed, 11 Jan 2023 16:05:36 -0600 Subject: [PATCH 1/6] add api for selection download --- caracal.js | 3 +++ handlers/dataHandlers.js | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/caracal.js b/caracal.js index a06c1c7..fab970c 100644 --- a/caracal.js +++ b/caracal.js @@ -98,6 +98,9 @@ var HANDLERS = { "markSpatial": function() { return dataHandlers.Mark.spatial; }, + "markSegmentationCount": function() { + return dataHandlers.Mark.segmentationCountByExecid; + }, "findMarkTypes": function() { return dataHandlers.Mark.findMarkTypes; }, diff --git a/handlers/dataHandlers.js b/handlers/dataHandlers.js index e6d5430..3ae90e1 100644 --- a/handlers/dataHandlers.js +++ b/handlers/dataHandlers.js @@ -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 = {}; @@ -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(); From 5b6b77f15c9f92f202023ac8bf7a8d8cfd076b86 Mon Sep 17 00:00:00 2001 From: Ryan Birmingham Date: Mon, 27 Feb 2023 16:52:00 -0500 Subject: [PATCH 2/6] Add envEcho back --- caracal.js | 2 ++ handlers/envEcho.js | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 handlers/envEcho.js diff --git a/caracal.js b/caracal.js index fab970c..f9847ac 100644 --- a/caracal.js +++ b/caracal.js @@ -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'); @@ -82,6 +83,7 @@ var HANDLERS = { "permissionHandler": permissionHandler, "editHandler": auth.editHandler, "proxyHandler": proxyHandler, + "envEcho": envEcho, "writeFile": fileHandlers.writeFile, "iipHandler": function() { return iipHandlers.iipHandler; diff --git a/handlers/envEcho.js b/handlers/envEcho.js new file mode 100644 index 0000000..c2f9d43 --- /dev/null +++ b/handlers/envEcho.js @@ -0,0 +1,10 @@ +// echo enviornment variables +function envEcho() { + return function(req, res, next) { + req.data = process.env; + next(); + }; +} + + +module.exports = envEcho; From 8b998eaeeb427d6b420c6ee35712c272646c6675 Mon Sep 17 00:00:00 2001 From: Ryan Birmingham Date: Mon, 6 Mar 2023 00:22:15 -0500 Subject: [PATCH 3/6] Add openssl --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 21441e8..34f6a5d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 From f6b6f2cd7627a971a67c221f2dcb17e2401fe9c2 Mon Sep 17 00:00:00 2001 From: MuminAhmadKhan Date: Thu, 9 Mar 2023 10:51:15 +0530 Subject: [PATCH 4/6] defined variable for data --- handlers/authHandlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/authHandlers.js b/handlers/authHandlers.js index fec64af..5e4af2b 100644 --- a/handlers/authHandlers.js +++ b/handlers/authHandlers.js @@ -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, { From f85a68df24ca9c25922b1e5de49ddb62ef7bf221 Mon Sep 17 00:00:00 2001 From: Ryan Birmingham Date: Fri, 10 Mar 2023 02:31:19 -0500 Subject: [PATCH 5/6] try to make it less likely to complain about EXPECTED errors --- idx_mongo.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idx_mongo.js b/idx_mongo.js index c2a2b0b..90a3dee 100644 --- a/idx_mongo.js +++ b/idx_mongo.js @@ -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); } From 9488299615ad0c70959cef097fef891905d0273c Mon Sep 17 00:00:00 2001 From: Ryan Birmingham Date: Tue, 9 May 2023 19:53:31 -0400 Subject: [PATCH 6/6] default false run indexer --- caracal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caracal.js b/caracal.js index f9847ac..944bc4b 100644 --- a/caracal.js +++ b/caracal.js @@ -35,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());