@@ -53,9 +53,9 @@ import {
53
53
import { clearBioLucidaCredentials } from "../../stores/slices/authSlice";
54
54
import { setMicroFilePlusInstalledStatus } from "../../stores/slices/backgroundServicesSlice";
55
55
import {
56
- addOrUpdateProcessStatusRow ,
57
- removeProcessStatusRows ,
58
- } from "../../stores/slices/tableDataSlice ";
56
+ setProgressElementData ,
57
+ removeProgressElementData ,
58
+ } from "../../stores/slices/progressElementSlice.js ";
59
59
60
60
import "bootstrap-select";
61
61
// import DragSort from '@yaireo/dragsort'
@@ -15858,11 +15858,10 @@ const hideDatasetMetadataGenerationTableRows = (destination) => {
15858
15858
}
15859
15859
};
15860
15860
const convertMicroscopyImagesViaMfPlus = async () => {
15861
- addOrUpdateProcessStatusRow(
15862
- "guided-div-microscopy-image-conversion-status-table",
15863
- "microfileplus-installation-status",
15861
+ setProgressElementData(
15862
+ "guided-progress-display-microscopy-image-conversion",
15864
15863
"Making sure MicroFile+ is installed",
15865
- "loading"
15864
+ 0
15866
15865
);
15867
15866
// wait for 10000 seconds
15868
15867
await new Promise((resolve) => setTimeout(resolve, 5000));
@@ -15875,55 +15874,85 @@ const convertMicroscopyImagesViaMfPlus = async () => {
15875
15874
`SODA was unable to detect MicroFile+ on your machine. Please install MicroFile+ and try again.`
15876
15875
);
15877
15876
}
15878
- addOrUpdateProcessStatusRow(
15879
- "guided-div-microscopy-image-conversion-status-table",
15880
- "microfileplus-installation-status",
15881
- "SODA detected MicroFile+ installation!",
15882
- "success"
15883
- );
15877
+
15884
15878
console.log("Converting microscopy images via MicroFilePlus");
15885
15879
const microscopyImagesToConvert = window.sodaJSONObj["confirmed-microscopy-images"];
15886
15880
const microscopyImagesToConvertCount = microscopyImagesToConvert.length;
15887
15881
15888
15882
let imageConvertedCount = 1;
15889
15883
for await (const image of microscopyImagesToConvert) {
15890
15884
console.log(`Converting image: ${image.filePath}`);
15891
- addOrUpdateProcessStatusRow(
15892
- "guided-div-microscopy-image-conversion-status-table",
15893
- `microscopy-image-conversion-progress-count`,
15894
- `Converting and adding metadata to images`,
15895
- `${imageConvertedCount}/${microscopyImagesToConvert.length}`
15885
+
15886
+ const progressPercentage = Math.round(
15887
+ (imageConvertedCount / microscopyImagesToConvertCount) * 100
15896
15888
);
15897
- addOrUpdateProcessStatusRow(
15898
- "guided-div-microscopy-image-conversion-status-table",
15899
- `${ image.filePath} -conversion-status` ,
15889
+
15890
+ setProgressElementData(
15891
+ "guided-progress-display-microscopy- image-conversion" ,
15900
15892
`Converting image: ${image.filePath}`,
15901
- "loading"
15893
+ progressPercentage
15902
15894
);
15903
- // wait for 1 second
15895
+ // wait for 5 second
15904
15896
await new Promise((resolve) => setTimeout(resolve, 1000));
15905
- addOrUpdateProcessStatusRow(
15906
- "guided-div-microscopy-image-conversion-status-table",
15907
- `${image.filePath}-conversion-status`,
15908
- `Successfully converted image: ${image.filePath}`,
15909
- "success"
15910
- );
15897
+
15911
15898
imageConvertedCount++;
15912
15899
}
15913
15900
15914
- addOrUpdateProcessStatusRow (
15915
- "guided-div- microscopy-image-conversion-status-table ",
15916
- "Converting microscopy images with MicroFile+ ",
15917
- `0/${microscopyImagesToConvertCount}`
15901
+ setProgressElementData (
15902
+ "guided-progress-display- microscopy-image-conversion",
15903
+ "Microscopy images successfully converted ",
15904
+ 100
15918
15905
);
15919
- // wait for 10000 seconds
15920
- await new Promise((resolve) => setTimeout(resolve, 10000000));
15921
15906
};
15922
15907
15923
15908
const uploadMicroscopyImagesToBioLucida = async () => {
15909
+ setProgressElementData(
15910
+ "guided-progress-display-microscopy-image-conversion",
15911
+ "Making sure MicroFile+ is installed",
15912
+ 0
15913
+ );
15914
+ // wait for 10000 seconds
15915
+ await new Promise((resolve) => setTimeout(resolve, 5000));
15916
+ // Ensure that MicroFile+ is installed on the user's machine
15917
+ const req = await client.get("/image_processing/is_microfileplus_installed");
15918
+ const { status: microFilePlusIsInstalled } = req.data;
15919
+
15920
+ if (!microFilePlusIsInstalled) {
15921
+ throw new Error(
15922
+ `SODA was unable to detect MicroFile+ on your machine. Please install MicroFile+ and try again.`
15923
+ );
15924
+ }
15925
+
15924
15926
console.log("Converting microscopy images via MicroFilePlus");
15925
- // wait for 10 seconds
15926
- await new Promise((resolve) => setTimeout(resolve, 10000));
15927
+ const microscopyImagesToConvert = window.sodaJSONObj["confirmed-microscopy-images"];
15928
+ const microscopyImagesToConvertCount = microscopyImagesToConvert.length;
15929
+
15930
+ let imageConvertedCount = 1;
15931
+ for await (const image of microscopyImagesToConvert) {
15932
+ console.log(`Converting image: ${image.filePath}`);
15933
+
15934
+ const progressPercentage = Math.round(
15935
+ (imageConvertedCount / microscopyImagesToConvertCount) * 100
15936
+ );
15937
+
15938
+ setProgressElementData(
15939
+ "guided-progress-display-microscopy-image-conversion",
15940
+ `Converting image: ${image.filePath}`,
15941
+ progressPercentage
15942
+ );
15943
+ // wait for 5 second
15944
+ await new Promise((resolve) => setTimeout(resolve, 1000));
15945
+
15946
+ imageConvertedCount++;
15947
+ }
15948
+
15949
+ setProgressElementData(
15950
+ "guided-progress-display-microscopy-image-conversion",
15951
+ "Microscopy images successfully converted",
15952
+ 100
15953
+ );
15954
+ // wait for 10000 seconds
15955
+ await new Promise((resolve) => setTimeout(resolve, 10000000));
15927
15956
};
15928
15957
15929
15958
const guidedPennsieveDatasetUpload = async () => {
@@ -15949,12 +15978,12 @@ const guidedPennsieveDatasetUpload = async () => {
15949
15978
}
15950
15979
15951
15980
// Display the MicroFilePlus conversion status table
15952
- window.unHideAndSmoothScrollToElement("guided-div- microscopy-image-conversion-status-table ");
15981
+ window.unHideAndSmoothScrollToElement("guided-progress-display- microscopy-image-conversion");
15953
15982
15954
15983
await convertMicroscopyImagesViaMfPlus();
15955
15984
15956
15985
//Display the BioLucida Image upload table
15957
- window.unHideAndSmoothScrollToElement("guided-div- biolucida-image-upload-status-table ");
15986
+ window.unHideAndSmoothScrollToElement("guided-progress-display- biolucida-image-upload");
15958
15987
await uploadMicroscopyImagesToBioLucida();
15959
15988
15960
15989
// sleep for 20 seconds
0 commit comments