2023-10-06 10:10:53 +02:00
|
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
2019-02-25 17:46:16 +01:00
|
|
|
import { Inject, Component } from '@angular/core';
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-dialog-confirmation-upload',
|
|
|
|
templateUrl: './dialog-confirmation-upload-profiles.component.html',
|
|
|
|
styleUrls: ['./dialog-confirmation-upload-profiles.component.scss']
|
|
|
|
})
|
2021-02-03 10:06:40 +01:00
|
|
|
export class DialogConfirmationUploadDatasetProfiles {
|
2019-02-25 17:46:16 +01:00
|
|
|
|
|
|
|
sizeError = false;
|
2021-02-03 10:06:40 +01:00
|
|
|
selectedFileName= "";
|
2019-02-25 17:46:16 +01:00
|
|
|
selectFile =false;
|
|
|
|
maxFileSize: number = 1048576;
|
|
|
|
|
|
|
|
constructor(
|
2021-02-03 10:06:40 +01:00
|
|
|
public dialogRef: MatDialogRef<DialogConfirmationUploadDatasetProfiles>,
|
2019-02-25 17:46:16 +01:00
|
|
|
@Inject(MAT_DIALOG_DATA) public data: any
|
|
|
|
) { }
|
|
|
|
|
|
|
|
|
|
|
|
selectXML(event) {
|
2021-03-31 17:31:57 +02:00
|
|
|
let file: FileList = null;
|
|
|
|
|
|
|
|
if(event.target && event.target.files){
|
|
|
|
file = event.target.files;
|
|
|
|
}else if(event.addedFiles && event.addedFiles.length){
|
|
|
|
file = event.addedFiles;
|
|
|
|
}
|
2021-02-03 10:06:40 +01:00
|
|
|
if(!file) return;//no select closed with cancel . no file selected
|
2019-02-25 17:46:16 +01:00
|
|
|
const size: number = file[0].size; // Get file size.
|
|
|
|
this.sizeError = size > this.maxFileSize; // Checks if file size is valid.
|
|
|
|
const formdata: FormData = new FormData();
|
|
|
|
if (!this.sizeError) {
|
|
|
|
this.data.file = file;
|
|
|
|
this.selectFile=true;
|
2021-02-03 10:06:40 +01:00
|
|
|
this.selectedFileName = file[0].name;
|
2019-02-25 17:46:16 +01:00
|
|
|
}
|
|
|
|
this.data.name = file[0].name;
|
|
|
|
}
|
|
|
|
|
|
|
|
cancel() {
|
|
|
|
this.data.sucsess = false;
|
|
|
|
this.dialogRef.close(this.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
confirm() {
|
|
|
|
this.data.sucsess = true;
|
|
|
|
this.dialogRef.close(this.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
hasProfile():boolean{
|
|
|
|
return (this.selectFile && !this.sizeError);
|
|
|
|
}
|
|
|
|
|
2021-02-03 10:06:40 +01:00
|
|
|
//remove selected file
|
|
|
|
onRemove(){
|
|
|
|
this.data.name="";
|
|
|
|
this.selectFile = false;
|
|
|
|
this.selectedFileName = "";
|
|
|
|
}
|
2019-02-25 17:46:16 +01:00
|
|
|
}
|