.
This commit is contained in:
@@ -150,7 +150,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
readFileAndProcess();
|
//readFileAndProcess();
|
||||||
|
readFileAndProcess2();
|
||||||
|
|
||||||
// Check if we have selected a examination type
|
// Check if we have selected a examination type
|
||||||
if (!$("#id_examination_to option").length) {
|
if (!$("#id_examination_to option").length) {
|
||||||
@@ -450,6 +451,89 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function readFileAndProcess2(callback) {
|
||||||
|
//$("#single-dicom-viewer").empty()
|
||||||
|
//images = []
|
||||||
|
//Function that returns a promise to read the file
|
||||||
|
const reader = (file) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const fileReader = new FileReader();
|
||||||
|
fileReader.onload = () => resolve(fileReader);
|
||||||
|
fileReader.readAsDataURL(file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add file to the process list
|
||||||
|
active_file_inputs.add(el)
|
||||||
|
const readFile = (file, el) => {
|
||||||
|
reader(file).then(reader => {
|
||||||
|
console.log("12345", reader)
|
||||||
|
$(el).parent().parent().find(".temp-thumb").remove();
|
||||||
|
|
||||||
|
if (reader.result.startsWith("data:application/octet-stream;base64")) {
|
||||||
|
const element = $(`<div class='temp-thumb' src=${reader.result}></div>`).get(0)
|
||||||
|
$(el).parent().parent().prepend(element);
|
||||||
|
const imageId = cornerstoneWADOImageLoader.wadouri.fileManager.add(
|
||||||
|
file
|
||||||
|
);
|
||||||
|
cornerstone.enable(element);
|
||||||
|
cornerstone.loadAndCacheImage(imageId).then(function (image) {
|
||||||
|
cornerstone.displayImage(element, image);
|
||||||
|
cornerstone.resize(element)
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var image = new Image();
|
||||||
|
image.title = file.name;
|
||||||
|
image.src = reader.result;
|
||||||
|
image.className = "temp-thumb";
|
||||||
|
$(el).parent().parent().prepend(image);
|
||||||
|
//images.push(reader.result);
|
||||||
|
}
|
||||||
|
|
||||||
|
active_file_inputs.delete(el)
|
||||||
|
console.log("active", active_file_inputs)
|
||||||
|
// Only load once all queued files have been processed
|
||||||
|
if (active_file_inputs.size < 1) {
|
||||||
|
loadViewer();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
file_set = $("#image_form_set input[type=file]");
|
||||||
|
|
||||||
|
file_set.each(async (n, el) => {
|
||||||
|
if (el.files.length > 0) {
|
||||||
|
filename = el.files[0].name;
|
||||||
|
// Probably no need to await here anymore
|
||||||
|
//await readFile(el.files[0], el);
|
||||||
|
|
||||||
|
let url = URL.createObjectURL(el.files[0])
|
||||||
|
|
||||||
|
$(el).parent().parent().find(".temp-thumb").remove();
|
||||||
|
|
||||||
|
const element = $(`<div class='temp-thumb' src=${reader.result}></div>`).get(0)
|
||||||
|
$(el).parent().parent().prepend(element);
|
||||||
|
const imageId = `wadouri:${a}`;
|
||||||
|
cornerstone.enable(element);
|
||||||
|
cornerstone.loadAndCacheImage(imageId).then(function (image) {
|
||||||
|
cornerstone.displayImage(element, image);
|
||||||
|
cornerstone.resize(element)
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
active_file_inputs.delete(el)
|
||||||
|
console.log("active", active_file_inputs)
|
||||||
|
// Only load once all queued files have been processed
|
||||||
|
if (active_file_inputs.size < 1) {
|
||||||
|
loadViewer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function readFileAndProcess(callback) {
|
async function readFileAndProcess(callback) {
|
||||||
//$("#single-dicom-viewer").empty()
|
//$("#single-dicom-viewer").empty()
|
||||||
//images = []
|
//images = []
|
||||||
@@ -491,9 +575,6 @@
|
|||||||
//images.push(reader.result);
|
//images.push(reader.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
active_file_inputs.delete(el)
|
active_file_inputs.delete(el)
|
||||||
console.log("active", active_file_inputs)
|
console.log("active", active_file_inputs)
|
||||||
// Only load once all queued files have been processed
|
// Only load once all queued files have been processed
|
||||||
@@ -503,12 +584,8 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
file_set = $("#image_form_set input[type=file]");
|
file_set = $("#image_form_set input[type=file]");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
file_set.each(async (n, el) => {
|
file_set.each(async (n, el) => {
|
||||||
if (el.files.length > 0) {
|
if (el.files.length > 0) {
|
||||||
filename = el.files[0].name;
|
filename = el.files[0].name;
|
||||||
@@ -516,10 +593,6 @@
|
|||||||
await readFile(el.files[0], el);
|
await readFile(el.files[0], el);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadViewer() {
|
function loadViewer() {
|
||||||
|
|||||||
Reference in New Issue
Block a user