Revision 55964
Added by Argiro Kokogiannaki almost 5 years ago
modules/uoa-services-library/trunk/ng-openaire-library/src/app/connect/communityGuard/connectSubscriber.guard.ts | ||
---|---|---|
1 |
|
|
2 |
import {filter, mergeMap} from 'rxjs/operators'; |
|
1 | 3 |
import { Injectable } from '@angular/core'; |
2 | 4 |
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router'; |
3 |
import {Observable} from 'rxjs/Observable';
|
|
5 |
import {Observable} from 'rxjs'; |
|
4 | 6 |
import {Session} from '../../login/utils/helper.class'; |
5 | 7 |
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; |
6 | 8 |
import {CommunityService} from '../community/community.service'; |
... | ... | |
8 | 10 |
import {ConnectHelper} from '../connectHelper'; |
9 | 11 |
|
10 | 12 |
@Injectable() |
11 |
export class ConnectSubscriberGuard implements CanActivate, CanLoad {
|
|
13 |
export class ConnectSubscriberGuard implements CanActivate { |
|
12 | 14 |
constructor(private router: Router, |
13 | 15 |
private communityService: CommunityService, |
14 | 16 |
private propertiesService: EnvironmentSpecificService) {} |
... | ... | |
20 | 22 |
this.router.navigate(['/user-info'], {queryParams: {'errorCode': errorCode, 'redirectUrl': path, communityId:community}}); |
21 | 23 |
return false; |
22 | 24 |
} else { |
23 |
const obs = this.propertiesService.subscribeEnvironment().mergeMap(properties => { |
|
25 |
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
|
|
24 | 26 |
if(!community){ |
25 | 27 |
community = ConnectHelper.getCommunityFromDomain(properties.domain); |
26 | 28 |
} |
27 | 29 |
return this.communityService.isSubscribedToCommunity( community, Session.getUserEmail(), properties["adminToolsAPIURL"]) |
28 |
}); |
|
29 |
obs.filter(enabled => !enabled)
|
|
30 |
}));
|
|
31 |
obs.pipe(filter(enabled => !enabled))
|
|
30 | 32 |
.subscribe(() => this.router.navigate(['/user-info'], { |
31 | 33 |
queryParams: { |
32 | 34 |
'errorCode': errorCode, |
... | ... | |
41 | 43 |
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { |
42 | 44 |
return this.check(route.queryParams['communityId'], state.url); |
43 | 45 |
} |
44 |
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean { |
|
45 |
const path = '/' + route.path + document.location.search; |
|
46 |
return this.check(ConnectHelper.getCommunityFromPath(path), path); |
|
47 | 46 |
|
48 |
} |
|
49 |
|
|
50 | 47 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/test/test.component.ts | ||
---|---|---|
1 | 1 |
import {Component, ElementRef} from '@angular/core'; |
2 |
import { Subject } from 'rxjs/Subject'; |
|
3 |
import {Observable} from 'rxjs/Observable'; |
|
2 |
import { Subject , Observable} from 'rxjs'; |
|
4 | 3 |
|
5 | 4 |
import {SearchFields, FieldDetails} from '../utils/properties/searchFields'; |
6 | 5 |
|
modules/uoa-services-library/trunk/ng-openaire-library/src/app/connect/communityGuard/connectCommunityGuard.guard.ts | ||
---|---|---|
1 |
|
|
2 |
import {filter, mergeMap} from 'rxjs/operators'; |
|
1 | 3 |
import { Injectable } from '@angular/core'; |
2 | 4 |
import { |
3 | 5 |
Router, |
... | ... | |
7 | 9 |
CanLoad, |
8 | 10 |
Route |
9 | 11 |
} from '@angular/router'; |
10 |
import {Observable} from 'rxjs/Observable';
|
|
12 |
import {Observable} from 'rxjs'; |
|
11 | 13 |
import {CommunityService} from '../community/community.service'; |
12 | 14 |
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; |
13 | 15 |
import {ConnectHelper} from '../connectHelper'; |
14 | 16 |
|
15 | 17 |
@Injectable() |
16 |
export class ConnectCommunityGuard implements CanActivate, CanLoad {
|
|
18 |
export class ConnectCommunityGuard implements CanActivate { |
|
17 | 19 |
|
18 | 20 |
constructor(private router: Router, |
19 | 21 |
private communityService: CommunityService, |
... | ... | |
21 | 23 |
} |
22 | 24 |
|
23 | 25 |
check(community: string): Observable<boolean> | boolean { |
24 |
const obs = this.propertiesService.subscribeEnvironment().mergeMap(properties => { |
|
26 |
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
|
|
25 | 27 |
return this.communityService.isCommunityType(properties, properties['communityAPI'] + community); |
26 |
}); |
|
27 |
obs.filter(enabled => !enabled)
|
|
28 |
}));
|
|
29 |
obs.pipe(filter(enabled => !enabled))
|
|
28 | 30 |
.subscribe(() => this.router.navigate(['errorcommunity'])); |
29 | 31 |
return obs; |
30 | 32 |
} |
... | ... | |
32 | 34 |
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { |
33 | 35 |
return this.check(route.queryParams['communityId']); |
34 | 36 |
} |
35 |
|
|
36 |
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean { |
|
37 |
const path = '/' + route.path + document.location.search; |
|
38 |
return this.check(ConnectHelper.getCommunityFromPath(path)); |
|
39 |
} |
|
40 | 37 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/connect/userEmailPreferences/mailPrefs.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http, RequestOptions, Headers, Response} from '@angular/http'; |
3 |
import {Observable} from 'rxjs/Observable'; |
|
3 |
import {HttpClient, HttpErrorResponse} from "@angular/common/http"; |
|
4 |
import {Observable, throwError} from 'rxjs'; |
|
4 | 5 |
//import { HttpErrorResponse } from '@angular/common/http'; |
5 | 6 |
|
6 | 7 |
import {EnvProperties} from '../../utils/properties/env-properties'; |
... | ... | |
8 | 9 |
|
9 | 10 |
@Injectable() |
10 | 11 |
export class MailPrefsService { |
11 |
constructor(private http: Http ) {} |
|
12 |
constructor(private http: HttpClient ) {}
|
|
12 | 13 |
|
13 | 14 |
getUserEmailPreferencesForCommunity (communityId:string, apiUrl:string):any { |
14 | 15 |
let url = apiUrl +"users/notification"+"?communityId="+communityId; |
15 | 16 |
|
16 | 17 |
return this.http.get(url, CustomOptions.getAuthOptions()) |
17 |
.map(request => <any> request.json()) |
|
18 |
//.map(request => <any> request.json())
|
|
18 | 19 |
//.do(request => console.info("Get user email preferences for communityId= "+communityId )); |
19 | 20 |
//.catch(this.handleError); |
20 | 21 |
} |
... | ... | |
23 | 24 |
let url = apiUrl +"users/notification"; |
24 | 25 |
|
25 | 26 |
//var error: HttpErrorResponse = new HttpErrorResponse({"error": {"code": 204}, "status" : 204}); // doesn't work |
26 |
var response: Response = new Response({"body" : {"code":200, "data": []}, "status": 200, "headers": null, "url": "", "merge": null}); |
|
27 |
//var response: Response = new Response({"body" : {"code":200, "data": []}, "status": 200, "headers": null, "url": "", "merge": null});
|
|
27 | 28 |
|
28 | 29 |
return this.http.get(url, CustomOptions.getAuthOptions()) |
29 | 30 |
//.timeoutWith(100, Observable.throw(response)) // goes to error |
30 | 31 |
//.timeoutWith(100, Observable.of(response)) // goes to |
31 | 32 |
//.do(request => console.info(request)) |
32 |
.map(request => <any> request.json()) |
|
33 |
//.map(request => <any> request.json())
|
|
33 | 34 |
//.do(request => console.info("Get user email preferences for OpenAIRE" )); |
34 | 35 |
//.catch(this.handleError); |
35 | 36 |
} |
... | ... | |
39 | 40 |
|
40 | 41 |
let body = JSON.stringify( notification ); |
41 | 42 |
//console.warn('Json body: : '+body); |
42 |
let headers = new Headers({ 'Content-Type': 'application/json' }); |
|
43 |
let options = new RequestOptions({ headers: headers }); |
|
43 |
//let headers = new Headers({ 'Content-Type': 'application/json' });
|
|
44 |
//let options = new RequestOptions({ headers: headers });
|
|
44 | 45 |
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody()) |
45 |
.map(res => res.json()) |
|
46 |
//.map(res => res.json())
|
|
46 | 47 |
//.do(request => console.info("Insert Response:"+request.status) ); |
47 | 48 |
//.catch(this.handleError); |
48 | 49 |
} |
49 | 50 |
|
50 |
private handleError (error: Response) { |
|
51 |
private handleError (error: HttpErrorResponse) {
|
|
51 | 52 |
// in a real world app, we may send the error to some remote logging infrastructure |
52 | 53 |
// instead of just logging it to the console |
53 | 54 |
console.log(error); |
54 |
return Observable.throw(error || 'Server error');
|
|
55 |
return throwError(error || 'Server error');
|
|
55 | 56 |
} |
56 | 57 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/searchPaging.component.ts | ||
---|---|---|
1 | 1 |
import {Component, Input, Output, EventEmitter} from '@angular/core'; |
2 |
import {Observable} from 'rxjs/Observable';
|
|
2 |
import {Observable} from 'rxjs'; |
|
3 | 3 |
import {ErrorCodes} from '../../utils/properties/errorCodes'; |
4 | 4 |
|
5 | 5 |
@Component({ |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/searchPageTableView.component.ts | ||
---|---|---|
6 | 6 |
import {ActivatedRoute, Router} from '@angular/router'; |
7 | 7 |
import {Title, Meta} from '@angular/platform-browser'; |
8 | 8 |
|
9 |
import {Observable} from 'rxjs/Observable'; |
|
10 |
import {Subject} from 'rxjs/Subject'; |
|
9 |
import {Observable, Subject} from 'rxjs'; |
|
11 | 10 |
|
12 | 11 |
import {DataTableDirective } from 'angular-datatables'; |
13 | 12 |
|
modules/uoa-services-library/trunk/ng-openaire-library/src/app/searchPages/searchUtils/dateFilter.component.ts | ||
---|---|---|
1 | 1 |
import {Component, Input, Output, EventEmitter} from '@angular/core'; |
2 |
import {Observable} from 'rxjs/Observable';
|
|
2 |
import {Observable} from 'rxjs'; |
|
3 | 3 |
|
4 | 4 |
import { Filter, Value, DateValue} from './searchHelperClasses.class'; |
5 | 5 |
import {IMyOptions, IMyDateModel} from '../../utils/my-date-picker/interfaces/index'; |
6 | 6 |
// import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface'; |
7 | 7 |
import {Dates} from '../../utils/string-utils.class'; |
8 |
import {FormControl} from "@angular/forms"; |
|
9 |
import {MatDatepickerInputEvent} from "@angular/material"; |
|
8 | 10 |
|
9 | 11 |
@Component({ |
10 | 12 |
selector: 'date-filter', |
11 | 13 |
template: ` |
12 | 14 |
|
13 |
<select *ngIf="dateValue.type!='range' " name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type > |
|
15 |
<select *ngIf="dateValue && dateValue.type!='range' " name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type >
|
|
14 | 16 |
<option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option> |
15 | 17 |
</select> |
16 |
<div *ngIf="dateValue.type=='range' " class="-row dateFilter" > |
|
17 |
|
|
18 |
<div *ngIf="dateValue && dateValue.type=='range' "> |
|
18 | 19 |
<table class=" uk-table uk-table-responsive" > |
19 |
<tr><td> |
|
20 |
<select name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type > |
|
21 |
<option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option> |
|
22 |
</select></td> |
|
23 |
<td> |
|
24 |
From</td><td style="width: 112px;"><my-date-picker name="from" [options]="myDatePickerOptions" |
|
25 |
[(ngModel)]="from" (dateChanged)="onFromDateChanged($event)" ></my-date-picker> |
|
26 |
</td> <td> |
|
27 |
To </td><td style="width: 112px;"> <my-date-picker name="to" [options]="myDatePickerOptions" |
|
28 |
[(ngModel)]="to" (dateChanged)="onToDateChanged($event)" ></my-date-picker></td></tr> |
|
20 |
<tr> |
|
21 |
<td class="uk-padding-remove-top"> |
|
22 |
<select name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type > |
|
23 |
<option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option> |
|
24 |
</select> |
|
25 |
</td> |
|
26 |
<td> |
|
27 |
From |
|
28 |
</td> |
|
29 |
<td class="uk-padding-remove-top" style="width: 112px;"> |
|
30 |
<mat-form-field style="max-width: 112px;"> |
|
31 |
<input matInput [matDatepicker]="pickerFrom" placeholder="Choose a date" |
|
32 |
[formControl]="fromDate" (click)="pickerFrom.open()" (dateChange)="fromDateChanged($event)"> |
|
33 |
<mat-datepicker-toggle matSuffix [for]="pickerFrom"></mat-datepicker-toggle> |
|
34 |
<mat-datepicker #pickerFrom></mat-datepicker> |
|
35 |
</mat-form-field> |
|
36 |
</td> |
|
37 |
<td> |
|
38 |
To |
|
39 |
</td> |
|
40 |
<td class="uk-padding-remove-top" style="width: 112px;"> |
|
41 |
<mat-form-field style="max-width: 112px;"> |
|
42 |
<input matInput [matDatepicker]="pickerTo" placeholder="Choose a date" |
|
43 |
[formControl]="toDate" (click)="pickerTo.open()" (dateChange)="toDateChanged($event)"> |
|
44 |
<mat-datepicker-toggle matSuffix [for]="pickerTo"></mat-datepicker-toggle> |
|
45 |
<mat-datepicker #pickerTo></mat-datepicker> |
|
46 |
</mat-form-field> |
|
47 |
</td> |
|
48 |
</tr> |
|
29 | 49 |
</table> |
30 |
</div> |
|
50 |
</div> |
|
51 |
<!-- <div *ngIf="dateValue.type=='range' " class="-row dateFilter" >--> |
|
52 |
|
|
53 |
<!-- <table class=" uk-table uk-table-responsive" >--> |
|
54 |
<!-- <tr><td>--> |
|
55 |
<!-- <select name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type >--> |
|
56 |
<!-- <option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option>--> |
|
57 |
<!-- </select></td>--> |
|
58 |
<!-- <td>--> |
|
59 |
<!-- From</td><td style="width: 112px;"><my-date-picker name="from" [options]="myDatePickerOptions"--> |
|
60 |
<!-- [(ngModel)]="from" (dateChanged)="onFromDateChanged($event)" ></my-date-picker>--> |
|
61 |
<!-- </td> <td>--> |
|
62 |
<!-- To </td><td style="width: 112px;"> <my-date-picker name="to" [options]="myDatePickerOptions"--> |
|
63 |
<!-- [(ngModel)]="to" (dateChanged)="onToDateChanged($event)" ></my-date-picker></td></tr>--> |
|
64 |
<!-- </table>--> |
|
65 |
<!-- </div>--> |
|
31 | 66 |
` |
32 | 67 |
|
33 | 68 |
}) |
... | ... | |
52 | 87 |
// Initialized to specific date (09.10.2018). |
53 | 88 |
public from;//: Object = { date: { year: 2018, month: 10, day: 9 } }; |
54 | 89 |
public to;//: Object = { date: { year: 2018, month: 10, day: 9 } }; |
90 |
public fromDate; |
|
91 |
public toDate; |
|
55 | 92 |
|
56 | 93 |
constructor() { |
94 |
//this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to); |
|
95 |
} |
|
96 |
|
|
97 |
ngOnInit() { |
|
57 | 98 |
this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to); |
58 | 99 |
} |
59 | 100 |
updateDefaultRangeDates(df:Date,dt:Date){ |
60 |
this.from = { date: { year: df.getFullYear(), month: (df.getMonth()+1), day: df.getDate() } }; |
|
61 |
this.to = { date: { year: dt.getFullYear(), month: (dt.getMonth()+1), day: dt.getDate() } }; |
|
101 |
df.setMonth(df.getMonth()-1); |
|
102 |
this.fromDate = new FormControl(df); |
|
103 |
this.toDate = new FormControl(dt); |
|
104 |
|
|
105 |
//this.from = { date: { year: df.getFullYear(), month: (df.getMonth()+1), day: df.getDate() } }; |
|
106 |
//this.to = { date: { year: dt.getFullYear(), month: (dt.getMonth()+1), day: dt.getDate() } }; |
|
62 | 107 |
} |
63 | 108 |
typeChanged(type:string){ |
64 | 109 |
this.dateValue.setDatesByType(type); |
65 | 110 |
this.updateDefaultRangeDates(this.dateValue.from, this.dateValue.to); |
66 | 111 |
} |
67 | 112 |
|
113 |
/* |
|
68 | 114 |
onFromDateChanged(event: IMyDateModel) { |
69 | 115 |
this.dateValue.from = Dates.getDateFromString(event.formatted); |
70 | 116 |
this.validDateFrom = true; |
... | ... | |
72 | 118 |
onToDateChanged(event: IMyDateModel) { |
73 | 119 |
this.dateValue.to = Dates.getDateFromString(event.formatted); |
74 | 120 |
this.validDateTo = true; |
75 |
}} |
|
121 |
} |
|
122 |
*/ |
|
123 |
|
|
124 |
fromDateChanged(event: MatDatepickerInputEvent<Date>) { |
|
125 |
this.dateValue.from = event.value; |
|
126 |
//console.info("FROM: "+Dates.getDateToString(this.dateValue.from)); |
|
127 |
} |
|
128 |
|
|
129 |
toDateChanged(event: MatDatepickerInputEvent<Date>) { |
|
130 |
this.dateValue.to = event.value; |
|
131 |
//console.info("TO: "+Dates.getDateToString(this.dateValue.to)); |
|
132 |
} |
|
133 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/error/isRouteEnabled.guard.ts | ||
---|---|---|
1 |
|
|
2 |
import {of as observableOf, Observable} from 'rxjs'; |
|
3 |
|
|
4 |
import {map, filter, mergeMap} from 'rxjs/operators'; |
|
1 | 5 |
import { Injectable } from '@angular/core'; |
2 | 6 |
import { |
3 | 7 |
Router, |
... | ... | |
7 | 11 |
RouterStateSnapshot, |
8 | 12 |
Route, Data |
9 | 13 |
} from '@angular/router'; |
10 |
import {Observable} from 'rxjs/Observable'; |
|
11 |
import 'rxjs/add/operator/filter'; |
|
14 |
|
|
12 | 15 |
import { ConfigurationService } from '../utils/configuration/configuration.service'; |
13 | 16 |
import { EnvironmentSpecificService} from '../utils/properties/environment-specific.service'; |
14 | 17 |
import {ConnectHelper} from '../connect/connectHelper'; |
15 | 18 |
|
16 | 19 |
@Injectable() |
17 |
export class IsRouteEnabled implements CanActivate, CanLoad {
|
|
20 |
export class IsRouteEnabled implements CanActivate { |
|
18 | 21 |
|
19 | 22 |
constructor(private router: Router, |
20 | 23 |
private config: ConfigurationService, |
... | ... | |
26 | 29 |
community = data['community']; |
27 | 30 |
} |
28 | 31 |
const redirect = customRedirect ? customRedirect : '/error'; |
29 |
const obs = this.propertiesService.subscribeEnvironment().map(res => { |
|
32 |
const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => {
|
|
30 | 33 |
if (!community) { |
31 | 34 |
community = ConnectHelper.getCommunityFromDomain(res.domain); |
32 | 35 |
} |
33 | 36 |
return res['adminToolsAPIURL']; |
34 |
}).mergeMap(url => {
|
|
37 |
}),mergeMap(url => {
|
|
35 | 38 |
if (!community) { // no community to check - return true |
36 |
return Observable.of(true);
|
|
39 |
return observableOf(true);
|
|
37 | 40 |
} |
38 | 41 |
return this.config.isPageEnabled(url, community, '/' + path.split('?')[0].substring(1)); |
39 |
}); |
|
40 |
obs.filter(enabled => !enabled)
|
|
42 |
}),);
|
|
43 |
obs.pipe(filter(enabled => !enabled))
|
|
41 | 44 |
.subscribe(() => this.router.navigate([redirect], {queryParams: {'page': path}})); |
42 | 45 |
return obs; |
43 | 46 |
} |
... | ... | |
45 | 48 |
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { |
46 | 49 |
return this.check(route.data, route.queryParams['communityId'], state.url); |
47 | 50 |
} |
48 |
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean { |
|
49 |
const path = '/' + route.path + document.location.search; |
|
50 |
return this.check(route.data, ConnectHelper.getCommunityFromPath(path), path); |
|
51 |
} |
|
52 | 51 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/connect/community/community.service.ts | ||
---|---|---|
1 | 1 |
import { Injectable } from '@angular/core'; |
2 | 2 |
import { Http, Headers, RequestOptions } from '@angular/http'; |
3 |
import {HttpClient, HttpHeaders} from "@angular/common/http"; |
|
3 | 4 |
import { CommunityInfo } from './communityInfo'; |
4 | 5 |
import {EnvProperties} from '../../utils/properties/env-properties'; |
6 |
import {map} from "rxjs/operators"; |
|
7 |
import {COOKIE} from "../../login/utils/helper.class"; |
|
5 | 8 |
|
6 | 9 |
@Injectable() |
7 | 10 |
export class CommunityService { |
8 | 11 |
|
9 |
constructor(private http: Http) { |
|
12 |
constructor(private http: HttpClient) {
|
|
10 | 13 |
} |
11 | 14 |
|
12 | 15 |
getCommunity(properties: EnvProperties, url: string) { |
13 | 16 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
14 |
.map(res => <any> res.json()).map(res => this.parseCommunity(res)); |
|
17 |
//.map(res => <any> res.json()) |
|
18 |
.pipe(map(res => this.parseCommunity(res))); |
|
15 | 19 |
} |
16 | 20 |
|
17 | 21 |
updateCommunity(url: string, community: any) { |
18 |
const headers = new Headers({'Content-Type': 'application/json'}); |
|
19 |
const options = new RequestOptions({headers: headers}); |
|
22 |
//const headers = new Headers({'Content-Type': 'application/json'}); |
|
23 |
//const options = new RequestOptions({headers: headers}); |
|
24 |
|
|
25 |
const options = { |
|
26 |
headers: new HttpHeaders({ |
|
27 |
'Content-Type': 'application/json', |
|
28 |
}) |
|
29 |
}; |
|
30 |
|
|
20 | 31 |
const body = JSON.stringify(community); |
21 | 32 |
return this.http.post(url, body, options); |
22 | 33 |
/*.map(res => res.json())*/ |
... | ... | |
24 | 35 |
|
25 | 36 |
isCommunityManager(properties: EnvProperties, url: string, manager: string) { |
26 | 37 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
27 |
.map(res => <any> res.json()).map(res => |
|
28 |
this.parseCommunity(res)).map(community => community.managers.indexOf(manager) !== -1); |
|
38 |
//.map(res => <any> res.json()) |
|
39 |
.pipe(map(res => this.parseCommunity(res))) |
|
40 |
.pipe(map(community => community.managers.indexOf(manager) !== -1)); |
|
29 | 41 |
} |
30 | 42 |
|
31 | 43 |
isRIType(properties: EnvProperties, url: string) { |
32 | 44 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
33 |
.map(res => <any> res.json()).map(res =>
|
|
34 |
this.parseCommunity(res)).map(community =>
|
|
35 |
(community && community.type && community.type === 'ri'));
|
|
45 |
//.map(res => <any> res.json())
|
|
46 |
.pipe(map(res => this.parseCommunity(res)))
|
|
47 |
.pipe(map(community => (community && community.type && community.type === 'ri')));
|
|
36 | 48 |
} |
37 | 49 |
|
38 | 50 |
isCommunityType(properties: EnvProperties, url: string) { |
39 | 51 |
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) |
40 |
.map(res => <any> res.json()).map(res =>
|
|
41 |
this.parseCommunity(res)).map(community =>
|
|
42 |
(community && community.type && community.type === 'community'));
|
|
52 |
//.map(res => <any> res.json())
|
|
53 |
.pipe(map(res => this.parseCommunity(res)))
|
|
54 |
.pipe(map(community => (community && community.type && community.type === 'community')));
|
|
43 | 55 |
} |
44 | 56 |
|
45 | 57 |
isSubscribedToCommunity(pid: string, email: string, url: string) { |
46 | 58 |
return this.http.get(url + '/community/' + pid + '/subscribers') |
47 |
.map(res => ((<any>res === '') ? {} : <any> res.json())) |
|
48 |
.map(res => { |
|
49 |
if (res.subscribers && res.subscribers != null) {
|
|
59 |
//.map(res => ((<any>res === '') ? {} : <any> res.json()))
|
|
60 |
.pipe(map(res => {
|
|
61 |
if (res['subscribers'] && res['subscribers'] != null) {
|
|
50 | 62 |
|
51 |
for (let i = 0; i < res.subscribers.length; i++ ) {
|
|
52 |
if (res.subscribers[i] != null && res.subscribers[i].email === email) {
|
|
63 |
for (let i = 0; i < res['subscribers'].length; i++ ) {
|
|
64 |
if (res['subscribers'][i] != null && res['subscribers'][i].email === email) {
|
|
53 | 65 |
return true; |
54 | 66 |
} |
55 | 67 |
} |
56 | 68 |
} |
57 | 69 |
return false; |
58 | 70 |
|
59 |
}); |
|
71 |
}));
|
|
60 | 72 |
} |
61 | 73 |
|
62 | 74 |
private parseCommunity(data: any): CommunityInfo { |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/connect/communityGuard/isCommunity.guard.ts | ||
---|---|---|
4 | 4 |
CanActivate, |
5 | 5 |
ActivatedRouteSnapshot, |
6 | 6 |
RouterStateSnapshot, |
7 |
CanLoad, Route |
|
7 |
CanLoad, Route, UrlSegment
|
|
8 | 8 |
} from '@angular/router'; |
9 |
import {Observable} from 'rxjs/Observable';
|
|
10 |
import 'rxjs/add/operator/filter'; |
|
9 |
import {Observable} from 'rxjs'; |
|
10 |
|
|
11 | 11 |
import {ConnectHelper} from '../connectHelper'; |
12 | 12 |
|
13 | 13 |
@Injectable() |
... | ... | |
29 | 29 |
return this.check(route.queryParams['communityId']); |
30 | 30 |
} |
31 | 31 |
|
32 |
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean { |
|
32 |
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
|
|
33 | 33 |
const path = '/' + route.path + document.location.search; |
34 | 34 |
return this.check(ConnectHelper.getCommunityFromPath(path)); |
35 | 35 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/connect/contentProviders/searchDataproviders.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http} from '@angular/http'; |
3 |
import {HttpClient} from "@angular/common/http"; |
|
3 | 4 |
import{EnvProperties} from '../../utils/properties/env-properties'; |
4 | 5 |
|
5 | 6 |
@Injectable() |
6 | 7 |
export class SearchCommunityDataprovidersService { |
7 |
constructor(private http: Http ) {} |
|
8 |
constructor(private http: HttpClient ) {}
|
|
8 | 9 |
|
9 | 10 |
searchDataproviders (properties:EnvProperties, communityId: string):any { |
10 | 11 |
let url = properties.communityAPI+communityId+"/contentproviders"; |
11 | 12 |
|
12 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
13 |
.map(res => <any> res.json()) |
|
13 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
|
|
14 |
//.map(res => <any> res.json())
|
|
14 | 15 |
} |
15 | 16 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/searchDataproviders.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http, Response} from '@angular/http'; |
3 |
import {Observable} from 'rxjs/Observable'; |
|
3 |
import {HttpClient} from "@angular/common/http"; |
|
4 |
import {Observable} from 'rxjs'; |
|
4 | 5 |
import {SearchResult} from '../utils/entities/searchResult'; |
5 | 6 |
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; |
6 |
import 'rxjs/add/observable/of'; |
|
7 |
import 'rxjs/add/operator/do'; |
|
8 |
import 'rxjs/add/operator/share'; |
|
7 |
|
|
8 |
|
|
9 |
|
|
9 | 10 |
import {StringUtils} from '../utils/string-utils.class'; |
10 | 11 |
import{EnvProperties} from '../utils/properties/env-properties'; |
12 |
import {map} from "rxjs/operators"; |
|
11 | 13 |
|
12 | 14 |
@Injectable() |
13 | 15 |
export class SearchDataprovidersService { |
14 |
constructor(private http: Http ) {} |
|
16 |
constructor(private http: HttpClient ) {}
|
|
15 | 17 |
|
16 | 18 |
searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { |
17 | 19 |
|
... | ... | |
28 | 30 |
|
29 | 31 |
|
30 | 32 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
31 |
.map(res => <any> res.json()) |
|
33 |
//.map(res => <any> res.json())
|
|
32 | 34 |
//.do(res => console.info(res)) |
33 |
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
|
|
35 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
|
|
34 | 36 |
} |
35 | 37 |
//((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb")) |
36 | 38 |
advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties ):any { |
... | ... | |
47 | 49 |
url += "&page="+(page-1)+"&size="+size+"&format=json"; |
48 | 50 |
|
49 | 51 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
50 |
.map(res => <any> res.json()) |
|
52 |
//.map(res => <any> res.json())
|
|
51 | 53 |
//.do(res => console.info(res)) |
52 |
.map(res => [res['meta'].total, this.parseResults(res['results'])])
|
|
54 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]))
|
|
53 | 55 |
} |
54 | 56 |
|
55 | 57 |
searchCompatibleDataprovidersTable ( properties:EnvProperties):any { |
... | ... | |
60 | 62 |
|
61 | 63 |
|
62 | 64 |
|
63 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
|
|
64 |
|
|
65 |
.map(res => res['meta'].total);
|
|
65 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
66 |
//.map(res => <any> res.json()) |
|
67 |
.pipe(map(res => res['meta'].total));
|
|
66 | 68 |
} |
67 | 69 |
|
68 | 70 |
searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { |
... | ... | |
77 | 79 |
url += "&page="+(page-1)+"&size="+size+"&format=json"; |
78 | 80 |
|
79 | 81 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
80 |
.map(res => <any> res.json()) |
|
82 |
//.map(res => <any> res.json())
|
|
81 | 83 |
//.do(res => console.info(res)) |
82 |
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
|
|
84 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
|
|
83 | 85 |
} |
84 | 86 |
|
85 | 87 |
searchEntityRegistriesTable (properties:EnvProperties):any { |
... | ... | |
90 | 92 |
|
91 | 93 |
|
92 | 94 |
|
93 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json()) |
|
94 |
.map(res => res['meta'].total); |
|
95 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
96 |
//.map(res => <any> res.json()) |
|
97 |
.pipe(map(res => res['meta'].total)); |
|
95 | 98 |
} |
96 | 99 |
|
97 | 100 |
searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { |
... | ... | |
106 | 109 |
url += "&page="+(page-1)+"&size="+size+"&format=json"; |
107 | 110 |
|
108 | 111 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
109 |
.map(res => <any> res.json()) |
|
112 |
//.map(res => <any> res.json())
|
|
110 | 113 |
//.do(res => console.info(res)) |
111 |
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
|
|
114 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
|
|
112 | 115 |
} |
113 | 116 |
|
114 | 117 |
searchJournalsTable ( properties:EnvProperties):any { |
... | ... | |
117 | 120 |
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))'; |
118 | 121 |
url += "&page=0&size=0&format=json"; |
119 | 122 |
|
120 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json()) |
|
121 |
.map(res => res['meta'].total);
|
|
123 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)//.map(res => <any> res.json())
|
|
124 |
.pipe(map(res => res['meta'].total));
|
|
122 | 125 |
} |
123 | 126 |
|
124 | 127 |
searchJournals (params: string,refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties):any { |
... | ... | |
135 | 138 |
url += "&page="+(page-1)+"&size="+size+"&format=json"; |
136 | 139 |
|
137 | 140 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
138 |
.map(res => <any> res.json()) |
|
141 |
//.map(res => <any> res.json())
|
|
139 | 142 |
//.do(res => console.info(res)) |
140 |
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
|
|
143 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
|
|
141 | 144 |
} |
142 | 145 |
|
143 | 146 |
searchDataprovidersForDeposit (id: string,type:string, page: number, size: number, properties:EnvProperties):any { |
... | ... | |
155 | 158 |
|
156 | 159 |
|
157 | 160 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
158 |
.map(res => <any> res.json()) |
|
159 |
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
|
161 |
//.map(res => <any> res.json())
|
|
162 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
|
160 | 163 |
} |
161 | 164 |
searchDataProvidersBySubjects(keyword:string, type:string, page: number, size: number, properties:EnvProperties):any { |
162 | 165 |
let link = properties.searchResourcesAPIURL; |
... | ... | |
173 | 176 |
|
174 | 177 |
|
175 | 178 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
176 |
.map(res => <any> res.json()) |
|
177 |
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
|
179 |
//.map(res => <any> res.json())
|
|
180 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
|
178 | 181 |
|
179 | 182 |
} |
180 | 183 |
|
... | ... | |
191 | 194 |
url += "&page="+(page-1)+"&size="+size+"&format=json"; |
192 | 195 |
|
193 | 196 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
194 |
.map(res => <any> res.json()) |
|
195 |
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
|
197 |
//.map(res => <any> res.json())
|
|
198 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
|
196 | 199 |
} |
197 | 200 |
searchDataprovidersForEntity (params: string, page: number, size: number, properties:EnvProperties):any { |
198 | 201 |
let link = properties.searchAPIURLLAst; |
199 | 202 |
let url = link+params+"/datasources?format=json"; |
200 | 203 |
|
201 | 204 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
202 |
.map(res => <any> res.json()) |
|
203 |
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
|
205 |
//.map(res => <any> res.json())
|
|
206 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
|
204 | 207 |
} |
205 | 208 |
/* |
206 | 209 |
searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any { |
... | ... | |
411 | 414 |
//let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json"; |
412 | 415 |
|
413 | 416 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
414 |
.map(res => <any> res.json()) |
|
415 |
.map(res => res.total);
|
|
417 |
//.map(res => <any> res.json())
|
|
418 |
.pipe(map(res => res['total']));
|
|
416 | 419 |
} |
417 | 420 |
|
418 | 421 |
numOfEntityDataproviders(id: string, entity: string, properties:EnvProperties):any { |
... | ... | |
454 | 457 |
|
455 | 458 |
|
456 | 459 |
|
457 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
|
|
458 |
|
|
459 |
.map(res => res['meta'].total);
|
|
460 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
|
461 |
//.map(res => <any> res.json()) |
|
462 |
.pipe(map(res => res['meta'].total));
|
|
460 | 463 |
} |
461 | 464 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/reports.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/observable/of'; |
|
5 |
import 'rxjs/add/operator/do'; |
|
6 |
import 'rxjs/add/operator/share'; |
|
3 |
import {HttpClient, HttpErrorResponse} from "@angular/common/http"; |
|
4 |
import {Observable, throwError} from 'rxjs'; |
|
7 | 5 |
|
6 |
|
|
7 |
|
|
8 |
import {map, tap} from "rxjs/operators"; |
|
9 |
|
|
8 | 10 |
@Injectable() |
9 | 11 |
export class ReportsService { |
10 | 12 |
// url:string = "http://beta.services.openaire.eu:8480/search/rest/v2/api/publications?format=csv&page=0&size=3&q=(%22test%22)&fq=instancetypename%20exact%20%22Dataset%22"; |
11 |
constructor(private http: Http) {} |
|
13 |
constructor(private http: HttpClient) {}
|
|
12 | 14 |
//text/html |
13 | 15 |
//On the service: |
14 | 16 |
downloadCSVFile(url: string){ |
15 |
var headers = new Headers(); |
|
16 |
headers.append('responseType', 'arraybuffer'); |
|
17 |
//var headers = new Headers();
|
|
18 |
//headers.append('responseType', 'arraybuffer');
|
|
17 | 19 |
return this.http.get(url) |
18 |
.map(res => new Blob([res['_body']], { type: 'text/csv' }));
|
|
20 |
.pipe(map(res => new Blob([res['_body']], { type: 'text/csv' })));
|
|
19 | 21 |
} |
20 | 22 |
getCSVResponse(url: string){ |
21 |
var headers = new Headers(); |
|
22 |
headers.append('responseType', 'arraybuffer'); |
|
23 |
//var headers = new Headers();
|
|
24 |
//headers.append('responseType', 'arraybuffer');
|
|
23 | 25 |
return this.http.get(url) |
24 |
.map(res => res['_body']);
|
|
26 |
.pipe(map(res => res['_body']));
|
|
25 | 27 |
} |
26 | 28 |
downloadHTMLFile(url: string, info: string){ |
27 |
var headers = new Headers(); |
|
28 |
headers.append('responseType', 'arraybuffer'); |
|
29 |
//var headers = new Headers();
|
|
30 |
//headers.append('responseType', 'arraybuffer');
|
|
29 | 31 |
return this.http.get(url) |
30 |
.map(res => this.addInfo(res, info))
|
|
31 |
.map(res => new Blob([res['_body']], { type: 'text/html' }))
|
|
32 |
.do(res => console.log(res))
|
|
32 |
.pipe(map(res => this.addInfo(res, info)))
|
|
33 |
.pipe(map(res => new Blob([res['_body']], { type: 'text/html' })))
|
|
34 |
.pipe(tap(res => console.log(res)))
|
|
33 | 35 |
} |
34 | 36 |
|
35 | 37 |
addInfo(res:any, info:string) { |
... | ... | |
43 | 45 |
return res; |
44 | 46 |
} |
45 | 47 |
|
46 |
private handleError (error: Response) { |
|
48 |
private handleError (error: HttpErrorResponse) {
|
|
47 | 49 |
// in a real world app, we may send the error to some remote logging infrastructure |
48 | 50 |
// instead of just logging it to the console |
49 | 51 |
console.log(error); |
50 |
return Observable.throw(error || 'Server error');
|
|
52 |
return throwError(error || 'Server error');
|
|
51 | 53 |
} |
52 | 54 |
|
53 | 55 |
|
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/refineFieldResults.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http, Response} from '@angular/http'; |
3 |
import {Observable} from 'rxjs/Observable'; |
|
3 |
import {HttpClient, HttpErrorResponse} from "@angular/common/http"; |
|
4 |
import {Observable, throwError} from 'rxjs'; |
|
4 | 5 |
import {AutoCompleteValue} from '../searchPages/searchUtils/searchHelperClasses.class'; |
5 |
import 'rxjs/add/observable/of'; |
|
6 |
import 'rxjs/add/operator/do'; |
|
7 |
import 'rxjs/add/operator/share'; |
|
6 |
|
|
7 |
|
|
8 |
|
|
8 | 9 |
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; |
9 | 10 |
import{EnvProperties} from '../utils/properties/env-properties'; |
11 |
import {map} from "rxjs/operators"; |
|
10 | 12 |
|
11 | 13 |
@Injectable() |
12 | 14 |
export class RefineFieldResultsService { |
13 |
constructor(private http: Http ) {} |
|
15 |
constructor(private http: HttpClient ) {}
|
|
14 | 16 |
getRefineFieldsResultsByEntityName(fields:string[], entityName:string, properties:EnvProperties, communityQuery=null):any{ |
15 | 17 |
let url = properties.searchAPIURLLAst + this.getSearchAPIURLForEntity(entityName)+"?format=json&refine=true&page=1&size=0"; |
16 | 18 |
for(var i=0; i < fields.length; i++){ |
... | ... | |
21 | 23 |
} |
22 | 24 |
|
23 | 25 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
24 |
.map(res => <any> res.json()) |
|
26 |
//.map(res => <any> res.json())
|
|
25 | 27 |
|
26 |
.map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]);
|
|
28 |
.pipe(map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]));
|
|
27 | 29 |
|
28 | 30 |
} |
29 | 31 |
getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{ |
... | ... | |
36 | 38 |
let url = link+"&refine=true&page=1&size=0"; |
37 | 39 |
|
38 | 40 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
39 |
.map(res => <any> res.json()) |
|
40 |
.map(res => res['refineResults'])
|
|
41 |
.map(res => this.parse(res,fieldName));
|
|
41 |
//.map(res => <any> res.json())
|
|
42 |
.pipe(map(res => res['refineResults']))
|
|
43 |
.pipe(map(res => this.parse(res,fieldName)));
|
|
42 | 44 |
|
43 | 45 |
} |
44 | 46 |
parse(data: any,fieldName:string):any { |
... | ... | |
78 | 80 |
} |
79 | 81 |
return suffix; |
80 | 82 |
} |
81 |
private handleError (error: Response) { |
|
83 |
private handleError (error: HttpErrorResponse) {
|
|
82 | 84 |
// in a real world app, we may send the error to some remote logging infrastructure |
83 | 85 |
// instead of just logging it to the console |
84 | 86 |
console.log(error); |
85 |
return Observable.throw(error || 'Server error');
|
|
87 |
return throwError(error || 'Server error');
|
|
86 | 88 |
} |
87 | 89 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/searchDatasets.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 |
import {Http, Response} from '@angular/http'; |
|
3 |
import {Observable} from 'rxjs/Observable'; |
|
4 |
import {SearchResult} from '../utils/entities/searchResult'; |
|
2 |
import {HttpClient} from "@angular/common/http"; |
|
3 |
import {SearchResult} from '../utils/entities/searchResult'; |
|
5 | 4 |
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; |
6 |
import 'rxjs/add/observable/of'; |
|
7 |
import 'rxjs/add/operator/do'; |
|
8 |
import 'rxjs/add/operator/share'; |
|
5 |
|
|
6 |
|
|
9 | 7 |
import {DOI, StringUtils} from '../utils/string-utils.class'; |
10 |
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class'; |
|
11 |
import{EnvProperties} from '../utils/properties/env-properties'; |
|
8 |
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class'; |
|
9 |
import {EnvProperties} from '../utils/properties/env-properties'; |
|
10 |
import {map} from "rxjs/operators"; |
|
12 | 11 |
|
13 | 12 |
@Injectable() |
14 | 13 |
export class SearchDatasetsService { |
15 | 14 |
private sizeOfDescription: number = 270; |
16 | 15 |
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); |
17 | 16 |
|
18 |
constructor(private http: Http ) {} |
|
17 |
constructor(private http: HttpClient ) {}
|
|
19 | 18 |
|
20 | 19 |
searchDatasets (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any { |
21 | 20 |
|
... | ... | |
35 | 34 |
|
36 | 35 |
|
37 | 36 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
38 |
.map(res => <any> res.json()) |
|
37 |
//.map(res => <any> res.json())
|
|
39 | 38 |
//.do(res => console.info(res)) |
40 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]); |
|
39 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")])); |
|
40 |
|
|
41 | 41 |
} |
42 | 42 |
searchDatasetById (id: string , properties:EnvProperties):any { |
43 | 43 |
|
44 | 44 |
let url = properties.searchAPIURLLAst+"datasets/"+id+"?format=json"; |
45 | 45 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
46 |
.map(res => <any> res.json()) |
|
47 |
.map(res => this.parseResults(res, properties));
|
|
46 |
//.map(res => <any> res.json())
|
|
47 |
.pipe(map(res => this.parseResults(res, properties)));
|
|
48 | 48 |
} |
49 | 49 |
|
50 | 50 |
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any { |
... | ... | |
63 | 63 |
|
64 | 64 |
|
65 | 65 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
66 |
.map(res => <any> res.json()) |
|
67 |
.map(res => this.parseRefineResults(id, res['refineResults']))
|
|
66 |
//.map(res => <any> res.json())
|
|
67 |
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
|
|
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
searchDatasetsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { |
... | ... | |
86 | 86 |
|
87 | 87 |
|
88 | 88 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
89 |
.map(res => <any> res.json()) |
|
89 |
//.map(res => <any> res.json())
|
|
90 | 90 |
//.do(res => console.info(res)) |
91 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")])); |
|
91 | 92 |
|
92 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]); |
|
93 | 93 |
} |
94 | 94 |
advancedSearchDatasets (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any { |
95 | 95 |
let url = properties.searchResourcesAPIURL; |
... | ... | |
110 | 110 |
url += "&format=json"; |
111 | 111 |
|
112 | 112 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
113 |
.map(res => <any> res.json()) |
|
113 |
//.map(res => <any> res.json())
|
|
114 | 114 |
//.do(res => console.info(res)) |
115 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
|
|
115 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
|
116 | 116 |
} |
117 | 117 |
searchDatasetsForEntity (params: string, page: number, size: number, properties:EnvProperties):any { |
118 | 118 |
let link = properties.searchAPIURLLAst; |
119 | 119 |
let url = link+params+"/datasets"+"?format=json"; |
120 | 120 |
|
121 | 121 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
122 |
.map(res => <any> res.json()) |
|
123 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]); |
|
122 |
//.map(res => <any> res.json()) |
|
123 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)])); |
|
124 |
|
|
124 | 125 |
} |
125 | 126 |
|
126 | 127 |
searchDatasetsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any { |
127 | 128 |
let link = properties.searchAPIURLLAst; |
128 | 129 |
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json"; |
129 | 130 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
130 |
.map(res => <any> res.json()) |
|
131 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]); |
|
131 |
//.map(res => <any> res.json()) |
|
132 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)])); |
|
133 |
|
|
132 | 134 |
} |
133 | 135 |
|
134 | 136 |
parseResults(data: any, properties: EnvProperties): SearchResult[] { |
... | ... | |
347 | 349 |
numOfDatasets(url: string, properties:EnvProperties):any { |
348 | 350 |
|
349 | 351 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
350 |
.map(res => <any> res.json()) |
|
351 |
.map(res => res.total);
|
|
352 |
//.map(res => <any> res.json())
|
|
353 |
.pipe(map(res => res['total']));
|
|
352 | 354 |
} |
353 | 355 |
|
354 | 356 |
numOfEntityDatasets(id: string, entity: string, properties:EnvProperties):any { |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/organization.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http, Response} from '@angular/http'; |
3 |
import {Observable} from 'rxjs/Observable'; |
|
3 |
import {HttpClient, HttpErrorResponse} from "@angular/common/http"; |
|
4 |
import {Observable, throwError} from 'rxjs'; |
|
4 | 5 |
import {OrganizationInfo} from '../utils/entities/organizationInfo'; |
5 |
import 'rxjs/add/observable/of'; |
|
6 |
import 'rxjs/add/operator/do'; |
|
7 |
import 'rxjs/add/operator/share'; |
|
6 |
|
|
7 |
|
|
8 |
|
|
8 | 9 |
import{EnvProperties} from '../utils/properties/env-properties'; |
10 |
import {map} from "rxjs/operators"; |
|
9 | 11 |
|
10 | 12 |
@Injectable() |
11 | 13 |
export class OrganizationService { |
12 | 14 |
|
13 |
constructor(private http: Http ) {} |
|
15 |
constructor(private http: HttpClient ) {}
|
|
14 | 16 |
|
15 | 17 |
organizationInfo: OrganizationInfo; |
16 | 18 |
|
... | ... | |
18 | 20 |
let url = properties.searchAPIURLLAst+'resources?format=json&query=( (oaftype exact organization) and (reldatasourcecompatibilityid=driver or reldatasourcecompatibilityid=driver-openaire2.0 or reldatasourcecompatibilityid=openaire2.0 or reldatasourcecompatibilityid=openaire3.0 or reldatasourcecompatibilityid=openaire2.0_data or reldatasourcecompatibilityid=hostedBy or relprojectid=* or reldatasourcecompatibilityid = native)) and ( objIdentifier ='+id+')'; |
19 | 21 |
|
20 | 22 |
return this.http.get((properties.useCache)? (properties.cacheUrl +encodeURIComponent(url)): url) |
21 |
.map(res => <any> res.json()) |
|
22 |
.map(res => res['results'][0])
|
|
23 |
//.map(res => <any> res.json())
|
|
24 |
.pipe(map(res => res['results'][0]))
|
|
23 | 25 |
//.map(res => res[0]['result']['metadata']['oaf:entity']['oaf:organization']) |
24 | 26 |
//.map(res => [res, res['rels']['rel']]) |
25 |
.map(res => this.parseOrganizationInfo(res));
|
|
27 |
.pipe(map(res => this.parseOrganizationInfo(res)));
|
|
26 | 28 |
|
27 | 29 |
|
28 | 30 |
} |
... | ... | |
31 | 33 |
let url = properties.searchAPIURLLAst+"organizations/"+id+"?format=json"; |
32 | 34 |
|
33 | 35 |
return this.http.get((properties.useCache) ? (properties.cacheUrl+encodeURIComponent(url)): url) |
34 |
.map(res => <any> res.json()) |
|
35 |
.map(res => res['result']['metadata']['oaf:entity']['oaf:organization'])
|
|
36 |
.map(res => this.parseOrganizationNameAndUrl(res));
|
|
36 |
//.map(res => <any> res.json())
|
|
37 |
.pipe(map(res => res['result']['metadata']['oaf:entity']['oaf:organization']))
|
|
38 |
.pipe(map(res => this.parseOrganizationNameAndUrl(res)));
|
|
37 | 39 |
} |
38 | 40 |
|
39 |
private handleError (error: Response) { |
|
41 |
private handleError (error: HttpErrorResponse) {
|
|
40 | 42 |
// in a real world app, we may send the error to some remote logging infrastructure |
41 | 43 |
// instead of just logging it to the console |
42 | 44 |
console.log(error); |
43 |
return Observable.throw(error || 'Server error');
|
|
45 |
return throwError(error || 'Server error');
|
|
44 | 46 |
} |
45 | 47 |
|
46 | 48 |
parseOrganizationInfo (data: any):any { |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/metrics.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http, Response} from '@angular/http'; |
3 |
import {Observable} from 'rxjs/Observable'; |
|
3 |
import {HttpClient} from "@angular/common/http"; |
|
4 |
import {Observable} from 'rxjs'; |
|
4 | 5 |
import {Metrics} from '../utils/entities/metrics'; |
5 |
import 'rxjs/add/operator/do'; |
|
6 |
|
|
6 | 7 |
import{EnvProperties} from '../utils/properties/env-properties'; |
8 |
import {map} from "rxjs/operators"; |
|
7 | 9 |
|
8 | 10 |
@Injectable() |
9 | 11 |
export class MetricsService { |
10 | 12 |
metrics: Metrics; |
11 | 13 |
|
12 |
constructor(private http: Http ) {} |
|
14 |
constructor(private http: HttpClient ) {}
|
|
13 | 15 |
|
14 | 16 |
getMetrics (id: string, entityType: string, properties:EnvProperties):any { |
15 | 17 |
let url = properties.metricsAPIURL+entityType+"/"+id+"/clicks"; |
16 | 18 |
let key = url; |
17 | 19 |
|
18 | 20 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
19 |
.map(res => <any> res.json()) |
|
20 |
.map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"], |
|
21 |
res["total_openaire_views"], res["total_openaire_downloads"], res["pageviews"], properties)); |
|
21 |
//.map(res => <any> res.json())
|
|
22 |
.pipe(map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"],
|
|
23 |
res["total_openaire_views"], res["total_openaire_downloads"], res["pageviews"], properties)));
|
|
22 | 24 |
} |
23 | 25 |
|
24 | 26 |
|
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/searchOrps.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 |
import {Http, Response} from '@angular/http'; |
|
3 |
import {Observable} from 'rxjs/Observable'; |
|
4 |
import {SearchResult} from '../utils/entities/searchResult'; |
|
2 |
import {HttpClient} from "@angular/common/http"; |
|
3 |
import {SearchResult} from '../utils/entities/searchResult'; |
|
5 | 4 |
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; |
6 |
import 'rxjs/add/observable/of'; |
|
7 |
import 'rxjs/add/operator/do'; |
|
8 |
import 'rxjs/add/operator/share'; |
|
9 | 5 |
import {DOI, StringUtils} from '../utils/string-utils.class'; |
10 |
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class'; |
|
11 |
import{EnvProperties} from '../utils/properties/env-properties'; |
|
6 |
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class'; |
|
7 |
import {EnvProperties} from '../utils/properties/env-properties'; |
|
8 |
import {map} from "rxjs/operators"; |
|
12 | 9 |
|
13 | 10 |
@Injectable() |
14 | 11 |
export class SearchOrpsService { |
15 | 12 |
private sizeOfDescription: number = 270; |
16 | 13 |
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); |
17 | 14 |
|
18 |
constructor(private http: Http ) {} |
|
15 |
constructor(private http: HttpClient ) {}
|
|
19 | 16 |
|
20 | 17 |
searchOrps (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any { |
21 | 18 |
|
... | ... | |
35 | 32 |
|
36 | 33 |
|
37 | 34 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
38 |
.map(res => <any> res.json()) |
|
35 |
//.map(res => <any> res.json())
|
|
39 | 36 |
//.do(res => console.info(res)) |
40 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]);
|
|
37 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]));
|
|
41 | 38 |
} |
42 | 39 |
searchOrpById (id: string , properties:EnvProperties):any { |
43 | 40 |
|
44 | 41 |
let url = properties.searchAPIURLLAst+"other/"+id+"?format=json"; |
45 | 42 |
|
46 | 43 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
47 |
.map(res => <any> res.json()) |
|
48 |
.map(res => this.parseResults(res, properties));
|
|
44 |
//.map(res => <any> res.json())
|
|
45 |
.pipe(map(res => this.parseResults(res, properties)));
|
|
49 | 46 |
} |
50 | 47 |
|
51 | 48 |
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any { |
... | ... | |
64 | 61 |
|
65 | 62 |
|
66 | 63 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
67 |
.map(res => <any> res.json()) |
|
68 |
.map(res => this.parseRefineResults(id, res['refineResults']))
|
|
64 |
//.map(res => <any> res.json())
|
|
65 |
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
|
|
69 | 66 |
} |
70 | 67 |
|
71 | 68 |
searchOrpsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { |
... | ... | |
88 | 85 |
|
89 | 86 |
|
90 | 87 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
91 |
.map(res => <any> res.json()) |
|
88 |
//.map(res => <any> res.json())
|
|
92 | 89 |
//.do(res => console.info(res)) |
93 |
|
|
94 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]); |
|
90 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")])); |
|
95 | 91 |
} |
96 | 92 |
advancedSearchOrps (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any { |
97 | 93 |
let url = properties.searchResourcesAPIURL; |
... | ... | |
113 | 109 |
url += "&format=json"; |
114 | 110 |
|
115 | 111 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
116 |
.map(res => <any> res.json()) |
|
112 |
//.map(res => <any> res.json())
|
|
117 | 113 |
//.do(res => console.info(res)) |
118 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
|
|
114 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
|
119 | 115 |
} |
120 | 116 |
searchOrpsForEntity (params: string, page: number, size: number, properties:EnvProperties):any { |
121 | 117 |
let link = properties.searchAPIURLLAst; |
... | ... | |
123 | 119 |
let url = link+params+"/other"+"?format=json"; |
124 | 120 |
|
125 | 121 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
126 |
.map(res => <any> res.json()) |
|
127 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
|
|
122 |
//.map(res => <any> res.json())
|
|
123 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
|
128 | 124 |
} |
129 | 125 |
|
130 | 126 |
searchOrpsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any { |
... | ... | |
132 | 128 |
|
133 | 129 |
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json"; |
134 | 130 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
135 |
.map(res => <any> res.json()) |
|
136 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
|
|
131 |
//.map(res => <any> res.json())
|
|
132 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
|
|
137 | 133 |
} |
138 | 134 |
|
139 | 135 |
parseResults(data: any, properties: EnvProperties): SearchResult[] { |
... | ... | |
351 | 347 |
numOfOrps(url: string, properties:EnvProperties):any { |
352 | 348 |
|
353 | 349 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
354 |
.map(res => <any> res.json()) |
|
355 |
.map(res => res.total);
|
|
350 |
//.map(res => <any> res.json())
|
|
351 |
.pipe(map(res => res['total']));
|
|
356 | 352 |
} |
357 | 353 |
|
358 | 354 |
numOfEntityOrps(id: string, entity: string, properties:EnvProperties):any { |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/layout.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http, Response} from '@angular/http'; |
3 |
import {Observable} from 'rxjs/Observable'; |
|
3 |
import {HttpClient, HttpErrorResponse} from "@angular/common/http"; |
|
4 |
import {Observable, throwError} from 'rxjs'; |
|
4 | 5 |
import {CustomOptions} from './servicesUtils/customOptions.class'; |
6 |
import {catchError} from "rxjs/operators"; |
|
5 | 7 |
|
6 | 8 |
@Injectable() |
7 | 9 |
export class LayoutService { |
8 |
constructor(private http: Http) { |
|
10 |
constructor(private http: HttpClient) {
|
|
9 | 11 |
} |
10 | 12 |
|
11 | 13 |
static removeNulls(obj) { |
... | ... | |
22 | 24 |
saveLayout(pid: string, url: string, layout: any) { |
23 | 25 |
LayoutService.removeNulls(layout); |
24 | 26 |
return this.http.post(url + 'community/' + pid + '/updateLayout', JSON.stringify(layout), CustomOptions.getAuthOptionsWithBody()) |
25 |
.map(res => res.json()) |
|
26 |
.catch(this.handleError);
|
|
27 |
//.map(res => res.json())
|
|
28 |
.pipe(catchError(this.handleError));
|
|
27 | 29 |
} |
28 | 30 |
|
29 | 31 |
getLayout(pid: string, url: string) { |
30 | 32 |
return this.http.get(url + 'community/' + pid + '/layout') |
31 |
.map(res => res.json()) |
|
32 |
.catch(this.handleError);
|
|
33 |
//.map(res => res.json())
|
|
34 |
.pipe(catchError(this.handleError));
|
|
33 | 35 |
} |
34 | 36 |
|
35 | 37 |
loadDefaultLayout(pid: string, url: string) { |
36 | 38 |
return this.http.post(url + 'community/' + pid + '/resetLayout', null, CustomOptions.getAuthOptionsWithBody()) |
37 |
.map(res => res.json()) |
|
38 |
.catch(this.handleError);
|
|
39 |
//.map(res => res.json())
|
|
40 |
.pipe(catchError(this.handleError));
|
|
39 | 41 |
} |
40 | 42 |
|
41 |
private handleError(error: Response) { |
|
43 |
private handleError(error: HttpErrorResponse) {
|
|
42 | 44 |
// in a real world app, we may send the error to some remote logging infrastructure |
43 | 45 |
// instead of just logging it to the console |
44 | 46 |
console.error(error); |
45 |
return Observable.throw(error.json().error || 'Server error');
|
|
47 |
return throwError(error.error || 'Server error');
|
|
46 | 48 |
} |
47 | 49 |
} |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/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 { |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/searchProjects.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 |
@Injectable() |
12 | 14 |
export class SearchProjectsService { |
13 | 15 |
private sizeOfDescription: number = 270; |
14 | 16 |
|
15 |
constructor(private http: Http ) {} |
|
17 |
constructor(private http: HttpClient ) {}
|
|
16 | 18 |
|
17 | 19 |
searchProjects (params: string, refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any { |
18 | 20 |
|
... | ... | |
29 | 31 |
|
30 | 32 |
|
31 | 33 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
32 |
.map(res => <any> res.json()) |
|
33 |
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]);
|
|
34 |
//.map(res => <any> res.json())
|
|
35 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]));
|
|
34 | 36 |
} |
35 | 37 |
getProjectsforDataProvider (datasourceId: string, page: number, size: number, properties:EnvProperties ):any { |
36 | 38 |
let url = properties.searchResourcesAPIURL; |
... | ... | |
46 | 48 |
url += "&format=json"; |
47 | 49 |
|
48 | 50 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
49 |
.map(res => <any> res.json()) |
|
50 |
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
|
51 |
//.map(res => <any> res.json())
|
|
52 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
|
51 | 53 |
} |
52 | 54 |
advancedSearchProjects (params: string, page: number, size: number, properties:EnvProperties ):any { |
53 | 55 |
let url = properties.searchResourcesAPIURL; |
... | ... | |
62 | 64 |
url += "&page="+(page-1)+"&size="+size; |
63 | 65 |
url += "&format=json"; |
64 | 66 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
65 |
.map(res => <any> res.json()) |
|
66 |
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
|
|
67 |
//.map(res => <any> res.json())
|
|
68 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
|
67 | 69 |
} |
68 | 70 |
getProjectsForOrganizations (organizationId: string, filterquery: string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any { |
69 | 71 |
let url = properties.searchResourcesAPIURL; |
... | ... | |
84 | 86 |
url += "&format=json"; |
85 | 87 |
|
86 | 88 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
87 |
.map(res => <any> res.json()) |
|
88 |
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]);
|
|
89 |
//.map(res => <any> res.json())
|
|
90 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]));
|
|
89 | 91 |
} |
90 | 92 |
getFunders(properties:EnvProperties ):any { |
91 | 93 |
let url = properties.searchAPIURLLAst+"projects?refine=true&fields=funder&size=0"+ "&format=json";; |
92 | 94 |
|
93 | 95 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
94 |
.map(res => <any> res.json()) |
|
95 |
.map(res => [res['meta'].total, res['refineResults']['funder']]);
|
|
96 |
//.map(res => <any> res.json())
|
|
97 |
.pipe(map(res => [res['meta'].total, res['refineResults']['funder']]));
|
|
96 | 98 |
|
97 | 99 |
|
98 | 100 |
} |
... | ... | |
103 | 105 |
|
104 | 106 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).toPromise() |
105 | 107 |
.then(request =>{ |
106 |
return (request.json().response.results)?request.json().response.results.result:request.json().response.result; |
|
108 |
//return (request.json().response.results)?request.json().response.results.result:request.json().response.result; |
|
109 |
return (request['response'].results)?request['response'].results.result:request['response'].result; |
|
107 | 110 |
|
108 |
}) ; |
|
111 |
}) ;
|
|
109 | 112 |
} |
110 | 113 |
parseResults(data: any): SearchResult[] { |
111 | 114 |
let results: SearchResult[] = []; |
... | ... | |
219 | 222 |
numOfProjects(url: string, properties:EnvProperties ):any { |
220 | 223 |
|
221 | 224 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
222 |
.map(res => <any> res.json()) |
|
223 |
.map(res => res.total);
|
|
225 |
//.map(res => <any> res.json())
|
|
226 |
.pipe(map(res => res['total']));
|
|
224 | 227 |
} |
225 | 228 |
|
226 | 229 |
numOfEntityProjects(id: string, entity: string, properties:EnvProperties ):any { |
modules/uoa-services-library/trunk/ng-openaire-library/src/app/services/searchSoftware.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {Http, Response} from '@angular/http'; |
3 |
import {Observable} from 'rxjs/Observable'; |
|
3 |
import {HttpClient} from "@angular/common/http"; |
|
4 |
import {Observable} from 'rxjs'; |
|
4 | 5 |
import {SearchResult} from '../utils/entities/searchResult'; |
5 | 6 |
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; |
6 |
import 'rxjs/add/observable/of'; |
|
7 |
import 'rxjs/add/operator/do'; |
|
8 |
import 'rxjs/add/operator/share'; |
|
7 |
|
|
8 |
|
|
9 |
|
|
9 | 10 |
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class'; |
10 | 11 |
import{EnvProperties} from '../utils/properties/env-properties'; |
11 | 12 |
import {DOI, StringUtils} from '../utils/string-utils.class'; |
13 |
import {map} from "rxjs/operators"; |
|
12 | 14 |
@Injectable() |
13 | 15 |
export class SearchSoftwareService { |
14 | 16 |
private sizeOfDescription: number = 270; |
15 | 17 |
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); |
16 | 18 |
|
17 |
constructor(private http: Http ) {} |
|
19 |
constructor(private http: HttpClient ) {}
|
|
18 | 20 |
|
19 | 21 |
searchSoftware (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any { |
Also available in: Unified diff
[Library|Trunk]
Merge into trunk branch angular7 rev 55729