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
|
||||
let active_file_inputs = new Set()
|
||||
|
||||
async function listAllFilesAndDirs(dirHandle) {
|
||||
async function listAllFilesAndDirs(dirHandle, files_only) {
|
||||
const files = [];
|
||||
for await (let [name, handle] of dirHandle) {
|
||||
const {
|
||||
kind
|
||||
} = handle;
|
||||
if (handle.kind === 'directory') {
|
||||
files.push({
|
||||
name,
|
||||
handle,
|
||||
kind
|
||||
});
|
||||
if (files_only != true) {
|
||||
files.push({
|
||||
name,
|
||||
handle,
|
||||
kind
|
||||
});
|
||||
}
|
||||
files.push(...await listAllFilesAndDirs(handle));
|
||||
} else {
|
||||
files.push({
|
||||
@@ -51,7 +53,6 @@
|
||||
}
|
||||
|
||||
function closePopup(win, newID, newRepr, id) {
|
||||
console.log(id)
|
||||
$(id + "_to").append('<option value=' + newID + ' title=' + newRepr + ' >' + newRepr + '</option>')
|
||||
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) {
|
||||
// Makes sure we have n inputs available
|
||||
// returns available inputs
|
||||
@@ -84,7 +98,6 @@
|
||||
|
||||
// Make sure we have enough input targets
|
||||
input_diff = (n - inputs.length)
|
||||
console.log("diff", input_diff)
|
||||
|
||||
if (input_diff > 0) {
|
||||
for (let j = 0; j < input_diff; j++) {
|
||||
@@ -112,19 +125,15 @@
|
||||
}
|
||||
|
||||
function input_change(evt) {
|
||||
console.log("input change", evt)
|
||||
file = evt.target.files[0];
|
||||
$(evt.target).removeClass("image-ident-warning");
|
||||
$(evt.target).removeClass("image-ident-ok");
|
||||
|
||||
|
||||
console.log("input change1", evt);
|
||||
console.log("input change", evt.target);
|
||||
ocr(evt.target);
|
||||
|
||||
el = evt.target;
|
||||
|
||||
console.log(el);
|
||||
$(el).find(".temp-thumb").remove();
|
||||
if (el.files.length > 0) {
|
||||
extra_class = " image-ident-loading";
|
||||
@@ -141,7 +150,7 @@
|
||||
}
|
||||
|
||||
|
||||
loadDicomViewerAndFileImages();
|
||||
readFileAndProcess();
|
||||
|
||||
// Check if we have selected a examination type
|
||||
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)
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (file) {
|
||||
console.log("READ EXAMINIANS", file)
|
||||
var arrayBuffer = reader.result;
|
||||
// Here we have the file data as an ArrayBuffer. dicomParser requires as input a
|
||||
// Uint8Array so we create that here
|
||||
@@ -172,9 +180,8 @@
|
||||
if (el.files.length == 0) {
|
||||
el.files = dT.files;
|
||||
//ocr(el)
|
||||
$(el).change();
|
||||
|
||||
if(feedback) {
|
||||
if (feedback) {
|
||||
arr = el.name.split("-");
|
||||
arr.splice(2, 1, "feedback_image");
|
||||
feedback_el_name = arr.join("-");
|
||||
@@ -182,6 +189,7 @@
|
||||
$(`[name=${feedback_el_name}]`).prop("checked", true);
|
||||
}
|
||||
|
||||
$(el).change();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -260,19 +268,50 @@
|
||||
window.showDirectoryPicker().then((handler) => {
|
||||
monitor_directory_handler = handler;
|
||||
monitor_interval_id = setInterval(function () {
|
||||
listAllFilesAndDirs(monitor_directory_handler).then((items) => {
|
||||
console.log(items);
|
||||
listAllFilesAndDirs(monitor_directory_handler).then(async function (
|
||||
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);
|
||||
$("#directory-picker-display").text(monitor_directory_handler.name).after(
|
||||
$(
|
||||
" <span>[clear]</span>").click((evt) => {
|
||||
$(evt.target).remove();
|
||||
$("#directory-picker-display").text("");
|
||||
monitor_directory_handler = false;
|
||||
clearInterval(monitor_interval_id);
|
||||
//const files = await listAllFilesAndDirs(directoryHandle);
|
||||
}));
|
||||
$("#directory-picker-display").text(monitor_directory_handler.name)
|
||||
.after(
|
||||
$(
|
||||
" <span>[clear]</span>").click((evt) => {
|
||||
$(evt.target).remove();
|
||||
$("#directory-picker-display").text("");
|
||||
monitor_directory_handler = false;
|
||||
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()
|
||||
//images = []
|
||||
//Function that returns a promise to read the file
|
||||
@@ -432,7 +471,6 @@
|
||||
image.title = file.name;
|
||||
image.src = reader.result;
|
||||
image.className = "temp-thumb";
|
||||
console.log("read", reader, el);
|
||||
$(el).parent().parent().find(".temp-thumb").remove();
|
||||
$(el).parent().parent().prepend(image);
|
||||
//images.push(reader.result);
|
||||
@@ -463,7 +501,6 @@
|
||||
|
||||
|
||||
file_set.each(async (n, el) => {
|
||||
console.log(el);
|
||||
if (el.files.length > 0) {
|
||||
filename = el.files[0].name;
|
||||
// Probably no need to await here anymore
|
||||
@@ -477,7 +514,8 @@
|
||||
}
|
||||
|
||||
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]");
|
||||
|
||||
n = 0;
|
||||
@@ -637,6 +675,6 @@
|
||||
</ul>
|
||||
</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 %}
|
||||
Reference in New Issue
Block a user