added cache for files
This commit is contained in:
parent
15e17654fa
commit
432536184a
@ -17,5 +17,16 @@
|
|||||||
"files": ["/assets/**", "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"]
|
"files": ["/assets/**", "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"dataGroups": [
|
||||||
|
{
|
||||||
|
"name": "file-downloads",
|
||||||
|
"urls": ["/download/original/**"],
|
||||||
|
"cacheConfig": {
|
||||||
|
"maxAge": "7d",
|
||||||
|
"maxSize": 1000,
|
||||||
|
"strategy": "performance"
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<section [class.hidden]="!viewReady">
|
<section>
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<div
|
<div
|
||||||
@ -35,8 +35,7 @@
|
|||||||
(manualAnnotationRequested)="openManualRedactionDialog($event)"
|
(manualAnnotationRequested)="openManualRedactionDialog($event)"
|
||||||
(pageChanged)="viewerPageChanged($event)"
|
(pageChanged)="viewerPageChanged($event)"
|
||||||
(viewerReady)="viewerReady($event)"
|
(viewerReady)="viewerReady($event)"
|
||||||
*ngIf="fileData"
|
[fileData]="redactedView ? fileData?.redactedFileData : fileData?.annotatedFileData"
|
||||||
[fileData]="redactedView ? fileData.redactedFileData : fileData.annotatedFileData"
|
|
||||||
[fileStatus]="appStateService.activeFile"
|
[fileStatus]="appStateService.activeFile"
|
||||||
></redaction-pdf-viewer>
|
></redaction-pdf-viewer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -57,19 +57,25 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
if (changes.fileData && !changes.fileData.firstChange) {
|
if (this.instance) {
|
||||||
this._changeDocument();
|
if (changes.fileData) {
|
||||||
}
|
if (!this._viewerState) {
|
||||||
if (changes.canPerformActions) {
|
this._loadDocument();
|
||||||
this._handleCustomActions();
|
} else {
|
||||||
|
this._changeDocument();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changes.canPerformActions) {
|
||||||
|
this._handleCustomActions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this._loadViewer(this.fileData);
|
this._loadViewer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _loadViewer(pdfBlob: any) {
|
private _loadViewer() {
|
||||||
const license = this._appConfigService.getConfig(AppConfigKey.PDFTRON_LICENSE);
|
const license = this._appConfigService.getConfig(AppConfigKey.PDFTRON_LICENSE);
|
||||||
WebViewer(
|
WebViewer(
|
||||||
{
|
{
|
||||||
@ -109,9 +115,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.loadDocument(pdfBlob, {
|
this._loadDocument();
|
||||||
filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,12 +183,10 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _handleCustomActions() {
|
private _handleCustomActions() {
|
||||||
if (this.instance) {
|
if (this.canPerformActions) {
|
||||||
if (this.canPerformActions) {
|
this.instance.enableElements(['add-redaction', 'add-dictionary']);
|
||||||
this.instance.enableElements(['add-redaction', 'add-dictionary']);
|
} else {
|
||||||
} else {
|
this.instance.disableElements(['add-redaction', 'add-dictionary']);
|
||||||
this.instance.disableElements(['add-redaction', 'add-dictionary']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,6 +235,15 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _loadDocument() {
|
||||||
|
if (this.fileData) {
|
||||||
|
console.log('load');
|
||||||
|
this.instance.loadDocument(this.fileData, {
|
||||||
|
filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _changeDocument() {
|
private _changeDocument() {
|
||||||
// sync layout and display mode
|
// sync layout and display mode
|
||||||
|
|
||||||
@ -251,14 +262,13 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
|
|||||||
leftPanelState: instance.isElementOpen('leftPanel')
|
leftPanelState: instance.isElementOpen('leftPanel')
|
||||||
};
|
};
|
||||||
|
|
||||||
this.instance.loadDocument(this.fileData, {
|
this._loadDocument();
|
||||||
filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf'
|
|
||||||
});
|
|
||||||
|
|
||||||
this._viewerState = viewerState;
|
this._viewerState = viewerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _restoreViewerState() {
|
private _restoreViewerState() {
|
||||||
|
console.log('emit');
|
||||||
this.viewerReady.emit(this.instance);
|
this.viewerReady.emit(this.instance);
|
||||||
this._restoreState(this._viewerState, this.instance);
|
this._restoreState(this._viewerState, this.instance);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,12 +13,11 @@ import {
|
|||||||
import { NotificationService, NotificationType } from '../notification/notification.service';
|
import { NotificationService, NotificationType } from '../notification/notification.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { UserService, UserWrapper } from '../user/user.service';
|
import { UserService } from '../user/user.service';
|
||||||
import { forkJoin, of, timer } from 'rxjs';
|
import { forkJoin, timer } from 'rxjs';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap } from 'rxjs/operators';
|
||||||
import { download } from '../utils/file-download-utils';
|
import { download } from '../utils/file-download-utils';
|
||||||
import { humanize } from '../utils/functions';
|
import { humanize } from '../utils/functions';
|
||||||
import { AnnotationWrapper } from '../screens/file/model/annotation.wrapper';
|
|
||||||
import { FileStatusWrapper } from '../screens/file/model/file-status.wrapper';
|
import { FileStatusWrapper } from '../screens/file/model/file-status.wrapper';
|
||||||
import { ProjectWrapper } from './model/project.wrapper';
|
import { ProjectWrapper } from './model/project.wrapper';
|
||||||
|
|
||||||
@ -59,30 +58,6 @@ export class AppStateService {
|
|||||||
activeProject: null,
|
activeProject: null,
|
||||||
activeFile: null
|
activeFile: null
|
||||||
};
|
};
|
||||||
|
|
||||||
timer(5000, 5000)
|
|
||||||
.pipe(
|
|
||||||
tap(() => {
|
|
||||||
this.reloadActiveProjectFiles();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.subscribe();
|
|
||||||
|
|
||||||
timer(5000, 5000)
|
|
||||||
.pipe(
|
|
||||||
tap(() => {
|
|
||||||
this.updateDictionaryVersion();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.subscribe();
|
|
||||||
|
|
||||||
timer(5000, 30000)
|
|
||||||
.pipe(
|
|
||||||
tap(() => {
|
|
||||||
this.loadAllProjects();
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.subscribe();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get dictionaryVersion() {
|
get dictionaryVersion() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user