Project

General

Profile

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

    
11
@Injectable()
12
export class ConfigurationService {
13

    
14

    
15
   constructor(private http: HttpClient ) {}
16
   getCommunityInformation(APIUrl:string, community:string){
17
     return this.http.get(APIUrl + "/communityFull/" + community);
18
               //.map(res => res.json());
19
   }
20

    
21
   isEntityEnabled(APIUrl:string, community:string,entity: string){
22
     //console.log("isEntityEnabled:  "+entity);
23
     let url = "isEntityEnabled-"+entity;
24

    
25
    //  if(entity == "publication" || entity == "dataset" || entity == "datasource"){
26
    //     return Observable.of(new Object()).mapTo(false);
27
    //  }
28
    //  return Observable.of(new Object()).mapTo(true);
29
     return this.http.get(APIUrl + "/page")
30
               .pipe(map(res => true));
31
   }
32

    
33
   isPageEnabled(APIUrl:string, community:string,router: string){
34
      return this.http.get(APIUrl + "/community/" + community+"/pages?page_route="+router)
35
              //.map(res => res.json())
36
              .pipe(map(res => {
37
                let result = false;
38
                if(res['length'] >0 && res[0].route == router){
39
                  result =  res[0].isEnabled;
40
                }
41

    
42
                return result;
43
              }));//.do(res => {console.log("Route "+router +" is "+res)});
44
   }
45

    
46
   getMainPageContent(APIUrl:string, community:string,){
47
     return this.http.get(APIUrl + "/page")
48
               .pipe(map(res => true));
49
   }
50
   getSpecialAnouncementContent(APIUrl:string, community:string,){
51
     return this.http.get(APIUrl + "/page")
52
               .pipe(map(res => ""));
53
   }
54
   getHelpPageContent(APIUrl:string, community:string, router:string){
55
     return  this.http.get(APIUrl + "/page")
56
               .pipe(map(res => true));
57
   }
58
    // private handleError (error: Response) {
59
    // // in a real world app, we may send the error to some remote logging infrastructure
60
    // // instead of just logging it to the console
61
    //     console.log(error);
62
    //     return this.http.get(this.APIUrl + "/page")
63
    //               .map(res => true);
64
    // }
65

    
66

    
67
}
(1-1/2)