Refactor frontend data models
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import {
|
||||
PaperlessShareLink,
|
||||
PaperlessFileVersion,
|
||||
} from 'src/app/data/paperless-share-link'
|
||||
import { ShareLink, FileVersion } from 'src/app/data/share-link'
|
||||
import { AbstractNameFilterService } from './abstract-name-filter-service'
|
||||
import { HttpClient } from '@angular/common/http'
|
||||
import { Observable } from 'rxjs'
|
||||
@@ -10,24 +7,24 @@ import { Observable } from 'rxjs'
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ShareLinkService extends AbstractNameFilterService<PaperlessShareLink> {
|
||||
export class ShareLinkService extends AbstractNameFilterService<ShareLink> {
|
||||
constructor(http: HttpClient) {
|
||||
super(http, 'share_links')
|
||||
}
|
||||
|
||||
getLinksForDocument(documentId: number): Observable<PaperlessShareLink[]> {
|
||||
return this.http.get<PaperlessShareLink[]>(
|
||||
getLinksForDocument(documentId: number): Observable<ShareLink[]> {
|
||||
return this.http.get<ShareLink[]>(
|
||||
`${this.baseUrl}documents/${documentId}/${this.resourceName}/`
|
||||
)
|
||||
}
|
||||
|
||||
createLinkForDocument(
|
||||
documentId: number,
|
||||
file_version: PaperlessFileVersion = PaperlessFileVersion.Archive,
|
||||
file_version: FileVersion = FileVersion.Archive,
|
||||
expiration: Date = null
|
||||
) {
|
||||
this.clearCache()
|
||||
return this.http.post<PaperlessShareLink>(this.getResourceUrl(), {
|
||||
return this.http.post<ShareLink>(this.getResourceUrl(), {
|
||||
document: documentId,
|
||||
file_version,
|
||||
expiration: expiration?.toISOString(),
|
||||
|
||||
Reference in New Issue
Block a user