import { Injectable } from '@angular/core'; import { RdpCrudInterface } from 'portalsdk-tag-lib'; import { AdminService } from '../admin.service'; import { BehaviorSubject } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class RoleFunctionsService implements RdpCrudInterface { public statusResponse = new BehaviorSubject(""); public updatedData = new BehaviorSubject({}); loadTableData(filter: any, sortActive: any, sortDirection: any, pageIndex: any, pageSize: any): import("rxjs").Observable { throw new Error("Method not implemented."); } getTotalRowCount() { throw new Error("Method not implemented."); } constructor(private adminService: AdminService) { } add(data: any) { //console.log("Add method is getting called from RoleFunctionService data:: ", data); } update(data: any): any { console.log("Update method is getting called from RoleFunctionService data:: ", data); return this.adminService.saveRoleFunction(data).subscribe(response => { //console.log("Success Response ", response); this.statusResponse.next("200"); }, error => { console.log("Error ", error); }) } delete(data: any) { //console.log("Delete method is getting called from RoleFunctionService data::>> " + JSON.stringify(data)); this.adminService.deleteRoleFunction(data).subscribe(response => { //console.log("Repsonse : ", response); this.statusResponse.next("200"); }) } get() { let response = this.adminService.getRoleFunctionList(); let editedData; response.subscribe(res => { editedData = res; let data = JSON.parse(JSON.parse(editedData.data).availableRoleFunctions); //console.log("Get Method called : ", data); this.updatedData.next(data); }) } }