A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
document service adds observables for linked data to its results
jonaswinkler34f353f399ab
diff --git a/src-ui/src/app/data/paperless-document.ts b/src-ui/src/app/data/paperless-document.tsindex b69a35495..9d0aeda88 100644--- a/src-ui/src/app/data/paperless-document.ts+++ b/src-ui/src/app/data/paperless-document.ts@@ -2,14 +2,15 @@ import { PaperlessCorrespondent } from './paperless-correspondent'import { ObjectWithId } from './object-with-id'import { PaperlessTag } from './paperless-tag'import { PaperlessDocumentType } from './paperless-document-type'+import { Observable } from 'rxjs'export interface PaperlessDocument extends ObjectWithId {- correspondent_object?: PaperlessCorrespondent+ correspondent$?: Observable<PaperlessCorrespondent>correspondent?: number- document_type_object?: PaperlessDocumentType+ document_type$?: Observable<PaperlessDocumentType>document_type?: number@@ -19,7 +20,7 @@ export interface PaperlessDocument extends ObjectWithId {file_type?: string- tags_objects?: PaperlessTag[]+ tags$?: Observable<PaperlessTag[]>tags?: number[]diff --git a/src-ui/src/app/services/rest/document.service.ts b/src-ui/src/app/services/rest/document.service.tsindex e27dbeab3..5bf2308d4 100644--- a/src-ui/src/app/services/rest/document.service.ts+++ b/src-ui/src/app/services/rest/document.service.ts@@ -6,6 +6,10 @@ import { HttpClient } from '@angular/common/http';import { Observable } from 'rxjs';import { Results } from 'src/app/data/results';import { FilterRule } from 'src/app/data/filter-rule';+import { map } from 'rxjs/operators';+import { CorrespondentService } from './correspondent.service';+import { DocumentTypeService } from './document-type.service';+import { TagService } from './tag.service';export const DOCUMENT_SORT_FIELDS = [@@ -27,7 +31,7 @@ export const SORT_DIRECTION_DESCENDING = "des"})export class DocumentService extends AbstractPaperlessService<PaperlessDocument> {- constructor(http: HttpClient) {+ constructor(http: HttpClient, private correspondentService: CorrespondentService, private documentTypeService: DocumentTypeService, private tagService: TagService) {super(http, 'documents')}@@ -47,8 +51,26 @@ export class DocumentService extends AbstractPaperlessService<PaperlessDocument>}}+ addObservablesToDocument(doc: PaperlessDocument) {+ if (doc.correspondent) {+ doc.correspondent$ = this.correspondentService.getCached(doc.correspondent)+ }+ if (doc.document_type) {+ doc.document_type$ = this.documentTypeService.getCached(doc.document_type)+ }+ if (doc.tags) {+ doc.tags$ = this.tagService.getCachedMany(doc.tags)+ }+ return doc+ }+list(page?: number, pageSize?: number, sortField?: string, sortDirection?: string, filterRules?: FilterRule[]): Observable<Results<PaperlessDocument>> {- return super.list(page, pageSize, sortField, sortDirection, this.filterRulesToQueryParams(filterRules))+ return super.list(page, pageSize, sortField, sortDirection, this.filterRulesToQueryParams(filterRules)).pipe(+ map(results => {+ results.results.forEach(doc => this.addObservablesToDocument(doc))+ return results+ })+ )}getPreviewUrl(id: number, original: boolean = false): string {