Project

General

Profile

« Previous | Next » 

Revision 55573

[angular7: Library]: Move uoa-services-library project to Angular 7 (using webpack)

View differences:

configuration.service.ts
1 1
import {Injectable} from '@angular/core';
2 2
import {Http, Response, Headers} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import 'rxjs/add/operator/mapTo';
5
import 'rxjs/add/observable/of';
3
import {HttpClient} from "@angular/common/http";
4
import {Observable}     from 'rxjs';
5

  
6

  
6 7
// import 'rxjs/add/operator/do';
7 8
// import 'rxjs/add/operator/share';
8
import { mapTo } from 'rxjs/operators';
9
import {map, mapTo} from 'rxjs/operators';
9 10

  
10 11
@Injectable()
11 12
export class ConfigurationService {
12 13

  
13 14

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

  
20 21
   isEntityEnabled(APIUrl:string, community:string,entity: string){
......
26 27
    //  }
27 28
    //  return Observable.of(new Object()).mapTo(true);
28 29
     return this.http.get(APIUrl + "/page")
29
               .map(res => true);
30
               .pipe(map(res => true));
30 31
   }
31 32

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

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

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

Also available in: Unified diff