diff --git a/frontend/src/app/download/download.component.html b/frontend/src/app/download/download.component.html index 4b678f2..9f0eba2 100644 --- a/frontend/src/app/download/download.component.html +++ b/frontend/src/app/download/download.component.html @@ -3,29 +3,41 @@

Access your files quickly and securely

-
- -
- - - -
-
- +

Files are available for a limited time. Ensure the code or link is correct and the file is still downloadable.

- + diff --git a/frontend/src/app/download/download.component.ts b/frontend/src/app/download/download.component.ts index e57fc18..be619ae 100644 --- a/frontend/src/app/download/download.component.ts +++ b/frontend/src/app/download/download.component.ts @@ -1,23 +1,43 @@ -import { Component } from '@angular/core'; +import {Component, ElementRef, ViewChild} from '@angular/core'; import axios from "axios"; +import {DevelopmentStore} from "../../store/DevelopmentStore"; +import {FormsModule} from "@angular/forms"; +import {NgIf} from "@angular/common"; @Component({ selector: 'app-download', standalone: true, - imports: [], + imports: [ + FormsModule, + NgIf + ], templateUrl: './download.component.html', styleUrl: './download.component.scss' }) export class DownloadComponent { - fileId: string = ""; + @ViewChild('download_not_possible') download_not_possible: ElementRef | undefined; - constructor() { + inputFileId: string = ""; + fileId: string = ""; + filePassword: string = ""; + downloadInfo: DownloadInfo | null = null; + + + constructor(private developmentStore: DevelopmentStore) { this.speedTest(); } checkFile() { - console.log("Moin") + + console.log(this.inputFileId); + this.fileId = this.inputFileId; // TODO: Implement link extraction logic + + this.getDownloadInfo(); + } + + checkPassword() { + } private speedTest() { @@ -25,7 +45,7 @@ export class DownloadComponent { axios({ method: 'get', - url: 'http://localhost:/api/v1/speed-test', + url: this.developmentStore.getBaseUrl() + 'api/v1/speed-test', responseType: 'arraybuffer', headers: { 'Access-Control-Allow-Origin': '*', // Allow CORS @@ -44,4 +64,29 @@ export class DownloadComponent { console.error('Error during download test:', error); }); } + + private getDownloadInfo() { + axios({ + method: 'get', + url: this.developmentStore.getBaseUrl() + 'api/v1/download-info?fileId=' + this.fileId, + responseType: 'json', + headers: { + 'Access-Control-Allow-Origin': '*', // Allow CORS + } + }) + .then(response => { + this.downloadInfo = response.data; + console.log(response.data); + return response.data; + }) + .catch(error => { + console.error('Error during download info request:', error); + }); + } +} +interface DownloadInfo { + downloadable: boolean; + passwordProtected: boolean; + singleDownload: boolean; + fileId: string; } diff --git a/frontend/src/app/upload/upload.component.ts b/frontend/src/app/upload/upload.component.ts index fdc2c96..8251840 100644 --- a/frontend/src/app/upload/upload.component.ts +++ b/frontend/src/app/upload/upload.component.ts @@ -147,7 +147,7 @@ export class UploadComponent { axios({ method: 'post', - url: 'http://localhost/api/v1/upload-speed-test', + url: this.developmentStore.getBaseUrl() + 'api/v1/upload-speed-test', data: uint8View, headers: { 'Content-Type': 'application/octet-stream', diff --git a/frontend/src/assets/poop-solid.svg b/frontend/src/assets/poop-solid.svg new file mode 100644 index 0000000..e38eabb --- /dev/null +++ b/frontend/src/assets/poop-solid.svg @@ -0,0 +1 @@ + diff --git a/src/main/java/de/w665/sharepulse/rest/mappings/Download.java b/src/main/java/de/w665/sharepulse/rest/mappings/Download.java index b534780..392d7e5 100644 --- a/src/main/java/de/w665/sharepulse/rest/mappings/Download.java +++ b/src/main/java/de/w665/sharepulse/rest/mappings/Download.java @@ -75,10 +75,13 @@ public class Download extends ApiRestController { public ResponseEntity getDownloadInfo(@RequestParam String fileId) { FileUpload fileUpload = fileService.getFileUploadByFileId(fileId); + boolean downloadable = !fileUpload.isSingleDownload() || fileUpload.getDownloadCount() == 0; + Map response = new HashMap<>(); response.put("fileId", fileUpload.getFileId()); response.put("passwordProtected", fileUpload.isPasswordProtected()); response.put("singleDownload", fileUpload.isSingleDownload()); + response.put("downloadable", downloadable); return new ResponseEntity<>(response, HttpStatus.OK); }