import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; 
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from '../../../environments/environment';
import {Smartchart} from './smartchart';
let header = new HttpHeaders();
header = header.set('Content-Type', 'application/json; charset=utf-8');
@Injectable({
  providedIn: 'root'
})

export class SmartchartService {

    baseUrl: string = environment.serviceUrl;
  constructor(private httpClient: HttpClient) { }

  getMasterTable(): Observable<any>{
    return this.httpClient.get<any>(this.baseUrl + 'api/SmartChartApi/GetActiveMasterTables');
    }

    getFieldAlias(): Observable<any> {
      return this.httpClient.get<any>(this.baseUrl + 'api/SmartChartApi/GetActiveFieldAlias');
    }    

    postSmartChart(smartChart: Smartchart): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/SmartChartApi/add', smartChart, { headers: header, observe: 'response' })
    }
  
    getByID(smartChart: any): Observable<any> {
      return this.httpClient.post(this.baseUrl + 'api/SmartChartApi/GetById', smartChart, {  observe: 'response' });
    }
  
    putSmartChart(smartChart: Smartchart): Observable<any> {
      return this.httpClient.post<any>(this.baseUrl + 'api/SmartChartApi/Update', smartChart, { headers: header, observe: 'response' })
    }

    getFormConfigDisplayField(id: number): Observable<any> {
      return this.httpClient.get<any>(this.baseUrl + 'api/SmartChartApi/getEditorDisplayStatus/' + id);
    }
}