import { Component, Inject, OnInit, Injectable } from '@angular/core'; import { HttpErrorHandler, HandleError } from '../auth/http-error-handler.service'; import { AuthService } from './auth.service'; import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http'; import { BaseService } from '../baseclass/BaseService'; import { AppConfig } from '../AppConfig/AppConfig'; import { OcBasedPermission } from './OcBasedPermission'; import { Observable } from 'rxjs'; import { catchError } from 'rxjs/operators'; @Injectable() export class OcBasedPermissionService { private handleError: HandleError; constructor( public httpErrorHandler: HttpErrorHandler, private http: HttpClient, @Inject('BASE_URL') baseUrl: string) { this.handleError = httpErrorHandler.createHandleError('OcBasedPermission'); } GetByUserName(username: string, token: any): Observable { const httpHeaders = new HttpHeaders() .set('Content-Type', 'application/json') .set('Authorization', token); // console.log("URL: " + this.apiserviceurl + this.apiUrl); return this.http.post (AppConfig.settings.UserManagerSettings.authority + 'api/OcBasedPermission/GetOcBasedPermissions', '\'' + username + '\'', { headers: httpHeaders }) .pipe( catchError(this.handleError('OcBasedPermission', [])) ); } GetClaimsByModuleName(token: any): Observable { const httpHeaders = new HttpHeaders() .set('Content-Type', 'application/json') .set('Authorization', token); return this.http.get (AppConfig.settings.UserManagerSettings.authority + 'api/AuthFunctionApi/GetClaimListByModule/' + AppConfig.settings.module_name, { headers: httpHeaders }) .pipe( catchError(this.handleError('GetClaimListByModule', [])) ); } GetClaimListByModuleOc(token: any, selectedOc: string): Observable { const httpHeaders = new HttpHeaders() .set('Content-Type', 'application/json') .set('Authorization', token); return this.http.get (AppConfig.settings.UserManagerSettings.authority + 'api/AuthFunctionApi/GetClaimListByModuleOc/' + AppConfig.settings.module_name + '/' + selectedOc, { headers: httpHeaders }) .pipe( catchError(this.handleError('GetClaimListByModuleOc', [])) ); } GetDynamicObjListCache(token: any, selectedOc): Observable { const httpHeaders = new HttpHeaders() .set('Content-Type', 'application/json') .set('Authorization', token) .set('OC', selectedOc) .set('offset', new Date().getTimezoneOffset().toString()); return this.http.get (AppConfig.settings.apiserviceurl + 'api/Dynamic/GetDynamicObjListCache/' + AppConfig.settings.module_name, { headers: httpHeaders }) .pipe( // catchError(this.handleError('GetDynamicObjListCache', null)) ); } }