From 6306bd4c80c992a7309aacdf9ef4340f8a84ab69 Mon Sep 17 00:00:00 2001 From: BenediktMKuehne Date: Thu, 21 Dec 2023 12:50:56 +0000 Subject: [PATCH 1/2] Add dragndrop --- embark/static/content/css/globalStyle.css | 3 +- embark/static/content/css/uploader.css | 19 +++++- embark/static/scripts/fileUpload.js | 76 +++++++++++++++++------ embark/templates/uploader/start.html | 2 +- embark/templates/uploader/upload.html | 30 +++++++-- 5 files changed, 102 insertions(+), 28 deletions(-) diff --git a/embark/static/content/css/globalStyle.css b/embark/static/content/css/globalStyle.css index 697cf3e0c..e8012069e 100644 --- a/embark/static/content/css/globalStyle.css +++ b/embark/static/content/css/globalStyle.css @@ -36,8 +36,6 @@ textarea:focus, .form-control:focus, .btn:focus { outline: none; - -webkit-appearance: none; - -moz-appearance: none; box-shadow: none; } @@ -137,6 +135,7 @@ button[type="delete"]:hover { background-color: #fff; color: #000; padding-top: 12px; + border-radius: 10px; } .innerBlock { diff --git a/embark/static/content/css/uploader.css b/embark/static/content/css/uploader.css index c60d28033..443ec57dd 100644 --- a/embark/static/content/css/uploader.css +++ b/embark/static/content/css/uploader.css @@ -202,4 +202,21 @@ input:checked+.slider:before { .alert { margin: 30px; -} \ No newline at end of file +} + +.upload_dropZone { + color: #0f3c4b; + background-color: var(--colorPrimaryPale, #c8dadf); + outline: 2px dashed var(--colorPrimaryHalf, #c1ddef); + outline-offset: -12px; + transition: + outline-offset 0.2s ease-out, + outline-color 0.3s ease-in-out, + background-color 0.2s ease-out; +} + +.upload_dropZone.highlight { + outline-offset: -4px; + outline-color: var(--colorPrimaryNormal, #0576bd); + background-color: var(--colorPrimaryEighth, #c8dadf); +} diff --git a/embark/static/scripts/fileUpload.js b/embark/static/scripts/fileUpload.js index fe2fd3247..7f4316012 100644 --- a/embark/static/scripts/fileUpload.js +++ b/embark/static/scripts/fileUpload.js @@ -1,13 +1,5 @@ // jshint unused:false // ^ this should only be added AFTER successful check (disables warning for global functions) -/** - * The following event calls prevent default to turn off the browsers default drag and drop handler - * @param {*} ev Event - */ -function dragOverHandler(ev) { - "use strict"; - ev.preventDefault(); -} function getCookie(name) { "use strict"; @@ -47,7 +39,7 @@ $(window).bind("load", function() { * Makes Ajax call and save files locally * @param {*} formData Information of the uploaded file or Files */ - async function postFiles(formData) { +async function postFiles(formData) { "use strict"; try { //formData.append('file', fileData); @@ -97,7 +89,7 @@ $(window).bind("load", function() { } }); } catch (error) { - console.log(error.message); + console.log(error.message); } } @@ -105,15 +97,61 @@ $(window).bind("load", function() { * Checks for any Multiple uploads and the Passes to save */ function saveFiles() { - "use strict"; - var progressBar = document.getElementById("progress-wrapper"); - progressBar.style.display = "block"; - var fileData = document.getElementById('file-input').files; - var formData = new FormData(); - for (let index = 0; index < fileData.length; index++) { - fileData[index].inputFileName = fileData[index].name; - formData.append('file', fileData[index]); - } + "use strict"; + var progressBar = document.getElementById("progress-wrapper"); + progressBar.style.display = "block"; + var fileData = document.getElementById('file-input').files; + var formData = new FormData(); + for (let index = 0; index < fileData.length; index++) { + fileData[index].inputFileName = fileData[index].name; + formData.append('file', fileData[index]); + } postFiles(formData); } +function dragOverHandler(ev) { + "use strict"; + console.log("File(s) in drop zone"); + + // Prevent default behavior (Prevent file from being opened) + ev.preventDefault(); + ev.target.classList.add('highlight'); +} + +function addFiles(files) { + "use strict"; + var progressBar = document.getElementById("progress-wrapper"); + progressBar.style.display = "block"; + var fileData = files; + var formData = new FormData(); + for (let index = 0; index < fileData.length; index++) { + fileData[index].inputFileName = fileData[index].name; + formData.append('file', fileData[index]); + } + postFiles(formData); +} + +function dropHandler(ev) { + "use strict"; + console.log("File(s) dropped"); + + // Prevent default behavior (Prevent file from being opened) + ev.preventDefault(); + if (ev.dataTransfer.items) { + // Use DataTransferItemList interface to access the file(s) + [...ev.dataTransfer.items].forEach((item, i) => { + // If dropped items aren't files, reject them + if (item.kind === "file") { + const file = item.getAsFile(); + console.log(`… file[${i}].name = ${file.name}`); + } + }); + } else { + // Use DataTransfer interface to access the file(s) + [...ev.dataTransfer.files].forEach((file, i) => { + console.log(`… file[${i}].name = ${file.name}`); + }); + } + addFiles(ev.dataTransfer.files); + ev.target.classList.remove('highlight'); +} diff --git a/embark/templates/uploader/start.html b/embark/templates/uploader/start.html index 278c01e98..d3f24fb93 100644 --- a/embark/templates/uploader/start.html +++ b/embark/templates/uploader/start.html @@ -8,7 +8,7 @@
{% csrf_token %}
- +
+ From 41ccf380bbb7721518793f4702f78752586b3496 Mon Sep 17 00:00:00 2001 From: BenediktMKuehne Date: Thu, 21 Dec 2023 12:52:40 +0000 Subject: [PATCH 2/2] adjust checks --- dev-tools/check_project.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev-tools/check_project.sh b/dev-tools/check_project.sh index afb51113e..b3bf48643 100755 --- a/dev-tools/check_project.sh +++ b/dev-tools/check_project.sh @@ -184,7 +184,7 @@ banditer() { exit 1 fi - mapfile -t PY_SCRIPTS < <(find . -type d -name migrations -prune -false -o -iname "*.py" -not -path "./.venv/*") + mapfile -t PY_SCRIPTS < <(find . -type d -name migrations -prune -false -o -iname "*.py" -not -path "./.venv/*" -not -path "./emba/*") for PY_SCRIPT in "${PY_SCRIPTS[@]}"; do echo -e "\\n""${GREEN}""Run bandit on ${PY_SCRIPT}:""${NC}""\\n" @@ -244,7 +244,7 @@ dockerchecker(){ mapfile -t DOCKER_COMPS < <(find . -maxdepth 1 -type d -name migrations -prune -false -o -iname "docker-compose*.yml") for DOCKER_COMP in "${DOCKER_COMPS[@]}"; do echo -e "\\n""${GREEN}""Run docker check on ${DOCKER_COMP}:""${NC}""\\n" - if docker-compose -f "${DOCKER_COMP}" config 1>/dev/null || [[ $? -ne 1 ]]; then # TODO check + if docker-compose -f "${DOCKER_COMP}" config 1>/dev/null || [[ $? -ne 1 ]]; then echo -e "${GREEN}""${BOLD}""==> SUCCESS""${NC}""\\n" else echo -e "\\n""${ORANGE}${BOLD}==> FIX ERRORS""${NC}""\\n"