diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts index 3ae7de0aeaa164ce92dcf7cc5afb2690945e3f24..acc522961a1e73e8dc3df0cc4cb4817682c42eae 100644 --- a/src/frontend/app/document/document.component.ts +++ b/src/frontend/app/document/document.component.ts @@ -18,6 +18,7 @@ import { import { SignaturesComponent } from '../signatures/signatures.component'; import { ActivatedRoute } from '@angular/router'; import { HttpClient } from '@angular/common/http'; +import { connectableObservableDescriptor } from 'rxjs/internal/observable/ConnectableObservable'; @Component({ selector: 'app-document', @@ -81,6 +82,7 @@ export class DocumentComponent implements OnInit { }); this.pdfRender(this.docList[this.currentDoc]); this.context = (<HTMLCanvasElement>this.canvas.nativeElement).getContext('2d'); + this.loadNextDoc(); }, () => { console.log('error !'); }); @@ -92,6 +94,7 @@ export class DocumentComponent implements OnInit { }); } + pdfRender(document: any) { const pdfData = atob(document.document); @@ -164,17 +167,8 @@ export class DocumentComponent implements OnInit { this.signaturesService.isTaggable = false; this.pageNum = 1; this.currentDoc++; - if (this.docList[this.currentDoc].document.length === 0) { - this.http.get('../rest/attachments/' + this.docList[this.currentDoc].id) - .subscribe((data: any) => { - this.docList[this.currentDoc] = data.attachment; - this.pdfRender(this.docList[this.currentDoc]); - }, () => { - console.log('error !'); - }); - } else { - this.pdfRender(this.docList[this.currentDoc]); - } + this.pdfRender(this.docList[this.currentDoc]); + this.loadNextDoc(); } prevDoc() { @@ -360,6 +354,24 @@ export class DocumentComponent implements OnInit { } }); } + + loadNextDoc () { + if (this.docList[this.currentDoc + 1] && this.docList[this.currentDoc + 1].id && this.docList[this.currentDoc + 1].document === '') { + this.http.get('../rest/attachments/' + this.docList[this.currentDoc + 1].id) + .subscribe((dataPj: any) => { + this.docList[this.currentDoc + 1] = dataPj.attachment; + this.snackBar.open('Pièce jointe chargé', null, + { + duration: 3000, + panelClass: 'center-snackbar', + verticalPosition: 'top' + } + ); + }, () => { + console.log('error !'); + }); + } + } } @Component({ diff --git a/tslint.json b/tslint.json index 3ea984c776ef691c92b37ddf933df452cdc3d8bc..caee1cd679ec8dded34a5b1406c7c62bb4cbc43d 100644 --- a/tslint.json +++ b/tslint.json @@ -28,7 +28,7 @@ "interface-over-type-literal": true, "label-position": true, "max-line-length": [ - true, + false, 140 ], "member-access": false,