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
|
/**
|
24
|
* @deprecated
|
25
|
*/
|
26
|
isEntityEnabled(APIUrl:string, community:string,entity: string){
|
27
|
//console.log("isEntityEnabled: "+entity);
|
28
|
let url = "isEntityEnabled-"+entity;
|
29
|
|
30
|
// if(entity == "publication" || entity == "dataset" || entity == "datasource"){
|
31
|
// return Observable.of(new Object()).mapTo(false);
|
32
|
// }
|
33
|
// return Observable.of(new Object()).mapTo(true);
|
34
|
return this.http.get(APIUrl + "/page")
|
35
|
.pipe(map(res => true));
|
36
|
}
|
37
|
|
38
|
isPageEnabled(properties:EnvProperties, community:string,router: string){
|
39
|
let page_route: string = router.split('?')[0].substring(1);
|
40
|
let url = properties.adminToolsAPIURL + "/community/" + community+"/pages?page_route="+page_route;
|
41
|
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
42
|
//.map(res => res.json())
|
43
|
.pipe(map(res => {
|
44
|
let result = false;
|
45
|
if(res['length'] >0 && res[0].route == page_route){
|
46
|
result = res[0].isEnabled;
|
47
|
}
|
48
|
|
49
|
return result;
|
50
|
}));//.do(res => {console.log("Route "+page_route +" is "+res)});
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* @deprecated
|
55
|
*/
|
56
|
getMainPageContent(APIUrl:string, community:string,){
|
57
|
return this.http.get(APIUrl + "/page")
|
58
|
.pipe(map(res => true));
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* @deprecated
|
63
|
*/
|
64
|
getSpecialAnouncementContent(APIUrl:string, community:string,){
|
65
|
return this.http.get(APIUrl + "/page")
|
66
|
.pipe(map(res => ""));
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* @deprecated
|
71
|
*/
|
72
|
getHelpPageContent(APIUrl:string, community:string, router:string){
|
73
|
return this.http.get(APIUrl + "/page")
|
74
|
.pipe(map(res => true));
|
75
|
}
|
76
|
// private handleError (error: Response) {
|
77
|
// // in a real world app, we may send the error to some remote logging infrastructure
|
78
|
// // instead of just logging it to the console
|
79
|
// console.log(error);
|
80
|
// return this.http.get(this.APIUrl + "/page")
|
81
|
// .map(res => true);
|
82
|
// }
|
83
|
|
84
|
|
85
|
}
|