import { Injectable } from '@angular/core'; import { BaseService } from 'ekangularbase/src/baseclass/BaseService'; import { HandleError, HttpErrorHandler } from 'ekangularbase/src/auth/http-error-handler.service'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { AppConfig } from 'ekangularbase/src/AppConfig/AppConfig'; import { Observable } from 'rxjs'; import { AuthService } from 'ekangularbase/src/auth/auth.service'; import { catchError, tap } from 'rxjs/operators'; import { FieldHasAuditTrailClass } from '../../interface/field-has-audit-trial'; import { SyncResponseErrorHandleService } from 'ekangularbase/src/route/SyncResponseErrorHandle'; import { AuditTrailClass, LogHasChangeById, SpecifyLogHasChangeById } from 'ekangularbase/src/interface/audit-trail'; @Injectable() export class AuditTrailService extends BaseService { public handleError: HandleError; constructor( public syncResponseErrorHandleService: SyncResponseErrorHandleService, public authService: AuthService, public http: HttpClient, public httpErrorHandler: HttpErrorHandler) { super(authService, httpErrorHandler, http, AppConfig.settings.apiserviceurl, 'Logs', '', syncResponseErrorHandleService); this.handleError = httpErrorHandler.createHandleError('AuditTrailService'); } apiserviceurl = AppConfig.settings.apiserviceurl; apiUrl = 'api/Logs/'; // httpHeaders = new HttpHeaders() // .set('Content-Type', 'application/json') // .set('Authorization', this.authService.getAuthorizationHeaderValue()); GetHasChanges(entityType: string, rowId: string): Observable { const paramsInput: HttpParams = new HttpParams() .append('type', entityType) .append('id', rowId); return this.http.get(this.apiserviceurl + this.apiUrl + 'HasChanges', { headers: this.GetHeaders(), params: paramsInput }) .pipe( catchError(this.handleError('getAuditTrailHasChanges', [])) ); } GetChanges(entityType: string, rowId: string, columnName: string): Observable { const paramsInput: HttpParams = new HttpParams() .append('type', entityType) .append('id', rowId) .append('column', columnName); return this.http.get(this.apiserviceurl + this.apiUrl + 'GetChanges', { headers: this.GetHeaders(), params: paramsInput }) .pipe( catchError(this.handleError('getAuditTrailGetChanges', [])) ); } HasChangesList(entityType: string, object: any[]): Observable { return this.http.post(this.apiserviceurl + this.apiUrl + 'HasChangesList/' + entityType, object, this.optionss()).pipe( catchError(this.handleError('HasChangesList', [])) ); } HasSpecifyChangesList(entityType: string, object: SpecifyLogHasChangeById): Observable { return this.http.post(this.apiserviceurl + this.apiUrl + 'HasSpecifyChangesList/' + entityType, object, this.optionss()).pipe( catchError(this.handleError('HasSpecifyChangesList', null)) ); } PostHasChanges(entityType: string, rowId: string, columnList: string[]): Observable { return this.http.post(this.apiserviceurl + this.apiUrl + 'HasChanges/' + entityType + '/' + rowId, columnList, { headers: this.GetHeaders(), }) .pipe( catchError(this.handleError('PostHasChanges', null)) ); } }