Skip to content

Commit

Permalink
1. add the new api to delete the slideInformativeness data
Browse files Browse the repository at this point in the history
2. get the current collection data in viewer
3. delete the slideInformativeness data when updating evaluation form
  • Loading branch information
nanli-emory committed Oct 5, 2023
1 parent 0299fee commit 5924395
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
1 change: 0 additions & 1 deletion apps/port/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ window.addEventListener('load', async ()=> {

function dataExport() {
const nodes = $DTable.rows({search: 'applied'}).nodes().to$();
console.log(nodes);
const cids = [...nodes].reduce((rs, node)=>{
if (node.querySelector('input[type=checkbox]:checked')) {
const data = $D.collectionData.find((c)=>c.id==node.id);
Expand Down
10 changes: 7 additions & 3 deletions apps/viewer/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function initialize() {
// setting core functionalities
function initCore() {
// start initial

// create the message queue
$UI.message = new MessageQueue({position: 'bottom-left'});

Expand Down Expand Up @@ -357,6 +356,11 @@ async function initUIcomponents() {
$D.user = user[0];
}

// get current collection id
if($D.params.data&&$D.params.data.token_id) {

Check failure on line 360 in apps/viewer/init.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Expected space(s) after "if"

Check failure on line 360 in apps/viewer/init.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Expected space(s) after "if"
const colData = await $CAMIC.store.getCollection({text: $D.params.data.token_id});
if(Array.isArray(colData)&&colData.length > 0) $D.colData = colData[0]

Check failure on line 362 in apps/viewer/init.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Expected space(s) after "if"

Check failure on line 362 in apps/viewer/init.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Missing semicolon

Check failure on line 362 in apps/viewer/init.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Expected space(s) after "if"

Check failure on line 362 in apps/viewer/init.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Missing semicolon
}
/* loading configurations */
$D.configurations = await $CAMIC.store.getConfigByName();
/* create UI components */
Expand All @@ -378,6 +382,7 @@ async function initUIcomponents() {
// get collection list
$D.collections = await $CAMIC.store.getAllCollection();


// get senior pathologist list
$D.seniors = await $CAMIC.store.getSeniorUsers();
$UI.caseReassignmentModal.setFooterHTML(`<button class='btn btn-default btn-xs' onclick='reassignCaseClickhandler()' disabled>Reassign</button>`);
Expand Down Expand Up @@ -476,7 +481,7 @@ async function initUIcomponents() {
'updater': $D.user.key,
};
try {
const rs = await $CAMIC.store.updateEvaluation(query, evalData);
const rs = await $CAMIC.store.updateEvaluation(query, evalData);

Check failure on line 484 in apps/viewer/init.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Trailing spaces not allowed

Check failure on line 484 in apps/viewer/init.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Trailing spaces not allowed
if (rs.error) {
$UI.message.addError(rs.text);
} else if (rs && rs.result && rs.result.ok ) {
Expand All @@ -490,7 +495,6 @@ async function initUIcomponents() {
}
}
}
// const formOpt = evaluationConfig.configuration;
const formOpt = {
data: {
slide_quality: null,
Expand Down
22 changes: 10 additions & 12 deletions apps/viewer/uicallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1886,30 +1886,28 @@ async function saveEvaluation(e) {
$D.isDraftEvalData = false;
const evalMessage = document.getElementById('eval_message');
evalMessage.textContent = null;
// change collection status

Check failure on line 1889 in apps/viewer/uicallbacks.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Trailing spaces not allowed

Check failure on line 1889 in apps/viewer/uicallbacks.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Trailing spaces not allowed
try {
// change collection status
const rs = await $CAMIC.store.setCollectionTaskStatusBySlideId($D.user.key, $D.params.slideId, false);
if (rs&&rs.ok) {
console.log(`Eval setCollectionTaskStatusBySlideId(${$D.user.key}, ${$D.params.slideId},false) succeeded`);
} else {
// db update error
console.error(`Eval setCollectionTaskStatusBySlideId update failed`);
}
// // clean the relative informativeness
if ($D.colData&&$D.colData._id&&$D.colData._id.$oid) {
console.log($D.colData._id.$oid)

Check failure on line 1901 in apps/viewer/uicallbacks.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Missing semicolon

Check failure on line 1901 in apps/viewer/uicallbacks.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Missing semicolon
const data = await $CAMIC.store.deleteSlidesInformativeness(
$D.colData._id.$oid,
$D.user.key

Check failure on line 1904 in apps/viewer/uicallbacks.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Missing trailing comma

Check failure on line 1904 in apps/viewer/uicallbacks.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Missing trailing comma
);
}

Check failure on line 1906 in apps/viewer/uicallbacks.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Trailing spaces not allowed

Check failure on line 1906 in apps/viewer/uicallbacks.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Trailing spaces not allowed
} catch (error) {
// server error
console.error(`Eval setCollectionTaskStatusBySlideId error`);
}
// change
if (evaluation.informativeness==0) {
const collection = $D.collections.find((c)=>c.text==$D.params.crumb.split('/')[1]);
if (collection&&collection._id&&collection._id.$oid) {
const data = await $CAMIC.store.removeRankSlidesInformativeness(
collection._id.$oid,
$D.user.key,
$D.params.slideId,
);
}
}
} else {
$UI.message.addWarning(`Something Happened When Saving Evaluation!`);
}
Expand Down
20 changes: 20 additions & 0 deletions core/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,26 @@ class Store {
}).then(this.errorHandler);
}

/**
* delete slidesInformativeness
* @param {object} cid - the collection id object id
* @param {object} creator - the creator id
* @return {promise} - promise which resolves with response
**/
deleteSlidesInformativeness(cid, creator) {
const suffix = 'SlideInformativeness/delete';
const url = this.base + suffix;
const query = {
'cid': cid,
'creator': creator

Check failure on line 1506 in core/Store.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Missing trailing comma

Check failure on line 1506 in core/Store.js

View workflow job for this annotation

GitHub Actions / build (15.x)

Missing trailing comma
};
return fetch(url + '?' + objToParamStr(query), {
method: 'DELETE',
credentials: 'include',
mode: 'cors',
}).then(this.errorHandler);
}

removeRankSlidesInformativeness(cid, creator=null, sid) {
//
if (!cid || !sid) {
Expand Down

0 comments on commit 5924395

Please sign in to comment.