From f7a609517b11bc801fab5e16a6a06412f94e49e0 Mon Sep 17 00:00:00 2001 From: "florian.azizian" <florian.azizian@maarch.org> Date: Fri, 11 Oct 2019 14:47:30 +0100 Subject: [PATCH] FEAT #11875 TIME 2:15 rest for new scanToMaarch (old mcc) --- apps/maarch_entreprise/index.php | 2 ++ .../app/indexation/indexation.component.html | 2 +- .../app/indexation/indexation.component.ts | 9 +++++++- .../app/viewer/document-viewer.component.ts | 23 ++++++++++++++++++- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/apps/maarch_entreprise/index.php b/apps/maarch_entreprise/index.php index 45e63145a75..821fb2d4178 100755 --- a/apps/maarch_entreprise/index.php +++ b/apps/maarch_entreprise/index.php @@ -375,6 +375,8 @@ if (!empty($_REQUEST['page']) && empty($_REQUEST['triggerAngular'])) { ?><script>triggerAngular('#/activate-user')</script><?php } elseif ($cookie['userId'] == 'superadmin' && !empty($_REQUEST['administration'])) { ?><script>triggerAngular('#/administration')</script><?php + } elseif (!empty($_REQUEST['scanToMaarch']) && !empty($_REQUEST['tmpfilename'])) { + ?><script>triggerAngular('#/indexing/<?php echo $_REQUEST['scanToMaarch']?>?tmpfilename=<?php echo $_REQUEST['tmpfilename']?>')</script><?php } elseif (empty($_REQUEST['page'])) { ?> <script> diff --git a/src/frontend/app/indexation/indexation.component.html b/src/frontend/app/indexation/indexation.component.html index 1d5915985fe..f2c8e2326ec 100644 --- a/src/frontend/app/indexation/indexation.component.html +++ b/src/frontend/app/indexation/indexation.component.html @@ -86,7 +86,7 @@ style="align-items: center;justify-content: center;text-align: center;display: flex;">Choisissez votre fichier</button> </div>--> - <app-document-viewer #appDocumentViewer style="height:100%;width:100%;"></app-document-viewer> + <app-document-viewer #appDocumentViewer [tmpFilename]="tmpFilename" style="height:100%;width:100%;"></app-document-viewer> </div> </div> </mat-sidenav-content> diff --git a/src/frontend/app/indexation/indexation.component.ts b/src/frontend/app/indexation/indexation.component.ts index d47c9b8646e..d80f2c9e766 100644 --- a/src/frontend/app/indexation/indexation.component.ts +++ b/src/frontend/app/indexation/indexation.component.ts @@ -43,9 +43,11 @@ export class IndexationComponent implements OnInit { actionsList: any[] = []; selectedAction: any = {}; + tmpFilename: string = ''; constructor( private route: ActivatedRoute, + private _activatedRoute: ActivatedRoute, public http: HttpClient, public dialog: MatDialog, private headerService: HeaderService, @@ -53,7 +55,12 @@ export class IndexationComponent implements OnInit { private notify: NotificationService, public overlay: Overlay, public viewContainerRef: ViewContainerRef, - public appService: AppService) { } + public appService: AppService) { + + _activatedRoute.queryParams.subscribe( + params => this.tmpFilename = params.tmpfilename + ); + } ngOnInit(): void { this.loading = false; diff --git a/src/frontend/app/viewer/document-viewer.component.ts b/src/frontend/app/viewer/document-viewer.component.ts index a037af12817..04b53a4e67d 100644 --- a/src/frontend/app/viewer/document-viewer.component.ts +++ b/src/frontend/app/viewer/document-viewer.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input } from '@angular/core'; import { HttpClient, HttpEventType } from '@angular/common/http'; import { LANG } from '../translate.component'; import { NotificationService } from '../notification.service'; @@ -25,6 +25,8 @@ import { PDFProgressData } from 'ng2-pdf-viewer'; export class DocumentViewerComponent implements OnInit { + @Input('tmpFilename') tmpFilename: string; + lang: any = LANG; loading: boolean = false; @@ -82,6 +84,25 @@ export class DocumentViewerComponent implements OnInit { return of(false); }) ).subscribe(); + + if (this.tmpFilename != '') { + this.http.get('../../rest/convertedFile/'+this.tmpFilename).pipe( + tap((data: any) => { + this.file = { + name: this.tmpFilename, + type: 'application/pdf', + content: this.getBase64Document(this.base64ToArrayBuffer(data.encodedResource)), + src: this.base64ToArrayBuffer(data.encodedResource) + }; + this.noConvertedFound = false; + this.loading = false; + }), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); + }) + ).subscribe(); + } } uploadTrigger(fileInput: any) { -- GitLab