1
|
import {Injectable} from '@angular/core';
|
2
|
import {Http, Response, Headers} from '@angular/http';
|
3
|
import {HttpClient} from "@angular/common/http";
|
4
|
import {Observable} from 'rxjs';
|
5
|
|
6
|
|
7
|
// import 'rxjs/add/operator/do';
|
8
|
// import 'rxjs/add/operator/share';
|
9
|
import {map, mapTo} from 'rxjs/operators';
|
10
|
import {EnvProperties} from "../properties/env-properties";
|
11
|
|
12
|
@Injectable()
|
13
|
export class ConfigurationService {
|
14
|
|
15
|
|
16
|
constructor(private http: HttpClient ) {}
|
17
|
getCommunityInformation(properties:EnvProperties, community:string){
|
18
|
let url = properties.adminToolsAPIURL +"/communityFull/" + community;
|
19
|
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
|
20
|
//.map(res => res.json());
|
21
|
}
|
22
|
|
23
|
isEntityEnabled(APIUrl:string, community:string,entity: string){
|
24
|
//console.log("isEntityEnabled: "+entity);
|
25
|
let url = "isEntityEnabled-"+entity;
|
26
|
|
27
|
// if(entity == "publication" || entity == "dataset" || entity == "datasource"){
|
28
|
// return Observable.of(new Object()).mapTo(false);
|
29
|
// }
|
30
|
// return Observable.of(new Object()).mapTo(true);
|
31
|
return this.http.get(APIUrl + "/page")
|
32
|
.pipe(map(res => true));
|
33
|
}
|
34
|
|
35
|
isPageEnabled(properties:EnvProperties, community:string,router: string){
|
36
|
let url = properties.adminToolsAPIURL + "/community/" + community+"/pages?page_route="+router;
|
37
|
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
38
|
//.map(res => res.json())
|
39
|
.pipe(map(res => {
|
40
|
let result = false;
|
41
|
if(res['length'] >0 && res[0].route == router){
|
42
|
result = res[0].isEnabled;
|
43
|
}
|
44
|
|
45
|
return result;
|
46
|
}));//.do(res => {console.log("Route "+router +" is "+res)});
|
47
|
}
|
48
|
|
49
|
getMainPageContent(APIUrl:string, community:string,){
|
50
|
return this.http.get(APIUrl + "/page")
|
51
|
.pipe(map(res => true));
|
52
|
}
|
53
|
getSpecialAnouncementContent(APIUrl:string, community:string,){
|
54
|
return this.http.get(APIUrl + "/page")
|
55
|
.pipe(map(res => ""));
|
56
|
}
|
57
|
getHelpPageContent(APIUrl:string, community:string, router:string){
|
58
|
return this.http.get(APIUrl + "/page")
|
59
|
.pipe(map(res => true));
|
60
|
}
|
61
|
// private handleError (error: Response) {
|
62
|
// // in a real world app, we may send the error to some remote logging infrastructure
|
63
|
// // instead of just logging it to the console
|
64
|
// console.log(error);
|
65
|
// return this.http.get(this.APIUrl + "/page")
|
66
|
// .map(res => true);
|
67
|
// }
|
68
|
|
69
|
|
70
|
}
|