Added file details display
- Added password generator logic to backend - Added UI for file details
This commit is contained in:
@ -59,43 +59,51 @@
|
||||
|
||||
<h3 class="text-lg font-semibold mt-3">File uploaded successfully!</h3>
|
||||
|
||||
<div class="flex flex-wrap mt-5 mb-5">
|
||||
<div class="flex flex-wrap mt-5 mb-5" *ngIf="uploadData && fileUrls">
|
||||
<div class="w-full px-4">
|
||||
<div class="grid grid-cols-2 gap-4 items-center">
|
||||
<div class="text-gray-600 text-right">File Name:</div>
|
||||
<div>{{uploadData.fileName}}</div>
|
||||
|
||||
<div class="text-gray-600 text-right">Is password protected:</div>
|
||||
<label class="flex items-center space-x-2">
|
||||
<!-- Use property binding to set checked based on uploadData.passwordProtected -->
|
||||
<input type="checkbox" class="checkbox checkbox-primary" [checked]="uploadData.passwordProtected" (click)="$event.preventDefault()"/>
|
||||
<span>{{uploadData.passwordProtected ? 'Yes' : 'No'}}</span>
|
||||
</label>
|
||||
|
||||
<div class="text-gray-600 text-right">Is single download:</div>
|
||||
<label class="flex items-center space-x-2">
|
||||
<!-- Use property binding to set checked based on uploadData.singleDownload -->
|
||||
<input type="checkbox" class="checkbox checkbox-primary" [checked]="uploadData.singleDownload" (click)="$event.preventDefault()"/>
|
||||
<span>{{uploadData.singleDownload ? 'Yes' : 'No'}}</span>
|
||||
</label>
|
||||
|
||||
<div class="text-gray-600 text-right">Download Password:</div>
|
||||
<div>{{uploadData.password || 'N/A'}}</div>
|
||||
|
||||
<div class="text-gray-600 text-right">File ID:</div>
|
||||
<div>166554</div>
|
||||
<div>{{uploadData.fileId}}</div>
|
||||
|
||||
<div class="text-gray-600 text-right">Material:</div>
|
||||
<div>Aluminum & Plastic</div>
|
||||
<!-- Assuming you have properties for downloadURL and statusURL -->
|
||||
<div class="text-gray-600 text-right">Download URL:</div>
|
||||
<div><a href="{{fileUrls.downloadUrl}}" target="_blank">{{fileUrls.downloadUrl}}</a></div>
|
||||
|
||||
<div class="text-gray-600 text-right">Color:</div>
|
||||
<div>Black/Silver</div>
|
||||
|
||||
<div class="text-gray-600 text-right">Dimensions:</div>
|
||||
<div>15 x 15 x 25 cm</div>
|
||||
|
||||
<div class="text-gray-600 text-right">Weight:</div>
|
||||
<div>1.2 kg</div>
|
||||
|
||||
<div class="text-gray-600 text-right">Power:</div>
|
||||
<div>10W LED (included)</div>
|
||||
|
||||
<div class="text-gray-600 text-right">Brightness:</div>
|
||||
<div>700 lumens</div>
|
||||
|
||||
<div class="text-gray-600 text-right">Warranty:</div>
|
||||
<div>2 years</div>
|
||||
<div class="text-gray-600 text-right">File Status URL:</div>
|
||||
<div><a href="{{fileUrls.statusUrl}}" target="_blank">{{fileUrls.statusUrl}}</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<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">
|
||||
<button class="btn btn-primary w-full max-w-xs">Upload Another File</button>
|
||||
<button class="btn btn-outline btn-secondary mt-2 w-full max-w-xs">Download a file</button>
|
||||
<button class="btn btn-success w-full max-w-xs text-white">Copy URL</button>
|
||||
<button class="btn btn-primary mt-2 w-full max-w-xs">Upload Another File</button>
|
||||
<button class="btn btn-outline btn-secondary mt-2 w-full max-w-xs">Delete this file</button>
|
||||
</div>
|
||||
<a href="#" class="link link-primary mt-4">Manage your uploads</a>
|
||||
</div>
|
||||
|
@ -27,7 +27,6 @@ export class UploadComponent {
|
||||
singleDownload: boolean = false;
|
||||
fileDescription: string = '';
|
||||
passwordProtected: boolean = false;
|
||||
password: string = ''; // Generated by the server for only this file
|
||||
|
||||
uploadStarted: boolean = false;
|
||||
uploadProgress = 0; // Real progress
|
||||
@ -35,6 +34,8 @@ export class UploadComponent {
|
||||
uploadFinished = false;
|
||||
uploadSpeedBps: number = 0;
|
||||
|
||||
uploadData: FileDetails | null = null;
|
||||
fileUrls: { downloadUrl: string, statusUrl: string, deleteUrl: string } | null = null;
|
||||
|
||||
|
||||
constructor(private developmentStore: DevelopmentStore) {
|
||||
@ -98,6 +99,8 @@ export class UploadComponent {
|
||||
.then(response => {
|
||||
console.log('Upload completed successfully!');
|
||||
console.log(response.data);
|
||||
this.fileUrls = this.buildFileUrls(response.data);
|
||||
this.uploadData = response.data;
|
||||
this.uploadFinished = true;
|
||||
})
|
||||
.catch(error => {
|
||||
@ -106,13 +109,26 @@ export class UploadComponent {
|
||||
}
|
||||
}
|
||||
|
||||
buildFileUrls(fileDetails: FileDetails) {
|
||||
const baseUrl = this.developmentStore.getBaseUrl();
|
||||
const fileId = fileDetails.fileId;
|
||||
const downloadUrl = `${baseUrl}download?fileId=${fileId}`;
|
||||
const deleteUrl = `${baseUrl}api/v1/deletefile?fileId=${fileId}`;
|
||||
const statusUrl = `${baseUrl}status?fileId=${fileId}`;
|
||||
return {
|
||||
downloadUrl,
|
||||
statusUrl,
|
||||
deleteUrl,
|
||||
}; }
|
||||
|
||||
buildFormDataObject(): FormData {
|
||||
const formData = new FormData();
|
||||
formData.append('file', this.fileToUpload as Blob);
|
||||
formData.append('password', this.passwordProtected ? this.password : '');
|
||||
formData.append('passwordProtected', this.passwordProtected ? 'true' : 'false');
|
||||
formData.append('singleDownload', this.singleDownload.toString());
|
||||
formData.append('shortStorage', this.shortStorage.toString());
|
||||
formData.append('fileDescription', this.fileDescription);
|
||||
console.log(formData.get("passwordProtected"));
|
||||
return formData;
|
||||
}
|
||||
|
||||
@ -169,3 +185,12 @@ export class UploadComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
interface FileDetails {
|
||||
fileId: string;
|
||||
fileName: string;
|
||||
message: string;
|
||||
passwordProtected: boolean;
|
||||
singleDownload: boolean;
|
||||
uploadDate: string;
|
||||
password: string;
|
||||
}
|
||||
|
Reference in New Issue
Block a user