Skip to content

Commit

Permalink
Merge branch 'develop' into gsoc/ml_assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Oct 10, 2023
2 parents 3a7f5f2 + cdf716b commit c9e6e5f
Show file tree
Hide file tree
Showing 30 changed files with 818 additions and 4,747 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm install
- run: npm install jsdom
- run: npm install -g http-server
Expand Down
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion Caracal
Submodule Caracal deleted from 945e44
1 change: 0 additions & 1 deletion Distro
Submodule Distro deleted from 4f107a
25 changes: 20 additions & 5 deletions apps/batchloader/batchLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let finishUrl = '../../loader/upload/finish/';
let checkUrl = '../../loader/data/one/';
let chunkSize = 5*1024*1024;
let finishUploadSuccess = false;
const allowedExtensions = ['svs', 'tif', 'tiff', 'vms', 'vmu', 'ndpi', 'scn', 'mrxs', 'bif', 'svslide'];
const allowedExtensions = ["svs", "tif", "tiff", "vms", "vmu", "ndpi", "scn", "mrxs", "bif", "svslide", "jpg", "png", "dcm", "v3draw", "ano", "cfg", "csv", "htm", "rec", "tim", "zpo", "dic", "dicom", "jp2", "j2ki", "j2kr", "raw", "ima", "cr2", "crw", "thm", "wav", "dv", "r3d", "r3d_d3d", "log", "mvd2", "aisf", "aiix", "dat", "atsf", "tf2", "tf8", "btf", "pbm", "pgm", "ppm", "xdce", "xml", "xlog", "apl", "tnb", "mtb", "im", "mea", "res", "aim", "arf", "psd", "al3d", "gel", "am", "amiramesh", "grey", "hx", "labels", "img", "hdr", "sif", "afi", "exp", "h5", "1sc", "pic", "ims", "ch5", "vsi", "ets", "pnl", "htd", "c01", "dib", "cxd", "v", "eps", "epsi", "ps", "flex", "xlef", "fits", "fts", "dm2", "dm3", "dm4", "naf", "his", "ndpis", "txt", "i2i", "hed", "mod", "inr", "ipl", "ipm", "fff", "ics", "ids", "seq", "ips", "ipw", "frm", "par", "j2k", "jpf", "jpk", "jpx", "klb", "xv", "bip", "sxm", "fli", "lim", "msr", "lif", "lof", "lei", "l2d", "mnc", "stk", "nd", "scan", "vff", "mrw", "stp", "mng", "nii", "nrrd", "nhdr", "nd2", "nef", "obf", "omp2info", "oib", "oif", "pty", "lut", "oir", "sld", "spl", "liff", "top", "pcoraw", "pcx", "pict", "pct", "df3", "im3", "qptiff", "bin", "env", "spe", "afm", "sm2", "sm3", "spc", "set", "sdt", "spi", "xqd", "xqf", "db", "vws", "pst", "inf", "tfr", "ffr", "zfr", "zfp", "2fl", "tga", "pr3", "dti", "fdf", "hdf", "xys", "html", "acff", "wat", "bmp", "wpi", "czi", "lms", "lsm", "mdb", "zvi", "mrc", "st", "ali", "map", "mrcs", "jpeg", "gif", "ptif"];

// call on document ready
$(document).ready(function() {
Expand All @@ -21,8 +21,12 @@ $(document).ready(function() {
store.findSlide().then((response) => {
for (i=0; i<response.length; i++) {
existingSlides.push(response[i].name);
existingFiles.push((response[i].location).substring((response[i].location).lastIndexOf('/')+1,
if (response[i].filepath) {
existingFiles.push(response[i].filepath);
} else {
existingFiles.push((response[i].location).substring((response[i].location).lastIndexOf('/')+1,
(response[i].location).length));
}
}
}).catch((error) => {
console.log(error);
Expand Down Expand Up @@ -198,7 +202,7 @@ function checkNames() {
}
numErrors++;
} else if (!allowedExtensions.includes(fileNames[i].substring(fileNames[i].lastIndexOf('.')+1,
fileNames[i].length))) {
fileNames[i].length).toLowerCase())) {
let errorIcon = `<i id='fileNameError' class="fas fa-exclamation-circle text-danger" title='File extension not allowed'></i> &nbsp;&nbsp;`;
if ($('.fileNameEdit:eq('+i+')').prev().prev('#fileNameError').length == 0) {
$('.fileNameEdit:eq('+i+')').parent().prepend(errorIcon);
Expand Down Expand Up @@ -346,8 +350,11 @@ function finishBatch() {
}

async function handleUpload(selectedFile, filename, i) {
const token = await startUpload(filename);
const uploadMetadata = await startUpload(filename);
const token = uploadMetadata.upload_token;
tokens.push(token);
fileNames[i] = uploadMetadata.filename;
$('tr:eq('+(i+1)+') td:nth-child(2) span')[0].innerText = uploadMetadata.filename;
let j = 0;
$('.token').each(function() {
$(this).html(tokens[j++]);
Expand All @@ -371,7 +378,7 @@ async function startUpload(filename) {
}}).then((x)=>x.json());
try {
const a = await token;
return a['upload_token'];
return { upload_token: a['upload_token'], filename: a['filename'] };
} catch (e) {
console.log(e);
}
Expand All @@ -395,6 +402,14 @@ function finishUpload(token, filename, i) {
}});
regReq.then((x)=>x.json()).then((a)=>{
// changeStatus('UPLOAD | Finished', a, reset); reset = false;
if (a.filepath) {
const newName = a.filepath.slice(a.filepath.lastIndexOf('/')+1);
fileNames[i] = newName;
$('tr:eq('+(i+1)+') td:nth-child(2) span')[0].innerText = newName;
}
if (a.relpath) {
fileNames[i] = a.relpath;
}
if (typeof a === 'object' && a.error) {
finishUploadSuccess = false;
// $('#check_btn').hide();
Expand Down
2 changes: 1 addition & 1 deletion apps/batchloader/batchloader.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
type="file"
class="custom-file-input"
id="filesInput"
accept=".svs, .tif, .tiff, .vms, .vmu, .ndpi, .scn, .mrxs, .bif, .svslide"
accept=".svs, .tif, .tiff, .vms, .vmu, .ndpi, .scn, .mrxs, .bif, .svslide, .jpg, .png, .dcm, .v3draw, .ano, .cfg, .csv, .htm, .rec, .tim, .zpo, .dic, .dicom, .jp2, .j2ki, .j2kr, .raw, .ima, .cr2, .crw, .thm, .wav, .dv, .r3d, .r3d_d3d, .log, .mvd2, .aisf, .aiix, .dat, .atsf, .tf2, .tf8, .btf, .pbm, .pgm, .ppm, .xdce, .xml, .xlog, .apl, .tnb, .mtb, .im, .mea, .res, .aim, .arf, .psd, .al3d, .gel, .am, .amiramesh, .grey, .hx, .labels, .img, .hdr, .sif, .afi, .exp, .h5, .1sc, .pic, .ims, .ch5, .vsi, .ets, .pnl, .htd, .c01, .dib, .cxd, .v, .eps, .epsi, .ps, .flex, .xlef, .fits, .fts, .dm2, .dm3, .dm4, .naf, .his, .ndpis, .txt, .i2i, .hed, .mod, .inr, .ipl, .ipm, .fff, .ics, .ids, .seq, .ips, .ipw, .frm, .par, .j2k, .jpf, .jpk, .jpx, .klb, .xv, .bip, .sxm, .fli, .lim, .msr, .lif, .lof, .lei, .l2d, .mnc, .stk, .nd, .scan, .vff, .mrw, .stp, .mng, .nii, .nrrd, .nhdr, .nd2, .nef, .obf, .omp2info, .oib, .oif, .pty, .lut, .oir, .sld, .spl, .liff, .top, .pcoraw, .pcx, .pict, .pct, .df3, .im3, .qptiff, .bin, .env, .spe, .afm, .sm2, .sm3, .spc, .set, .sdt, .spi, .xqd, .xqf, .db, .vws, .pst, .inf, .tfr, .ffr, .zfr, .zfp, .2fl, .tga, .pr3, .dti, .fdf, .hdf, .xys, .html, .acff, .wat, .bmp, .wpi, .czi, .lms, .lsm, .mdb, .zvi, .mrc, .st, .ali, .map, .mrcs, .jpeg, .gif, .ptif"
multiple
required
/>
Expand Down
19 changes: 13 additions & 6 deletions apps/loader/chunked_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ async function readFileChunks(file, token) {
async function handleUpload(selectedFiles) {
selectedFile = selectedFiles[0];
const filename = selectedFiles[0]['name'];
const token = await startUpload(filename);
const uploadMetadata = await startUpload(filename);
const token = uploadMetadata.upload_token;
$('#tokenRow').show(300);
const callback = continueUpload(token);
readFileChunks(selectedFile, token);
// parseFile(selectedFile, callback, 0, x=>(changeStatus("UPLOAD", "Finished Reading File")))
updateFormOnUpload(selectedFiles[0]['name'], token);
updateFormOnUpload(uploadMetadata.filename, token);

document.getElementById('fileUploadInput').colSpan = selectedFiles.length;
document.getElementById('controlButtons').colSpan = selectedFiles.length+1;
Expand All @@ -78,7 +79,7 @@ async function startUpload(filename) {
try {
const a = await token;
changeStatus('UPLOAD', 'Begun upload - Token:' + a['upload_token']);
return a['upload_token'];
return {upload_token: a['upload_token'], filename: a['filename']}; ;
} catch (e) {
changeStatus('UPLOAD | ERROR;', e);
}
Expand Down Expand Up @@ -130,6 +131,13 @@ function finishUpload() {
regReq.then((x)=>x.json()).then((a)=>{
changeStatus('UPLOAD | Finished', a, reset); reset = false;
console.log(a);
if (a.relpath) {
document.getElementById('filename'+0).value = a.relpath;
} else if (a.filename) {
document.getElementById('filename'+0).value = a.filename;
} else if (a.filepath) {
document.getElementById('filename'+0).value = a.filepath.slice(a.filepath.lastIndexOf('/')+1);
}
if (typeof a === 'object' && a.error) {
finishUploadSuccess = false;
$('#check_btn').hide();
Expand All @@ -143,6 +151,7 @@ function finishUpload() {
$('#check_btn').show();
$('#post_btn').hide();
}
validateForm(CheckBtn);
}
});
regReq.then((e)=> {
Expand All @@ -153,8 +162,6 @@ function finishUpload() {
changeStatus('UPLOAD | ERROR;', e);
reset = true;
console.log(e);
} else {
validateForm(CheckBtn);
}
},
);
Expand All @@ -163,7 +170,7 @@ function finishUpload() {

async function handleUrlUpload(url) {
$('#uploadLoading').css('display', 'block');
const token = await startUpload(url);
const token = (await startUpload(url)).upload_token;
await continueUrlUpload(token, url);
}

Expand Down
36 changes: 20 additions & 16 deletions apps/loader/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,20 @@ function changeStatus(step, text, reset=true) {
}
}
if (step == 'CHECK') {
// During check, thumbnail needs to be fetched & added to the table
// show post button
if (text['location']) {
// indicating successful check
checkSuccess = true;
if (finishUploadSuccess === true) {
$('#post_btn').show();
} else {
$('#post_btn').hide();
}
} else {
checkSuccess = false;
$('#post_btn').hide();
}
// fetch thumbnail and add to table as we can
// In this case, text[col[col.length - 1]] is the filename
fetch(thumbUrl + text[col[col.length - 1]], {credentials: 'same-origin'}).then(
(response) => response.json(), // if the response is a JSON object
Expand All @@ -69,18 +82,6 @@ function changeStatus(step, text, reset=true) {
const img = new Image();
img.src = x.slide;
tabCell.appendChild(img);
if (text['location']) {
// indicating successful check
checkSuccess = true;
if (finishUploadSuccess === true) {
$('#post_btn').show();
} else {
$('#post_btn').hide();
}
} else {
checkSuccess = false;
$('#post_btn').hide();
}
});
}
}
Expand Down Expand Up @@ -121,12 +122,15 @@ function handleDownload(id) {
store.getSlide(id)
.then((response) => {
if (response[0]) {
return response[0]['location'];
if (response[0]['filepath']) {
return response[0]['filepath'];
}
let location = response[0]['location'];
return location.substring(location.lastIndexOf('/')+1, location.length);
} else {
throw new Error('Slide not found');
}
}).then((location) => {
fileName = location.substring(location.lastIndexOf('/')+1, location.length);
}).then((fileName) => {
console.log(fileName);
return fileName;
}).then((fileName) =>{
Expand Down
14 changes: 8 additions & 6 deletions apps/model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,17 @@ function initCore() {

$CAMIC.store.getSlide($D.params.slideId).then((response) => {
if (response[0]) {
return response[0]['location'];
if (response[0]['filepath']) {
return response[0]['filepath'];
}
return location.substring(
location.lastIndexOf('/') + 1,
location.length,
);
} else {
throw new Error('Slide not found');
}
}).then((location) => {
fileName = location.substring(
location.lastIndexOf('/') + 1,
location.length,
);
}).then((fileName) => {
console.log(fileName);
});

Expand Down
56 changes: 29 additions & 27 deletions apps/redir.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
let params = getUrlVars();
let isPathdb = false;
document.addEventListener('DOMContentLoaded', async function() {
let params = getUrlVars();
let isPathdb = false;

if (params.hasOwnProperty('mode') && params.mode == 'pathdb') {
PathDbMods();
isPathdb = true;
}
if (params.hasOwnProperty('mode') && params.mode == 'pathdb') {
await PathDbMods();
isPathdb = true;
}

const store = new Store('../data/');
const store = new Store('../data/');

if (params.hasOwnProperty('slide')) {
store.findSlide(params.slide, params.specimen, params.study, 0, 0, params.collection).then((x)=>{
console.info(x);
if (x.length <=0) {
throw new Error('No Matches found');
}
if (isPathdb) {
// get the pathdb url
window.location = './viewer/viewer.html?slideId=' + x[0]['_id']['$oid'] + '&mode=pathdb';
} else {
// get the normal url
window.location = './viewer/viewer.html?slideId=' + x[0]['_id']['$oid'];
}
}).catch((e)=>{
console.error(e);
if (params.hasOwnProperty('slide')) {
store.findSlide(params.slide, params.specimen, params.study, 0, 0, params.collection).then((x)=>{
console.info(x);
if (x.length <=0) {
throw new Error('No Matches found');
}
if (isPathdb) {
// get the pathdb url
window.location = './viewer/viewer.html?slideId=' + x[0]['_id']['$oid'] + '&mode=pathdb';
} else {
// get the normal url
window.location = './viewer/viewer.html?slideId=' + x[0]['_id']['$oid'];
}
}).catch((e)=>{
console.error(e);
alert('ERROR!');
});
} else {
console.error('no slide passed?');
alert('ERROR!');
});
} else {
console.error('no slide passed?');
alert('ERROR!');
}
}
});
Loading

0 comments on commit c9e6e5f

Please sign in to comment.