mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-09 09:58:20 -05:00
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { HttpClient, HttpParams } from '@angular/common/http';
|
|
import { PaperlessDocumentComment } from 'src/app/data/paperless-document-comment';
|
|
import { AbstractPaperlessService } from './abstract-paperless-service';
|
|
import { Observable } from 'rxjs';
|
|
import { PaperlessDocumentCommentFrame } from 'src/app/data/paperless-document-comment-frame';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class DocumentCommentService extends AbstractPaperlessService<PaperlessDocumentComment> {
|
|
|
|
constructor(http: HttpClient) {
|
|
super(http, 'documents')
|
|
}
|
|
|
|
|
|
getComments(id: number): Observable<PaperlessDocumentComment> {
|
|
return this.http.get<PaperlessDocumentComment[]>(this.getResourceUrl(id, "comments"))
|
|
}
|
|
|
|
addComment(id: number, comment): Observable<PaperlessDocumentComment[]>{
|
|
return this.http.post<PaperlessDocumentComment[]>(this.getResourceUrl(id, 'comments'), {"payload": comment})
|
|
}
|
|
|
|
deleteComment(documentId: number, commentId: number): Observable<PaperlessDocumentComment[]>{
|
|
let httpParams = new HttpParams();
|
|
httpParams = httpParams.set("commentId", commentId.toString());
|
|
return this.http.delete<PaperlessDocumentComment[]>(this.getResourceUrl(documentId, 'comments'), {params: httpParams});
|
|
}
|
|
}
|