mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
Remove ng2-pdf-viewer and use only native viewer
This commit is contained in:
parent
5306d58991
commit
706b1f4622
@ -24,7 +24,6 @@
|
|||||||
"@ng-select/ng-select": "^5.0.9",
|
"@ng-select/ng-select": "^5.0.9",
|
||||||
"bootstrap": "^4.5.0",
|
"bootstrap": "^4.5.0",
|
||||||
"ng-bootstrap": "^1.6.3",
|
"ng-bootstrap": "^1.6.3",
|
||||||
"ng2-pdf-viewer": "^6.3.2",
|
|
||||||
"ngx-cookie-service": "^10.1.1",
|
"ngx-cookie-service": "^10.1.1",
|
||||||
"ngx-file-drop": "^10.0.0",
|
"ngx-file-drop": "^10.0.0",
|
||||||
"ngx-infinite-scroll": "^9.1.0",
|
"ngx-infinite-scroll": "^9.1.0",
|
||||||
|
@ -48,7 +48,6 @@ import { SavedViewWidgetComponent } from './components/dashboard/widgets/saved-v
|
|||||||
import { StatisticsWidgetComponent } from './components/dashboard/widgets/statistics-widget/statistics-widget.component';
|
import { StatisticsWidgetComponent } from './components/dashboard/widgets/statistics-widget/statistics-widget.component';
|
||||||
import { UploadFileWidgetComponent } from './components/dashboard/widgets/upload-file-widget/upload-file-widget.component';
|
import { UploadFileWidgetComponent } from './components/dashboard/widgets/upload-file-widget/upload-file-widget.component';
|
||||||
import { WidgetFrameComponent } from './components/dashboard/widgets/widget-frame/widget-frame.component';
|
import { WidgetFrameComponent } from './components/dashboard/widgets/widget-frame/widget-frame.component';
|
||||||
import { PdfViewerModule } from 'ng2-pdf-viewer';
|
|
||||||
import { WelcomeWidgetComponent } from './components/dashboard/widgets/welcome-widget/welcome-widget.component';
|
import { WelcomeWidgetComponent } from './components/dashboard/widgets/welcome-widget/welcome-widget.component';
|
||||||
import { YesNoPipe } from './pipes/yes-no.pipe';
|
import { YesNoPipe } from './pipes/yes-no.pipe';
|
||||||
import { FileSizePipe } from './pipes/file-size.pipe';
|
import { FileSizePipe } from './pipes/file-size.pipe';
|
||||||
@ -129,7 +128,6 @@ registerLocaleData(localeDe)
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
NgxFileDropModule,
|
NgxFileDropModule,
|
||||||
InfiniteScrollModule,
|
InfiniteScrollModule,
|
||||||
PdfViewerModule,
|
|
||||||
NgSelectModule
|
NgSelectModule
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
|
@ -1,14 +1,4 @@
|
|||||||
<app-page-header [(title)]="title">
|
<app-page-header [(title)]="title">
|
||||||
<div class="input-group input-group-sm mr-5 d-none d-md-flex" *ngIf="getContentType() == 'application/pdf' && !useNativePdfViewer">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<div class="input-group-text" i18n>Page</div>
|
|
||||||
</div>
|
|
||||||
<input class="form-control flex-grow-0 w-auto" type="number" min="1" [max]="previewNumPages" [(ngModel)]="previewCurrentPage" />
|
|
||||||
<div class="input-group-append">
|
|
||||||
<div class="input-group-text" i18n>of {{previewNumPages}}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-danger mr-2 ml-auto" (click)="delete()">
|
<button type="button" class="btn btn-sm btn-outline-danger mr-2 ml-auto" (click)="delete()">
|
||||||
<svg class="buttonicon" fill="currentColor">
|
<svg class="buttonicon" fill="currentColor">
|
||||||
<use xlink:href="assets/bootstrap-icons.svg#trash" />
|
<use xlink:href="assets/bootstrap-icons.svg#trash" />
|
||||||
@ -135,12 +125,7 @@
|
|||||||
|
|
||||||
<div class="col-md-6 col-xl-8 mb-3">
|
<div class="col-md-6 col-xl-8 mb-3">
|
||||||
<ng-container *ngIf="getContentType() == 'application/pdf'">
|
<ng-container *ngIf="getContentType() == 'application/pdf'">
|
||||||
<div class="preview-sticky pdf-viewer-container" *ngIf="!useNativePdfViewer ; else nativePdfViewer">
|
<object [data]="previewUrl | safe" class="preview-sticky" width="100%">If error</object>
|
||||||
<pdf-viewer [src]="previewUrl" [original-size]="false" [show-borders]="true" [show-all]="true" [(page)]="previewCurrentPage" [render-text-mode]="2" (after-load-complete)="pdfPreviewLoaded($event)"></pdf-viewer>
|
|
||||||
</div>
|
|
||||||
<ng-template #nativePdfViewer>
|
|
||||||
<object [data]="previewUrl | safe" type="application/pdf" class="preview-sticky" width="100%"></object>
|
|
||||||
</ng-template>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="getContentType() == 'text/plain'">
|
<ng-container *ngIf="getContentType() == 'text/plain'">
|
||||||
<object [data]="previewUrl | safe" type="text/plain" class="preview-sticky" width="100%"></object>
|
<object [data]="previewUrl | safe" type="text/plain" class="preview-sticky" width="100%"></object>
|
||||||
|
@ -15,7 +15,6 @@ import { DocumentService } from 'src/app/services/rest/document.service';
|
|||||||
import { ConfirmDialogComponent } from '../common/confirm-dialog/confirm-dialog.component';
|
import { ConfirmDialogComponent } from '../common/confirm-dialog/confirm-dialog.component';
|
||||||
import { CorrespondentEditDialogComponent } from '../manage/correspondent-list/correspondent-edit-dialog/correspondent-edit-dialog.component';
|
import { CorrespondentEditDialogComponent } from '../manage/correspondent-list/correspondent-edit-dialog/correspondent-edit-dialog.component';
|
||||||
import { DocumentTypeEditDialogComponent } from '../manage/document-type-list/document-type-edit-dialog/document-type-edit-dialog.component';
|
import { DocumentTypeEditDialogComponent } from '../manage/document-type-list/document-type-edit-dialog/document-type-edit-dialog.component';
|
||||||
import { PDFDocumentProxy } from 'ng2-pdf-viewer';
|
|
||||||
import { ToastService } from 'src/app/services/toast.service';
|
import { ToastService } from 'src/app/services/toast.service';
|
||||||
import { TextComponent } from '../common/input/text/text.component';
|
import { TextComponent } from '../common/input/text/text.component';
|
||||||
import { SettingsService, SETTINGS_KEYS } from 'src/app/services/settings.service';
|
import { SettingsService, SETTINGS_KEYS } from 'src/app/services/settings.service';
|
||||||
@ -61,9 +60,6 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
tags: new FormControl([])
|
tags: new FormControl([])
|
||||||
})
|
})
|
||||||
|
|
||||||
previewCurrentPage: number = 1
|
|
||||||
previewNumPages: number = 1
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private documentsService: DocumentService,
|
private documentsService: DocumentService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
@ -77,10 +73,6 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private settings: SettingsService) { }
|
private settings: SettingsService) { }
|
||||||
|
|
||||||
get useNativePdfViewer(): boolean {
|
|
||||||
return this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER)
|
|
||||||
}
|
|
||||||
|
|
||||||
getContentType() {
|
getContentType() {
|
||||||
return this.metadata?.has_archive_version ? 'application/pdf' : this.metadata?.original_mime_type
|
return this.metadata?.has_archive_version ? 'application/pdf' : this.metadata?.original_mime_type
|
||||||
}
|
}
|
||||||
@ -222,8 +214,4 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
return this.documentListViewService.hasNext(this.documentId)
|
return this.documentListViewService.hasNext(this.documentId)
|
||||||
}
|
}
|
||||||
|
|
||||||
pdfPreviewLoaded(pdf: PDFDocumentProxy) {
|
|
||||||
this.previewNumPages = pdf.numPages
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,15 +47,9 @@
|
|||||||
</a>
|
</a>
|
||||||
<ng-template #previewContent>
|
<ng-template #previewContent>
|
||||||
<ng-container *ngIf="getContentType() == 'application/pdf'">
|
<ng-container *ngIf="getContentType() == 'application/pdf'">
|
||||||
<div class="preview pdf-viewer-container" *ngIf="!useNativePdfViewer ; else nativePdfViewer">
|
<div class="preview">
|
||||||
<div class="spinner-border text-primary spinner-border-sm" role="status">
|
<object [data]="previewUrl | safe" class="preview" width="100%"></object>
|
||||||
<span class="sr-only">Loading...</span>
|
|
||||||
</div>
|
|
||||||
<pdf-viewer [src]="previewUrl" [original-size]="false" [show-borders]="false" [show-all]="true" [render-text-mode]="2"></pdf-viewer>
|
|
||||||
</div>
|
</div>
|
||||||
<ng-template #nativePdfViewer>
|
|
||||||
<object [data]="previewUrl | safe" type="application/pdf" class="preview" width="100%"></object>
|
|
||||||
</ng-template>
|
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container *ngIf="getContentType() == 'text/plain'">
|
<ng-container *ngIf="getContentType() == 'text/plain'">
|
||||||
<object [data]="previewUrl | safe" type="text/plain" class="preview" width="100%"></object>
|
<object [data]="previewUrl | safe" type="text/plain" class="preview" width="100%"></object>
|
||||||
|
@ -70,10 +70,6 @@ export class DocumentCardSmallComponent implements OnInit {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
get useNativePdfViewer(): boolean {
|
|
||||||
return this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER)
|
|
||||||
}
|
|
||||||
|
|
||||||
getContentType() {
|
getContentType() {
|
||||||
return this.metadata?.has_archive_version ? 'application/pdf' : this.metadata?.original_mime_type
|
return this.metadata?.has_archive_version ? 'application/pdf' : this.metadata?.original_mime_type
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ export class SettingsComponent implements OnInit {
|
|||||||
'documentListItemPerPage': new FormControl(this.settings.get(SETTINGS_KEYS.DOCUMENT_LIST_SIZE)),
|
'documentListItemPerPage': new FormControl(this.settings.get(SETTINGS_KEYS.DOCUMENT_LIST_SIZE)),
|
||||||
'darkModeUseSystem': new FormControl(this.settings.get(SETTINGS_KEYS.DARK_MODE_USE_SYSTEM)),
|
'darkModeUseSystem': new FormControl(this.settings.get(SETTINGS_KEYS.DARK_MODE_USE_SYSTEM)),
|
||||||
'darkModeEnabled': new FormControl(this.settings.get(SETTINGS_KEYS.DARK_MODE_ENABLED)),
|
'darkModeEnabled': new FormControl(this.settings.get(SETTINGS_KEYS.DARK_MODE_ENABLED)),
|
||||||
'useNativePdfViewer': new FormControl(this.settings.get(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER)),
|
|
||||||
'savedViews': this.savedViewGroup,
|
'savedViews': this.savedViewGroup,
|
||||||
'displayLanguage': new FormControl(this.settings.getLanguage()),
|
'displayLanguage': new FormControl(this.settings.getLanguage()),
|
||||||
'dateLocale': new FormControl(this.settings.get(SETTINGS_KEYS.DATE_LOCALE)),
|
'dateLocale': new FormControl(this.settings.get(SETTINGS_KEYS.DATE_LOCALE)),
|
||||||
@ -74,7 +73,6 @@ export class SettingsComponent implements OnInit {
|
|||||||
this.settings.set(SETTINGS_KEYS.DOCUMENT_LIST_SIZE, this.settingsForm.value.documentListItemPerPage)
|
this.settings.set(SETTINGS_KEYS.DOCUMENT_LIST_SIZE, this.settingsForm.value.documentListItemPerPage)
|
||||||
this.settings.set(SETTINGS_KEYS.DARK_MODE_USE_SYSTEM, this.settingsForm.value.darkModeUseSystem)
|
this.settings.set(SETTINGS_KEYS.DARK_MODE_USE_SYSTEM, this.settingsForm.value.darkModeUseSystem)
|
||||||
this.settings.set(SETTINGS_KEYS.DARK_MODE_ENABLED, (this.settingsForm.value.darkModeEnabled == true).toString())
|
this.settings.set(SETTINGS_KEYS.DARK_MODE_ENABLED, (this.settingsForm.value.darkModeEnabled == true).toString())
|
||||||
this.settings.set(SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, this.settingsForm.value.useNativePdfViewer)
|
|
||||||
this.settings.set(SETTINGS_KEYS.DATE_LOCALE, this.settingsForm.value.dateLocale)
|
this.settings.set(SETTINGS_KEYS.DATE_LOCALE, this.settingsForm.value.dateLocale)
|
||||||
this.settings.set(SETTINGS_KEYS.DATE_FORMAT, this.settingsForm.value.dateFormat)
|
this.settings.set(SETTINGS_KEYS.DATE_FORMAT, this.settingsForm.value.dateFormat)
|
||||||
this.settings.set(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT, this.settingsForm.value.notificationsConsumerNewDocument)
|
this.settings.set(SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT, this.settingsForm.value.notificationsConsumerNewDocument)
|
||||||
|
@ -21,7 +21,6 @@ export const SETTINGS_KEYS = {
|
|||||||
DOCUMENT_LIST_SIZE: 'general-settings:documentListSize',
|
DOCUMENT_LIST_SIZE: 'general-settings:documentListSize',
|
||||||
DARK_MODE_USE_SYSTEM: 'general-settings:dark-mode:use-system',
|
DARK_MODE_USE_SYSTEM: 'general-settings:dark-mode:use-system',
|
||||||
DARK_MODE_ENABLED: 'general-settings:dark-mode:enabled',
|
DARK_MODE_ENABLED: 'general-settings:dark-mode:enabled',
|
||||||
USE_NATIVE_PDF_VIEWER: 'general-settings:document-details:native-pdf-viewer',
|
|
||||||
DATE_LOCALE: 'general-settings:date-display:date-locale',
|
DATE_LOCALE: 'general-settings:date-display:date-locale',
|
||||||
DATE_FORMAT: 'general-settings:date-display:date-format',
|
DATE_FORMAT: 'general-settings:date-display:date-format',
|
||||||
NOTIFICATIONS_CONSUMER_NEW_DOCUMENT: 'general-settings:notifications:consumer-new-documents',
|
NOTIFICATIONS_CONSUMER_NEW_DOCUMENT: 'general-settings:notifications:consumer-new-documents',
|
||||||
@ -36,7 +35,6 @@ const SETTINGS: PaperlessSettings[] = [
|
|||||||
{key: SETTINGS_KEYS.DOCUMENT_LIST_SIZE, type: "number", default: 50},
|
{key: SETTINGS_KEYS.DOCUMENT_LIST_SIZE, type: "number", default: 50},
|
||||||
{key: SETTINGS_KEYS.DARK_MODE_USE_SYSTEM, type: "boolean", default: true},
|
{key: SETTINGS_KEYS.DARK_MODE_USE_SYSTEM, type: "boolean", default: true},
|
||||||
{key: SETTINGS_KEYS.DARK_MODE_ENABLED, type: "boolean", default: false},
|
{key: SETTINGS_KEYS.DARK_MODE_ENABLED, type: "boolean", default: false},
|
||||||
{key: SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER, type: "boolean", default: false},
|
|
||||||
{key: SETTINGS_KEYS.DATE_LOCALE, type: "string", default: ""},
|
{key: SETTINGS_KEYS.DATE_LOCALE, type: "string", default: ""},
|
||||||
{key: SETTINGS_KEYS.DATE_FORMAT, type: "string", default: "mediumDate"},
|
{key: SETTINGS_KEYS.DATE_FORMAT, type: "string", default: "mediumDate"},
|
||||||
{key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT, type: "boolean", default: true},
|
{key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT, type: "boolean", default: true},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user