Project

General

Profile

« Previous | Next » 

Revision 56714

[Library|Trunk]
Merging branch newlinking into Trunk 55132:56708

View differences:

contexts.service.ts
1

  
2
import {throwError as observableThrowError, Observable} from 'rxjs';
1
import {throwError as observableThrowError} from 'rxjs';
3 2
import {Injectable} from '@angular/core';
4
import {Jsonp, URLSearchParams, RequestOptions, Headers} from '@angular/http';
5
import {Http, Response} from '@angular/http';
6
import { HttpClient } from '@angular/common/http';
7
import {Claim}           from '../claim';
8
import {AutoCompleteValue} from '../../../searchPages/searchUtils/searchHelperClasses.class';
3
import {Response} from '@angular/http';
4
import {HttpClient} from '@angular/common/http';
9 5
import {catchError, map} from "rxjs/operators";
10
import { COOKIE  } from '../../../login/utils/helper.class';
11 6
@Injectable()
12 7
export class ContextsService {
13 8
  constructor(private http: HttpClient ) {
......
15 10

  
16 11
  public getCommunities( apiUrl:string):any {
17 12
  let  url   = apiUrl + 's/';
18

  
19
  let key = url;
20
    //console.info('ContextsService: request communities  '+url);
21 13
      return this.http.get(url)
22
                    //.map(res => <any> res.json())
23 14
                    .pipe(map(res => this.parseCommunities(res, true) ))
24 15
                    // .do(request => console.info("Get claims: offset = "))
25 16
                    .pipe(catchError(this.handleError));
26 17
  }
27 18
  public getPublicCommunities( apiUrl:string):any {
28 19
    let  url   = apiUrl + 's/';
29

  
30
    let key = url;
31
    //console.info('ContextsService: request communities  '+url);
32 20
    return this.http.get(url)
33 21
      .pipe(map(res => this.parseCommunities(res, true) ));
34 22
  }
......
47 35
  public getCategories(communityId :string, apiUrl:string):any {
48 36
    //console.info('ContextsService:  request categories for community  with id '+communityId);
49 37
    let url= apiUrl  + '/' + communityId ;
50
    let key = url;
51

  
52

  
53 38
      return this.http.get(url)
54 39
                    //.map(request => <any> request.json())
55 40
                    // .do(request => console.info("Get claims: offset = " ))
......
58 43
  public getConcepts(categoryId :string, keyword: string, parsing:boolean, apiUrl:string):any {
59 44
    //console.info('ContextsService:  request concept for category  with id '+categoryId + ' and keyword '+ keyword);
60 45
    let url= apiUrl  + '/category/' + categoryId;
61
    let key = url+"_parsing="+parsing;
62 46

  
63 47

  
64 48
      return this.http.get(url )
65
                    //.map(request => <any> request.json())
66 49
                    .pipe(catchError(this.handleError))
67 50
                    .pipe(map(res => (parsing)?this.parse(res):res));
68
                    // .do(res => console.info("Result is "+ res.length ));
69 51
  }
70 52
  public getSubConcepts(subConceptID :string, keyword: string, parsing:boolean, apiUrl:string):any {
71 53
    //console.info('ContextsService:  request sub concept for concept with id '+subConceptID + ' and keyword '+ keyword);
......
74 56

  
75 57

  
76 58
      return this.http.get(url )
77
                    //.map(request => <any> request.json())
78 59
                    .pipe(catchError(this.handleError))
79 60
                    .pipe(map(res => (parsing)?this.parseSubConcepts(res):res));
80
                    // .do(res => console.info("Result is "+ res.length ));
81 61
  }
82 62
  parse (data: any):any {
83 63
      var array =[]
......
131 111
    console.log(error);
132 112
    return observableThrowError(error  || 'Server error');
133 113
  }
134
  private getAuthOptions():RequestOptions{
135
  let headers = new Headers();
136
  headers.append('X-XSRF-TOKEN',  COOKIE.getCookie(COOKIE.cookieName_id));
137
  let options = new RequestOptions({ headers: headers, withCredentials:true });
138
    return options;
139
  }
140 114
}

Also available in: Unified diff