Merge ssh://penracourses.org.uk:/home/django/rad
This commit is contained in:
@@ -12,18 +12,20 @@
|
|||||||
// set to hold the files that are still being processed
|
// set to hold the files that are still being processed
|
||||||
let active_file_inputs = new Set()
|
let active_file_inputs = new Set()
|
||||||
|
|
||||||
async function listAllFilesAndDirs(dirHandle) {
|
async function listAllFilesAndDirs(dirHandle, files_only) {
|
||||||
const files = [];
|
const files = [];
|
||||||
for await (let [name, handle] of dirHandle) {
|
for await (let [name, handle] of dirHandle) {
|
||||||
const {
|
const {
|
||||||
kind
|
kind
|
||||||
} = handle;
|
} = handle;
|
||||||
if (handle.kind === 'directory') {
|
if (handle.kind === 'directory') {
|
||||||
files.push({
|
if (files_only != true) {
|
||||||
name,
|
files.push({
|
||||||
handle,
|
name,
|
||||||
kind
|
handle,
|
||||||
});
|
kind
|
||||||
|
});
|
||||||
|
}
|
||||||
files.push(...await listAllFilesAndDirs(handle));
|
files.push(...await listAllFilesAndDirs(handle));
|
||||||
} else {
|
} else {
|
||||||
files.push({
|
files.push({
|
||||||
@@ -51,7 +53,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closePopup(win, newID, newRepr, id) {
|
function closePopup(win, newID, newRepr, id) {
|
||||||
console.log(id)
|
|
||||||
$(id + "_to").append('<option value=' + newID + ' title=' + newRepr + ' >' + newRepr + '</option>')
|
$(id + "_to").append('<option value=' + newID + ' title=' + newRepr + ' >' + newRepr + '</option>')
|
||||||
win.close();
|
win.close();
|
||||||
}
|
}
|
||||||
@@ -75,6 +76,19 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentFiles() {
|
||||||
|
inputs = $("#rapid-form input[type=file]");
|
||||||
|
|
||||||
|
let files = new Set();
|
||||||
|
for (let j = 0; j < inputs.length; j++) {
|
||||||
|
i = inputs.get(j);
|
||||||
|
if (i.files.length > 0) {
|
||||||
|
files.add(i.files[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
function extendInputs(n) {
|
function extendInputs(n) {
|
||||||
// Makes sure we have n inputs available
|
// Makes sure we have n inputs available
|
||||||
// returns available inputs
|
// returns available inputs
|
||||||
@@ -84,7 +98,6 @@
|
|||||||
|
|
||||||
// Make sure we have enough input targets
|
// Make sure we have enough input targets
|
||||||
input_diff = (n - inputs.length)
|
input_diff = (n - inputs.length)
|
||||||
console.log("diff", input_diff)
|
|
||||||
|
|
||||||
if (input_diff > 0) {
|
if (input_diff > 0) {
|
||||||
for (let j = 0; j < input_diff; j++) {
|
for (let j = 0; j < input_diff; j++) {
|
||||||
@@ -112,19 +125,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function input_change(evt) {
|
function input_change(evt) {
|
||||||
console.log("input change", evt)
|
|
||||||
file = evt.target.files[0];
|
file = evt.target.files[0];
|
||||||
$(evt.target).removeClass("image-ident-warning");
|
$(evt.target).removeClass("image-ident-warning");
|
||||||
$(evt.target).removeClass("image-ident-ok");
|
$(evt.target).removeClass("image-ident-ok");
|
||||||
|
|
||||||
|
|
||||||
console.log("input change1", evt);
|
|
||||||
console.log("input change", evt.target);
|
|
||||||
ocr(evt.target);
|
ocr(evt.target);
|
||||||
|
|
||||||
el = evt.target;
|
el = evt.target;
|
||||||
|
|
||||||
console.log(el);
|
|
||||||
$(el).find(".temp-thumb").remove();
|
$(el).find(".temp-thumb").remove();
|
||||||
if (el.files.length > 0) {
|
if (el.files.length > 0) {
|
||||||
extra_class = " image-ident-loading";
|
extra_class = " image-ident-loading";
|
||||||
@@ -141,7 +150,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loadDicomViewerAndFileImages();
|
readFileAndProcess();
|
||||||
|
|
||||||
// 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) {
|
||||||
@@ -149,7 +158,6 @@
|
|||||||
// Yes we do read the file twice (here and where loading it in the viewer)
|
// Yes we do read the file twice (here and where loading it in the viewer)
|
||||||
var reader = new FileReader();
|
var reader = new FileReader();
|
||||||
reader.onload = function (file) {
|
reader.onload = function (file) {
|
||||||
console.log("READ EXAMINIANS", file)
|
|
||||||
var arrayBuffer = reader.result;
|
var arrayBuffer = reader.result;
|
||||||
// Here we have the file data as an ArrayBuffer. dicomParser requires as input a
|
// Here we have the file data as an ArrayBuffer. dicomParser requires as input a
|
||||||
// Uint8Array so we create that here
|
// Uint8Array so we create that here
|
||||||
@@ -172,9 +180,8 @@
|
|||||||
if (el.files.length == 0) {
|
if (el.files.length == 0) {
|
||||||
el.files = dT.files;
|
el.files = dT.files;
|
||||||
//ocr(el)
|
//ocr(el)
|
||||||
$(el).change();
|
|
||||||
|
|
||||||
if(feedback) {
|
if (feedback) {
|
||||||
arr = el.name.split("-");
|
arr = el.name.split("-");
|
||||||
arr.splice(2, 1, "feedback_image");
|
arr.splice(2, 1, "feedback_image");
|
||||||
feedback_el_name = arr.join("-");
|
feedback_el_name = arr.join("-");
|
||||||
@@ -182,6 +189,7 @@
|
|||||||
$(`[name=${feedback_el_name}]`).prop("checked", true);
|
$(`[name=${feedback_el_name}]`).prop("checked", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(el).change();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,19 +268,50 @@
|
|||||||
window.showDirectoryPicker().then((handler) => {
|
window.showDirectoryPicker().then((handler) => {
|
||||||
monitor_directory_handler = handler;
|
monitor_directory_handler = handler;
|
||||||
monitor_interval_id = setInterval(function () {
|
monitor_interval_id = setInterval(function () {
|
||||||
listAllFilesAndDirs(monitor_directory_handler).then((items) => {
|
listAllFilesAndDirs(monitor_directory_handler).then(async function (
|
||||||
console.log(items);
|
items) {
|
||||||
|
files_to_add = new Set();
|
||||||
|
current_files = getCurrentFiles();
|
||||||
|
current_files_tuple = new Set()
|
||||||
|
for (let elem of current_files) {
|
||||||
|
current_files_tuple.add(
|
||||||
|
`${elem.size}, ${elem.name}, ${elem.lastModified}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(current_files_tuple)
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
|
||||||
|
f = await items[i].handle.getFile()
|
||||||
|
console.log("f", f)
|
||||||
|
if (!current_files_tuple.has(
|
||||||
|
`${f.size}, ${f.name}, ${f.lastModified}`
|
||||||
|
)) {
|
||||||
|
files_to_add.add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// file objects differ enough that the following does not work
|
||||||
|
//let distinct_set = new Set([...files_to_add].filter(
|
||||||
|
// x => !current_files.has(x)));
|
||||||
|
|
||||||
|
|
||||||
|
extendInputs(files_to_add.size);
|
||||||
|
files_to_add.forEach((file) => {
|
||||||
|
addFile(file, false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 5000);
|
||||||
$("#directory-picker-display").text(monitor_directory_handler.name).after(
|
$("#directory-picker-display").text(monitor_directory_handler.name)
|
||||||
$(
|
.after(
|
||||||
" <span>[clear]</span>").click((evt) => {
|
$(
|
||||||
$(evt.target).remove();
|
" <span>[clear]</span>").click((evt) => {
|
||||||
$("#directory-picker-display").text("");
|
$(evt.target).remove();
|
||||||
monitor_directory_handler = false;
|
$("#directory-picker-display").text("");
|
||||||
clearInterval(monitor_interval_id);
|
monitor_directory_handler = false;
|
||||||
//const files = await listAllFilesAndDirs(directoryHandle);
|
clearInterval(monitor_interval_id);
|
||||||
}));
|
//const files = await listAllFilesAndDirs(directoryHandle);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -411,7 +450,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadDicomViewerAndFileImages(callback) {
|
async function readFileAndProcess(callback) {
|
||||||
//$("#single-dicom-viewer").empty()
|
//$("#single-dicom-viewer").empty()
|
||||||
//images = []
|
//images = []
|
||||||
//Function that returns a promise to read the file
|
//Function that returns a promise to read the file
|
||||||
@@ -432,7 +471,6 @@
|
|||||||
image.title = file.name;
|
image.title = file.name;
|
||||||
image.src = reader.result;
|
image.src = reader.result;
|
||||||
image.className = "temp-thumb";
|
image.className = "temp-thumb";
|
||||||
console.log("read", reader, el);
|
|
||||||
$(el).parent().parent().find(".temp-thumb").remove();
|
$(el).parent().parent().find(".temp-thumb").remove();
|
||||||
$(el).parent().parent().prepend(image);
|
$(el).parent().parent().prepend(image);
|
||||||
//images.push(reader.result);
|
//images.push(reader.result);
|
||||||
@@ -463,7 +501,6 @@
|
|||||||
|
|
||||||
|
|
||||||
file_set.each(async (n, el) => {
|
file_set.each(async (n, el) => {
|
||||||
console.log(el);
|
|
||||||
if (el.files.length > 0) {
|
if (el.files.length > 0) {
|
||||||
filename = el.files[0].name;
|
filename = el.files[0].name;
|
||||||
// Probably no need to await here anymore
|
// Probably no need to await here anymore
|
||||||
@@ -477,7 +514,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadViewer() {
|
function loadViewer() {
|
||||||
//dicomViewer.loadCornerstone($("#single-dicom-viewer"), null, images, annotations);
|
// temp fix before starting viewer collapsed
|
||||||
|
$("#single-dicom-viewer").show()
|
||||||
file_set = $("#image_form_set input[type=file]");
|
file_set = $("#image_form_set input[type=file]");
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
@@ -637,6 +675,6 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="single-dicom-viewer" class="rapid-dicom-viewer" data-images="" data-annotations=''></div>
|
<div id="single-dicom-viewer" class="rapid-dicom-viewer" data-images="" data-annotations='' style="display:none"></div>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user