Finished upload logic

This commit is contained in:
Max W. 2024-02-16 18:32:59 +01:00
parent b607424d8a
commit cd9a800bf0
4 changed files with 27 additions and 5 deletions

View File

@ -98,9 +98,12 @@
<p class="text-sm text-gray-500 mt-1">Your file is now securely stored on our servers.</p> <p class="text-sm text-gray-500 mt-1">Your file is now securely stored on our servers.</p>
<div class="mt-4 flex flex-col w-full items-center"> <div class="mt-4 flex flex-col w-full items-center">
<button class="btn btn-success w-full max-w-xs text-white">Copy URL</button> <button class="btn btn-success w-full max-w-xs text-white" (click)="copyUrlToClipboard(this.fileUrls?.downloadUrl)">
<button class="btn btn-primary mt-2 w-full max-w-xs">Upload Another File</button> <div *ngIf="!urlCopied">Copy Download URL</div>
<button class="btn btn-outline btn-secondary mt-2 w-full max-w-xs">Delete this file</button> <div *ngIf="urlCopied"><img width="20" src="./assets/check-solid.svg" alt="kk"></div>
</button>
<button class="btn btn-primary mt-2 w-full max-w-xs" routerLink="/home">Home</button>
<button class="btn btn-outline btn-secondary mt-2 w-full max-w-xs" disabled>Delete this file</button>
</div> </div>
</div> </div>
@ -109,5 +112,6 @@
<!-- Invisible SVGs to prevent lazy loading --> <!-- Invisible SVGs to prevent lazy loading -->
<div class="invisible h-0 w-0"> <div class="invisible h-0 w-0">
<img src="./assets/file-solid.svg"> <img src="./assets/file-solid.svg">
<img src="./assets/check-solid.svg">
<img src="./assets/circle-check-solid.svg"> <img src="./assets/circle-check-solid.svg">
</div> </div>

View File

@ -4,6 +4,7 @@ import {FormatFileSizePipePipe} from "../format-file-size-pipe.pipe";
import {FormsModule} from "@angular/forms"; import {FormsModule} from "@angular/forms";
import axios, {AxiosProgressEvent} from "axios"; import axios, {AxiosProgressEvent} from "axios";
import { DevelopmentStore } from '../../store/DevelopmentStore'; import { DevelopmentStore } from '../../store/DevelopmentStore';
import {RouterLink} from "@angular/router";
@Component({ @Component({
selector: 'app-upload', selector: 'app-upload',
@ -13,7 +14,8 @@ import { DevelopmentStore } from '../../store/DevelopmentStore';
FormatFileSizePipePipe, FormatFileSizePipePipe,
FormsModule, FormsModule,
DecimalPipe, DecimalPipe,
NgClass NgClass,
RouterLink
], ],
templateUrl: './upload.component.html', templateUrl: './upload.component.html',
styleUrl: './upload.component.scss' styleUrl: './upload.component.scss'
@ -36,6 +38,7 @@ export class UploadComponent {
uploadData: FileDetails | null = null; uploadData: FileDetails | null = null;
fileUrls: { downloadUrl: string, statusUrl: string, deleteUrl: string } | null = null; fileUrls: { downloadUrl: string, statusUrl: string, deleteUrl: string } | null = null;
urlCopied: boolean = false;
constructor(private developmentStore: DevelopmentStore) { constructor(private developmentStore: DevelopmentStore) {
@ -184,6 +187,17 @@ export class UploadComponent {
this.uploadProgress = this.targetUploadProgress; this.uploadProgress = this.targetUploadProgress;
} }
} }
copyUrlToClipboard(url: string | undefined) {
if(url) {
navigator.clipboard.writeText(url).then(() => {
this.urlCopied = true;
console.log('Text successfully copied to clipboard');
}).catch(err => {
console.error('Failed to copy text to clipboard', err);
});
}
}
} }
interface FileDetails { interface FileDetails {
fileId: string; fileId: string;

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path fill="#fff" d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>

After

Width:  |  Height:  |  Size: 424 B

View File

@ -58,7 +58,10 @@ public class FileService {
String fileId = fileIdService.generateNewUniqueId(); String fileId = fileIdService.generateNewUniqueId();
String password = fileSecurityService.generateFilePassword(); // TODO: generate password String password = "";
if (passwordProtected) {
password = fileSecurityService.generateFilePassword();
}
FileUpload fileUpload = FileUpload.builder() FileUpload fileUpload = FileUpload.builder()
.fileId(fileId) .fileId(fileId)