|
|
@@ -15,6 +15,7 @@ import { MatIconRegistry } from '@angular/material/icon';
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
|
import { DOCUMENT } from '@angular/common';
|
|
|
import { ControlPanelService } from 'src/app/services/control-panel.service';
|
|
|
+import { DocumentManagementService } from 'src/app/services/document-management/document-management.service';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-control-panel-view',
|
|
|
@@ -48,6 +49,7 @@ export class ControlPanelViewComponent implements OnInit {
|
|
|
private _matIconRegistry: MatIconRegistry,
|
|
|
private _domSanitizer: DomSanitizer,
|
|
|
private _controlPanelService: ControlPanelService,
|
|
|
+ private _documentManagementService: DocumentManagementService,
|
|
|
) {
|
|
|
this.isPreview = false;
|
|
|
this.controlPanel = null;
|
|
|
@@ -385,4 +387,35 @@ export class ControlPanelViewComponent implements OnInit {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async exportExcelData(module: string, indicator: string){
|
|
|
+ try{
|
|
|
+ this._resourcesService.openSnackBar('Generando archivo...');
|
|
|
+
|
|
|
+ let idUser = localStorage.getItem('idusuario')!;
|
|
|
+ let idModule = await this._encService.encrypt(module);
|
|
|
+ let indicatorEnc = await this._encService.encrypt(indicator);
|
|
|
+
|
|
|
+ let excelDoc = await lastValueFrom(this._controlPanelService.getInfoToExcel(indicatorEnc, idModule, idUser, 1));
|
|
|
+ let downloadToken = await lastValueFrom(this._documentManagementService.getDownloadToken(
|
|
|
+ excelDoc.response.report,
|
|
|
+ idUser,
|
|
|
+ 1
|
|
|
+ ));
|
|
|
+
|
|
|
+ let idFile = await this._encService.decrypt(excelDoc.response.report);
|
|
|
+ let download = this._document.getElementById('download') as HTMLAnchorElement;
|
|
|
+ download.href = `http://git.ittec.mx/sam/public/api/download-file/${downloadToken.response.TOKEN}/${idUser}/1`;
|
|
|
+ download.download = idFile;
|
|
|
+ download.click();
|
|
|
+ }catch(error: any){
|
|
|
+ if(error.error == undefined){
|
|
|
+ this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
+ }else if(error.error.msg == undefined){
|
|
|
+ this._resourcesService.openSnackBar('Ocurrió un error inesperado.');
|
|
|
+ }else{
|
|
|
+ this._resourcesService.openSnackBar(error.error.msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|