import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { environment } from '../../environments/environment';
import { TemplateFileModel, TemplateModel } from '../model/template.model';
import { ModuleModel } from '../model/module.model';
import { ExcelPortalModel, ExcelPortalGroupModel, ExcelPortalTagsModel } from '../model/excel-portal.model';
import { AlertModel } from '../model/alert.model';
import { TemplateFileMiniModel } from '../model/template-file-mini.model';
import { DatasourceTableModel } from '../model/datasource-table.model';

@Injectable({
  providedIn: 'root'
})
export class DatasourseTableService {

  constructor(private http: HttpClient,
    private translateService: TranslateService
  ) { }
  getid(companyid: string): Observable<DatasourceTableModel> {
    return this.http.get<DatasourceTableModel>(environment.url + "datasource/" + companyid)
  }
  getList(): Observable<DatasourceTableModel[]> {
    return this.http.get<DatasourceTableModel[]>(environment.url + "datasource/lists")
  }
  post(body: DatasourceTableModel): Observable<AlertModel> {
    return this.http.post<AlertModel>(environment.url + "datasource", body)
  }
  delete(body: DatasourceTableModel): Observable<AlertModel> {
    let option = {
      headers: new HttpHeaders({
        "Content-Type": "application/json",
      }),
      body: body
    }
    return this.http.delete<AlertModel>(environment.url + "datasource", option)
  }
}