From 62dcfe49655197822050dea883161bf753930fbf Mon Sep 17 00:00:00 2001 From: Rostislav Raykov Date: Thu, 17 Oct 2024 19:46:36 +0300 Subject: [PATCH] made the pages prettier and responsive for mobile users. --- .../quickdrop/service/FileService.java | 4 +- src/main/resources/static/js/fileView.js | 10 ++ .../resources/templates/filePassword.html | 59 ++++++-- src/main/resources/templates/fileView.html | 141 +++++++++++++----- src/main/resources/templates/listFiles.html | 97 +++++++----- src/main/resources/templates/password.html | 40 +++-- src/main/resources/templates/upload.html | 116 ++++++++++---- 7 files changed, 337 insertions(+), 130 deletions(-) create mode 100644 src/main/resources/static/js/fileView.js diff --git a/src/main/java/org/rostislav/quickdrop/service/FileService.java b/src/main/java/org/rostislav/quickdrop/service/FileService.java index 95a41cc..2ea3eeb 100644 --- a/src/main/java/org/rostislav/quickdrop/service/FileService.java +++ b/src/main/java/org/rostislav/quickdrop/service/FileService.java @@ -50,7 +50,7 @@ public class FileService { String uuid = UUID.randomUUID().toString(); Path path = Path.of(fileSavePath, uuid); - if (fileUploadRequest.password == null) { + if (fileUploadRequest.password == null || fileUploadRequest.password.isEmpty()) { if (!saveUnencryptedFile(file, path)) { return null; } @@ -67,7 +67,7 @@ public class FileService { fileEntity.size = file.getSize(); fileEntity.keepIndefinitely = fileUploadRequest.keepIndefinitely; - if (fileUploadRequest.password != null) { + if (fileUploadRequest.password != null && !fileUploadRequest.password.isEmpty()) { fileEntity.passwordHash = passwordEncoder.encode(fileUploadRequest.password); } diff --git a/src/main/resources/static/js/fileView.js b/src/main/resources/static/js/fileView.js new file mode 100644 index 0000000..e2b6b4c --- /dev/null +++ b/src/main/resources/static/js/fileView.js @@ -0,0 +1,10 @@ +function copyToClipboard() { + const copyText = document.getElementById("downloadLink"); + const copyButton = document.querySelector(".copyButton"); + navigator.clipboard.writeText(copyText.value).then(function () { + copyButton.innerText = "Copied!"; + copyButton.classList.add("btn-success"); + }).catch(function (err) { + console.error("Could not copy text: ", err); + }); +} \ No newline at end of file diff --git a/src/main/resources/templates/filePassword.html b/src/main/resources/templates/filePassword.html index 6134ef9..b19b7c3 100644 --- a/src/main/resources/templates/filePassword.html +++ b/src/main/resources/templates/filePassword.html @@ -3,12 +3,30 @@ Enter Password - + + + + - + + -

Enter Password

-
- - -
- - + +
+

Enter Password

+
+
+ + + + +
+ + +
+ + +
- - - +
- \ No newline at end of file + diff --git a/src/main/resources/templates/fileView.html b/src/main/resources/templates/fileView.html index fcb3eac..fd27e82 100644 --- a/src/main/resources/templates/fileView.html +++ b/src/main/resources/templates/fileView.html @@ -3,54 +3,121 @@ File View - + + + + - + + -

File View

-
-

File Name

-

+ +
+

File View

+
+
+ +
+
+ +
File Name
-

File description

-

+ +
+

+
-

Uploaded/Renewed At

-

-

Files are kept only for 30 days after this date.

+ +
+
Uploaded/Renewed At:
+

+
+ Files are kept only for 30 days after this date. -

Keep Indefinitely

-

+ +
+
Keep Indefinitely:
+

+
-

File Size

-

+ +
+
File Size:
+

+
-

Renew file lifetime

-
- - -
+ +
Link
+
+ + +
-

Link

-

- -

Download

-

- Download -

+ +
+
+ + +
+ + Download + +
+
+
+ +
+
+ + diff --git a/src/main/resources/templates/listFiles.html b/src/main/resources/templates/listFiles.html index 4d110a7..8e72068 100644 --- a/src/main/resources/templates/listFiles.html +++ b/src/main/resources/templates/listFiles.html @@ -2,48 +2,69 @@ - All files - + All Files + + + + + + - -

All Files

- - - - - - - - - - - - - - - - - - - - - -
File NameDescriptionUploaded AtKeep IndefinitelyPassword ProtectedDownload
- Go to file page -
+ +
+

All Files

+ +
+ +
+
+
+
File Name
+

+

Keep Indefinitely

+

Password + Protected

+

+
+ +
+
+
+
diff --git a/src/main/resources/templates/password.html b/src/main/resources/templates/password.html index 3f71ffc..add9e56 100644 --- a/src/main/resources/templates/password.html +++ b/src/main/resources/templates/password.html @@ -3,21 +3,37 @@ Password Required - + + + + -
-

Please enter the password to continue

-
- -
- - +
+
+
+

Please Enter the Password to Continue

+ + +
+ + +
+ + +
+

+
- - -
-

diff --git a/src/main/resources/templates/upload.html b/src/main/resources/templates/upload.html index 316dcb1..73acb39 100644 --- a/src/main/resources/templates/upload.html +++ b/src/main/resources/templates/upload.html @@ -3,12 +3,30 @@ Upload File - + + + + - + + -

Upload a File

-

Max file size 1GB

-

Files are deleted after 30 days if the option for indefinite upload is not selected

-
- -
- - + +
+

Upload a File

+

Max file size 1GB

+

+ Files are deleted after 30 days if the option for indefinite upload is not selected +

+
+
+ + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + +
-
- - + + -
- - -
-
- - -
- - - - - +