|
|
@@ -33,6 +33,7 @@ export class GDELComponent implements AfterViewInit, OnInit {
|
|
|
public dataSource: MatTableDataSource<any>;
|
|
|
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
|
|
@ViewChild(MatSort) sort!: MatSort;
|
|
|
+ @ViewChild('download') a?: ElementRef;
|
|
|
|
|
|
public isLoading: boolean;
|
|
|
public isLoadingForm: boolean;
|
|
|
@@ -41,6 +42,7 @@ export class GDELComponent implements AfterViewInit, OnInit {
|
|
|
public ulOptSmall: boolean;
|
|
|
public txtBuscador: string;
|
|
|
public clickedIndex: any = 0;
|
|
|
+ public downloadLink: String;
|
|
|
public options = [
|
|
|
{
|
|
|
id: 1,
|
|
|
@@ -65,7 +67,6 @@ export class GDELComponent implements AfterViewInit, OnInit {
|
|
|
private _dialog: MatDialog,
|
|
|
private _router: Router,
|
|
|
public dialog: MatDialog,
|
|
|
- private _documentManagement: DocumentManagementService,
|
|
|
private _gdelService: GdelService,
|
|
|
private _snackBar: MatSnackBar
|
|
|
) {
|
|
|
@@ -85,6 +86,7 @@ export class GDELComponent implements AfterViewInit, OnInit {
|
|
|
this.btnSmall = false;
|
|
|
this.ulOptSmall = false;
|
|
|
this.txtBuscador = '';
|
|
|
+ this.downloadLink = '';
|
|
|
}
|
|
|
|
|
|
ngOnInit(): void {
|
|
|
@@ -132,25 +134,39 @@ export class GDELComponent implements AfterViewInit, OnInit {
|
|
|
let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idEnc));
|
|
|
|
|
|
let documents: any = await lastValueFrom(
|
|
|
- this._gdelService.getDocumentsByUser(
|
|
|
- shortEnc.response.encrypted,
|
|
|
- 1
|
|
|
- )
|
|
|
+ this._gdelService.getDocumentsByUser(shortEnc.response.encrypted, 1)
|
|
|
);
|
|
|
|
|
|
if (documents.error) {
|
|
|
this.openSnackBar(documents.msg);
|
|
|
} else {
|
|
|
for (let index = 0; index < documents.response.length; index++) {
|
|
|
+ let codeSAM =
|
|
|
+ documents.response[index].NUMERO_LINEA +
|
|
|
+ '-' +
|
|
|
+ documents.response[index].MODULO +
|
|
|
+ '-' +
|
|
|
+ documents.response[index].CLASIFICACION +
|
|
|
+ '-' +
|
|
|
+ documents.response[index].FECHA_REGISTRO +
|
|
|
+ '-' +
|
|
|
+ documents.response[index].SECUENCIAL +
|
|
|
+ '=' +
|
|
|
+ documents.response[index].VERSION +
|
|
|
+ '=' +
|
|
|
+ documents.response[index].NOMBRE_ARC +
|
|
|
+ '.' +
|
|
|
+ documents.response[index].EXTENSION;
|
|
|
+ let encript = await this._encService.encriptar(codeSAM);
|
|
|
+ let short = await lastValueFrom(this._encService.shortEncrypt(encript));
|
|
|
+ documents.response[index].ID = short.response.encrypted;
|
|
|
documents.response[index].TAMANIO = this.formatBytes(
|
|
|
documents.response[index].TAMANIO
|
|
|
);
|
|
|
}
|
|
|
this.dataSource.data = documents.response;
|
|
|
this.isLoading = false;
|
|
|
-
|
|
|
}
|
|
|
- console.log(documents);
|
|
|
}
|
|
|
|
|
|
async modifyDocument(idDocument: number) {
|
|
|
@@ -183,25 +199,7 @@ export class GDELComponent implements AfterViewInit, OnInit {
|
|
|
this.ulOptSmall = window.innerWidth <= 1405;
|
|
|
}
|
|
|
|
|
|
- selectTab(index: number) {
|
|
|
- this.active = index;
|
|
|
- console.log(index);
|
|
|
-
|
|
|
- switch (index) {
|
|
|
- case 0:
|
|
|
- this.getDocuments();
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- this.getShareDocuments();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public openViewer(url: string) {
|
|
|
+ public openViewer(url: string) {
|
|
|
let dialogRef: any;
|
|
|
let fileData = {
|
|
|
url: url,
|
|
|
@@ -257,31 +255,36 @@ export class GDELComponent implements AfterViewInit, OnInit {
|
|
|
}
|
|
|
|
|
|
// Funcion para descargar archivos
|
|
|
- async downloadFile(idFile: string) {
|
|
|
- console.log('descargar archivo');
|
|
|
-
|
|
|
- /* try{
|
|
|
- let shortAvi = await lastValueFrom(this._encService.shortEncrypt(idFile));
|
|
|
+ async downloadFile(idFile: any) {
|
|
|
+ try {
|
|
|
let idEnc = localStorage.getItem('idusuario');
|
|
|
let shortEnc = await lastValueFrom(this._encService.shortEncrypt(idEnc!));
|
|
|
|
|
|
- let downloadToken = await lastValueFrom(this._advicesService.getDownloadToken(shortAvi.response.encrypted, shortEnc.response.encrypted, 1));
|
|
|
- //this.downloadLink = "http://git.ittec.mx/sam/public/api/download-file///1";
|
|
|
- this.downloadLink = `http://git.ittec.mx/sam/public/api/download-file/${downloadToken.response.TOKEN}/${shortEnc.response.encrypted}/1`;
|
|
|
- console.log(this.downloadLink);
|
|
|
+ let downloadToken = await lastValueFrom(
|
|
|
+ this._gdelService.getDownloadToken(
|
|
|
+ idFile,
|
|
|
+ shortEnc.response.encrypted,
|
|
|
+ 1
|
|
|
+ )
|
|
|
+ );
|
|
|
+ //this.downloadL ink = "http://git.ittec.mx/sam/public/api/download-file///1";
|
|
|
+ //this.downloadLink = `http://git.ittec.mx/sam/public/api/download-file/${downloadToken.response.TOKEN}/${shortEnc.response.encrypted}/1`;
|
|
|
+ this.downloadLink = `http://192.168.1.2:8000/api/download-file/${downloadToken.response.TOKEN}/${shortEnc.response.encrypted}/1`;
|
|
|
+ console.log(this.downloadLink );
|
|
|
+
|
|
|
this.a?.nativeElement.click();
|
|
|
- }catch(error: any){
|
|
|
+ } catch (error: any) {
|
|
|
let msg = '';
|
|
|
- if(error.error == undefined){
|
|
|
+ if (error.error == undefined) {
|
|
|
msg = 'Ocurrió un error inesperado.';
|
|
|
- }else if(error.error.msg == undefined){
|
|
|
+ } else if (error.error.msg == undefined) {
|
|
|
msg = 'Ocurrió un error inesperado.';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
msg = error.error.msg;
|
|
|
}
|
|
|
|
|
|
this.openSnackBar(msg);
|
|
|
- } */
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public goBack(steps: number) {
|
|
|
@@ -305,4 +308,35 @@ export class GDELComponent implements AfterViewInit, OnInit {
|
|
|
duration: 2500,
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ selectTab(index: number) {
|
|
|
+ this.active = index;
|
|
|
+ switch (index) {
|
|
|
+ case 0:
|
|
|
+ this.getDocuments();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ this.getShareDocuments();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ refreshDocuments() {
|
|
|
+ switch (this.active) {
|
|
|
+ case 0:
|
|
|
+ this.getDocuments();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ this.getShareDocuments();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|