Revision 55964
Added by Argiro Kokogiannaki almost 5 years ago
zenodo-communities.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http, Response} from '@angular/http'; |
3 | 3 |
import {Headers, RequestOptions} from '@angular/http'; |
4 |
import {Observable} from 'rxjs/Rx'; |
|
4 |
import {HttpClient} from "@angular/common/http"; |
|
5 |
import {Observable} from 'rxjs'; |
|
5 | 6 |
|
6 | 7 |
import {ZenodoCommunityInfo} from './zenodoCommunityInfo'; |
7 | 8 |
import {EnvProperties} from '../../utils/properties/env-properties'; |
9 |
import {map} from "rxjs/operators"; |
|
8 | 10 |
|
9 | 11 |
@Injectable() |
10 | 12 |
export class ZenodoCommunitiesService { |
11 | 13 |
|
12 |
constructor(private http:Http) { |
|
14 |
constructor(private http:HttpClient) {
|
|
13 | 15 |
} |
14 | 16 |
|
15 | 17 |
getZenodoCommunities(properties:EnvProperties, url: string) { |
16 | 18 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url) |
17 |
.map(res => <any> res.json()).map(res => [this.parseZenodoCommunities(res.hits.hits),res.hits.total]); |
|
19 |
//.map(res => <any> res.json()) |
|
20 |
.pipe(map(res => [this.parseZenodoCommunities(res['hits'].hits),res['hits'].total])); |
|
18 | 21 |
} |
19 | 22 |
getZenodoCommunityById(properties:EnvProperties, url: string, openaireId:string) { |
20 | 23 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url) |
21 |
.map(res => <any> res.json()).map(res => { |
|
24 |
//.map(res => <any> res.json()) |
|
25 |
.pipe(map(res => { |
|
22 | 26 |
var community = this.parseZenodoCommunity(res); |
23 | 27 |
community["openaireId"]=openaireId; |
24 | 28 |
return community; |
25 |
}); |
|
29 |
}));
|
|
26 | 30 |
} |
27 | 31 |
|
28 | 32 |
parseZenodoCommunities(data: any): ZenodoCommunityInfo[] { |
... | ... | |
53 | 57 |
|
54 | 58 |
getTotalZenodoCommunities(properties:EnvProperties, url: string) { |
55 | 59 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url) |
56 |
.map(res => <any> res.json()).map(res => res.hits.total); |
|
60 |
//.map(res => <any> res.json()) |
|
61 |
.pipe(map(res => res['hits'].total)); |
|
57 | 62 |
} |
58 | 63 |
} |
Also available in: Unified diff
[Library|Trunk]
Merge into trunk branch angular7 rev 55729