Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async convertFile() {
- if(this.f.bank.value.bankName === '' || this.f.tglAwalUjiTuntas.value ===''){
- console.log('bank tidak valid')
- return
- }else{
- const file = this.f.file.value[0];
- const dialogConfig = new MatDialogConfig();
- dialogConfig.disableClose = true;
- dialogConfig.data = {
- dialogTitle: 'Converting file',
- dialogText: 'Silahkan menunggu...',
- isLoading: true,
- };
- const dialogRef = this.dialog.open(DialogComponent, dialogConfig);
- const folderBank = this.f.bank.value.bankName.replaceAll(' ' , '-') + '-' + moment( this.f.tglAwalUjiTuntas.value).format('MM') + '-' + moment(this.f.tglAwalUjiTuntas.value).format('yy')
- let pathArray = []
- let fullPath : any = '';
- pathArray.push(folderBank);
- pathArray.push("Penugasan-uji-tuntas");
- pathArray.push("Upload-Files");
- let tempFile = [];
- tempFile.push(file);
- let resp = await this.fileService.generateFolder(pathArray,0,pathArray.length)
- resp.subscribe(
- async (res : any) => {
- await this.generateFile.state.subscribe(
- (fileRes : any) => {
- fullPath = fileRes
- if(fileRes.index == pathArray.length){
- this.fileService.convertFileBase64Try(tempFile , fullPath?.pathTo ).subscribe((res) => {
- if (res) {
- this.formModel = {
- fileContent: res.formModel.fileContent,
- filename: res.formModel.filename,
- fiturId: res.formModel.fiturId,
- folderPath: res.formModel.folderPath,
- fileSize: res.formModel.fileSize
- }
- dialogRef.close();
- }
- }, (error) => {
- dialogRef.close();
- const dialogConfigError = new MatDialogConfig();
- dialogConfigError.disableClose = true;
- dialogConfigError.data = {
- dialogTitle: 'Gagal Convert File',
- dialogText: error.error.detail,
- isLoading: false
- };
- const dialogErr = this.dialog.open(DialogInfoComponent, dialogConfigError);
- });
- }
- }
- )
- }
- )
- }
- }
Add Comment
Please, Sign In to add comment