mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
frontend support for downloading originals
This commit is contained in:
parent
17a581495c
commit
fe7aa10d2c
@ -5,12 +5,26 @@
|
|||||||
</svg>
|
</svg>
|
||||||
<span class="d-none d-lg-inline"> Delete</span>
|
<span class="d-none d-lg-inline"> Delete</span>
|
||||||
</button>
|
</button>
|
||||||
<a [href]="downloadUrl" class="btn btn-sm btn-outline-primary mr-2">
|
|
||||||
<svg class="buttonicon" fill="currentColor">
|
<div class="btn-group mr-2">
|
||||||
<use xlink:href="assets/bootstrap-icons.svg#download" />
|
|
||||||
</svg>
|
<a [href]="downloadUrl" class="btn btn-sm btn-outline-primary">
|
||||||
<span class="d-none d-lg-inline"> Download</span>
|
<svg class="buttonicon" fill="currentColor">
|
||||||
</a>
|
<use xlink:href="assets/bootstrap-icons.svg#download" />
|
||||||
|
</svg>
|
||||||
|
<span class="d-none d-lg-inline"> Download</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="btn-group" ngbDropdown role="group" *ngIf="metadata?.paperless__has_archive_version">
|
||||||
|
<button class="btn btn-sm btn-outline-primary dropdown-toggle-split" ngbDropdownToggle></button>
|
||||||
|
<div class="dropdown-menu" ngbDropdownMenu>
|
||||||
|
<a ngbDropdownItem [href]="downloadOriginalUrl">Download original</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-primary" (click)="close()">
|
<button type="button" class="btn btn-sm btn-outline-primary" (click)="close()">
|
||||||
<svg class="buttonicon" fill="currentColor">
|
<svg class="buttonicon" fill="currentColor">
|
||||||
<use xlink:href="assets/bootstrap-icons.svg#x" />
|
<use xlink:href="assets/bootstrap-icons.svg#x" />
|
||||||
|
@ -5,6 +5,7 @@ import { ActivatedRoute, Router } from '@angular/router';
|
|||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent';
|
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent';
|
||||||
import { PaperlessDocument } from 'src/app/data/paperless-document';
|
import { PaperlessDocument } from 'src/app/data/paperless-document';
|
||||||
|
import { PaperlessDocumentMetadata } from 'src/app/data/paperless-document-metadata';
|
||||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type';
|
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type';
|
||||||
import { TAG_COLOURS, PaperlessTag } from 'src/app/data/paperless-tag';
|
import { TAG_COLOURS, PaperlessTag } from 'src/app/data/paperless-tag';
|
||||||
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
|
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
|
||||||
@ -27,9 +28,11 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
|
|
||||||
documentId: number
|
documentId: number
|
||||||
document: PaperlessDocument
|
document: PaperlessDocument
|
||||||
|
metadata: PaperlessDocumentMetadata
|
||||||
title: string
|
title: string
|
||||||
previewUrl: string
|
previewUrl: string
|
||||||
downloadUrl: string
|
downloadUrl: string
|
||||||
|
downloadOriginalUrl: string
|
||||||
|
|
||||||
correspondents: PaperlessCorrespondent[]
|
correspondents: PaperlessCorrespondent[]
|
||||||
documentTypes: PaperlessDocumentType[]
|
documentTypes: PaperlessDocumentType[]
|
||||||
@ -66,6 +69,7 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
this.documentId = +paramMap.get('id')
|
this.documentId = +paramMap.get('id')
|
||||||
this.previewUrl = this.documentsService.getPreviewUrl(this.documentId)
|
this.previewUrl = this.documentsService.getPreviewUrl(this.documentId)
|
||||||
this.downloadUrl = this.documentsService.getDownloadUrl(this.documentId)
|
this.downloadUrl = this.documentsService.getDownloadUrl(this.documentId)
|
||||||
|
this.downloadOriginalUrl = this.documentsService.getDownloadUrl(this.documentId, true)
|
||||||
if (this.openDocumentService.getOpenDocument(this.documentId)) {
|
if (this.openDocumentService.getOpenDocument(this.documentId)) {
|
||||||
this.updateComponent(this.openDocumentService.getOpenDocument(this.documentId))
|
this.updateComponent(this.openDocumentService.getOpenDocument(this.documentId))
|
||||||
} else {
|
} else {
|
||||||
@ -80,6 +84,9 @@ export class DocumentDetailComponent implements OnInit {
|
|||||||
|
|
||||||
updateComponent(doc: PaperlessDocument) {
|
updateComponent(doc: PaperlessDocument) {
|
||||||
this.document = doc
|
this.document = doc
|
||||||
|
this.documentsService.getMetadata(doc.id).subscribe(result => {
|
||||||
|
this.metadata = result
|
||||||
|
})
|
||||||
this.title = doc.title
|
this.title = doc.title
|
||||||
this.documentForm.patchValue(doc)
|
this.documentForm.patchValue(doc)
|
||||||
}
|
}
|
||||||
|
11
src-ui/src/app/data/paperless-document-metadata.ts
Normal file
11
src-ui/src/app/data/paperless-document-metadata.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
export interface PaperlessDocumentMetadata {
|
||||||
|
|
||||||
|
paperless__checksum?: string
|
||||||
|
|
||||||
|
paperless__mime_type?: string
|
||||||
|
|
||||||
|
paperless__filename?: string
|
||||||
|
|
||||||
|
paperless__has_archive_version?: boolean
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { PaperlessDocument } from 'src/app/data/paperless-document';
|
import { PaperlessDocument } from 'src/app/data/paperless-document';
|
||||||
|
import { PaperlessDocumentMetadata } from 'src/app/data/paperless-document-metadata';
|
||||||
import { AbstractPaperlessService } from './abstract-paperless-service';
|
import { AbstractPaperlessService } from './abstract-paperless-service';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
@ -50,20 +51,32 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>
|
|||||||
return super.list(page, pageSize, sortField, sortDirection, this.filterRulesToQueryParams(filterRules))
|
return super.list(page, pageSize, sortField, sortDirection, this.filterRulesToQueryParams(filterRules))
|
||||||
}
|
}
|
||||||
|
|
||||||
getPreviewUrl(id: number): string {
|
getPreviewUrl(id: number, original: boolean = false): string {
|
||||||
return this.getResourceUrl(id, 'preview')
|
let url = this.getResourceUrl(id, 'preview')
|
||||||
|
if (original) {
|
||||||
|
url += "?original=true"
|
||||||
|
}
|
||||||
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
getThumbUrl(id: number): string {
|
getThumbUrl(id: number): string {
|
||||||
return this.getResourceUrl(id, 'thumb')
|
return this.getResourceUrl(id, 'thumb')
|
||||||
}
|
}
|
||||||
|
|
||||||
getDownloadUrl(id: number): string {
|
getDownloadUrl(id: number, original: boolean = false): string {
|
||||||
return this.getResourceUrl(id, 'download')
|
let url = this.getResourceUrl(id, 'download')
|
||||||
|
if (original) {
|
||||||
|
url += "?original=true"
|
||||||
|
}
|
||||||
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadDocument(formData) {
|
uploadDocument(formData) {
|
||||||
return this.http.post(this.getResourceUrl(null, 'post_document'), formData)
|
return this.http.post(this.getResourceUrl(null, 'post_document'), formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getMetadata(id: number): Observable<PaperlessDocumentMetadata> {
|
||||||
|
return this.http.get<PaperlessDocumentMetadata>(this.getResourceUrl(id, 'metadata'))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user