Added password field

- Added download error modal
- Added password field show logic
- Redesigned UI
This commit is contained in:
2024-02-17 00:14:43 +01:00
parent 374d4dc40d
commit f30961f1f0
5 changed files with 83 additions and 22 deletions

View File

@ -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<HTMLDialogElement> | 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;
}