openaire-library/utils/configuration/configuration.service.ts

66 lines
2.2 KiB
TypeScript

import {Injectable} from '@angular/core';
import {Http, Response, Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/mapTo';
import 'rxjs/add/observable/of';
// import 'rxjs/add/operator/do';
// import 'rxjs/add/operator/share';
import { mapTo } from 'rxjs/operators';
@Injectable()
export class ConfigurationService {
constructor(private http: Http ) {}
getCommunityInformation(APIUrl:string, community:string){
return this.http.get(APIUrl + "/communityFull/" + community)
.map(res => res.json());
}
isEntityEnabled(APIUrl:string, community:string,entity: string){
//console.log("isEntityEnabled: "+entity);
let url = "isEntityEnabled-"+entity;
// if(entity == "publication" || entity == "dataset" || entity == "datasource"){
// return Observable.of(new Object()).mapTo(false);
// }
// return Observable.of(new Object()).mapTo(true);
return this.http.get(APIUrl + "/page")
.map(res => true);
}
isPageEnabled(APIUrl:string, community:string,router: string){
return this.http.get(APIUrl + "/community/" + community+"/pages?page_route="+router)
.map(res => res.json()).map(res => {
var result = false;
if(res.length >0 && res[0].route == router){
result = res[0].isEnabled;
}
return result;
});//.do(res => {console.log("Route "+router +" is "+res)});
}
getMainPageContent(APIUrl:string, community:string,){
return this.http.get(APIUrl + "/page")
.map(res => true);
}
getSpecialAnouncementContent(APIUrl:string, community:string,){
return this.http.get(APIUrl + "/page")
.map(res => "");
}
getHelpPageContent(APIUrl:string, community:string, router:string){
return this.http.get(APIUrl + "/page")
.map(res => true);
}
// private handleError (error: Response) {
// // in a real world app, we may send the error to some remote logging infrastructure
// // instead of just logging it to the console
// console.log(error);
// return this.http.get(this.APIUrl + "/page")
// .map(res => true);
// }
}