From cec0deea2f30cd41f80c2aa119cf571ff01ac7c4 Mon Sep 17 00:00:00 2001 From: Birm Date: Tue, 10 Oct 2023 12:34:38 -0400 Subject: [PATCH] style changes to assistant --- .eslintignore | 1 + apps/viewer/init.js | 24 +- apps/viewer/uicallbacks.js | 10 +- components/ml-assistant/ml-assistant.js | 503 ++++----- components/ml-assistant/ml-tool.js | 1278 ++++++++++++----------- components/sidemenu/sidemenu.js | 2 +- 6 files changed, 913 insertions(+), 905 deletions(-) diff --git a/.eslintignore b/.eslintignore index 964c7135b..79ea1a305 100644 --- a/.eslintignore +++ b/.eslintignore @@ -12,3 +12,4 @@ apps/landing/jquery.min.js apps/landing/jquery.scrollex.min.js apps/segment/opencv.js common/bootstrap-tour-standalone/bootstrap-tour-standalone.min.js +apps/viewer/turf.min.js \ No newline at end of file diff --git a/apps/viewer/init.js b/apps/viewer/init.js index e6b689bef..fcfc83066 100644 --- a/apps/viewer/init.js +++ b/apps/viewer/init.js @@ -314,7 +314,7 @@ function initCore() { $UI.annotPopup.open(e.position); }); - $CAMIC.viewer.addHandler('annot-edit-save', function (e) { + $CAMIC.viewer.addHandler('annot-edit-save', function(e) { if (!e.data) { return; } @@ -327,16 +327,16 @@ function initCore() { const dataSize = dataCopy.geometries.features[0].properties.size; const {points, bound, size} = convertToNormalized(dataPoints, dataSize, $CAMIC.viewer); dataCopy.geometries.features[0].properties.size = size; - dataCopy.geometries.features[0].geometry.coordinates = [points] - dataCopy.geometries.features[0].bound.coordinates = [bound] + dataCopy.geometries.features[0].geometry.coordinates = [points]; + dataCopy.geometries.features[0].bound.coordinates = [bound]; } else { dataCopy.geometries = ImageFeaturesToVieweportFeatures( - $CAMIC.viewer, - dataCopy.geometries - ) + $CAMIC.viewer, + dataCopy.geometries, + ); } editAnnoCallback(id, slide, dataCopy); - }) + }); // create the message bar TODO for reading slide Info TODO $UI.slideInfos = new CaMessage({ @@ -845,7 +845,7 @@ async function initUIcomponents() { // $UI.AssistantViewer.enableBtn.checked = false; $UI.AssistantViewer.elt.style.display = 'none'; } - }) + }); // create UI and set data $UI.layersViewer = createLayerViewer( @@ -968,11 +968,11 @@ async function initUIcomponents() { // Handle event $CAMIC.viewer.addHandler('open-add-model', () => { uploadModel(); - }) + }); $CAMIC.viewer.addHandler('open-model-info', () => { showInfo(); - }) + }); $CAMIC.viewer.addHandler('ml-draw-setting-change', () => { if (!$CAMIC.viewer.canvasDrawInstance) return; @@ -981,7 +981,7 @@ async function initUIcomponents() { if (canvasDraw._draws_data_.length) { canvasDraw.__endNewFeature(true); } - }) + }); } function initModelModals() { @@ -1150,7 +1150,7 @@ async function uploadModel() { const value = element.split('/').pop(); if (value.slice(0, 3) == 'seg') { const title = element.split('/').pop().split('_')[1].slice(0, -3); - console.log() + console.log(); modelName.push(title); } }); diff --git a/apps/viewer/uicallbacks.js b/apps/viewer/uicallbacks.js index 60ba62a94..8f2015fd0 100644 --- a/apps/viewer/uicallbacks.js +++ b/apps/viewer/uicallbacks.js @@ -979,8 +979,8 @@ function annoCallback(data) { } function editAnnoCallback(id, slide, annotJson) { - // save edit annotation - $CAMIC.store + // save edit annotation + $CAMIC.store .updateMaskEdit(id, slide, annotJson) .then((data) => { // server error @@ -2092,10 +2092,10 @@ function savePresetLabel() { // many brush const values = features.reduce((p, f) => { return p.concat(getGrids( - f.geometry.coordinates[0], - f.properties.size, + f.geometry.coordinates[0], + f.properties.size, )); - },[]); + }, []); const set = new Set(); values.map((i) => i.toString()).forEach((v) => set.add(v)); const points = Array.from(set).map((d) => d.split(',')); diff --git a/components/ml-assistant/ml-assistant.js b/components/ml-assistant/ml-assistant.js index bdeb14d94..efcec975b 100644 --- a/components/ml-assistant/ml-assistant.js +++ b/components/ml-assistant/ml-assistant.js @@ -1,65 +1,65 @@ function Assistant(options) { - this.className = 'Assistant'; - this.setting = { - // id: doc element - // data: labels dataset - }; - this.view; - this.addBtn; - this.enableBtn; - this.modelSelectionBtn; - this.infoBtn; - - this.annotateModeZone; - this.settingZone; - - extend(this.setting, options); - this.elt = document.getElementById(this.setting.id); - if (!this.elt) { - console.error(`${this.className}: No Main Elements...`); - return; - } - - this.elt.classList.add('ml-assistant-container'); - - this.__refreshUI(); + this.className = 'Assistant'; + this.setting = { + // id: doc element + // data: labels dataset + }; + this.view; + this.addBtn; + this.enableBtn; + this.modelSelectionBtn; + this.infoBtn; + + this.annotateModeZone; + this.settingZone; + + extend(this.setting, options); + this.elt = document.getElementById(this.setting.id); + if (!this.elt) { + console.error(`${this.className}: No Main Elements...`); + return; + } + + this.elt.classList.add('ml-assistant-container'); + + this.__refreshUI(); } Assistant.prototype.__clearUI = function() { - empty(this.elt); - - this.view = null; - this.addBtn = null; - this.enableBtn = null; - this.modelSelectionBtn = null; - this.infoBtn = null; - this.modelList = null; - this.pixelScaleList = null; - - this.annotateModeZone = null; - this.settingZone = null; - this.processedImgContainer = null; - this.modelPredictImgContainer = null; + empty(this.elt); + + this.view = null; + this.addBtn = null; + this.enableBtn = null; + this.modelSelectionBtn = null; + this.infoBtn = null; + this.modelList = null; + this.pixelScaleList = null; + + this.annotateModeZone = null; + this.settingZone = null; + this.processedImgContainer = null; + this.modelPredictImgContainer = null; }; Assistant.prototype.__refreshUI = async function() { - this.__clearUI(); - // - this._viewer = this.setting.viewer; - this.view = document.createElement('div'); - this.view.classList.add('ml-assistant'); - const modelEnableId = randomId(); - const modelSelectionId = randomId(); - const pixelScalingId = randomId(); - const modelInfoId = randomId(); - const undoInfoId = randomId(); - - // Pixel Scaling ID - const noScaleId = randomId(); - const normId = randomId(); - const centerId = randomId(); - const stdId = randomId(); - - const viewHtml = ` + this.__clearUI(); + // + this._viewer = this.setting.viewer; + this.view = document.createElement('div'); + this.view.classList.add('ml-assistant'); + const modelEnableId = randomId(); + const modelSelectionId = randomId(); + const pixelScalingId = randomId(); + const modelInfoId = randomId(); + const undoInfoId = randomId(); + + // Pixel Scaling ID + const noScaleId = randomId(); + const normId = randomId(); + const centerId = randomId(); + const stdId = randomId(); + + const viewHtml = `