add comment function

This commit is contained in:
tim-vogel
2022-08-07 12:41:30 -07:00
committed by Michael Shamoon
parent c2fda245ac
commit 278e9c12e1
20 changed files with 416 additions and 1 deletions

View File

@@ -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();
});
});

View 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});
}
}

View 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();
});
});

View 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})
}
}