Commit a02ef958 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #20778 TIME 0:35 add a wait time for documents being converted + loader

parent 268caac4
......@@ -649,6 +649,7 @@
"licence": "GNU GPLv3 license",
"groupsToManage": "Choose the authorized assignment groups",
"unlinkGroup": "Unlink group",
"emptyGroups": "No groups available to associate"
"emptyGroups": "No groups available to associate",
"errorConvertingDocument": "Error converting document"
}
}
\ No newline at end of file
......@@ -648,6 +648,7 @@
"licence": "licence GNU GPLv3",
"groupsToManage": "Choisir les groupes d'affectations autorisés",
"unlinkGroup": "Dissocier le groupe",
"emptyGroups": "Aucun groupe disponible à associer"
"emptyGroups": "Aucun groupe disponible à associer",
"errorConvertingDocument": "Erreur lors de la conversion du document"
}
}
......@@ -44,9 +44,12 @@
*ngIf="authService.user.substitute !== null && docList[currentDoc]">
<ion-label style="font-size: 13px;">{{'lang.substitutionInfo' | translate}}</ion-label>
</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>
</ion-toolbar>
<ion-toolbar class="ion-text-center" color="danger" *ngIf="mainDocument.id !== 0 && mainDocument.status === 'ERROR'">
<ion-label style="font-size: 13px;">{{'lang.errorConvertingDocument' | translate}}</ion-label>
</ion-toolbar>
<ion-content *ngIf="!loadingdocument" #mainContent>
<ng-container *ngIf="(mainDocument.notes !== undefined && mainDocument.notes !== null) || hasWorkflowNotes">
<ion-fab-button *ngIf="!expandedNote" ngDraggable [bounds]="myBounds" [inBounds]="true"
......@@ -134,7 +137,7 @@
</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-button [disabled]="mainDocument.status === 'CONVERTING'" *ngFor="let action of actionsList" [color]="action.color" shape="round" size="large" fill="outline" (click)="launchEvent(action)" style="width: auto;">
<ion-button [disabled]="isNotReady()" *ngFor="let action of actionsList" [color]="action.color" shape="round" size="large" fill="outline" (click)="launchEvent(action)" style="width: auto;">
<ion-icon *ngIf="action.logo !== ''" [slot]="'start'" [name]="action.logo"></ion-icon>
<ion-label style="font-size: 13px;">{{getLabel(action)}}</ion-label>
</ion-button>
......
......@@ -398,7 +398,7 @@ button.disabled {
.popover-content{
height: 50%;
top: 50px;
}
}
}
::ng-deep .custom-popover-class {
......@@ -407,3 +407,7 @@ button.disabled {
top: 50px;
}
}
::ng-deep.popover-viewport.sc-ion-popover-md {
overflow: auto;
}
......@@ -18,7 +18,7 @@ import { LocalStorageService } from '../service/local-storage.service';
import { ActionSheetController, AlertController, LoadingController, MenuController, ModalController, NavController } from '@ionic/angular';
import { NgxExtendedPdfViewerService } from 'ngx-extended-pdf-viewer';
import { catchError, exhaustMap, tap } from 'rxjs/operators';
import { of, Subscription } from 'rxjs';
import { of, Subscription, timer } from 'rxjs';
import { SignatureMethodService } from '../service/signature-method/signature-method.service';
import { FunctionsService } from '../service/functions.service';
import { ActionsService } from '../service/actions.service';
......@@ -74,6 +74,7 @@ export class DocumentComponent implements OnInit, OnDestroy {
};
subscription: Subscription;
timerSubscription: Subscription;
signaturesContent: any = [];
docList: any = [];
......@@ -135,17 +136,15 @@ export class DocumentComponent implements OnInit, OnDestroy {
});
}
ngOnDestroy(): void {
this.subscription.unsubscribe();
}
imageLoaded(ev: any) {
this.userMode = this.mainDocument.workflow.find((item: any) => item.current)?.mode;
if (this.userMode === 'note') {
this.actionsList = this.actionsList.filter((item: any) => item.event !== 'openSignatures');
}
this.getImageDimensions(true);
this.load.dismiss();
if (this.mainDocument.status !== 'CONVERTING') {
this.load.dismiss();
}
this.menu.enable(true, 'right-menu');
this.loadingImage = false;
document.getElementsByClassName('drag-scroll-content')[0].scrollTop = 0;
......@@ -310,6 +309,11 @@ export class DocumentComponent implements OnInit, OnDestroy {
});
}
ngOnDestroy(): void {
this.timerSubscription?.unsubscribe();
this.subscription.unsubscribe();
}
initDocumentInfos(params: any) {
this.http.get('../rest/documents/' + params['id']).pipe(
tap((data: any) => {
......@@ -391,6 +395,38 @@ export class DocumentComponent implements OnInit, OnDestroy {
// this.renderPdf();
this.renderImage();
this.loadingdocument = false;
this.load.dismiss();
if (this.mainDocument.status === 'CONVERTING') {
// CHECK DOCUMENT STATUS
this.loadingController.create({
message: this.translate.instant('lang.convertingDocument'),
spinner: 'dots'
}).then((loader: HTMLIonLoadingElement) => {
this.load = loader;
this.load.present();
// 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) => {
if (res.document.status !== 'CONVERTING') {
this.totalPages = res.document.pages;
this.mainDocument.status = res.document.status;
this.load.dismiss();
this.timerSubscription?.unsubscribe();
}
})
).subscribe();
}),
catchError((err: any) => {
this.load.dismiss();
this.notificationService.handleErrors(err);
return of(false);
})
).subscribe();
});
}
}),
catchError((err: any) => {
console.log('error', err);
......@@ -769,4 +805,8 @@ export class DocumentComponent implements OnInit, OnDestroy {
}
}
}
isNotReady() {
return ['CONVERTING', 'ERROR'].indexOf(this.mainDocument.status) > -1;
}
}
......@@ -301,35 +301,44 @@ export class IndexationComponent implements OnInit {
}
uploadTrigger(fileInput: any) {
if (fileInput.target.files && fileInput.target.files[0] && this.isExtensionAllowed(fileInput.target.files)) {
for (let index = 0; index < fileInput.target.files.length; index++) {
const filename = fileInput.target.files[index].name;
const file = {
title: filename.substr(0, filename.lastIndexOf('.')),
reference: filename.substr(0, filename.lastIndexOf('.')).substr(0, 53),
mainDocument: true,
content: ''
};
const reader = new FileReader();
reader.readAsArrayBuffer(fileInput.target.files[index]);
reader.onload = (value: any) => {
file.mainDocument = this.filesToUpload.length === 0;
file.reference = this.filesToUpload.length === 0 ? file.reference : '';
file.content = this.getBase64Document(value.target.result);
this.filesToUpload.push(file);
if (this.filesToUpload.length === 1) {
setTimeout(() => {
this.menu.open('right-menu');
}, 500);
}
};
this.loadingController.create({
message: this.translate.instant('lang.loadingDocument'),
spinner: 'dots'
}).then(async (load: HTMLIonLoadingElement) => {
load.present();
if (fileInput.target.files && fileInput.target.files[0] && this.isExtensionAllowed(fileInput.target.files)) {
for (let index = 0; index < fileInput.target.files.length; index++) {
const filename = fileInput.target.files[index].name;
const file = {
title: filename.substr(0, filename.lastIndexOf('.')),
reference: filename.substr(0, filename.lastIndexOf('.')).substr(0, 53),
mainDocument: true,
content: ''
};
const reader = new FileReader();
reader.readAsArrayBuffer(fileInput.target.files[index]);
reader.onload = (value: any) => {
file.mainDocument = this.filesToUpload.length === 0;
file.reference = this.filesToUpload.length === 0 ? file.reference : '';
file.content = this.getBase64Document(value.target.result);
this.filesToUpload.push(file);
if (this.filesToUpload.length === 1) {
setTimeout(() => {
this.menu.open('right-menu');
}, 500);
}
};
}
this.fileImport.nativeElement.value = '';
load.dismiss();
} else {
this.loading = false;
load.dismiss();
}
this.fileImport.nativeElement.value = '';
} else {
this.loading = false;
}
});
}
isExtensionAllowed(files: any[]) {
for (let index = 0; index < files.length; index++) {
if (files[index].name.toLowerCase().split('.').pop() !== 'pdf') {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment