From 8f7008c9102c5cbdd4183dff3142de617d4fa34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20M=C3=BCller?= Date: Mon, 11 Mar 2024 10:56:29 +0100 Subject: [PATCH] add toast for succes and failed upload --- static/img/check-square.svg | 4 ++++ static/img/x-square.svg | 4 ++++ static/js/merge.js | 10 +++++++++- static/js/project.js | 8 ++++++++ static/js/split.js | 10 +++++++++- templates/base.html | 30 ++++++++++++++++++++++++++++++ 6 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 static/img/check-square.svg create mode 100644 static/img/x-square.svg diff --git a/static/img/check-square.svg b/static/img/check-square.svg new file mode 100644 index 0000000..b7d1116 --- /dev/null +++ b/static/img/check-square.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/static/img/x-square.svg b/static/img/x-square.svg new file mode 100644 index 0000000..eb62b61 --- /dev/null +++ b/static/img/x-square.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/static/js/merge.js b/static/js/merge.js index 676f371..a445bf2 100644 --- a/static/js/merge.js +++ b/static/js/merge.js @@ -75,9 +75,17 @@ const vueInstance = new Vue({ }); // eslint-disable-next-line no-unused-vars - dropzone.on('complete', (file, xhr, formData) => { + dropzone.on('success', (file, xhr, formData) => { pdf_uploaded = true; document.getElementById('btn-group-download').style.display = 'flex'; + // eslint-disable-next-line no-undef + bootstrap.Toast.getOrCreateInstance(document.getElementById('success-upload-toast')).show(); + }); + + // eslint-disable-next-line no-unused-vars + dropzone.on('error', (file, xhr, formData) => { + // eslint-disable-next-line no-undef + bootstrap.Toast.getOrCreateInstance(document.getElementById('warn-upload-toast')).show(); }); }, }, diff --git a/static/js/project.js b/static/js/project.js index 39486db..c74bf4c 100644 --- a/static/js/project.js +++ b/static/js/project.js @@ -151,6 +151,14 @@ const vueInstance = new Vue({ pdf_uploaded = true; document.getElementById('btn-group-download').style.display = 'flex'; this.display_pages(); + // eslint-disable-next-line no-undef + bootstrap.Toast.getOrCreateInstance(document.getElementById('success-upload-toast')).show(); + }); + + // eslint-disable-next-line no-unused-vars + dropzone.on('error', (file, xhr, formData) => { + // eslint-disable-next-line no-undef + bootstrap.Toast.getOrCreateInstance(document.getElementById('warn-upload-toast')).show(); }); }, }, diff --git a/static/js/split.js b/static/js/split.js index 4e7ae89..c0142f4 100644 --- a/static/js/split.js +++ b/static/js/split.js @@ -75,9 +75,17 @@ const vueInstance = new Vue({ }); // eslint-disable-next-line no-unused-vars - dropzone.on('complete', (file, xhr, formData) => { + dropzone.on('success', (file, xhr, formData) => { pdf_uploaded = true; document.getElementById('btn-group-download').style.display = 'flex'; + // eslint-disable-next-line no-undef + bootstrap.Toast.getOrCreateInstance(document.getElementById('success-upload-toast')).show(); + }); + + // eslint-disable-next-line no-unused-vars + dropzone.on('error', (file, xhr, formData) => { + // eslint-disable-next-line no-undef + bootstrap.Toast.getOrCreateInstance(document.getElementById('warn-upload-toast')).show(); }); }, }, diff --git a/templates/base.html b/templates/base.html index 85edf79..c5fb62b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -67,5 +67,35 @@ + +
+ + + + +
+ +
+