mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-30 18:27:45 -05:00
add comment function
This commit is contained in:

committed by
Michael Shamoon

parent
d1e8299010
commit
817882ff6f
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DocumentCommentService } from './document-comment.service';
|
||||
|
||||
describe('DocumentCommentService', () => {
|
||||
let service: DocumentCommentService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(DocumentCommentService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
31
src-ui/src/app/services/rest/document-comment.service.ts
Normal file
31
src-ui/src/app/services/rest/document-comment.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
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});
|
||||
}
|
||||
}
|
16
src-ui/src/app/services/rest/environment.service.spec.ts
Normal file
16
src-ui/src/app/services/rest/environment.service.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { EnvironmentService } from './environment.service';
|
||||
|
||||
describe('EnvironmentService', () => {
|
||||
let service: EnvironmentService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(EnvironmentService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
22
src-ui/src/app/services/rest/environment.service.ts
Normal file
22
src-ui/src/app/services/rest/environment.service.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PaperlessEnvironment } from 'src/app/data/paperless-environment';
|
||||
import { environment } from 'src/environments/environment'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class EnvironmentService {
|
||||
|
||||
protected baseUrl: string = environment.apiBaseUrl
|
||||
|
||||
constructor(protected http: HttpClient) { }
|
||||
|
||||
get(environment: string): Observable<PaperlessEnvironment> {
|
||||
let httpParams = new HttpParams();
|
||||
httpParams = httpParams.set('name', environment);
|
||||
|
||||
return this.http.get<PaperlessEnvironment>(`${this.baseUrl}environment/`, {params: httpParams})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user