import { Injectable } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; import { environment } from 'src/environments/environment'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class CommonService { private baseUrl = ''; private baseUDCUrl = ''; private params = new HttpParams(); constructor(private http: HttpClient) { this.baseUrl = environment.hostUrl + '/DataManage'; this.baseUDCUrl = environment.hostUrl + '/udc'; } getRowPerPageData(code: string, userId: string): Observable { const apid: number = environment.api.RowsPerPage; return this.http.get(this.baseUrl + '/' + apid + '?search=ConfigCode:' + "'" + code + "'" + 'and UserId:' + "'" + userId + "'").pipe(map(res => res as T[] | any)); } updateRowPerPage(value: T, params: number) { const apid: number = environment.api.RowsPerPage; return this.http.put(this.baseUrl + '/' + apid + '?search=Id:' + params, value) .pipe(map(res => res as boolean| any)); // Successfull Update response=TRUE,Else=False } saveRowPerPage(value: T) { const apid: number = environment.api.RowsPerPage; return this.http.post(this.baseUrl + '/' + apid, value) .pipe(map(res => res as boolean| any)); // Successfull Update response=TRUE,Else=False } doDecrypt(value) { const appDecrypt = (salt) => { const textToChars = (text) => text.split('').map((c) => c.charCodeAt(0)); const applySaltToChar = (code) => textToChars(salt).reduce((a, b) => a ^ b, code); return (encoded) => encoded .match(/.{1,2}/g) .map((hex) => parseInt(hex, 16)) .map(applySaltToChar) .map((charCode) => String.fromCharCode(charCode)) .join(''); }; const RRDecrypt = appDecrypt('zibal2020'); return RRDecrypt(value); } getUserInfo(email: string): Observable { const apid: number = environment.api.UserData; return this.http .get( this.baseUrl + '/' + apid + '?search=Email:' + "'" + email + "'and IsActive:'true'" ) .pipe(map((res) => res as T[] | any)); } }