mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-08 07:45:32 +01:00
Feature: loading preview, better text popup preview (#8011)
This commit is contained in:
parent
74d0c9fda5
commit
a283a65813
15 changed files with 192 additions and 95 deletions
|
|
@ -131,9 +131,11 @@ export class DocumentDetailComponent
|
|||
title: string
|
||||
titleSubject: Subject<string> = new Subject()
|
||||
previewUrl: string
|
||||
thumbUrl: string
|
||||
previewText: string
|
||||
downloadUrl: string
|
||||
downloadOriginalUrl: string
|
||||
previewLoaded: boolean = false
|
||||
|
||||
correspondents: Correspondent[]
|
||||
documentTypes: DocumentType[]
|
||||
|
|
@ -221,15 +223,17 @@ export class DocumentDetailComponent
|
|||
}
|
||||
|
||||
get archiveContentRenderType(): ContentRenderType {
|
||||
return this.getRenderType(
|
||||
this.metadata?.has_archive_version
|
||||
? 'application/pdf'
|
||||
: this.metadata?.original_mime_type
|
||||
)
|
||||
return this.document?.archived_file_name
|
||||
? this.getRenderType('application/pdf')
|
||||
: this.getRenderType(this.document?.mime_type)
|
||||
}
|
||||
|
||||
get originalContentRenderType(): ContentRenderType {
|
||||
return this.getRenderType(this.metadata?.original_mime_type)
|
||||
return this.getRenderType(this.document?.mime_type)
|
||||
}
|
||||
|
||||
get showThumbnailOverlay(): boolean {
|
||||
return this.settings.get(SETTINGS_KEYS.DOCUMENT_EDITING_OVERLAY_THUMBNAIL)
|
||||
}
|
||||
|
||||
private getRenderType(mimeType: string): ContentRenderType {
|
||||
|
|
@ -339,6 +343,7 @@ export class DocumentDetailComponent
|
|||
}`
|
||||
},
|
||||
})
|
||||
this.thumbUrl = this.documentsService.getThumbUrl(documentId)
|
||||
return this.documentsService.get(documentId)
|
||||
})
|
||||
)
|
||||
|
|
@ -537,6 +542,9 @@ export class DocumentDetailComponent
|
|||
.subscribe({
|
||||
next: (result) => {
|
||||
this.metadata = result
|
||||
if (this.archiveContentRenderType !== ContentRenderType.PDF) {
|
||||
this.previewLoaded = true
|
||||
}
|
||||
},
|
||||
error: (error) => {
|
||||
this.metadata = {} // allow display to fallback to <object> tag
|
||||
|
|
@ -903,11 +911,15 @@ export class DocumentDetailComponent
|
|||
pdfPreviewLoaded(pdf: PDFDocumentProxy) {
|
||||
this.previewNumPages = pdf.numPages
|
||||
if (this.password) this.requiresPassword = false
|
||||
setTimeout(() => {
|
||||
this.previewLoaded = true
|
||||
}, 300)
|
||||
}
|
||||
|
||||
onError(event) {
|
||||
if (event.name == 'PasswordException') {
|
||||
this.requiresPassword = true
|
||||
this.previewLoaded = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue