* Implement share links Basic implementation of share links Make certain share link fields not editable, automatically grant permissions on migrate Updated styling, error messages from expired / deleted links frontend code linting, reversable sharelink migration testing coverage Update translation strings No links message * Consolidate file response methods * improvements to share links on mobile devices * Refactor share links file_version * Add docs for share links * Apply suggestions from code review * When filtering share links, use the timezone aware now() * Removes extra call to setup directories for usage in testing * FIx copied badge display on some browsers * Move copy to ngx-clipboard library --------- Co-authored-by: Trenton H <797416+stumpylog@users.noreply.github.com>
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { Injectable } from '@angular/core'
|
|
import {
|
|
PaperlessShareLink,
|
|
PaperlessFileVersion,
|
|
} from 'src/app/data/paperless-share-link'
|
|
import { AbstractNameFilterService } from './abstract-name-filter-service'
|
|
import { HttpClient } from '@angular/common/http'
|
|
import { Observable } from 'rxjs'
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ShareLinkService extends AbstractNameFilterService<PaperlessShareLink> {
|
|
constructor(http: HttpClient) {
|
|
super(http, 'share_links')
|
|
}
|
|
|
|
getLinksForDocument(documentId: number): Observable<PaperlessShareLink[]> {
|
|
return this.http.get<PaperlessShareLink[]>(
|
|
`${this.baseUrl}documents/${documentId}/${this.resourceName}/`
|
|
)
|
|
}
|
|
|
|
createLinkForDocument(
|
|
documentId: number,
|
|
file_version: PaperlessFileVersion = PaperlessFileVersion.Archive,
|
|
expiration: Date = null
|
|
) {
|
|
this.clearCache()
|
|
return this.http.post<PaperlessShareLink>(this.getResourceUrl(), {
|
|
document: documentId,
|
|
file_version,
|
|
expiration: expiration?.toISOString(),
|
|
})
|
|
}
|
|
}
|