|
|
@@ -217,11 +217,35 @@ export class ExtractMaintenancePlanComponent implements OnInit {
|
|
|
|
|
|
async getFileToMSProject(idOrder: number){
|
|
|
try{
|
|
|
+ this.openSnackBar('Generando PDF...');
|
|
|
+ this.extractEnabled = false;
|
|
|
+
|
|
|
let idUser = localStorage.getItem('idusuario');
|
|
|
let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idUser!));
|
|
|
let idOrderEnc = await this._encService.encrypt(`${idOrder}`);
|
|
|
let idOrderShort = await lastValueFrom(this._encService.shortEncrypt(idOrderEnc));
|
|
|
- console.log(idOrderShort);
|
|
|
+
|
|
|
+ let projectFile = await lastValueFrom(this._prevMaintService.getFileToMSProject(
|
|
|
+ idOrderShort.response.encrypted,
|
|
|
+ shortEnc.response.encrypted,
|
|
|
+ 1
|
|
|
+ ));
|
|
|
+
|
|
|
+ let idFileEnc = await this._encService.encrypt(projectFile.response.fileID);
|
|
|
+ let idFileShort = await lastValueFrom(this._encService.shortEncrypt(idFileEnc));
|
|
|
+ let download = this._document.getElementById(`download`) as HTMLAnchorElement;
|
|
|
+
|
|
|
+ let downloadToken = await lastValueFrom(this._docManageService.getDownloadToken(
|
|
|
+ idFileShort.response.encrypted,
|
|
|
+ shortEnc.response.encrypted,
|
|
|
+ 1
|
|
|
+ ));
|
|
|
+
|
|
|
+ download.href = `http://git.ittec.mx/sam/public/api/download-file/${downloadToken.response.TOKEN}/${shortEnc.response.encrypted}/1`;
|
|
|
+ download.download = projectFile.response.fileID;
|
|
|
+ download.click();
|
|
|
+
|
|
|
+ this.extractEnabled = true;
|
|
|
}catch(error: any){
|
|
|
if(error.error == undefined){
|
|
|
this.openSnackBar('Ocurrió un error inesperado.');
|
|
|
@@ -230,6 +254,8 @@ export class ExtractMaintenancePlanComponent implements OnInit {
|
|
|
}else{
|
|
|
this.openSnackBar(error.error.msg);
|
|
|
}
|
|
|
+
|
|
|
+ this.extractEnabled = true;
|
|
|
}
|
|
|
}
|
|
|
}
|