mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ADF-5173] - improved fix for closing pdfjs worker error (#7225)
* [ACA-3847] - fixed download for external source file * [ADF-5173] - improved fix for closing pdfjs worker error * Fixed lint error
This commit is contained in:
parent
df08e36d24
commit
f963c6d15e
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,6 +9,7 @@ workspace.xml
|
|||||||
dist/
|
dist/
|
||||||
e2e/.env.cloud
|
e2e/.env.cloud
|
||||||
tmp
|
tmp
|
||||||
|
temp
|
||||||
e2e-output*/
|
e2e-output*/
|
||||||
/e2e/downloads/
|
/e2e/downloads/
|
||||||
*.npmrc
|
*.npmrc
|
||||||
@ -28,3 +29,4 @@ out-tsc
|
|||||||
/reports/
|
/reports/
|
||||||
e2e-result-*
|
e2e-result-*
|
||||||
licenses.txt
|
licenses.txt
|
||||||
|
.DS_Store
|
||||||
|
@ -33,7 +33,8 @@ import { RenderingQueueServices } from '../services/rendering-queue.services';
|
|||||||
import { PdfPasswordDialogComponent } from './pdf-viewer-password-dialog';
|
import { PdfPasswordDialogComponent } from './pdf-viewer-password-dialog';
|
||||||
import { AppConfigService } from './../../app-config/app-config.service';
|
import { AppConfigService } from './../../app-config/app-config.service';
|
||||||
import { PDFDocumentProxy, PDFSource } from 'pdfjs-dist';
|
import { PDFDocumentProxy, PDFSource } from 'pdfjs-dist';
|
||||||
import { timer } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
import { catchError, delay, takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
declare const pdfjsLib: any;
|
declare const pdfjsLib: any;
|
||||||
declare const pdfjsViewer: any;
|
declare const pdfjsViewer: any;
|
||||||
@ -106,6 +107,8 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
disableAutoFetch: true,
|
disableAutoFetch: true,
|
||||||
disableStream: true
|
disableStream: true
|
||||||
};
|
};
|
||||||
|
private pdfjsWorkerDestroy$ = new Subject<boolean>();
|
||||||
|
private onDestroy$ = new Subject<boolean>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
@ -118,6 +121,7 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
this.onPageRendered = this.onPageRendered.bind(this);
|
this.onPageRendered = this.onPageRendered.bind(this);
|
||||||
this.randomPdfId = this.generateUuid();
|
this.randomPdfId = this.generateUuid();
|
||||||
this.currentScale = this.getUserScaling();
|
this.currentScale = this.getUserScaling();
|
||||||
|
this.pdfjsWorkerDestroy$.pipe(catchError(() => null), delay(700), takeUntil(this.onDestroy$)).subscribe(() => this.destroyPdJsWorker());
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserScaling(): number {
|
getUserScaling(): number {
|
||||||
@ -237,8 +241,11 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.loadingTask) {
|
if (this.loadingTask) {
|
||||||
timer(700).subscribe(() => this.destroyPdJsWorker());
|
this.pdfjsWorkerDestroy$.next();
|
||||||
}
|
}
|
||||||
|
this.onDestroy$.next();
|
||||||
|
this.pdfjsWorkerDestroy$.complete();
|
||||||
|
this.onDestroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private destroyPdJsWorker() {
|
private destroyPdJsWorker() {
|
||||||
|
@ -45,7 +45,7 @@ export class AttachFileWidgetDialogService {
|
|||||||
* @param currentFolderId Upload file from specific folder
|
* @param currentFolderId Upload file from specific folder
|
||||||
* @returns Information about the chosen file(s)
|
* @returns Information about the chosen file(s)
|
||||||
*/
|
*/
|
||||||
openLogin(repository: AlfrescoEndpointRepresentation, currentFolderId = '-my-'): Observable<Node[]> {
|
openLogin(repository: AlfrescoEndpointRepresentation, currentFolderId = '-my-', accountIdentifier?: string): Observable<Node[]> {
|
||||||
const { title, ecmHost, selected, registerExternalHost } = this.constructPayload(repository);
|
const { title, ecmHost, selected, registerExternalHost } = this.constructPayload(repository);
|
||||||
const data: AttachFileWidgetDialogComponentData = {
|
const data: AttachFileWidgetDialogComponentData = {
|
||||||
title,
|
title,
|
||||||
@ -54,7 +54,8 @@ export class AttachFileWidgetDialogService {
|
|||||||
currentFolderId,
|
currentFolderId,
|
||||||
isSelectionValid: (entry: Node) => entry.isFile,
|
isSelectionValid: (entry: Node) => entry.isFile,
|
||||||
showFilesInResult: true,
|
showFilesInResult: true,
|
||||||
registerExternalHost
|
registerExternalHost,
|
||||||
|
accountIdentifier
|
||||||
};
|
};
|
||||||
|
|
||||||
this.openLoginDialog(data, 'adf-attach-file-widget-dialog', '630px');
|
this.openLoginDialog(data, 'adf-attach-file-widget-dialog', '630px');
|
||||||
|
@ -238,11 +238,12 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private uploadFileFromExternalCS(repository: AlfrescoEndpointRepresentation, currentFolderId?: string) {
|
private uploadFileFromExternalCS(repository: AlfrescoEndpointRepresentation, currentFolderId?: string) {
|
||||||
this.attachDialogService.openLogin(repository, currentFolderId).subscribe(
|
const accountIdentifier = `alfresco-${repository.id}-${repository.name}`;
|
||||||
|
this.attachDialogService.openLogin(repository, currentFolderId, accountIdentifier).subscribe(
|
||||||
(selections: any[]) => {
|
(selections: any[]) => {
|
||||||
selections.forEach((node) => node.isExternal = true);
|
selections.forEach((node) => node.isExternal = true);
|
||||||
this.tempFilesList.push(...selections);
|
this.tempFilesList.push(...selections);
|
||||||
this.uploadFileFromCS(selections, `alfresco-${repository.id}-${repository.name}`);
|
this.uploadFileFromCS(selections, accountIdentifier);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user