2017-12-19 13:53:46 +01:00
|
|
|
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 {
|
2018-02-05 14:14:59 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
constructor(private http: Http ) {}
|
|
|
|
getCommunityInformation(APIUrl:string, community:string){
|
|
|
|
return this.http.get(APIUrl + "/communityFull/" + community)
|
|
|
|
.map(res => res.json()).do(res => {console.log(res)});
|
|
|
|
}
|
|
|
|
|
|
|
|
isEntityEnabled(APIUrl:string, community:string,entity: string){
|
2017-12-19 13:53:46 +01:00
|
|
|
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);
|
2018-02-05 14:14:59 +01:00
|
|
|
return this.http.get(APIUrl + "/page")
|
2017-12-19 13:53:46 +01:00
|
|
|
.map(res => true);
|
|
|
|
}
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
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)});
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
|
|
|
|
getMainPageContent(APIUrl:string, community:string,){
|
|
|
|
return this.http.get(APIUrl + "/page")
|
2017-12-19 13:53:46 +01:00
|
|
|
.map(res => true);
|
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
getSpecialAnouncementContent(APIUrl:string, community:string,){
|
|
|
|
return this.http.get(APIUrl + "/page")
|
2017-12-19 13:53:46 +01:00
|
|
|
.map(res => "");
|
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
getHelpPageContent(APIUrl:string, community:string, router:string){
|
|
|
|
return this.http.get(APIUrl + "/page")
|
2017-12-19 13:53:46 +01:00
|
|
|
.map(res => true);
|
|
|
|
}
|
2018-02-05 14:14:59 +01:00
|
|
|
// 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);
|
|
|
|
// }
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
}
|