From d171a218ebf12d6845fd02b1c866bbd9b60c5195 Mon Sep 17 00:00:00 2001 From: Lino Schmidt Date: Mon, 12 Jun 2023 18:06:03 +0200 Subject: [PATCH] fixed foldersructure+loading animation --- src/static/index.ejs | 23 ++++++++++ src/static/index.js | 47 ++++++++++++++++++++ src/static/style.css | 56 +++++++++++++++++++++++ src/templates/index.ejs | 98 ----------------------------------------- 4 files changed, 126 insertions(+), 98 deletions(-) create mode 100644 src/static/index.ejs create mode 100644 src/static/index.js create mode 100644 src/static/style.css delete mode 100644 src/templates/index.ejs diff --git a/src/static/index.ejs b/src/static/index.ejs new file mode 100644 index 0000000..68ddf1e --- /dev/null +++ b/src/static/index.ejs @@ -0,0 +1,23 @@ + + + + + + BerichtExporter + + + +

BerichtExporter

+
+ + +
+ + + + + \ No newline at end of file diff --git a/src/static/index.js b/src/static/index.js new file mode 100644 index 0000000..a5cb61f --- /dev/null +++ b/src/static/index.js @@ -0,0 +1,47 @@ +const exportTextarea = document.getElementById('export-textarea'); +const weekList = document.getElementById('week-list'); +const exportButton = document.getElementById('export-button'); +let loadingInterval; + +function loading() { + exportButton.disabled = true; + exportTextarea.value = 'Loading'; + loadingInterval = setInterval(() => { + if (exportTextarea.value != 'Loading...') { + exportTextarea.value += '.'; + } else { + exportTextarea.value = 'Loading'; + } + }, 500); +} + +function loaded() { + exportButton.disabled = false; + clearInterval(loadingInterval); + exportTextarea.value = ''; +} + +function exportReport() { + const week = weekList.value; + + loading(); + + fetch('/getreport?week=' + week) + .then(response => { + if (response.ok) { + return response.text(); + } else { + exportTextarea.value = 'Error while fetching report'; + throw new Error('Error while fetching report'); + } + }).then(text => { + exportTextarea.value = text; + exportTextarea.style.height = "auto"; + exportTextarea.style.height = exportTextarea.scrollHeight + "px"; + loaded(); + }).catch(error => { + exportTextarea.value = 'Error while fetching report'; + console.error(error); + loaded(); + }); +} \ No newline at end of file diff --git a/src/static/style.css b/src/static/style.css new file mode 100644 index 0000000..a1339b0 --- /dev/null +++ b/src/static/style.css @@ -0,0 +1,56 @@ +body { + font-family: 'Roboto', sans-serif; + font-size: 16px; + color: #fff; + background-color: #0d131e; + margin: 0; + padding: 15px; +} + +h1 { + margin: 0; + margin-bottom: 10px; +} + +.selector { + margin-bottom: 10px; +} + +select::-webkit-scrollbar { + display: none; +} + +.selector select { + height: 30px; + font-size: 16px; + border-radius: 15px; + background-color: #172336; + color: #fff; + border: none; + overflow-y: scroll; +} + +.selector button { + font-size: 16px; + height: 30px; + margin-left: 10px; + border-radius: 15px; + background-color: #172336; + color: #fff; + border: none; +} +.selector button:hover { + scale: 1.1; + cursor: pointer; +} + +#export-textarea { + font-size: 16px; + width: 100%; + resize: none; + overflow-y: hidden; + background-color: #172336; + color: #fff; + border-radius: 15px; + border: none; +} \ No newline at end of file diff --git a/src/templates/index.ejs b/src/templates/index.ejs deleted file mode 100644 index f306ef6..0000000 --- a/src/templates/index.ejs +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - BerichtExporter - - - -

BerichtExporter

-
- - -
- - - - - \ No newline at end of file