Project

General

Profile

« Previous | Next » 

Revision 55964

[Library|Trunk]

Merge into trunk branch angular7 rev 55729

View differences:

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

  
6

  
7

  
7 8
import {SearchResult}     from '../utils/entities/searchResult';
8 9
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
9 10
import{EnvProperties} from '../utils/properties/env-properties';
10 11
import {StringUtils} from '../utils/string-utils.class';
12
import {map} from "rxjs/operators";
11 13

  
12 14
@Injectable()
13 15
export class SearchOrganizationsService {
14 16

  
15
    constructor(private http: Http ) {}
17
    constructor(private http: HttpClient ) {}
16 18

  
17 19
    parseResultsForDeposit(data: any): {"name": string, "id": string}[] {
18 20
        let results: {"name": string, "id": string}[] = [];
......
51 53

  
52 54

  
53 55
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
54
                    .map(res => <any> res.json())
55
                    .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]);
56
                    //.map(res => <any> res.json())
57
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]));
56 58
    }
57 59
    advancedSearchOrganizations (params: string, page: number, size: number, properties:EnvProperties ):any {
58 60
      let url = properties.searchResourcesAPIURL;
......
72 74
      url += "&format=json";
73 75

  
74 76
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
75
      .map(res => <any> res.json())
77
      //.map(res => <any> res.json())
76 78

  
77
      .map(res => [res['meta'].total, this.parseResults(res['results'])]);
79
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
78 80
    }
79 81
    parseResults(data: any): SearchResult[] {
80 82
        let results: SearchResult[] = [];
......
165 167
    numOfOrganizations(url: string, properties:EnvProperties ): any {
166 168

  
167 169
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
168
                  .map(res => <any> res.json())
169
                  .map(res => res.total);
170
                  //.map(res => <any> res.json())
171
                  .pipe(map(res => res['total']));
170 172
    }
171 173

  
172 174
    numOfEntityOrganizations(id: string, entity: string, properties:EnvProperties ):any {

Also available in: Unified diff