From a32fb2c89b0e0a9009b0793d70d630fb0058624e Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 22 Nov 2021 20:18:34 +0000 Subject: [PATCH] . --- anatomy/static/css/anatomy.css | 4 ++ rapids/templates/rapids/rapid_form.html | 71 ++++++++++++++++--------- rapids/views.py | 2 +- static/css/anatomy.css | 4 ++ 4 files changed, 56 insertions(+), 25 deletions(-) diff --git a/anatomy/static/css/anatomy.css b/anatomy/static/css/anatomy.css index 678b6481..eefb1c8a 100644 --- a/anatomy/static/css/anatomy.css +++ b/anatomy/static/css/anatomy.css @@ -792,4 +792,8 @@ input { width: 1000px; height: 1000px; max-width: 1000px; + } + + .image-duplicate { + border: 2px solid orange; } \ No newline at end of file diff --git a/rapids/templates/rapids/rapid_form.html b/rapids/templates/rapids/rapid_form.html index 38bf4ce1..2faf4756 100755 --- a/rapids/templates/rapids/rapid_form.html +++ b/rapids/templates/rapids/rapid_form.html @@ -569,7 +569,7 @@ }) } - const viewLoadChecker = setInterval(function() { + const viewLoadChecker = setInterval(function () { if (load_viewer) { load_viewer = false; loadViewer(); @@ -632,31 +632,54 @@ } - function checkHash(hash) { - $.ajax({ - url: "{% url 'rapids:rapid_question_by_hash' %}", - data: { - csrfmiddlewaretoken: '{{ csrf_token }}', - hash: hash - }, - type: "POST", - dataType: "json", + function checkHash(hash, input) { + $.ajax({ + url: "{% url 'rapids:rapid_question_by_hash' %}", + data: { + csrfmiddlewaretoken: '{{ csrf_token }}', + hash: hash + }, + type: "POST", + dataType: "json", }) - // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly - .done(function (data) { - console.log(data); + // $.ajax().done(), $.ajax().fail(), $ajax().always() are upto you. Add/change accordingly + .done(function (data) { + console.log(data); - if (data.status == "success") { - console.log("success"); - console.log(data.id) - if (data.id) { - toastr.info(`id ${data.id}`) - } - } - }) - .always(function () { - console.log('[Done]'); - }) + if (data.status == "success") { + console.log("success"); + console.log(data.id) + if (data.id) { + //toastr.info(`id ${data.id}`) + uploading_el = $(`img[data-input-id='${input.id}'], div[data-input-id='${input.id}']`) + $(input).addClass("image-duplicate"); + uploading_el.addClass("image-duplicate"); + + toastr.warning(`Image (${input.files[0].name}) already exists.
Click to view
`, "Duplicate image", { + "closeButton": false, + "debug": false, + "newestOnTop": false, + "progressBar": false, + "positionClass": "toast-top-full-width", + "preventDuplicates": false, + "onclick": null, + "showDuration": "0", + "hideDuration": "0", + "timeOut": 0, + "extendedTimeOut": 0, + "showEasing": "swing", + "hideEasing": "linear", + "showMethod": "fadeIn", + "hideMethod": "fadeOut", + "tapToDismiss": false + }) + + } + } + }) + .always(function () { + console.log('[Done]'); + }) } function extractDicomStudyDescription(byteArray) { diff --git a/rapids/views.py b/rapids/views.py index ab92941d..823b8c86 100755 --- a/rapids/views.py +++ b/rapids/views.py @@ -1115,7 +1115,7 @@ def get_question_by_hash(request): try: question = RapidImage.objects.get(image_md5_hash=hash) - data = {"status": "success", "id": question.pk} + data = {"status": "success", "id": question.pk, "url": question.get_absolute_url()} return JsonResponse(data, status=200) except RapidImage.DoesNotExist: data = {"status": "success", "id": False} diff --git a/static/css/anatomy.css b/static/css/anatomy.css index 678b6481..eefb1c8a 100644 --- a/static/css/anatomy.css +++ b/static/css/anatomy.css @@ -792,4 +792,8 @@ input { width: 1000px; height: 1000px; max-width: 1000px; + } + + .image-duplicate { + border: 2px solid orange; } \ No newline at end of file