From 0841dcfc4896ca2e471d0b533d0e7362e6301fe7 Mon Sep 17 00:00:00 2001 From: brenno-silva Date: Sun, 29 Jan 2023 16:11:38 -0300 Subject: [PATCH 1/3] Removing duplicated translation --- locale/pt_BR/LC_MESSAGES/django.po | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/locale/pt_BR/LC_MESSAGES/django.po b/locale/pt_BR/LC_MESSAGES/django.po index 9ff705fe..e44c05ac 100644 --- a/locale/pt_BR/LC_MESSAGES/django.po +++ b/locale/pt_BR/LC_MESSAGES/django.po @@ -500,11 +500,8 @@ msgstr "Digite o código que você recebeu em seu e-mail." msgid "Type your username or e-mail" msgstr "Digite seu nome de usuário ou email" -#: src/ARte/users/jinja2/users/signup.jinja2:29 -msgid "Remember me" -msgstr "Lembre-se de mim" - #: src/ARte/users/jinja2/users/login.jinja2:35 +#: src/ARte/users/jinja2/users/signup.jinja2:29 msgid "Remember me" msgstr "Lembre-se de mim" From 91e72ffce428225bb278fb0a8c0522480dbdb66d Mon Sep 17 00:00:00 2001 From: brenno-silva Date: Sun, 29 Jan 2023 16:14:47 -0300 Subject: [PATCH 2/3] Adding alert on Upload Object page --- locale/pt_BR/LC_MESSAGES/django.po | 7 ++++++- src/users/jinja2/users/upload-object.jinja2 | 10 +++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/locale/pt_BR/LC_MESSAGES/django.po b/locale/pt_BR/LC_MESSAGES/django.po index e44c05ac..3de8dbea 100644 --- a/locale/pt_BR/LC_MESSAGES/django.po +++ b/locale/pt_BR/LC_MESSAGES/django.po @@ -756,4 +756,9 @@ msgstr "Não encontramos nenhum objeto por aqui :( Tente fazer upload." #: src/ARte/users/jinja2/users/upload-marker.jinja2:19 msgid "Choose Marker's title" -msgstr "Escolha o título do seu Marcador" \ No newline at end of file +msgstr "Escolha o título do seu Marcador" + +#: src/ARte/users/jinja2/users/upload-object.jinja2:138 +#: src/ARte/users/jinja2/users/upload.jinja2:188 +msgid "Invalid file type! Only image or video files are accepted." +msgstr "Arquivo inválido! Apenas imagens ou videos são aceitos." \ No newline at end of file diff --git a/src/users/jinja2/users/upload-object.jinja2 b/src/users/jinja2/users/upload-object.jinja2 index f2c404bf..30501632 100644 --- a/src/users/jinja2/users/upload-object.jinja2 +++ b/src/users/jinja2/users/upload-object.jinja2 @@ -114,6 +114,7 @@ var previewAndLoadFile = null; var content_box = document.createElement("div"); content_box.id = "content-box"; + if (file.type === "video/mp4" || file.type === "video/webm") { image_preview = document.createElement("video"); previewAndLoadFile = function() { @@ -125,7 +126,7 @@ document.getElementById("id_source").after(content_box); document.getElementById("content-box").appendChild(image_preview); //make preview image of the object/marker show } - } else { + } else if(file.type.includes("image/")) { image_preview = document.createElement("img"); previewAndLoadFile = function() { image_preview.src = reader.result; @@ -133,6 +134,13 @@ document.getElementById("id_source").after(content_box); document.getElementById("content-box").appendChild(image_preview); //make preview image of the object/marker show } + } else { + alert("{{ _("Invalid file type! Only image or video files are accepted.") }}") + + document.getElementById("id_source").value = ""; + + if (document.querySelector('#img-preview')) + document.querySelector('#img-preview').remove(); } var reader = new FileReader(); From e294bff411f24139153802ee0b3911ee7998f0ec Mon Sep 17 00:00:00 2001 From: brenno-silva Date: Sun, 29 Jan 2023 16:47:19 -0300 Subject: [PATCH 3/3] Adding validation to Edit object page --- locale/pt_BR/LC_MESSAGES/django.po | 2 +- src/users/jinja2/users/edit-object.jinja2 | 42 ++++++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/locale/pt_BR/LC_MESSAGES/django.po b/locale/pt_BR/LC_MESSAGES/django.po index 3de8dbea..68e7abf2 100644 --- a/locale/pt_BR/LC_MESSAGES/django.po +++ b/locale/pt_BR/LC_MESSAGES/django.po @@ -759,6 +759,6 @@ msgid "Choose Marker's title" msgstr "Escolha o título do seu Marcador" #: src/ARte/users/jinja2/users/upload-object.jinja2:138 -#: src/ARte/users/jinja2/users/upload.jinja2:188 +#: src/ARte/users/jinja2/users/edit-object.jinja2:88 msgid "Invalid file type! Only image or video files are accepted." msgstr "Arquivo inválido! Apenas imagens ou videos são aceitos." \ No newline at end of file diff --git a/src/users/jinja2/users/edit-object.jinja2 b/src/users/jinja2/users/edit-object.jinja2 index cc69957e..4f161dc1 100644 --- a/src/users/jinja2/users/edit-object.jinja2 +++ b/src/users/jinja2/users/edit-object.jinja2 @@ -69,19 +69,43 @@ $("#id_source").change( function(e) { - for (var i = 0; i < e.originalEvent.srcElement.files.length; i++) { - var file = e.originalEvent.srcElement.files[i]; - - var image_preview = document.createElement("img"); - var reader = new FileReader(); - reader.onloadend = function() { + var file = e.originalEvent.srcElement.files[0]; + var image_preview = null; + var previewAndLoadFile = null; + var content_box = document.createElement("div"); + content_box.id = "content-box"; + + if (file.type === "video/mp4" || file.type === "video/webm") { + image_preview = document.createElement("video"); + previewAndLoadFile = function () { + image_preview.src = reader.result; + image_preview.id = "img-preview"; + image_preview.controls = "controls"; + image_preview.autoplay = "autoplay"; + image_preview.muted = "muted"; + document.getElementById("id_source").after(content_box); + document.getElementById("content-box").appendChild(image_preview); //make preview image of the object/marker show + } + } else if (file.type.includes("image/")) { + image_preview = document.createElement("img"); + previewAndLoadFile = function () { image_preview.src = reader.result; image_preview.id = "img-preview"; - image_preview.hidden = "hidden"; + document.getElementById("id_source").after(content_box); + document.getElementById("content-box").appendChild(image_preview); //make preview image of the object/marker show } - reader.readAsDataURL(file); - $("input").after(image_preview); //make preview image of the object/marker show + } else { + alert("{{ _("Invalid file type! Only image or video files are accepted.") }}") + + document.getElementById("id_source").value = ""; + + if (document.querySelector('#img-preview')) + document.querySelector('#img-preview').remove(); } + + var reader = new FileReader(); + reader.onloadend = previewAndLoadFile; + reader.readAsDataURL(file); } );