Project

General

Profile

1 50169 argiro.kok
import {Injectable} from '@angular/core';
2
import {Http, Response, Headers} from '@angular/http';
3 55964 argiro.kok
import {HttpClient} from "@angular/common/http";
4
import {Observable}     from 'rxjs';
5
6
7 50169 argiro.kok
// import 'rxjs/add/operator/do';
8
// import 'rxjs/add/operator/share';
9 55964 argiro.kok
import {map, mapTo} from 'rxjs/operators';
10 50169 argiro.kok
11
@Injectable()
12
export class ConfigurationService {
13
14 54775 konstantin
15 55964 argiro.kok
   constructor(private http: HttpClient ) {}
16 50586 argiro.kok
   getCommunityInformation(APIUrl:string, community:string){
17 55964 argiro.kok
     return this.http.get(APIUrl + "/communityFull/" + community);
18
               //.map(res => res.json());
19 50586 argiro.kok
   }
20
21
   isEntityEnabled(APIUrl:string, community:string,entity: string){
22 54775 konstantin
     //console.log("isEntityEnabled:  "+entity);
23 50169 argiro.kok
     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 50586 argiro.kok
     return this.http.get(APIUrl + "/page")
30 55964 argiro.kok
               .pipe(map(res => true));
31 50169 argiro.kok
   }
32
33 50586 argiro.kok
   isPageEnabled(APIUrl:string, community:string,router: string){
34
      return this.http.get(APIUrl + "/community/" + community+"/pages?page_route="+router)
35 55964 argiro.kok
              //.map(res => res.json())
36
              .pipe(map(res => {
37 54906 k.triantaf
                let result = false;
38 55964 argiro.kok
                if(res['length'] >0 && res[0].route == router){
39 50586 argiro.kok
                  result =  res[0].isEnabled;
40
                }
41
42
                return result;
43 55964 argiro.kok
              }));//.do(res => {console.log("Route "+router +" is "+res)});
44 50169 argiro.kok
   }
45 50586 argiro.kok
46
   getMainPageContent(APIUrl:string, community:string,){
47
     return this.http.get(APIUrl + "/page")
48 55964 argiro.kok
               .pipe(map(res => true));
49 50169 argiro.kok
   }
50 50586 argiro.kok
   getSpecialAnouncementContent(APIUrl:string, community:string,){
51
     return this.http.get(APIUrl + "/page")
52 55964 argiro.kok
               .pipe(map(res => ""));
53 50169 argiro.kok
   }
54 50586 argiro.kok
   getHelpPageContent(APIUrl:string, community:string, router:string){
55
     return  this.http.get(APIUrl + "/page")
56 55964 argiro.kok
               .pipe(map(res => true));
57 50169 argiro.kok
   }
58 50586 argiro.kok
    // 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 50169 argiro.kok
66
67
}