Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Angular interfaces for split+merge API support #335
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaswinkler committed Mar 11, 2021
1 parent 1e131f0 commit 5e096bc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src-ui/src/app/data/split-merge-request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export enum SplitMergeMetadata {

redo,

copy_first

}

export interface SplitMergeDocumentPart {

document: number,

pages?: number[]

}

export interface SplitMergeRequest {

split_merge_plan: SplitMergeDocumentPart[][]

delete_source: boolean

metadata: SplitMergeMetadata

preview: boolean

}
21 changes: 20 additions & 1 deletion src-ui/src/app/services/split-merge.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { PaperlessDocument } from '../data/paperless-document';
import { SplitMergeMetadata, SplitMergeRequest } from '../data/split-merge-request';

@Injectable({
providedIn: 'root'
Expand All @@ -8,7 +12,7 @@ export class SplitMergeService {

private documents: PaperlessDocument[] = []

constructor() { }
constructor(private http: HttpClient) { }

addDocument(document: PaperlessDocument) {
this.documents.push(document)
Expand All @@ -17,4 +21,19 @@ export class SplitMergeService {
hasDocuments(): boolean {
return this.documents.length > 0
}

executeSplitMerge(preview: boolean, delete_source: boolean, metadata: SplitMergeMetadata): Observable<string[]> {
let request: SplitMergeRequest = {
delete_source: delete_source,
preview: preview,
metadata: metadata,
split_merge_plan: []
}
return this.http.post<string[]>(`${environment.apiBaseUrl}/split_merge/`, request)
}

getPreviewUrl(previewKey: string) {
return `${environment.apiBaseUrl}/split_merge/${previewKey}/`
}

}

0 comments on commit 5e096bc

Please sign in to comment.