Skip to content

Commit 420475f

Browse files
authored
Merge pull request #190 from camicroscope/release
3.4.0
2 parents 1b12262 + b4d3293 commit 420475f

33 files changed

Lines changed: 1913 additions & 558 deletions

apps/heatmap/init.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,30 +69,29 @@ function initCore(){
6969
}else{
7070
$D.params.data = e;
7171
// loading heatmap data
72-
$D.heatMapData = await $CAMIC.store.getHeatmap($D.params.data.name,$D.params.execId).then(d=> d[0]);
73-
const subject = $D.heatMapData.provenance.image.subject_id;
74-
const caseid = $D.heatMapData.provenance.image.case_id;
72+
$D.heatMapData = await $CAMIC.store.getHeatmap($D.params.slideId,$D.params.execId).then(d=> d[0]);
73+
const slide = $D.params.slideId
7574
const exec = $D.heatMapData.provenance.analysis.execution_id;
76-
75+
7776
if(ImgloaderMode!='imgbox'){
7877
// query from DB
79-
const editData = await $CAMIC.store.findHeatmapEdit(getUserId(), subject, caseid, exec).then(d=>d[0]);
80-
//const editData = await $CAMIC.store.findHeatmapEdit('test', subject, caseid, exec).then(d=>d[0]);
78+
const editData = await $CAMIC.store.findHeatmapEdit(getUserId(), slide, exec).then(d=>d[0]);
79+
//const editData = await $CAMIC.store.findHeatmapEdit('test', slide, exec).then(d=>d[0]);
8180
$D.editedDataClusters = new EditDataCluster();
8281
if(editData&&Array.isArray(editData.data)&&editData.data.length > 0){
8382
setEditedDataClusters(editData.data);
8483
}
8584
}else{
8685
$D.editedDataClusters = new EditDataCluster();
8786
}
88-
87+
8988

9089

9190
if(!$D.heatMapData){
9291
redirect($D.pages.table,`No Heatmap's Data Found. Redirecting To Table.`);
9392
}
9493

95-
94+
9695
$UI.slideInfos = new CaMessage({
9796
/* opts that need to think of*/
9897
id:'cames',
@@ -110,7 +109,7 @@ function initCore(){
110109
$CAMIC.viewer.addHandler('open',function(){
111110
Loading.open(document.body, `Loading Data ...`);
112111
// load the heatmap data
113-
112+
114113
var checkImagingHelperIsReady = setInterval(function () {
115114
if($CAMIC.viewer.imagingHelper&& $CAMIC.viewer.imagingHelper._haveImage && $D.heatMapData && $D.editedDataClusters && $UI.editedListSideMenu) {
116115
clearInterval(checkImagingHelperIsReady);
@@ -153,39 +152,39 @@ function initCore(){
153152

154153

155154
// create heatmap editor
156-
155+
157156
$UI.heatmapEditorPanel = new HeatmapEditorPanel({
158157
fields:$D.heatMapData.provenance.analysis.fields,
159-
// editedDate:$D.
160-
onFieldChange: editorPenChange,
158+
// editedDate:$D.
159+
onFieldChange: editorPenChange,
161160
onReset: function(){
162161
if(confirm('Do You Want To Clear Edited Data?')){
163-
$CAMIC.viewer.canvasDrawInstance.clear();
162+
$CAMIC.viewer.canvasDrawInstance.clear();
164163
}
165164
}, // clearEditData
166165
onSave: saveEditData
167166
});
168167
$UI.editorSideMenu.addContent($UI.heatmapEditorPanel.elt);
169168

170-
// create edited data list
169+
// create edited data list
171170
$UI.heatmapEditedDataPanel = new HeatmapEditedDataPanel({
172171
// data:$D.heatMapData.editedClusters,
173172
data:$D.editedDataClusters,
174-
// editedDate:$D.
173+
// editedDate:$D.
175174
onDBClick: locateEditData,
176175
onDelete: onDeleteEditData
177176
});
178177

179178
$UI.editedListSideMenu.addContent($UI.heatmapEditedDataPanel.elt);
180-
181-
179+
180+
182181
// TODO create save botton if user is admin
183182
if(ImgloaderMode!='imgbox'){
184183
const btnDiv = createThreshold();
185184
$UI.settingsSideMenu.addContent(btnDiv);
186185
} else{
187186
const btnDiv = createExportEditData();
188-
$UI.editedListSideMenu.addContent(btnDiv);
187+
$UI.editedListSideMenu.addContent(btnDiv);
189188
}
190189

191190

@@ -234,7 +233,7 @@ function initUIcomponents(){
234233
title:'editor',
235234
type:'check',// btn/check/dropdown
236235
value:'editor',
237-
callback:toggleHeatMapEditor
236+
callback:toggleHeatMapEditor
238237
},
239238
// home
240239
// {
@@ -495,7 +494,7 @@ function createThreshold(){
495494
const div1 = document.createElement('div');
496495
div1.classList.add('btn-panel');
497496

498-
497+
499498
const btn = document.createElement('button');
500499
btn.classList.add('action');
501500
btn.style.float = 'right';
@@ -512,7 +511,7 @@ function createExportEditData(){
512511
const div1 = document.createElement('div');
513512
div1.classList.add('btn-panel');
514513

515-
514+
516515
const btn = document.createElement('button');
517516
btn.classList.add('action');
518517
btn.style.float = 'right';

apps/heatmap/uicallbacks.js

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function closeSecondaryViewer(){
148148
minor.classList.add('none');
149149
minor.classList.remove('right');
150150
$CAMIC.viewer.controls.bottomright.style.display = '';
151-
151+
152152
const li = $UI.toolbar.getSubTool('sbsviewer');
153153
li.querySelector('input[type="checkbox"]').checked = false;
154154
Loading.close();
@@ -192,7 +192,7 @@ function heatmapSettingChanged(data){
192192
}else{
193193
$CAMIC.viewer.heatmap.changeMode(data.mode);
194194
}
195-
195+
196196
}
197197

198198
function heatmapOpacityChanaged(data){
@@ -305,15 +305,15 @@ function toggleHeatMapDataList(e){
305305
break;
306306
// default:
307307
// console.warn('Editor error');
308-
// break;
308+
// break;
309309
}
310310
}
311311

312312
function heatMapEditedListOn(){
313313
$UI.editedListSideMenu.open();
314314
const li = $UI.toolbar.getSubTool('editeddate')
315315
li.querySelector('input[type=checkbox]').checked = true;
316-
toggleHeatMapSettings({checked:false,isOpen:false});
316+
toggleHeatMapSettings({checked:false,isOpen:false});
317317
heatmapEditorOff();
318318
measurementOff();
319319
magnifierOff();
@@ -322,7 +322,7 @@ function heatMapEditedListOn(){
322322
function heatMapEditedListOff(){
323323
$UI.editedListSideMenu.close();
324324
const li = $UI.toolbar.getSubTool('editeddate')
325-
li.querySelector('input[type=checkbox]').checked = false;
325+
li.querySelector('input[type=checkbox]').checked = false;
326326

327327
}
328328

@@ -336,7 +336,7 @@ function toggleHeatMapEditor(e){
336336
break;
337337
// default:
338338
// console.warn('Editor error');
339-
// break;
339+
// break;
340340
}
341341
}
342342

@@ -349,7 +349,7 @@ function heatMapEditorOn(){
349349
measurementOff();
350350
magnifierOff();
351351
if(!$CAMIC.viewer.canvasDrawInstance) return;
352-
352+
353353
const data = $UI.heatmapEditorPanel.getCurrentOperation();
354354
if(data){
355355
$CAMIC.viewer.canvasDrawInstance.style.color = data[3];
@@ -362,7 +362,7 @@ function heatmapEditorOff(){
362362
const li = $UI.toolbar.getSubTool('editor');
363363
li.querySelector('input[type=checkbox]').checked = false;
364364
$CAMIC.viewer.canvasDrawInstance.drawOff();
365-
365+
366366
}
367367

368368
/*
@@ -373,19 +373,20 @@ function heatmapEditorOff(){
373373
async function onUpdateHeatmapFields(){
374374
if(!confirm('Do You Want To Update Threshold?')) return;
375375
Loading.open(document.body,'Saving Threshold ... ');
376-
376+
377377
const setting = {
378378
mode:$CAMIC.viewer.heatmap.mode
379379
};
380-
380+
381381
if($CAMIC.viewer.heatmap.mode=='gradient') setting.field = $CAMIC.viewer.heatmap._currentField.name
382-
382+
383383
const fields = $D.heatMapData.provenance.analysis.fields;
384-
const subject = $D.heatMapData.provenance.image.subject_id;
385-
const caseid = $D.heatMapData.provenance.image.case_id;
386-
const exec = $D.heatMapData.provenance.analysis.execution_id;
387-
const rs = await $CAMIC.store.updateHeatmapFields(subject, caseid, exec, JSON.stringify(fields), JSON.stringify(setting));
388-
384+
const specimen = $D.heatMapData.provenance.image.specimen;
385+
const slide = $D.heatMapData.provenance.image.slide;
386+
const study = $D.heatMapData.provenance.image.study;
387+
const exec = $D.heatMapData.provenance.analysis.execution_id;
388+
const rs = await $CAMIC.store.updateHeatmapFields(slide, exec, JSON.stringify(fields), JSON.stringify(setting));
389+
389390
//const rs = await $CAMIC.store.updateHeatmap
390391
Loading.close();
391392
};
@@ -406,7 +407,7 @@ async function onExportEditData(){
406407
data:editData
407408
}
408409
// let data = JSON.parse(window.localStorage.getItem("mark"))
409-
410+
410411
// let text = ""
411412
// if (data) {
412413
// text = JSON.stringify(data.filter(x => {
@@ -433,17 +434,18 @@ function editorPenChange(data){
433434
}
434435

435436
async function saveEditData(){
436-
437+
437438
if(!$CAMIC.viewer.canvasDrawInstance._draws_data_.length){
438439
alert('No Data Edited!');
439440
return;
440441
}
441442
Loading.open(document.body,`Saving Edit Data ...`);
442443
// does data exist
443-
// user, subject, case, execution, data
444+
// user, specimen, case, execution, data
444445
const user = getUserId();
445-
const subject = $D.heatMapData.provenance.image.subject_id;
446-
const caseid = $D.heatMapData.provenance.image.case_id;
446+
const specimen = $D.heatMapData.provenance.image.specimen;
447+
const slide = $D.heatMapData.provenance.image.slide;
448+
const study = $D.heatMapData.provenance.image.study;
447449
const exec = $D.heatMapData.provenance.analysis.execution_id;
448450

449451
// get draw lines info
@@ -466,14 +468,14 @@ async function saveEditData(){
466468
// add new one or update old one
467469
const now = getDateInString();
468470
const editData = $D.editedDataClusters.toJSON()
469-
471+
470472

471473
// delete old one
472474
let create_date = now;
473475

474476
if(ImgloaderMode!='imgbox'){
475477
// find editor data
476-
const data = await $CAMIC.store.findHeatmapEdit(user, subject, caseid, exec);
478+
const data = await $CAMIC.store.findHeatmapEdit(user, slide, exec);
477479
// error
478480
if(!Array.isArray(data)&&data.hasError&&data.hasError==true){
479481
$UI.message.addError(data.message);
@@ -483,7 +485,7 @@ async function saveEditData(){
483485

484486
if(data.length!==0){
485487
create_date = data[0].create_date;
486-
const del = await $CAMIC.store.deleteHeatmapEdit(user, subject, caseid, exec);
488+
const del = await $CAMIC.store.deleteHeatmapEdit(user, slide, exec);
487489
// error
488490
if(del.hasError&&del.hasError==true){
489491
$UI.message.addError(del.message);
@@ -541,10 +543,10 @@ function getDateInString(){
541543
function locateEditData(data){
542544
const cluster = data.cluster;
543545
const index = data.index;
544-
546+
545547
const rect = getViewRect(
546548
data.cluster.editDataArray[index],
547-
$D.heatMapData.provenance.analysis.size,
549+
$D.heatMapData.provenance.analysis.size,
548550
$CAMIC.viewer
549551
);
550552

@@ -564,16 +566,17 @@ async function onDeleteEditData(data){
564566

565567
// delete data
566568
const user = getUserId();
567-
const subject = $D.heatMapData.provenance.image.subject_id;
568-
const caseid = $D.heatMapData.provenance.image.case_id;
569-
const exec = $D.heatMapData.provenance.analysis.execution_id;
570-
569+
const specimen = $D.heatMapData.provenance.image.specimen;
570+
const slide = $D.heatMapData.provenance.image.slide;
571+
const study = $D.heatMapData.provenance.image.study;
572+
const exec = $D.heatMapData.provenance.analysis.execution_id;
573+
571574
let rs = null;
572575
if(ImgloaderMode!='imgbox'){
573576
if($D.editedDataClusters.isEmpty()){
574-
rs = await $CAMIC.store.deleteHeatmapEdit(user, subject, caseid, exec);
577+
rs = await $CAMIC.store.deleteHeatmapEdit(user, slide, exec);
575578
}else{
576-
rs = await $CAMIC.store.updateHeatmapEdit(user, subject, caseid, exec, JSON.stringify($D.editedDataClusters.toJSON()));
579+
rs = await $CAMIC.store.updateHeatmapEdit(user, slide, exec, JSON.stringify($D.editedDataClusters.toJSON()));
577580
}
578581
// error
579582
if(rs.hasError&&rs.hasError==true){
@@ -585,17 +588,17 @@ async function onDeleteEditData(data){
585588
}
586589
}
587590
Loading.close();
588-
591+
589592

590593

591594
// refresh UI
592595
$UI.heatmapEditedDataPanel.__refresh();
593596
$CAMIC.viewer.heatmap.updateView(0);
594597

595598
// close pen panel
596-
599+
597600
// open list panel
598-
601+
599602
}
600603

601604
function findPenInfoByColor(color,info){
@@ -612,7 +615,7 @@ function getViewRect(points , size, viewer){ // points in normalized, size in no
612615

613616

614617
return viewport.imageToViewportRectangle(min[0],min[1],max[0]-min[0], max[1]-min[1]);
615-
618+
616619
}
617620

618621
function getBounds(points){ // return x,y,w,h
@@ -633,4 +636,3 @@ function getBounds(points){ // return x,y,w,h
633636
max:max
634637
};
635638
}
636-

0 commit comments

Comments
 (0)