From b21c6d80e268b10515f700a461fc9d4373097910 Mon Sep 17 00:00:00 2001 From: Ross Date: Thu, 11 Nov 2021 23:15:41 +0000 Subject: [PATCH] . --- rapids/templates/rapids/rapid_form.html | 99 ++++++++++++++----------- 1 file changed, 57 insertions(+), 42 deletions(-) diff --git a/rapids/templates/rapids/rapid_form.html b/rapids/templates/rapids/rapid_form.html index 41fa2760..dc25f527 100755 --- a/rapids/templates/rapids/rapid_form.html +++ b/rapids/templates/rapids/rapid_form.html @@ -134,21 +134,6 @@ el = evt.target; - $(el).find(".temp-thumb").remove(); - if (el.files.length > 0) { - extra_class = " image-ident-loading"; - if ($(el).hasClass("image-ident-warning")) { - extra_class = " image-ident-warning"; - } else if ($(el).hasClass("image-ident-ok")) { - extra_class = " image-ident-ok"; - } - n = el.id.split("-")[1]; - $(`#drop-filenames span[data-input-id='${el.id}']`).remove(); - $("#drop-filenames").append( - `${n}: ${el.files[0].name}` - ) - } - //readFileAndProcess(); readFileAndProcess2(el); @@ -452,11 +437,11 @@ } async function blobToBase64(blob) { - return new Promise((resolve, _) => { - const reader = new FileReader(); - reader.onloadend = () => resolve(reader.result); - reader.readAsDataURL(blob); - }); + return new Promise((resolve, _) => { + const reader = new FileReader(); + reader.onloadend = () => resolve(reader.result); + reader.readAsDataURL(blob); + }); } async function readFileAndProcess2(el) { @@ -465,26 +450,44 @@ //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); + if (el.files.length > 0) { + filename = el.files[0].name; + // Probably no need to await here anymore + //await readFile(el.files[0], el); - console.log(el.files[0]) - $(el).parent().parent().find(".temp-thumb").remove(); - let imageId; - if (el.files[0].type.startsWith("image")) { - base = await blobToBase64(el.files[0]); - imageId = "base64://" + base.split(",")[1]; - imageId2 = base; - } else { - let url = URL.createObjectURL(el.files[0]) - imageId = `wadouri:${url}`; - imageId2 = imageId - } + console.log(el.files[0]) + + $(el).parent().parent().find(".temp-thumb").remove(); + + let url = URL.createObjectURL(el.files[0]) + + extra_class = " image-ident-loading"; + if ($(el).hasClass("image-ident-warning")) { + extra_class = " image-ident-warning"; + } else if ($(el).hasClass("image-ident-ok")) { + extra_class = " image-ident-ok"; + } + n = el.id.split("-")[1]; + $(`#drop-filenames span[data-input-id='${el.id}']`).remove(); + + let imageId; + if (el.files[0].type.startsWith("image")) { + base = await blobToBase64(el.files[0]); + imageId = "base64://" + base.split(",")[1]; + imageId2 = base; + const element = $(``).get(0) + $(el).parent().parent().prepend(element); + + $("#drop-filenames").append( + `${n}: ${el.files[0].name}
` + ) + } else { + imageId = `wadouri:${url}`; + imageId2 = imageId + console.log(imageId) const element = $(`
`).get(0) $(el).parent().parent().prepend(element); @@ -495,14 +498,26 @@ }); + const element2 = $(`#drop-filenames div[data-input-id='${el.id}']`).get(0); + cornerstone.enable(element2); + cornerstone.loadAndCacheImage(imageId).then(function (image) { + cornerstone.displayImage(element2, image); + cornerstone.resize(element2) + + }); - 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(); - } } + + + + + 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(); + } + } //}) }