import { Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
// import 'rxjs/add/operator/map';
import { ContentsSandbox } from '../shared/sandbox/content.sandbox';
import { getHostURL } from '../content-library.component';
import { HttpClient, HttpResponse, HttpHeaders } from '@angular/common/http';
// import 'rxjs/Rxjs';

@Injectable({
  providedIn: 'root'
})
export class HtmlContentManagerService {
  
  content: any;  
  private url=  "/ibase/extractedFiles/";  

  constructor(private http:HttpClient, public contentSandbox: ContentsSandbox) { }
  
  getData(){
         {
             this.content = this.contentSandbox.getSelectedContent(); 
             var loactionUrl = this.contentSandbox.getHostUrl() + this.url + this.content.docId +'/'+this.content.docId+".json";
             console.log("htmlPage rest service ==>", loactionUrl);
            //  return this.http.get(loactionUrl)
              //  .pipe(map((response:Response)=>response.json()))
            return this.http.get<any>(loactionUrl).pipe(map((response:Response)=>response.json()))
       }
  }
  
}
