Skip to content
Snippets Groups Projects
Commit d0a03fda authored by bationo's avatar bationo
Browse files

FIX #20777

parent dd1d7cb1
No related branches found
No related tags found
No related merge requests found
...@@ -27,5 +27,5 @@ ...@@ -27,5 +27,5 @@
<link rel="stylesheet" href="styles.8b6195db994dd1043497.css"></head> <link rel="stylesheet" href="styles.8b6195db994dd1043497.css"></head>
<body> <body>
<app-root></app-root> <app-root></app-root>
<script src="runtime-es2015.6d764e26596b8259b2e2.js" type="module"></script><script src="runtime-es5.6d764e26596b8259b2e2.js" nomodule defer></script><script src="polyfills-es5.016de5c7b74a5782d968.js" nomodule defer></script><script src="polyfills-es2015.61606da6d5867aea9335.js" type="module"></script><script src="scripts.839aa34c61ed64fb6304.js" defer></script><script src="main-es2015.352b1c80033996869ed1.js" type="module"></script><script src="main-es5.352b1c80033996869ed1.js" nomodule defer></script></body> <script src="runtime-es2015.6d764e26596b8259b2e2.js" type="module"></script><script src="runtime-es5.6d764e26596b8259b2e2.js" nomodule defer></script><script src="polyfills-es5.016de5c7b74a5782d968.js" nomodule defer></script><script src="polyfills-es2015.61606da6d5867aea9335.js" type="module"></script><script src="scripts.839aa34c61ed64fb6304.js" defer></script><script src="main-es2015.4c2291da5c99d669341e.js" type="module"></script><script src="main-es5.4c2291da5c99d669341e.js" nomodule defer></script></body>
</html> </html>
...@@ -631,6 +631,7 @@ ...@@ -631,6 +631,7 @@
"originaleize": "Original size", "originaleize": "Original size",
"scalingDocWith": "{{value}} % of document width", "scalingDocWith": "{{value}} % of document width",
"azure_samlConnection": "Azure SAML", "azure_samlConnection": "Azure SAML",
"errorConvertingDocument": "Error converting document",
"cannotSetSignature": "You cannot pre-position a signature for a user with the annotator role", "cannotSetSignature": "You cannot pre-position a signature for a user with the annotator role",
"resumeOriginalDoc": "Warning ! The return document action will use the original document", "resumeOriginalDoc": "Warning ! The return document action will use the original document",
"emptyUsers": "No users available to associate", "emptyUsers": "No users available to associate",
......
...@@ -626,6 +626,7 @@ ...@@ -626,6 +626,7 @@
"originaleize": "Taille originale", "originaleize": "Taille originale",
"scalingDocWith": "{{value}} % de la largeur du document", "scalingDocWith": "{{value}} % de la largeur du document",
"azure_samlConnection": "Azure SAML", "azure_samlConnection": "Azure SAML",
"errorConvertingDocument": "Erreur lors de la conversion du document",
"cannotSetSignature": "Vous ne pouvez pas pré-positionner une signature pour un utilisateur avec le rôle annotateur", "cannotSetSignature": "Vous ne pouvez pas pré-positionner une signature pour un utilisateur avec le rôle annotateur",
"resumeOriginalDoc": "Attention ! L'action renvoi de document reprend le document original", "resumeOriginalDoc": "Attention ! L'action renvoi de document reprend le document original",
"emptyUsers": "Aucun utilisateur disponible à associer", "emptyUsers": "Aucun utilisateur disponible à associer",
......
...@@ -44,8 +44,14 @@ ...@@ -44,8 +44,14 @@
*ngIf="authService.user.substitute !== null && docList[currentDoc]"> *ngIf="authService.user.substitute !== null && docList[currentDoc]">
<ion-label style="font-size: 13px;">{{'lang.substitutionInfo' | translate}}</ion-label> <ion-label style="font-size: 13px;">{{'lang.substitutionInfo' | translate}}</ion-label>
</ion-toolbar> </ion-toolbar>
<ion-toolbar class="ion-text-center" color="danger" *ngIf="mainDocument.id !== 0 && mainDocument.status !== 'READY'"> <ion-toolbar class="ion-text-center" color="danger" *ngIf="mainDocument.id !== 0 && mainDocument.status === 'CONVERTING'">
<ion-label style="font-size: 13px;">{{'lang.convertingDocument' | translate}}</ion-label> <div class="loading" style="display:flex;height:100%;">
<ion-label class="loadingMsg">{{'lang.convertingDocument' | translate}}</ion-label>
<ion-spinner name="dots" color="light" style="padding-top: 6.5%;"></ion-spinner>
</div>
</ion-toolbar>
<ion-toolbar class="ion-text-center" color="danger" *ngIf="mainDocument.id !== 0 && mainDocument.status === 'ERROR'">
<ion-label style="font-size: 14px; font-weight: bold;">{{'lang.errorConvertingDocument' | translate}}</ion-label>
</ion-toolbar> </ion-toolbar>
<ion-content *ngIf="!loadingdocument" #mainContent> <ion-content *ngIf="!loadingdocument" #mainContent>
<ng-container *ngIf="(mainDocument.notes !== undefined && mainDocument.notes !== null) || hasWorkflowNotes"> <ng-container *ngIf="(mainDocument.notes !== undefined && mainDocument.notes !== null) || hasWorkflowNotes">
...@@ -134,7 +140,7 @@ ...@@ -134,7 +140,7 @@
</ion-content> </ion-content>
<ion-footer *ngIf="!loadingImage && currentDoc === 0" class="ion-no-border footer-buttons" [ngStyle]="{'grid-template-columns': actionsList.length === 2 ? 'repeat(2, 1fr)' : 'repeat(3, 1fr)'}"> <ion-footer *ngIf="!loadingImage && currentDoc === 0" class="ion-no-border footer-buttons" [ngStyle]="{'grid-template-columns': actionsList.length === 2 ? 'repeat(2, 1fr)' : 'repeat(3, 1fr)'}">
<ion-button [disabled]="mainDocument.status === 'CONVERTING'" *ngFor="let action of actionsList" [color]="action.color" shape="round" size="large" fill="outline" (click)="launchEvent(action)"> <ion-button [disabled]="isNotReady()" *ngFor="let action of actionsList" [color]="action.color" shape="round" size="large" fill="outline" (click)="launchEvent(action)">
<ion-icon *ngIf="action.logo !== ''" [slot]="'start'" [name]="action.logo"></ion-icon> <ion-icon *ngIf="action.logo !== ''" [slot]="'start'" [name]="action.logo"></ion-icon>
<ion-label style="font-size: 13px;">{{action.label | translate}}</ion-label> <ion-label style="font-size: 13px;">{{action.label | translate}}</ion-label>
</ion-button> </ion-button>
......
...@@ -407,3 +407,22 @@ button.disabled { ...@@ -407,3 +407,22 @@ button.disabled {
top: 50px; top: 50px;
} }
} }
.loading {
display: flex;
position: absolute;
justify-content: center;
top: 0;
left: 0px;
width: 100%;
height: 100%;
z-index: 2;
overflow: hidden;
}
.loadingMsg {
padding: 2%;
color: var(--ion-color-light);
font-weight: bold;
margin-right: -5px;
}
\ No newline at end of file
import { Component, OnInit, ViewChild, TemplateRef, ViewContainerRef, Injectable } from '@angular/core'; import { Component, OnInit, ViewChild, TemplateRef, ViewContainerRef, Injectable, OnDestroy } from '@angular/core';
import { SignaturesContentService } from '../service/signatures.service'; import { SignaturesContentService } from '../service/signatures.service';
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
import { MatBottomSheet, MatBottomSheetConfig } from '@angular/material/bottom-sheet'; import { MatBottomSheet, MatBottomSheetConfig } from '@angular/material/bottom-sheet';
...@@ -17,8 +17,8 @@ import { AuthService } from '../service/auth.service'; ...@@ -17,8 +17,8 @@ import { AuthService } from '../service/auth.service';
import { LocalStorageService } from '../service/local-storage.service'; import { LocalStorageService } from '../service/local-storage.service';
import { ActionSheetController, AlertController, LoadingController, MenuController, ModalController, NavController } from '@ionic/angular'; import { ActionSheetController, AlertController, LoadingController, MenuController, ModalController, NavController } from '@ionic/angular';
import { NgxExtendedPdfViewerService } from 'ngx-extended-pdf-viewer'; import { NgxExtendedPdfViewerService } from 'ngx-extended-pdf-viewer';
import { catchError, exhaustMap, tap } from 'rxjs/operators'; import { catchError, exhaustMap, tap, switchMap, map } from 'rxjs/operators';
import { of } from 'rxjs'; import { of, interval, Subscription, timer } from 'rxjs';
import { SignatureMethodService } from '../service/signature-method/signature-method.service'; import { SignatureMethodService } from '../service/signature-method/signature-method.service';
import { FunctionsService } from '../service/functions.service'; import { FunctionsService } from '../service/functions.service';
import { ActionsService } from '../service/actions.service'; import { ActionsService } from '../service/actions.service';
...@@ -31,7 +31,7 @@ import { SuccessInfoValidBottomSheetComponent } from '../modal/success-info-vali ...@@ -31,7 +31,7 @@ import { SuccessInfoValidBottomSheetComponent } from '../modal/success-info-vali
}) })
export class DocumentComponent implements OnInit { export class DocumentComponent implements OnInit, OnDestroy {
@ViewChild('mainContent') mainContent: any; @ViewChild('mainContent') mainContent: any;
@ViewChild('img') img: any; @ViewChild('img') img: any;
...@@ -106,6 +106,7 @@ export class DocumentComponent implements OnInit { ...@@ -106,6 +106,7 @@ export class DocumentComponent implements OnInit {
userMode: string = ''; userMode: string = '';
userDelegated: boolean = false; userDelegated: boolean = false;
timerSubscription: Subscription;
constructor(private translate: TranslateService, constructor(private translate: TranslateService,
private router: Router, private router: Router,
...@@ -140,7 +141,9 @@ export class DocumentComponent implements OnInit { ...@@ -140,7 +141,9 @@ export class DocumentComponent implements OnInit {
this.actionsList = this.actionsList.filter((item: any) => item.event !== 'openSignatures'); this.actionsList = this.actionsList.filter((item: any) => item.event !== 'openSignatures');
} }
this.getImageDimensions(true); this.getImageDimensions(true);
this.load.dismiss(); if (this.mainDocument.status !== 'CONVERTING') {
this.load.dismiss();
}
this.menu.enable(true, 'right-menu'); this.menu.enable(true, 'right-menu');
this.loadingImage = false; this.loadingImage = false;
document.getElementsByClassName('drag-scroll-content')[0].scrollTop = 0; document.getElementsByClassName('drag-scroll-content')[0].scrollTop = 0;
...@@ -414,6 +417,29 @@ export class DocumentComponent implements OnInit { ...@@ -414,6 +417,29 @@ export class DocumentComponent implements OnInit {
// this.renderPdf(); // this.renderPdf();
this.renderImage(); this.renderImage();
this.loadingdocument = false; this.loadingdocument = false;
this.load.dismiss();
if (this.mainDocument.status === 'CONVERTING') {
// timer(0, 10000) call the function immediately and every 10 seconds
this.timerSubscription = timer(0, 10000).pipe(
tap(() => {
this.http.get('../rest/documents/' + params['id']).pipe(
tap((res: any) => {
this.totalPages = res.document.pages;
if (res.document.status !== 'CONVERTING') {
this.mainDocument.status = res.document.status;
this.timerSubscription?.unsubscribe();
}
})
).subscribe();
}),
catchError((err: any) => {
this.load.dismiss();
this.notificationService.handleErrors(err);
return of(false);
})
).subscribe();
}
}), }),
catchError((err: any) => { catchError((err: any) => {
console.log('error', err); console.log('error', err);
...@@ -430,6 +456,10 @@ export class DocumentComponent implements OnInit { ...@@ -430,6 +456,10 @@ export class DocumentComponent implements OnInit {
}); });
} }
ngOnDestroy(): void {
this.timerSubscription?.unsubscribe();
}
checkSubstitute(currentUser: any) { checkSubstitute(currentUser: any) {
if (!this.functionsService.empty(currentUser)) { if (!this.functionsService.empty(currentUser)) {
return new Promise((resolve) => { return new Promise((resolve) => {
...@@ -874,5 +904,8 @@ export class DocumentComponent implements OnInit { ...@@ -874,5 +904,8 @@ export class DocumentComponent implements OnInit {
} }
return res.buffer; return res.buffer;
} }
isNotReady() {
return ['CONVERTING', 'ERROR'].indexOf(this.mainDocument.status) > -1;
}
} }
...@@ -290,33 +290,43 @@ export class IndexationComponent implements OnInit { ...@@ -290,33 +290,43 @@ export class IndexationComponent implements OnInit {
} }
uploadTrigger(fileInput: any) { uploadTrigger(fileInput: any) {
if (fileInput.target.files && fileInput.target.files[0] && this.isExtensionAllowed(fileInput.target.files)) { this.loadingController.create({
for (let index = 0; index < fileInput.target.files.length; index++) { message: this.translate.instant('lang.loadingDocument'),
const filename = fileInput.target.files[index].name; spinner: 'dots'
const file = { }).then(async (load: HTMLIonLoadingElement) => {
title: filename.substr(0, filename.lastIndexOf('.')), load.present();
reference: filename.substr(0, filename.lastIndexOf('.')).substr(0, 53), if (fileInput.target.files && fileInput.target.files[0] && this.isExtensionAllowed(fileInput.target.files)) {
mainDocument: true, for (let index = 0; index < fileInput.target.files.length; index++) {
content: '' const filename = fileInput.target.files[index].name;
}; const file = {
const reader = new FileReader(); title: filename.substr(0, filename.lastIndexOf('.')),
reader.readAsArrayBuffer(fileInput.target.files[index]); reference: filename.substr(0, filename.lastIndexOf('.')).substr(0, 53),
reader.onload = (value: any) => { mainDocument: true,
file.mainDocument = this.filesToUpload.length === 0; content: ''
file.reference = this.filesToUpload.length === 0 ? file.reference : ''; };
file.content = this.getBase64Document(value.target.result); const reader = new FileReader();
this.filesToUpload.push(file); reader.readAsArrayBuffer(fileInput.target.files[index]);
if (this.filesToUpload.length === 1) { reader.onload = (value: any) => {
setTimeout(() => { file.mainDocument = this.filesToUpload.length === 0;
this.menu.open('right-menu'); file.reference = this.filesToUpload.length === 0 ? file.reference : '';
}, 500); file.content = this.getBase64Document(value.target.result);
this.filesToUpload.push(file);
if (this.filesToUpload.length === 1) {
setTimeout(() => {
this.menu.open('right-menu');
}, 500);
}
};
if (index === fileInput.target.files.length - 1) {
load.dismiss();
} }
}; }
this.fileImport.nativeElement.value = '';
} else {
this.loading = false;
load.dismiss();
} }
this.fileImport.nativeElement.value = ''; });
} else {
this.loading = false;
}
} }
isExtensionAllowed(files: any[]) { isExtensionAllowed(files: any[]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment