[Library|Trunk]

Merge into trunk branch angular7 rev 55729




git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@55964 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2019-06-03 13:20:36 +00:00
parent e3d0462f9d
commit f8913dfdbd
112 changed files with 998 additions and 824 deletions

View File

@ -1,6 +1,6 @@
import { Component, Directive, ElementRef, Renderer, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
import { Component, Directive, ElementRef, Renderer2, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
import { ConfigurationService } from './utils/configuration/configuration.service';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { EnvProperties } from './utils/properties/env-properties';
import {ActivatedRoute} from '@angular/router';
import{EnvironmentSpecificService} from './utils/properties/environment-specific.service';

View File

@ -4,7 +4,7 @@ import { SharedModule } from './shared/shared.module';
import { BrowserModule } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { APP_BASE_HREF, CommonModule } from '@angular/common';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import {NavigationBarModule} from './sharedComponents/navigationBar.module';
@ -69,10 +69,10 @@ import { AppRoutingModule } from './app-routing.module';
SharedModule,
NoopAnimationsModule,
CommonModule,
CookieLawModule, BottomModule,
HttpModule,
NavigationBarModule,
CookieLawModule,
BottomModule,
HttpClientModule,
NavigationBarModule,
MainSearchModule,
ErrorModule,
DepositDatasetsModule,DepositDatasetsResultsModule, DepositBySubjectResultsModule,DepositPublicationsModule , DepositPublicationsResultsModule,

View File

@ -1,5 +1,5 @@
import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Router} from '@angular/router';
import {ContextsService} from './service/contexts.service';
import {ClaimContext} from './claimEntities.class';

View File

@ -1,9 +1,7 @@
import {Component, Input,Output, ElementRef, EventEmitter, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable, Subject } from 'rxjs';
import {SearchProjectsService} from '../../services/searchProjects.service';
import {ProjectService} from '../../landingPages/project/project.service';
// import {ModalLoading} from '../../utils/modal/loading.component';
import { Subject } from 'rxjs/Subject';
import {ClaimProject} from './claimEntities.class';
declare var UIkit:any;
import{EnvProperties} from '../../utils/properties/env-properties';

View File

@ -1,8 +1,9 @@
import {distinctUntilChanged, debounceTime} from 'rxjs/operators';
import {Component, ViewChild, Input} from '@angular/core';
import {Location} from '@angular/common';
import {Observable} from 'rxjs/Observable';
import {Observable, Subject} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router';
import {Subject} from 'rxjs/Subject';
import {ClaimsService} from '../service/claims.service';
import {ModalLoading} from '../../../utils/modal/loading.component';
import {AlertModal} from '../../../utils/modal/alert';
@ -58,8 +59,8 @@ private seoService: SEOService) {
this.setTypes(params['types']); // check the appropriate checkboxes
this.setSortby(params['sort']);
this.getClaims();
this.searchTermStream
.debounceTime(300).distinctUntilChanged()
this.searchTermStream.pipe(
debounceTime(300),distinctUntilChanged(),)
.subscribe((term: string) => {
this.keyword = this.inputkeyword;
//console.log("keyword: "+this.keyword + " VS inputkeyword: "+this.inputkeyword);

View File

@ -1,24 +1,28 @@
import {throwError as observableThrowError, Observable} from 'rxjs';
import {Injectable} from '@angular/core';
import {URLSearchParams } from '@angular/http';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import { HttpClient } from '@angular/common/http';
// import {Claim} from '../claim';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { catchError } from 'rxjs/operators';
import { CustomOptions } from '../../../services/servicesUtils/customOptions.class';
@Injectable()
export class ClaimsService {
constructor(private http: Http ) {
constructor(private http: HttpClient ) {
}
private getClaimRequest(size : number, page : number, url :string, fromCache:boolean):any {
//console.info('ClaimsService: Claims request: '+url);
let key = url;
return this.http.get(url, CustomOptions.getAuthOptions())
.map(request => <any> request.json())
//.map(request => <any> request.json())
//.do(request => console.info("Get claims: offset = "+(size*(page-1)) + " limit ="+size ))
.catch(this.handleError);
.pipe(catchError(this.handleError));
}
getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string, apiUrl:string):any {
let url = apiUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
@ -54,9 +58,9 @@ export class ClaimsService {
let url = apiUrl +"claims/"+claimId;
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.delete( url, CustomOptions.getAuthOptionsWithBody()).map(request => <any> request.json())
return this.http.delete( url, CustomOptions.getAuthOptionsWithBody())//.map(request => <any> request.json())
// .do(request => console.info("After delete" ))
.catch(this.handleError);
.pipe(catchError(this.handleError));
}
deleteBulk(claimIds:string[], apiUrl:string):any{
@ -71,9 +75,9 @@ export class ClaimsService {
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.delete( url, CustomOptions.getAuthOptions()).map(request => <any> request.json())
return this.http.delete( url, CustomOptions.getAuthOptions())//.map(request => <any> request.json())
// .do(request => console.info("After delete" ))
.catch(this.handleError);
.pipe(catchError(this.handleError));
}
insertBulkClaims(claims, apiUrl:string):any{
@ -84,9 +88,9 @@ export class ClaimsService {
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
//.map(res => res.json())
//.do(request => console.info("Insert Response:"+request.status) )
.catch(this.handleError);
.pipe(catchError(this.handleError));
}
insertClaim(claim, apiUrl:string):any{
@ -96,9 +100,9 @@ export class ClaimsService {
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
//.map(res => res.json())
//.do(request => console.info("Insert Response:"+request.status) )
.catch(this.handleError);
.pipe(catchError(this.handleError));
}
insertDirectRecords(records, apiUrl:string):any{
@ -109,26 +113,26 @@ export class ClaimsService {
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
//.map(res => res.json())
//.do(request => console.info("Insert Response:"+request) )
.catch(this.handleError);
.pipe(catchError(this.handleError));
}
private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return observableThrowError(error || 'Server error');
}
getClaim(id:string, apiUrl:string):any {
let url = apiUrl+"claims/"+id;
return new Promise((resolve, reject) => {
this.http.get(url)
.map(res => res.json())
//.map(res => res.json())
.subscribe(
data => {
resolve(data.data);
resolve(data['data']);
},
err => {
reject(err);

View File

@ -1,16 +1,16 @@
import {throwError as observableThrowError, Observable} from 'rxjs';
import {Injectable} from '@angular/core';
import {Jsonp, URLSearchParams, RequestOptions, Headers} from '@angular/http';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import { HttpClient } from '@angular/common/http';
import {Claim} from '../claim';
import {AutoCompleteValue} from '../../../searchPages/searchUtils/searchHelperClasses.class';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {catchError, map} from "rxjs/operators";
import { COOKIE } from '../../../login/utils/helper.class';
@Injectable()
export class ContextsService {
constructor(private http: Http ) {
constructor(private http: HttpClient ) {
}
public getCommunities( apiUrl:string):any {
@ -19,9 +19,10 @@ export class ContextsService {
let key = url;
//console.info('ContextsService: request communities '+url);
return this.http.get(url)
.map(res => <any> res.json()).map(res => this.parseCommunities(res, true) )
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunities(res, true) ))
// .do(request => console.info("Get claims: offset = "))
.catch(this.handleError);
.pipe(catchError(this.handleError));
}
public getPublicCommunities( apiUrl:string):any {
let url = apiUrl + 's/';
@ -29,9 +30,7 @@ export class ContextsService {
let key = url;
//console.info('ContextsService: request communities '+url);
return this.http.get(url)
.map(res => <any> res.json()).map(res => this.parseCommunities(res, false) )
// .do(request => console.info("Get claims: offset = "))
.catch(this.handleError);
.pipe(map(res => this.parseCommunities(res, true) ));
}
parseCommunities(data, getall){
var communities = [];
@ -52,9 +51,9 @@ export class ContextsService {
return this.http.get(url)
.map(request => <any> request.json())
//.map(request => <any> request.json())
// .do(request => console.info("Get claims: offset = " ))
.catch(this.handleError);;
.pipe(catchError(this.handleError));
}
public getConcepts(categoryId :string, keyword: string, parsing:boolean, apiUrl:string):any {
//console.info('ContextsService: request concept for category with id '+categoryId + ' and keyword '+ keyword);
@ -63,9 +62,9 @@ export class ContextsService {
return this.http.get(url )
.map(request => <any> request.json())
.catch(this.handleError)
.map(res => (parsing)?this.parse(res):res);
//.map(request => <any> request.json())
.pipe(catchError(this.handleError))
.pipe(map(res => (parsing)?this.parse(res):res));
// .do(res => console.info("Result is "+ res.length ));
}
public getSubConcepts(subConceptID :string, keyword: string, parsing:boolean, apiUrl:string):any {
@ -75,9 +74,9 @@ export class ContextsService {
return this.http.get(url )
.map(request => <any> request.json())
.catch(this.handleError)
.map(res => (parsing)?this.parseSubConcepts(res):res);
//.map(request => <any> request.json())
.pipe(catchError(this.handleError))
.pipe(map(res => (parsing)?this.parseSubConcepts(res):res));
// .do(res => console.info("Result is "+ res.length ));
}
parse (data: any):any {
@ -130,7 +129,7 @@ export class ContextsService {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return observableThrowError(error || 'Server error');
}
private getAuthOptions():RequestOptions{
let headers = new Headers();

View File

@ -1,13 +1,17 @@
import {throwError as observableThrowError, Observable} from 'rxjs';
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { HttpClient } from '@angular/common/http';
import { ClaimResult} from '../claimEntities.class';
import {map} from "rxjs/operators";
@Injectable()
export class SearchCrossrefService {
constructor( private http: Http ) {}
constructor( private http: HttpClient ) {}
searchCrossrefResults (term: string, size : number, page : number, apiUrl:string, parse:boolean = false):any {
@ -15,8 +19,9 @@ export class SearchCrossrefService {
let key = url;
return this.http.get(url)
.map(request => <any> request.json().message)
.map(request => (parse?this.parse(request.items):request))
//.map(request => <any> request.json().message)
.pipe(map(request => request['message']))
.pipe(map(request => (parse?this.parse(request.items):request)))
//.catch(this.handleError);
}
@ -31,8 +36,9 @@ export class SearchCrossrefService {
return this.http.get(url)
.map(request => <any> request.json().message)
.map(request => (parse?this.parse(request.items):request))
//.map(request => <any> request.json().message)
.pipe(map(request => request['message']))
.pipe(map(request => (parse?this.parse(request.items):request)))
//.catch(this.handleError);
}
@ -46,8 +52,9 @@ export class SearchCrossrefService {
return this.http.get(url)
.map(request => <any> request.json().message)
.map(request => (parse?this.parse(request.items):request))
//.map(request => <any> request.json().message)
.pipe(map(request => request['message']))
.pipe(map(request => (parse?this.parse(request.items):request)))
//.catch(this.handleError);
}
@ -56,7 +63,7 @@ export class SearchCrossrefService {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return observableThrowError(error || 'Server error');
}
parse(response):ClaimResult[]{
var results:ClaimResult[] = [];

View File

@ -1,15 +1,18 @@
import {throwError as observableThrowError, Observable} from 'rxjs';
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { HttpClient } from '@angular/common/http';
import{EnvProperties} from '../../../utils/properties/env-properties';
import { ClaimResult} from '../claimEntities.class';
import {map} from "rxjs/operators";
@Injectable()
export class SearchDataciteService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchDataciteResults (term: string, size : number, page : number, properties:EnvProperties, parse:boolean = false):any {
//console.info("In search datacite results "+term+ " "+properties.searchDataciteAPIURL);
@ -17,8 +20,8 @@ export class SearchDataciteService {
let key = url;
return this.http.get( ( properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(request => <any> request.json())
.map(request => (parse?this.parse(request.data):request))
//.map(request => <any> request.json())
.pipe(map(request => (parse?this.parse(request['data']):request)))
//.catch(this.handleError);
}
getDataciteResultByDOI (doi: string, properties:EnvProperties, parse:boolean = false):any {
@ -26,8 +29,8 @@ export class SearchDataciteService {
let key = url;
return this.http.get( (properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(request => <any> request.json())
.map(request => (parse?this.parse(request.data):request))
//.map(request => <any> request.json())
.pipe(map(request => (parse?this.parse(request['data']):request)))
// .do(items => console.log("Datacite Results: total results = "+items.meta.total+" doi = "+doi))
@ -39,7 +42,7 @@ export class SearchDataciteService {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return observableThrowError(error || 'Server error');
}
private extractData(res: Response) {
if (res.status < 200 || res.status >= 300) {

View File

@ -2,60 +2,68 @@ import {Injectable} from '@angular/core';
import {URLSearchParams} from '@angular/http';
import {Http, Response} from '@angular/http';
import { Headers, RequestOptions } from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Observable} from 'rxjs';
import{EnvProperties} from '../../../utils/properties/env-properties';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { ClaimResult} from '../claimEntities.class';
import {map} from "rxjs/operators";
@Injectable()
export class SearchOrcidService {
constructor( private http: Http ) {}
constructor( private http: HttpClient ) {}
searchOrcidAuthor (term: string, authorIds: string[], authors, properties:EnvProperties, addId):any {
var headers = new Headers();
headers.append('Accept', 'application/orcid+json');
//var headers = new Headers();
//headers.append('Accept', 'application/orcid+json');
let headers = new HttpHeaders({'Accept': 'application/orcid+json'});
let url = properties.searchOrcidURL + term+'/record';
let key = url;
return this.http.get(url, { headers: headers })
.map(res => res.json()['person'])
.map(res => [res['name']['given-names'],
//.map(res => res.json()['person'])
.pipe(map(res => res['person']))
.pipe(map(res => [res['name']['given-names'],
res['name']['family-name'],
res['name']])
.map(res => this.parseOrcidAuthor(res, authorIds, authors, addId));
res['name']]))
.pipe(map(res => this.parseOrcidAuthor(res, authorIds, authors, addId)));
}
searchOrcidAuthors (term: string, authorIds: string[],
properties:EnvProperties):any {
var headers = new Headers();
headers.append('Accept', 'application/orcid+json');
//var headers = new Headers();
//headers.append('Accept', 'application/orcid+json');
let headers = new HttpHeaders({'Accept': 'application/orcid+json'});
let url = properties.searchOrcidURL+'search?defType=edismax&q='+term+'&qf=given-name^1.0+family-name^2.0+other-names^1.0+credit-name^1.0&start=0&rows=10';
let key = url;
return this.http.get(url, { headers: headers })
.map(res => res.json()['result'])
.map(res => this.parseOrcidAuthors(res, authorIds));
//.map(res => res.json()['result'])
.pipe(map(res => res['result']))
.pipe(map(res => this.parseOrcidAuthors(res, authorIds)));
}
searchOrcidPublications (id: string, properties:EnvProperties, parse:boolean = false):any {
var headers = new Headers();
headers.append('Accept', 'application/orcid+json');
//var headers = new Headers();
//headers.append('Accept', 'application/orcid+json');
let headers = new HttpHeaders({'Accept': 'application/orcid+json'});
let url =properties.searchOrcidURL+id+'/works';
let key = url;
return this.http.get(url, { headers: headers })
.map(res => res.json()['group'])
.map(request => (parse?this.parse(id, request):request));
//.map(res => res.json()['group'])
.pipe(map(res => res['group']))
.pipe(map(request => (parse?this.parse(id, request):request)));
//.map(res => res['orcid-work']);
}

View File

@ -2,7 +2,7 @@ import {Component, ViewChild, Input} from '@angular/core';
import {Location} from '@angular/common';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
@Component({

View File

@ -4,8 +4,7 @@ import {ActivatedRoute, Params, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {DataTableDirective} from 'angular-datatables';
import {Observable} from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import {Observable, Subject } from 'rxjs';
import{EnvProperties} from '../../utils/properties/env-properties';
import {ErrorCodes} from '../../utils/properties/errorCodes';

View File

@ -1,15 +1,16 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/do';
import {RequestOptions, Headers} from '@angular/http';
import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http";
import {throwError} from 'rxjs';
import { CustomOptions } from '../../services/servicesUtils/customOptions.class';
import {catchError} from "rxjs/operators";
@Injectable()
export class ClaimsByTokenService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
getClaims(openaireId: string, apiURL:string):any {
@ -18,9 +19,9 @@ export class ClaimsByTokenService {
let key = url;
return this.http.get(url, CustomOptions.getAuthOptions())
return this.http.get(url, CustomOptions.getAuthOptions());
//.map(res => <any> res.text())
.map(request => <any> request.json());
//.map(request => <any> request.json());
}
@ -57,12 +58,11 @@ export class ClaimsByTokenService {
let body = JSON.stringify( claimsCurationInfo );
//console.warn('Json body: : '+body);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
//.map(res => res.json())
//.do(request => console.info("Insert Response:"+request.status) )
.catch(this.handleError);
.pipe(catchError(this.handleError));
}
@ -74,17 +74,17 @@ export class ClaimsByTokenService {
let body = JSON.stringify( claimsCurationInfo );
//console.warn('Json body: : '+body);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
.catch(this.handleError);
//.map(res => res.json())
.pipe(catchError(this.handleError));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
//return Observable.throw(error || 'Server error');
}
}

View File

@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';

View File

@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter,ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {SearchCrossrefService} from '../../claim-utils/service/searchCrossref.service';
import {SearchDataciteService} from '../../claim-utils/service/searchDatacite.service';

View File

@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {Router, ActivatedRoute} from '@angular/router';
import {ClaimsService} from '../../claim-utils/service/claims.service';

View File

@ -1,7 +1,7 @@
import {Component, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {EnvProperties} from '../../utils/properties/env-properties';

View File

@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {Title, Meta} from '@angular/platform-browser';
@Component({

View File

@ -1,16 +1,18 @@
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import {CommunityInfo} from '../community/communityInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {BehaviorSubject, Observable} from "rxjs";
import {map} from "rxjs/operators";
@Injectable()
export class CommunitiesService {
public communities: BehaviorSubject<CommunityInfo[]> = null;
constructor(private http: Http) {
constructor(private http: HttpClient) {
this.communities = new BehaviorSubject([]);
}
@ -26,7 +28,8 @@ export class CommunitiesService {
getCommunities(properties: EnvProperties, url: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.map(res => <any> res.json()).map(res => this.parseCommunities(res));
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunities(res)));
}
parseCommunities(data: any): CommunityInfo[] {

View File

@ -1,22 +1,33 @@
import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';
import {HttpClient, HttpHeaders} from "@angular/common/http";
import { CommunityInfo } from './communityInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators";
import {COOKIE} from "../../login/utils/helper.class";
@Injectable()
export class CommunityService {
constructor(private http: Http) {
constructor(private http: HttpClient) {
}
getCommunity(properties: EnvProperties, url: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.map(res => <any> res.json()).map(res => this.parseCommunity(res));
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunity(res)));
}
updateCommunity(url: string, community: any) {
const headers = new Headers({'Content-Type': 'application/json'});
const options = new RequestOptions({headers: headers});
//const headers = new Headers({'Content-Type': 'application/json'});
//const options = new RequestOptions({headers: headers});
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
})
};
const body = JSON.stringify(community);
return this.http.post(url, body, options);
/*.map(res => res.json())*/
@ -24,39 +35,40 @@ export class CommunityService {
isCommunityManager(properties: EnvProperties, url: string, manager: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.map(res => <any> res.json()).map(res =>
this.parseCommunity(res)).map(community => community.managers.indexOf(manager) !== -1);
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunity(res)))
.pipe(map(community => community.managers.indexOf(manager) !== -1));
}
isRIType(properties: EnvProperties, url: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.map(res => <any> res.json()).map(res =>
this.parseCommunity(res)).map(community =>
(community && community.type && community.type === 'ri'));
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunity(res)))
.pipe(map(community => (community && community.type && community.type === 'ri')));
}
isCommunityType(properties: EnvProperties, url: string) {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.map(res => <any> res.json()).map(res =>
this.parseCommunity(res)).map(community =>
(community && community.type && community.type === 'community'));
//.map(res => <any> res.json())
.pipe(map(res => this.parseCommunity(res)))
.pipe(map(community => (community && community.type && community.type === 'community')));
}
isSubscribedToCommunity(pid: string, email: string, url: string) {
return this.http.get(url + '/community/' + pid + '/subscribers')
.map(res => ((<any>res === '') ? {} : <any> res.json()))
.map(res => {
if (res.subscribers && res.subscribers != null) {
//.map(res => ((<any>res === '') ? {} : <any> res.json()))
.pipe(map(res => {
if (res['subscribers'] && res['subscribers'] != null) {
for (let i = 0; i < res.subscribers.length; i++ ) {
if (res.subscribers[i] != null && res.subscribers[i].email === email) {
for (let i = 0; i < res['subscribers'].length; i++ ) {
if (res['subscribers'][i] != null && res['subscribers'][i].email === email) {
return true;
}
}
}
return false;
});
}));
}
private parseCommunity(data: any): CommunityInfo {

View File

@ -1,12 +1,14 @@
import {map, filter, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import {
Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad, Route
CanLoad, Route, UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service';
@ -25,10 +27,10 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) {
return true;
} else {
const obs = this.propertiesService.subscribeEnvironment().map(res => res).mergeMap(properties => {
const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => res),mergeMap(properties => {
return this.communityService.isCommunityManager(properties, properties['communityAPI'] + community, Session.getUserEmail());
});
obs.filter(enabled => !enabled)
}),);
obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': errorCode,
@ -49,7 +51,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
return this.check(route.queryParams['communityId'], state.url);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
const path = '/' + route.path + document.location.search;
return this.check(ConnectHelper.getCommunityFromPath(path), path);
}

View File

@ -1,3 +1,5 @@
import {filter, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import {
Router,
@ -7,13 +9,13 @@ import {
CanLoad,
Route
} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper';
@Injectable()
export class ConnectCommunityGuard implements CanActivate, CanLoad {
export class ConnectCommunityGuard implements CanActivate {
constructor(private router: Router,
private communityService: CommunityService,
@ -21,10 +23,10 @@ export class ConnectCommunityGuard implements CanActivate, CanLoad {
}
check(community: string): Observable<boolean> | boolean {
const obs = this.propertiesService.subscribeEnvironment().mergeMap(properties => {
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
return this.communityService.isCommunityType(properties, properties['communityAPI'] + community);
});
obs.filter(enabled => !enabled)
}));
obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate(['errorcommunity']));
return obs;
}
@ -32,9 +34,4 @@ export class ConnectCommunityGuard implements CanActivate, CanLoad {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.queryParams['communityId']);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
const path = '/' + route.path + document.location.search;
return this.check(ConnectHelper.getCommunityFromPath(path));
}
}

View File

@ -1,3 +1,5 @@
import {filter, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import {
Router,
@ -5,9 +7,9 @@ import {
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad,
Route
Route, UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper';
@ -21,10 +23,10 @@ export class ConnectRIGuard implements CanActivate, CanLoad {
}
check(community: string): Observable<boolean> | boolean {
const obs = this.propertiesService.subscribeEnvironment().mergeMap(properties => {
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
return this.communityService.isRIType(properties, properties['communityAPI'] + community);
});
obs.filter(enabled => !enabled)
}));
obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate(['errorcommunity']));
return obs;
}
@ -33,7 +35,7 @@ export class ConnectRIGuard implements CanActivate, CanLoad {
return this.check(route.queryParams['communityId']);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
const path = '/' + route.path + document.location.search;
return this.check(ConnectHelper.getCommunityFromPath(path));
}

View File

@ -1,6 +1,8 @@
import {filter, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service';
@ -8,7 +10,7 @@ import { EnvironmentSpecificService} from '../../utils/properties/environment-sp
import {ConnectHelper} from '../connectHelper';
@Injectable()
export class ConnectSubscriberGuard implements CanActivate, CanLoad {
export class ConnectSubscriberGuard implements CanActivate {
constructor(private router: Router,
private communityService: CommunityService,
private propertiesService: EnvironmentSpecificService) {}
@ -20,13 +22,13 @@ export class ConnectSubscriberGuard implements CanActivate, CanLoad {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': errorCode, 'redirectUrl': path, communityId:community}});
return false;
} else {
const obs = this.propertiesService.subscribeEnvironment().mergeMap(properties => {
const obs = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
if(!community){
community = ConnectHelper.getCommunityFromDomain(properties.domain);
}
return this.communityService.isSubscribedToCommunity( community, Session.getUserEmail(), properties["adminToolsAPIURL"])
});
obs.filter(enabled => !enabled)
}));
obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': errorCode,
@ -41,10 +43,5 @@ export class ConnectSubscriberGuard implements CanActivate, CanLoad {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.queryParams['communityId'], state.url);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
const path = '/' + route.path + document.location.search;
return this.check(ConnectHelper.getCommunityFromPath(path), path);
}
}

View File

@ -4,10 +4,10 @@ import {
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad, Route
CanLoad, Route, UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/filter';
import {Observable} from 'rxjs';
import {ConnectHelper} from '../connectHelper';
@Injectable()
@ -29,7 +29,7 @@ export class IsCommunity implements CanActivate, CanLoad {
return this.check(route.queryParams['communityId']);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
const path = '/' + route.path + document.location.search;
return this.check(ConnectHelper.getCommunityFromPath(path));
}

View File

@ -1,15 +1,16 @@
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import{EnvProperties} from '../../utils/properties/env-properties';
@Injectable()
export class SearchCommunityDataprovidersService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchDataproviders (properties:EnvProperties, communityId: string):any {
let url = properties.communityAPI+communityId+"/contentproviders";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
//.map(res => <any> res.json())
}
}

View File

@ -1,9 +1,9 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {HttpClient} from '@angular/common/http';
import {BehaviorSubject, Observable} from 'rxjs';
import {Curator} from '../../utils/entities/CuratorInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {COOKIE} from '../../login/utils/helper.class';
import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
@Injectable()
export class CuratorService {
@ -34,20 +34,11 @@ export class CuratorService {
}
public updateCurator(url: string, curator: Curator) {
return this.http.post<Curator>(url, curator, this.getAuthOptions());
return this.http.post<Curator>(url, curator, CustomOptions.getAuthOptions());
}
public getCurator(properties: EnvProperties, url: string): Observable<Curator> {
return this.http.get<Curator>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url);
}
// TODO remove and use CustomOptions.getAuthOptions()
private getAuthOptions(): any {
const httpOptions = {
headers: new HttpHeaders({
'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id),
}), withCredentials: true
};
return httpOptions;
}
}

View File

@ -1,15 +1,16 @@
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import{EnvProperties} from '../../utils/properties/env-properties';
@Injectable()
export class SearchCommunityProjectsService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchProjects (properties:EnvProperties, communityId: string):any {
let url = properties.communityAPI+communityId+"/projects";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
//.map(res => <any> res.json())
}
}

View File

@ -1,6 +1,6 @@
import {Component, ViewChild, Input} from '@angular/core';
import {Location} from '@angular/common';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router';
import {ModalLoading} from '../../utils/modal/loading.component';
import {AlertModal} from '../../utils/modal/alert';

View File

@ -1,6 +1,7 @@
import {Injectable} from '@angular/core';
import {Http, RequestOptions, Headers, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
//import { HttpErrorResponse } from '@angular/common/http';
import {EnvProperties} from '../../utils/properties/env-properties';
@ -8,13 +9,13 @@ import { CustomOptions } from '../../services/servicesUtils/customOptions.class'
@Injectable()
export class MailPrefsService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
getUserEmailPreferencesForCommunity (communityId:string, apiUrl:string):any {
let url = apiUrl +"users/notification"+"?communityId="+communityId;
return this.http.get(url, CustomOptions.getAuthOptions())
.map(request => <any> request.json())
//.map(request => <any> request.json())
//.do(request => console.info("Get user email preferences for communityId= "+communityId ));
//.catch(this.handleError);
}
@ -23,13 +24,13 @@ export class MailPrefsService {
let url = apiUrl +"users/notification";
//var error: HttpErrorResponse = new HttpErrorResponse({"error": {"code": 204}, "status" : 204}); // doesn't work
var response: Response = new Response({"body" : {"code":200, "data": []}, "status": 200, "headers": null, "url": "", "merge": null});
//var response: Response = new Response({"body" : {"code":200, "data": []}, "status": 200, "headers": null, "url": "", "merge": null});
return this.http.get(url, CustomOptions.getAuthOptions())
//.timeoutWith(100, Observable.throw(response)) // goes to error
//.timeoutWith(100, Observable.of(response)) // goes to
//.do(request => console.info(request))
.map(request => <any> request.json())
//.map(request => <any> request.json())
//.do(request => console.info("Get user email preferences for OpenAIRE" ));
//.catch(this.handleError);
}
@ -39,18 +40,18 @@ export class MailPrefsService {
let body = JSON.stringify( notification );
//console.warn('Json body: : '+body);
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
//let headers = new Headers({ 'Content-Type': 'application/json' });
//let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
//.map(res => res.json())
//.do(request => console.info("Insert Response:"+request.status) );
//.catch(this.handleError);
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
}

View File

@ -1,15 +1,16 @@
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import{EnvProperties} from '../../utils/properties/env-properties';
@Injectable()
export class SearchZenodoCommunitiesService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchZCommunities (properties:EnvProperties, communityId: string):any {
let url = properties.communityAPI+communityId+"/zenodocommunities";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
//.map(res => <any> res.json())
}
}

View File

@ -1,28 +1,32 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Headers, RequestOptions} from '@angular/http';
import {Observable} from 'rxjs/Rx';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
import {ZenodoCommunityInfo} from './zenodoCommunityInfo';
import {EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class ZenodoCommunitiesService {
constructor(private http:Http) {
constructor(private http:HttpClient) {
}
getZenodoCommunities(properties:EnvProperties, url: string) {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
.map(res => <any> res.json()).map(res => [this.parseZenodoCommunities(res.hits.hits),res.hits.total]);
//.map(res => <any> res.json())
.pipe(map(res => [this.parseZenodoCommunities(res['hits'].hits),res['hits'].total]));
}
getZenodoCommunityById(properties:EnvProperties, url: string, openaireId:string) {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
.map(res => <any> res.json()).map(res => {
//.map(res => <any> res.json())
.pipe(map(res => {
var community = this.parseZenodoCommunity(res);
community["openaireId"]=openaireId;
return community;
});
}));
}
parseZenodoCommunities(data: any): ZenodoCommunityInfo[] {
@ -53,6 +57,7 @@ export class ZenodoCommunitiesService {
getTotalZenodoCommunities(properties:EnvProperties, url: string) {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)) : url)
.map(res => <any> res.json()).map(res => res.hits.total);
//.map(res => <any> res.json())
.pipe(map(res => res['hits'].total));
}
}

View File

@ -2,7 +2,7 @@ import {Component, Input} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {EnvProperties} from '../../utils/properties/env-properties';

View File

@ -3,7 +3,7 @@ import {Router} from '@angular/router';
import {ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {EnvProperties} from '../../utils/properties/env-properties';

View File

@ -2,7 +2,7 @@ import {Component, Input} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {EnvProperties} from '../utils/properties/env-properties';

View File

@ -2,7 +2,7 @@ import {Component, Input} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {ErrorCodes} from '../utils/properties/errorCodes';
import{EnvProperties} from '../utils/properties/env-properties';

View File

@ -1,3 +1,7 @@
import {of as observableOf, Observable} from 'rxjs';
import {map, filter, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import {
Router,
@ -7,14 +11,13 @@ import {
RouterStateSnapshot,
Route, Data
} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/filter';
import { ConfigurationService } from '../utils/configuration/configuration.service';
import { EnvironmentSpecificService} from '../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connect/connectHelper';
@Injectable()
export class IsRouteEnabled implements CanActivate, CanLoad {
export class IsRouteEnabled implements CanActivate {
constructor(private router: Router,
private config: ConfigurationService,
@ -26,18 +29,18 @@ export class IsRouteEnabled implements CanActivate, CanLoad {
community = data['community'];
}
const redirect = customRedirect ? customRedirect : '/error';
const obs = this.propertiesService.subscribeEnvironment().map(res => {
const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => {
if (!community) {
community = ConnectHelper.getCommunityFromDomain(res.domain);
}
return res['adminToolsAPIURL'];
}).mergeMap(url => {
}),mergeMap(url => {
if (!community) { // no community to check - return true
return Observable.of(true);
return observableOf(true);
}
return this.config.isPageEnabled(url, community, '/' + path.split('?')[0].substring(1));
});
obs.filter(enabled => !enabled)
}),);
obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate([redirect], {queryParams: {'page': path}}));
return obs;
}
@ -45,8 +48,4 @@ export class IsRouteEnabled implements CanActivate, CanLoad {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.data, route.queryParams['communityId'], state.url);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
const path = '/' + route.path + document.location.search;
return this.check(route.data, ConnectHelper.getCommunityFromPath(path), path);
}
}

View File

@ -1,12 +1,12 @@
import {merge as observableMerge, Observable} from 'rxjs';
import {Component, ViewChild} from '@angular/core';
import {Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/switch';
import 'rxjs/add/operator/switchMap';
import {EnvProperties} from '../../utils/properties/env-properties';
@ -419,7 +419,7 @@ export class DataProviderComponent {
&&
( this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.LOADING ||
this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.DONE )) {
this.relatedDatasourcesSub = Observable.merge(this.fetchAggregatorsPublications.requestComplete, this.fetchAggregatorsDatasets.requestComplete, this.fetchAggregatorsSoftware.requestComplete, this.fetchAggregatorsOrps.requestComplete)
this.relatedDatasourcesSub = observableMerge(this.fetchAggregatorsPublications.requestComplete, this.fetchAggregatorsDatasets.requestComplete, this.fetchAggregatorsSoftware.requestComplete, this.fetchAggregatorsOrps.requestComplete)
.subscribe(
data => {},
err => {},

View File

@ -1,17 +1,19 @@
import {Injectable} from '@angular/core';
import {Http, Response,Headers, RequestOptions} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
import {DataProviderInfo} from '../../utils/entities/dataProviderInfo';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import{EnvProperties} from '../../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class DataProviderService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
dataProviderInfo: DataProviderInfo;
@ -20,37 +22,43 @@ export class DataProviderService {
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity'])
.map(res => [res['oaf:datasource'],
//.map(res => <any> res.json())
.pipe(map(res => res['result']['metadata']['oaf:entity']))
.pipe(map(res => [res['oaf:datasource'],
res['oaf:datasource']['datasourcetype'],
res['oaf:datasource']['openairecompatibility'],
res['oaf:datasource']['collectedfrom'],
res['oaf:datasource']['accessinfopackage'],
res['oaf:datasource']['rels']['rel'],
res['oaf:datasource']['journal'] //6
])
.map(res => this.parseDataProviderInfo(res));
]))
.pipe(map(res => this.parseDataProviderInfo(res)));
}
getDataproviderAggregationStatus(original_id: string, properties:EnvProperties):any {
let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
let options = new RequestOptions({headers: headers});
//let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
//let options = new RequestOptions({headers: headers});
const options = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'accept': 'application/json'})
};
let page: number = 0;
let size: number = 1;
return this.http.post(properties.datasourcesAPI+page+"/"+size+"?requestSortBy=id&order=ASCENDING", JSON.stringify({ "id": original_id }), options)
.map(res => <any> res.json())
.map(res => res['datasourceInfo'])
.map(res => this.parseDataproviderAggregationStatus(res));
//.map(res => <any> res.json())
.pipe(map(res => res['datasourceInfo']))
.pipe(map(res => this.parseDataproviderAggregationStatus(res)));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
parseDataproviderAggregationStatus(data: any): any {

View File

@ -7,7 +7,7 @@ import { FetchOrps } from '../../utils/fetchEntitiesClasses/fetchOrps.class';
import { ErrorCodes} from '../../utils/properties/errorCodes';
import {RouterHelper} from '../../utils/routerHelper.class';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import{EnvProperties} from '../../utils/properties/env-properties';
@Component({

View File

@ -3,7 +3,7 @@ import {Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {DatasetInfo} from '../../utils/entities/datasetInfo';
import {EnvProperties} from '../../utils/properties/env-properties';

View File

@ -1,18 +1,20 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
import {DatasetInfo} from '../../utils/entities/datasetInfo';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import{EnvProperties} from '../../utils/properties/env-properties';
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
import {map} from "rxjs/operators";
@Injectable()
export class DatasetService {
constructor(private http: Http ) {
constructor(private http: HttpClient ) {
this.parsingFunctions = new ParsingFunctions();
}
@ -26,9 +28,9 @@ export class DatasetService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result'],res])
.map(res => [res[1], //0
//.map(res => <any> res.json())
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result'],res]))
.pipe(map(res => [res[1], //0
res[1]['title'], //1
res[1]['rels']['rel'], //2
res[1]['children'], //3
@ -45,14 +47,15 @@ export class DatasetService {
res[2], //13
(res[1]['extraInfo']!= undefined && res[1]['extraInfo']['citations']!= undefined)? res[1]['extraInfo']['citations']['citation']:null, //14
res[1]['journal'] //15
]).map(res => this.parseDatasetInfo(res, properties));
]))
.pipe(map(res => this.parseDatasetInfo(res, properties)));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
parseDatasetInfo (data: any, properties: EnvProperties):any {

View File

@ -2,7 +2,7 @@ import {Component, Input} from '@angular/core';
import {ActivatedRoute, Params, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {EnvProperties} from '../../utils/properties/env-properties';

View File

@ -1,12 +1,14 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/do';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
import {map} from "rxjs/operators";
@Injectable()
export class HtmlProjectReportService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
getHTML(id: string, size: number, type:string, csvAPIURL: string ):any {
@ -32,6 +34,9 @@ export class HtmlProjectReportService {
let key = url;
return this.http.get(url)
.map(res => <any> res.text());
.pipe(map(res => {
let resText:any = res;
return resText.text();
}));
}
}

View File

@ -2,7 +2,7 @@ import {Component, ViewChild} from '@angular/core';
import {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {DeletedByInferenceResult} from '../../../utils/entities/deletedByInferenceResult';
@ -11,8 +11,8 @@ import {ErrorCodes} from '../../../utils/properties/errorCodes
import {DeletedByInferenceService} from './deletedByInference.service';
//import {zip} from 'rxjs';
import 'rxjs/add/observable/zip';
import {zip} from 'rxjs';
@Component({
selector: 'deletedByInference',
@ -152,7 +152,7 @@ export class DeletedByInferenceComponent {
allRequests.push(this._deletedByInferenceService.getDeletedByInferencePublications(id, this.properties));
}
Observable.zip.apply(null, allRequests).subscribe(
zip.apply(null, allRequests).subscribe(
// this._deletedByInferenceService.getDeletedByInferencePublications(id, this.properties).subscribe(
data => {
this.results = data;

View File

@ -1,21 +1,15 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient} from "@angular/common/http";
import {DeletedByInferenceResult} from '../../../utils/entities/deletedByInferenceResult';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import 'rxjs/add/operator/map';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {ParsingFunctions} from '../parsingFunctions.class';
import {map} from "rxjs/operators";
@Injectable()
export class DeletedByInferenceService {
private sizeOfDescription: number = 270;
constructor(private http: Http ) {
constructor(private http: HttpClient ) {
this.parsingFunctions = new ParsingFunctions();
}
@ -26,9 +20,9 @@ export class DeletedByInferenceService {
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity'])
.map(res => this.parseDeletedByInferencePublications(res, properties));
//.map(res => <any> res.json())
.pipe(map(res => res['result']['metadata']['oaf:entity']))
.pipe(map(res => this.parseDeletedByInferencePublications(res, properties)));
}
parseDeletedByInferencePublications (result: any, properties: EnvProperties): DeletedByInferenceResult {

View File

@ -3,7 +3,7 @@ import {Metrics} from '../../utils/entities/metrics';
import {MetricsService } from '../../services/metrics.service';
import {ErrorCodes} from '../../utils/properties/errorCodes';
import { Subscription } from 'rxjs/Subscription';
import { Subscription } from 'rxjs';
import{EnvProperties} from '../../utils/properties/env-properties';
@Component({

View File

@ -3,8 +3,7 @@ import {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {Observable, Subject} from 'rxjs';
import {OrganizationService} from '../../services/organization.service';
import {OrganizationInfo} from '../../utils/entities/organizationInfo';

View File

@ -3,7 +3,7 @@ import {Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {OrpInfo} from '../../utils/entities/orpInfo';
import {EnvProperties} from '../../utils/properties/env-properties';

View File

@ -1,18 +1,15 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {throwError} from 'rxjs';
import {OrpInfo} from '../../utils/entities/orpInfo';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {EnvProperties} from '../../utils/properties/env-properties';
import {ParsingFunctions} from '../landing-utils/parsingFunctions.class';
import {map} from "rxjs/operators";
@Injectable()
export class OrpService {
constructor(private http: Http ) {
constructor(private http: HttpClient ) {
this.parsingFunctions = new ParsingFunctions();
}
@ -25,9 +22,9 @@ export class OrpService {
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'],res])
.map(res => [res[1]['oaf:result'], //0
//.map(res => <any> res.json())
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'],res]))
.pipe(map(res => [res[1]['oaf:result'], //0
res[1]['oaf:result']['title'], //1
res[1]['oaf:result']['rels']['rel'], //2
res[1]['oaf:result']['children'], //3
@ -43,14 +40,15 @@ export class OrpService {
res[2], //13
(res[1]['extraInfo']!= undefined && res[1]['extraInfo']['citations']!= undefined)? res[1]['extraInfo']['citations']['citation']:null, //14
res[1]['oaf:result']['journal'] //15
]).map(res => this.parseOrpInfo(res, properties));
]))
.pipe(map(res => this.parseOrpInfo(res, properties)));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
parseOrpInfo (data: any, properties: EnvProperties):any {

View File

@ -4,7 +4,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {Params} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {ProjectService} from './project.service';
import {ProjectInfo} from '../../utils/entities/projectInfo';

View File

@ -1,18 +1,20 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
import {ProjectInfo} from '../../utils/entities/projectInfo';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import{EnvProperties} from '../../utils/properties/env-properties';
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
import {map} from "rxjs/operators";
@Injectable()
export class ProjectService {
constructor(private http: Http ) {
constructor(private http: HttpClient ) {
this.parsingFunctions = new ParsingFunctions();
}
@ -25,12 +27,12 @@ export class ProjectService {
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity']['oaf:project'])
.map(res => [res,
//.map(res => <any> res.json())
.pipe(map(res => res['result']['metadata']['oaf:entity']['oaf:project']))
.pipe(map(res => [res,
res['fundingtree'],
res['rels']['rel']])
.map(res => this.parseProjectInfo(res, properties));
res['rels']['rel']]))
.pipe(map(res => this.parseProjectInfo(res, properties)));
}
@ -43,13 +45,13 @@ export class ProjectService {
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['results'][0])
.map(res => [res['result']['metadata']['oaf:entity']['oaf:project'],res['result']['header']['dri:objIdentifier']])
.map(res => [res[0],
//.map(res => <any> res.json())
.pipe(map(res => res['results'][0]))
.pipe(map(res => [res['result']['metadata']['oaf:entity']['oaf:project'],res['result']['header']['dri:objIdentifier']]))
.pipe(map(res => [res[0],
res[0]['fundingtree'],
res[0]['rels']['rel'],res[1]])
.map(res => this.parseProjectInfo(res, properties));
res[0]['rels']['rel'],res[1]]))
.pipe(map(res => this.parseProjectInfo(res, properties)));
}
/*
@ -61,12 +63,12 @@ export class ProjectService {
let key = url+'_projectDates';
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity']['oaf:project'])
.map(res => [res,
//.map(res => <any> res.json())
.pipe(map(res => res['result']['metadata']['oaf:entity']['oaf:project']))
.pipe(map(res => [res,
res['fundingtree'],
res['rels']['rel']])
.map(res => this.parseProjectDates(id,res))
res['rels']['rel']]))
.pipe(map(res => this.parseProjectDates(id,res)))
}
@ -75,14 +77,14 @@ export class ProjectService {
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity']['oaf:project'])
.map(res => this.parseHTMLInfo(res));
//.map(res => <any> res.json())
.pipe(map(res => res['result']['metadata']['oaf:entity']['oaf:project']))
.pipe(map(res => this.parseHTMLInfo(res)));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
parseHTMLInfo (data: any):any {

View File

@ -3,7 +3,7 @@ import {Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {EnvProperties} from '../../utils/properties/env-properties';
import {PublicationInfo} from '../../utils/entities/publicationInfo';

View File

@ -1,22 +1,15 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {throwError} from 'rxjs';
import {PublicationInfo} from '../../utils/entities/publicationInfo';
import {DeletedByInferenceResult} from '../../utils/entities/deletedByInferenceResult';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import 'rxjs/add/operator/map';
import {EnvProperties} from '../../utils/properties/env-properties';
import {ParsingFunctions} from '../landing-utils/parsingFunctions.class';
import {map} from "rxjs/operators";
@Injectable()
export class PublicationService {
constructor(private http: Http ) {
constructor(private http: HttpClient ) {
this.parsingFunctions = new ParsingFunctions();
}
@ -28,9 +21,9 @@ export class PublicationService {
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res])
.map(res => [ res[1]['oaf:result'], //0
//.map(res => <any> res.json())
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res]))
.pipe(map(res => [ res[1]['oaf:result'], //0
res[1]['oaf:result']['title'], //1
res[1]['oaf:result']['rels']['rel'], //2
res[1]['oaf:result']['children'], //3
@ -46,15 +39,15 @@ export class PublicationService {
res[1]['oaf:result']['creator'], //13
res[2], //14
res[1]['oaf:result']['country'] //15
])
.map(res => this.parsePublicationInfo(res, properties));
]))
.pipe(map(res => this.parsePublicationInfo(res, properties)));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
parsePublicationInfo (data: any, properties: EnvProperties):any {
@ -378,8 +371,8 @@ export class PublicationService {
//return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
return this.http.get(url)
.map(res => <any> res.json())
.map(res => [res['total'], this.parseOpenCitations(res['results'])]);
//.map(res => <any> res.json())
.pipe(map(res => [res['total'], this.parseOpenCitations(res['results'])]));
}
parseOpenCitations(openCitations: any): {"url": string, "title": string, "year": string, "doi": string, "authors": string[]}[] {

View File

@ -3,7 +3,7 @@ import {Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {SoftwareService} from './software.service';
import {SoftwareInfo} from '../../utils/entities/softwareInfo';

View File

@ -1,18 +1,15 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {throwError} from 'rxjs';
import {SoftwareInfo} from '../../utils/entities/softwareInfo';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {EnvProperties} from '../../utils/properties/env-properties';
import {ParsingFunctions} from '../landing-utils/parsingFunctions.class';
import {map} from "rxjs/operators";
@Injectable()
export class SoftwareService {
constructor(private http: Http ) {
constructor(private http: HttpClient ) {
this.parsingFunctions = new ParsingFunctions();
}
@ -26,9 +23,9 @@ export class SoftwareService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result'], res])
.map(res => [res[1],
//.map(res => <any> res.json())
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result'], res]))
.pipe(map(res => [res[1],
res[1]['title'],
res[1]['rels']['rel'],
res[1]['children'],
@ -45,14 +42,15 @@ export class SoftwareService {
res[1]['programmingLanguage'],
res[2],
res[1]['journal'] //15
]).map(res => this.parseSoftwareInfo(res, properties));
]))
.pipe(map(res => this.parseSoftwareInfo(res, properties)));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
parseSoftwareInfo (data: any, properties: EnvProperties):any {

View File

@ -1,11 +1,19 @@
import {Injectable} from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {
Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad,
Route,
UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class';
@Injectable()
export class AdminLoginGuard implements CanActivate, CanLoad {
export class AdminLoginGuard implements CanActivate{
constructor(private router: Router) {
}
@ -22,7 +30,12 @@ export class AdminLoginGuard implements CanActivate, CanLoad {
}
}
if (!loggedIn || !isAdmin) {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': errorCode, 'redirectUrl': path}});
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': errorCode,
'redirectUrl': path
}
});
}
return loggedIn && isAdmin;
}
@ -31,7 +44,4 @@ export class AdminLoginGuard implements CanActivate, CanLoad {
return this.check(state.url);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
return this.check('/' + route.path);
}
}

View File

@ -1,11 +1,19 @@
import {Injectable} from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {
Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad,
Route,
UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class';
@Injectable()
export class ClaimsCuratorGuard implements CanActivate, CanLoad {
export class ClaimsCuratorGuard implements CanActivate {
constructor(private router: Router) {
}
@ -24,7 +32,12 @@ export class ClaimsCuratorGuard implements CanActivate, CanLoad {
}
}
if (!loggedIn || !isAuthorized) {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': errorCode, 'redirectUrl': path}});
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': errorCode,
'redirectUrl': path
}
});
}
return loggedIn && isAuthorized;
}
@ -33,7 +46,4 @@ export class ClaimsCuratorGuard implements CanActivate, CanLoad {
return this.check(state.url);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
return this.check('/' + route.path);
}
}

View File

@ -7,11 +7,11 @@ import {
Route,
CanLoad
} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {LoginErrorCodes} from './utils/guardHelper.class';
@Injectable()
export class FreeGuard implements CanActivate, CanLoad {
export class FreeGuard implements CanActivate {
constructor(private router: Router) {
}
@ -28,7 +28,4 @@ export class FreeGuard implements CanActivate, CanLoad {
return this.check(state.url);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
return this.check('/' + route.path);
}
}

View File

@ -1,11 +1,19 @@
import {Injectable} from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Route, CanLoad} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {
Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
Route,
CanLoad,
UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class';
@Injectable()
export class LoginGuard implements CanActivate, CanLoad {
export class LoginGuard implements CanActivate {
constructor(private router: Router) {
}
@ -16,7 +24,12 @@ export class LoginGuard implements CanActivate, CanLoad {
loggedIn = true;
}
if (!loggedIn) {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, path}});
this.router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_LOGIN,
'redirectUrl': path
}
});
}
return loggedIn;
}
@ -24,8 +37,4 @@ export class LoginGuard implements CanActivate, CanLoad {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(state.url);
}
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
return this.check('/' + route.path);
}
}

View File

@ -1,5 +1,5 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';

View File

@ -1,5 +1,5 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchDatasetsService} from '../../services/searchDatasets.service';

View File

@ -1,5 +1,5 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';

View File

@ -1,5 +1,5 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchOrpsService} from '../../services/searchOrps.service';

View File

@ -1,5 +1,5 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchProjectsService} from '../../services/searchProjects.service';

View File

@ -1,5 +1,5 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchPublicationsService} from '../../services/searchPublications.service';

View File

@ -1,5 +1,5 @@
import {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchSoftwareService} from '../../services/searchSoftware.service';

View File

@ -6,7 +6,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class';
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
@ -155,9 +155,9 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
this.config.getCommunityInformation(this.properties.adminToolsAPIURL, (this.connectCommunityId)?this.connectCommunityId:this.properties.adminToolsCommunity ).subscribe(data => {
var showEntity = {};
for(var i=0; i< data.entities.length; i++){
for(var i=0; i< data['entities'].length; i++){
showEntity[""+data.entities[i]["pid"]+""] = data.entities[i]["isEnabled"];
showEntity[""+data['entities'][i]["pid"]+""] = data['entities'][i]["isEnabled"];
}
this.showPublications = showEntity["publication"];
this.showDatasets = showEntity["dataset"];

View File

@ -1,10 +1,8 @@
import {Component, Input, Output, EventEmitter, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {AdvancedField, OPERATOR} from '../searchUtils/searchHelperClasses.class';
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
import {AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchFields} from '../../utils/properties/searchFields';
import {Dates} from '../../utils/string-utils.class';
import {EnvProperties} from '../../utils/properties/env-properties';

View File

@ -4,7 +4,7 @@ import {Location} from '@angular/common';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {Filter, Value, AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchResult} from '../../utils/entities/searchResult';

View File

@ -1,33 +1,68 @@
import {Component, Input, Output, EventEmitter} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Filter, Value, DateValue} from './searchHelperClasses.class';
import {IMyOptions, IMyDateModel} from '../../utils/my-date-picker/interfaces/index';
// import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface';
import {Dates} from '../../utils/string-utils.class';
import {FormControl} from "@angular/forms";
import {MatDatepickerInputEvent} from "@angular/material";
@Component({
selector: 'date-filter',
template: `
<select *ngIf="dateValue.type!='range' " name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type >
<select *ngIf="dateValue && dateValue.type!='range' " name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type >
<option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option>
</select>
<div *ngIf="dateValue.type=='range' " class="-row dateFilter" >
<div *ngIf="dateValue && dateValue.type=='range' ">
<table class=" uk-table uk-table-responsive" >
<tr><td>
<tr>
<td class="uk-padding-remove-top">
<select name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type >
<option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option>
</select></td>
</select>
</td>
<td>
From</td><td style="width: 112px;"><my-date-picker name="from" [options]="myDatePickerOptions"
[(ngModel)]="from" (dateChanged)="onFromDateChanged($event)" ></my-date-picker>
</td> <td>
To </td><td style="width: 112px;"> <my-date-picker name="to" [options]="myDatePickerOptions"
[(ngModel)]="to" (dateChanged)="onToDateChanged($event)" ></my-date-picker></td></tr>
From
</td>
<td class="uk-padding-remove-top" style="width: 112px;">
<mat-form-field style="max-width: 112px;">
<input matInput [matDatepicker]="pickerFrom" placeholder="Choose a date"
[formControl]="fromDate" (click)="pickerFrom.open()" (dateChange)="fromDateChanged($event)">
<mat-datepicker-toggle matSuffix [for]="pickerFrom"></mat-datepicker-toggle>
<mat-datepicker #pickerFrom></mat-datepicker>
</mat-form-field>
</td>
<td>
To
</td>
<td class="uk-padding-remove-top" style="width: 112px;">
<mat-form-field style="max-width: 112px;">
<input matInput [matDatepicker]="pickerTo" placeholder="Choose a date"
[formControl]="toDate" (click)="pickerTo.open()" (dateChange)="toDateChanged($event)">
<mat-datepicker-toggle matSuffix [for]="pickerTo"></mat-datepicker-toggle>
<mat-datepicker #pickerTo></mat-datepicker>
</mat-form-field>
</td>
</tr>
</table>
</div>
<!-- <div *ngIf="dateValue.type=='range' " class="-row dateFilter" >-->
<!-- <table class=" uk-table uk-table-responsive" >-->
<!-- <tr><td>-->
<!-- <select name="{{'select_date_type'+filterId}}" [(ngModel)]=dateValue.type >-->
<!-- <option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option>-->
<!-- </select></td>-->
<!-- <td>-->
<!-- From</td><td style="width: 112px;"><my-date-picker name="from" [options]="myDatePickerOptions"-->
<!-- [(ngModel)]="from" (dateChanged)="onFromDateChanged($event)" ></my-date-picker>-->
<!-- </td> <td>-->
<!-- To </td><td style="width: 112px;"> <my-date-picker name="to" [options]="myDatePickerOptions"-->
<!-- [(ngModel)]="to" (dateChanged)="onToDateChanged($event)" ></my-date-picker></td></tr>-->
<!-- </table>-->
<!-- </div>-->
`
})
@ -52,19 +87,30 @@ export class DateFilterComponent {
// Initialized to specific date (09.10.2018).
public from;//: Object = { date: { year: 2018, month: 10, day: 9 } };
public to;//: Object = { date: { year: 2018, month: 10, day: 9 } };
public fromDate;
public toDate;
constructor() {
//this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to);
}
ngOnInit() {
this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to);
}
updateDefaultRangeDates(df:Date,dt:Date){
this.from = { date: { year: df.getFullYear(), month: (df.getMonth()+1), day: df.getDate() } };
this.to = { date: { year: dt.getFullYear(), month: (dt.getMonth()+1), day: dt.getDate() } };
df.setMonth(df.getMonth()-1);
this.fromDate = new FormControl(df);
this.toDate = new FormControl(dt);
//this.from = { date: { year: df.getFullYear(), month: (df.getMonth()+1), day: df.getDate() } };
//this.to = { date: { year: dt.getFullYear(), month: (dt.getMonth()+1), day: dt.getDate() } };
}
typeChanged(type:string){
this.dateValue.setDatesByType(type);
this.updateDefaultRangeDates(this.dateValue.from, this.dateValue.to);
}
/*
onFromDateChanged(event: IMyDateModel) {
this.dateValue.from = Dates.getDateFromString(event.formatted);
this.validDateFrom = true;
@ -72,4 +118,16 @@ onFromDateChanged(event: IMyDateModel) {
onToDateChanged(event: IMyDateModel) {
this.dateValue.to = Dates.getDateFromString(event.formatted);
this.validDateTo = true;
}}
}
*/
fromDateChanged(event: MatDatepickerInputEvent<Date>) {
this.dateValue.from = event.value;
//console.info("FROM: "+Dates.getDateToString(this.dateValue.from));
}
toDateChanged(event: MatDatepickerInputEvent<Date>) {
this.dateValue.to = event.value;
//console.info("TO: "+Dates.getDateToString(this.dateValue.to));
}
}

View File

@ -1,11 +1,16 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MyDatePickerModule } from '../../utils/my-date-picker/my-date-picker.module';
import {DateFilterComponent} from './dateFilter.component';
import {MatNativeDateModule} from '@angular/material';
import {MatDatepickerModule} from '@angular/material/datepicker';
import {MatFormFieldModule} from '@angular/material';
import {MatInputModule} from '@angular/material';
@NgModule({
imports: [
CommonModule, FormsModule, MyDatePickerModule
CommonModule, FormsModule, ReactiveFormsModule, MyDatePickerModule,
MatNativeDateModule, MatDatepickerModule, MatFormFieldModule, MatInputModule
],
declarations: [
DateFilterComponent

View File

@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { ActivatedRoute} from '@angular/router';
import {AlertModal} from '../../utils/modal/alert';
import {ReportsService} from '../../services/reports.service';
@ -8,7 +8,7 @@ import {PiwikService} from '../../utils/piwik/piwik.service';
import{EnvProperties} from '../../utils/properties/env-properties';
import {ErrorCodes} from '../../utils/properties/errorCodes';
import 'rxjs/Rx' ;
import 'rxjs' ;
@Component({
selector: 'search-download',

View File

@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import { Filter, Value} from './searchHelperClasses.class';
import {Open} from '../../utils/modal/open.component';

View File

@ -6,8 +6,7 @@ import {Location} from '@angular/common';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {Observable, Subject} from 'rxjs';
import {DataTableDirective } from 'angular-datatables';

View File

@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {ErrorCodes} from '../../utils/properties/errorCodes';
@Component({

View File

@ -1,8 +1,7 @@
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {CustomOptions} from './servicesUtils/customOptions.class';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {COOKIE} from '../login/utils/helper.class';
import {HttpClient} from '@angular/common/http';
@Injectable()
export class CuratorPhotoService {
@ -12,20 +11,11 @@ export class CuratorPhotoService {
uploadPhoto(url: string, photo: File): Observable<any> {
const formData = new FormData();
formData.append('photo', photo);
return this.http.post(url, formData, this.getAuthOptions());
return this.http.post(url, formData, CustomOptions.getAuthOptions());
}
deletePhoto(url: string) {
return this.http.delete(url, this.getAuthOptions());
return this.http.delete(url, CustomOptions.getAuthOptions());
}
// TODO remove and use CustomOptions.getAuthOptions(false)
private getAuthOptions(): any {
const httpOptions = {
headers: new HttpHeaders({
'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id),
})
};
return httpOptions;
}
}

View File

@ -1,11 +1,13 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
import {CustomOptions} from './servicesUtils/customOptions.class';
import {catchError} from "rxjs/operators";
@Injectable()
export class LayoutService {
constructor(private http: Http) {
constructor(private http: HttpClient) {
}
static removeNulls(obj) {
@ -22,26 +24,26 @@ export class LayoutService {
saveLayout(pid: string, url: string, layout: any) {
LayoutService.removeNulls(layout);
return this.http.post(url + 'community/' + pid + '/updateLayout', JSON.stringify(layout), CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
.catch(this.handleError);
//.map(res => res.json())
.pipe(catchError(this.handleError));
}
getLayout(pid: string, url: string) {
return this.http.get(url + 'community/' + pid + '/layout')
.map(res => res.json())
.catch(this.handleError);
//.map(res => res.json())
.pipe(catchError(this.handleError));
}
loadDefaultLayout(pid: string, url: string) {
return this.http.post(url + 'community/' + pid + '/resetLayout', null, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
.catch(this.handleError);
//.map(res => res.json())
.pipe(catchError(this.handleError));
}
private handleError(error: Response) {
private handleError(error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
return Observable.throw(error.json().error || 'Server error');
return throwError(error.error || 'Server error');
}
}

View File

@ -1,24 +1,26 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
import {Metrics} from '../utils/entities/metrics';
import 'rxjs/add/operator/do';
import{EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class MetricsService {
metrics: Metrics;
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
getMetrics (id: string, entityType: string, properties:EnvProperties):any {
let url = properties.metricsAPIURL+entityType+"/"+id+"/clicks";
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"],
res["total_openaire_views"], res["total_openaire_downloads"], res["pageviews"], properties));
//.map(res => <any> res.json())
.pipe(map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"],
res["total_openaire_views"], res["total_openaire_downloads"], res["pageviews"], properties)));
}

View File

@ -1,16 +1,18 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
import {OrganizationInfo} from '../utils/entities/organizationInfo';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import{EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class OrganizationService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
organizationInfo: OrganizationInfo;
@ -18,11 +20,11 @@ export class OrganizationService {
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+')';
return this.http.get((properties.useCache)? (properties.cacheUrl +encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['results'][0])
//.map(res => <any> res.json())
.pipe(map(res => res['results'][0]))
//.map(res => res[0]['result']['metadata']['oaf:entity']['oaf:organization'])
//.map(res => [res, res['rels']['rel']])
.map(res => this.parseOrganizationInfo(res));
.pipe(map(res => this.parseOrganizationInfo(res)));
}
@ -31,16 +33,16 @@ export class OrganizationService {
let url = properties.searchAPIURLLAst+"organizations/"+id+"?format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['result']['metadata']['oaf:entity']['oaf:organization'])
.map(res => this.parseOrganizationNameAndUrl(res));
//.map(res => <any> res.json())
.pipe(map(res => res['result']['metadata']['oaf:entity']['oaf:organization']))
.pipe(map(res => this.parseOrganizationNameAndUrl(res)));
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
parseOrganizationInfo (data: any):any {

View File

@ -1,16 +1,18 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
import {AutoCompleteValue} from '../searchPages/searchUtils/searchHelperClasses.class';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import{EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class RefineFieldResultsService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
getRefineFieldsResultsByEntityName(fields:string[], entityName:string, properties:EnvProperties, communityQuery=null):any{
let url = properties.searchAPIURLLAst + this.getSearchAPIURLForEntity(entityName)+"?format=json&refine=true&page=1&size=0";
for(var i=0; i < fields.length; i++){
@ -21,9 +23,9 @@ export class RefineFieldResultsService {
}
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
.map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]);
.pipe(map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)]));
}
getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{
@ -36,9 +38,9 @@ export class RefineFieldResultsService {
let url = link+"&refine=true&page=1&size=0";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res['refineResults'])
.map(res => this.parse(res,fieldName));
//.map(res => <any> res.json())
.pipe(map(res => res['refineResults']))
.pipe(map(res => this.parse(res,fieldName)));
}
parse(data: any,fieldName:string):any {
@ -78,10 +80,10 @@ export class RefineFieldResultsService {
}
return suffix;
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
}

View File

@ -1,35 +1,37 @@
import {Injectable} from '@angular/core';
import {Http, Response, Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
import {map, tap} from "rxjs/operators";
@Injectable()
export class ReportsService {
// 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";
constructor(private http: Http) {}
constructor(private http: HttpClient) {}
//text/html
//On the service:
downloadCSVFile(url: string){
var headers = new Headers();
headers.append('responseType', 'arraybuffer');
//var headers = new Headers();
//headers.append('responseType', 'arraybuffer');
return this.http.get(url)
.map(res => new Blob([res['_body']], { type: 'text/csv' }));
.pipe(map(res => new Blob([res['_body']], { type: 'text/csv' })));
}
getCSVResponse(url: string){
var headers = new Headers();
headers.append('responseType', 'arraybuffer');
//var headers = new Headers();
//headers.append('responseType', 'arraybuffer');
return this.http.get(url)
.map(res => res['_body']);
.pipe(map(res => res['_body']));
}
downloadHTMLFile(url: string, info: string){
var headers = new Headers();
headers.append('responseType', 'arraybuffer');
//var headers = new Headers();
//headers.append('responseType', 'arraybuffer');
return this.http.get(url)
.map(res => this.addInfo(res, info))
.map(res => new Blob([res['_body']], { type: 'text/html' }))
.do(res => console.log(res))
.pipe(map(res => this.addInfo(res, info)))
.pipe(map(res => new Blob([res['_body']], { type: 'text/html' })))
.pipe(tap(res => console.log(res)))
}
addInfo(res:any, info:string) {
@ -43,11 +45,11 @@ export class ReportsService {
return res;
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}

View File

@ -1,17 +1,19 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {StringUtils} from '../utils/string-utils.class';
import{EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class SearchDataprovidersService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
@ -28,9 +30,9 @@ export class SearchDataprovidersService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
}
//((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties ):any {
@ -47,9 +49,9 @@ export class SearchDataprovidersService {
url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'])])
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]))
}
searchCompatibleDataprovidersTable ( properties:EnvProperties):any {
@ -60,9 +62,9 @@ export class SearchDataprovidersService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
.map(res => res['meta'].total);
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json())
.pipe(map(res => res['meta'].total));
}
searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
@ -77,9 +79,9 @@ export class SearchDataprovidersService {
url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
}
searchEntityRegistriesTable (properties:EnvProperties):any {
@ -90,8 +92,9 @@ export class SearchDataprovidersService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
.map(res => res['meta'].total);
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json())
.pipe(map(res => res['meta'].total));
}
searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
@ -106,9 +109,9 @@ export class SearchDataprovidersService {
url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
}
searchJournalsTable ( properties:EnvProperties):any {
@ -117,8 +120,8 @@ export class SearchDataprovidersService {
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
url += "&page=0&size=0&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
.map(res => res['meta'].total);
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)//.map(res => <any> res.json())
.pipe(map(res => res['meta'].total));
}
searchJournals (params: string,refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties):any {
@ -135,9 +138,9 @@ export class SearchDataprovidersService {
url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
}
searchDataprovidersForDeposit (id: string,type:string, page: number, size: number, properties:EnvProperties):any {
@ -155,8 +158,8 @@ export class SearchDataprovidersService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
}
searchDataProvidersBySubjects(keyword:string, type:string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchResourcesAPIURL;
@ -173,8 +176,8 @@ export class SearchDataprovidersService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
}
@ -191,16 +194,16 @@ export class SearchDataprovidersService {
url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
}
searchDataprovidersForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
let url = link+params+"/datasources?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
}
/*
searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any {
@ -411,8 +414,8 @@ export class SearchDataprovidersService {
//let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res.total);
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
}
numOfEntityDataproviders(id: string, entity: string, properties:EnvProperties):any {
@ -454,8 +457,8 @@ getDataprovidersTableResults (queryType:string, properties:EnvProperties):any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
.map(res => res['meta'].total);
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json())
.pipe(map(res => res['meta'].total));
}
}

View File

@ -1,21 +1,20 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient} from "@angular/common/http";
import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {DOI, StringUtils} from '../utils/string-utils.class';
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
import {EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class SearchDatasetsService {
private sizeOfDescription: number = 270;
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchDatasets (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any {
@ -35,16 +34,17 @@ export class SearchDatasetsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]));
}
searchDatasetById (id: string , properties:EnvProperties):any {
let url = properties.searchAPIURLLAst+"datasets/"+id+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseResults(res, properties));
//.map(res => <any> res.json())
.pipe(map(res => this.parseResults(res, properties)));
}
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
@ -63,8 +63,8 @@ export class SearchDatasetsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseRefineResults(id, res['refineResults']))
//.map(res => <any> res.json())
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
}
searchDatasetsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
@ -86,10 +86,10 @@ export class SearchDatasetsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]));
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "dataset")]);
}
advancedSearchDatasets (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
@ -110,25 +110,27 @@ export class SearchDatasetsService {
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
searchDatasetsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
let url = link+params+"/datasets"+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
searchDatasetsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
parseResults(data: any, properties: EnvProperties): SearchResult[] {
@ -347,8 +349,8 @@ export class SearchDatasetsService {
numOfDatasets(url: string, properties:EnvProperties):any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res.total);
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
}
numOfEntityDatasets(id: string, entity: string, properties:EnvProperties):any {

View File

@ -1,18 +1,20 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import{EnvProperties} from '../utils/properties/env-properties';
import {StringUtils} from '../utils/string-utils.class';
import {map} from "rxjs/operators";
@Injectable()
export class SearchOrganizationsService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
parseResultsForDeposit(data: any): {"name": string, "id": string}[] {
let results: {"name": string, "id": string}[] = [];
@ -51,8 +53,8 @@ export class SearchOrganizationsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]));
}
advancedSearchOrganizations (params: string, page: number, size: number, properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
@ -72,9 +74,9 @@ export class SearchOrganizationsService {
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
}
parseResults(data: any): SearchResult[] {
let results: SearchResult[] = [];
@ -165,8 +167,8 @@ export class SearchOrganizationsService {
numOfOrganizations(url: string, properties:EnvProperties ): any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res.total);
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
}
numOfEntityOrganizations(id: string, entity: string, properties:EnvProperties ):any {

View File

@ -1,21 +1,18 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient} from "@angular/common/http";
import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {DOI, StringUtils} from '../utils/string-utils.class';
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
import {EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
export class SearchOrpsService {
private sizeOfDescription: number = 270;
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchOrps (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any {
@ -35,17 +32,17 @@ export class SearchOrpsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]));
}
searchOrpById (id: string , properties:EnvProperties):any {
let url = properties.searchAPIURLLAst+"other/"+id+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseResults(res, properties));
//.map(res => <any> res.json())
.pipe(map(res => this.parseResults(res, properties)));
}
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
@ -64,8 +61,8 @@ export class SearchOrpsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseRefineResults(id, res['refineResults']))
//.map(res => <any> res.json())
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
}
searchOrpsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
@ -88,10 +85,9 @@ export class SearchOrpsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]));
}
advancedSearchOrps (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
@ -113,9 +109,9 @@ export class SearchOrpsService {
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
searchOrpsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
@ -123,8 +119,8 @@ export class SearchOrpsService {
let url = link+params+"/other"+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
searchOrpsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
@ -132,8 +128,8 @@ export class SearchOrpsService {
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
parseResults(data: any, properties: EnvProperties): SearchResult[] {
@ -351,8 +347,8 @@ export class SearchOrpsService {
numOfOrps(url: string, properties:EnvProperties):any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res.total);
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
}
numOfEntityOrps(id: string, entity: string, properties:EnvProperties):any {

View File

@ -1,18 +1,20 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import{EnvProperties} from '../utils/properties/env-properties';
import {StringUtils} from '../utils/string-utils.class';
import {map} from "rxjs/operators";
@Injectable()
export class SearchProjectsService {
private sizeOfDescription: number = 270;
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchProjects (params: string, refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any {
@ -29,8 +31,8 @@ export class SearchProjectsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]));
}
getProjectsforDataProvider (datasourceId: string, page: number, size: number, properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
@ -46,8 +48,8 @@ export class SearchProjectsService {
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
}
advancedSearchProjects (params: string, page: number, size: number, properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
@ -62,8 +64,8 @@ export class SearchProjectsService {
url += "&page="+(page-1)+"&size="+size;
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'])]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
}
getProjectsForOrganizations (organizationId: string, filterquery: string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
@ -84,15 +86,15 @@ export class SearchProjectsService {
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "project")]));
}
getFunders(properties:EnvProperties ):any {
let url = properties.searchAPIURLLAst+"projects?refine=true&fields=funder&size=0"+ "&format=json";;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, res['refineResults']['funder']]);
//.map(res => <any> res.json())
.pipe(map(res => [res['meta'].total, res['refineResults']['funder']]));
}
@ -103,7 +105,8 @@ export class SearchProjectsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).toPromise()
.then(request =>{
return (request.json().response.results)?request.json().response.results.result:request.json().response.result;
//return (request.json().response.results)?request.json().response.results.result:request.json().response.result;
return (request['response'].results)?request['response'].results.result:request['response'].result;
}) ;
}
@ -219,8 +222,8 @@ export class SearchProjectsService {
numOfProjects(url: string, properties:EnvProperties ):any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res.total);
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
}
numOfEntityProjects(id: string, entity: string, properties:EnvProperties ):any {

View File

@ -1,15 +1,11 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {HttpClient} from "@angular/common/http";
import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import {DOI, StringUtils} from '../utils/string-utils.class';
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
import {EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable()
@ -17,7 +13,7 @@ export class SearchPublicationsService {
private sizeOfDescription: number = 270;
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchPublications (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[] , properties:EnvProperties):any {
let link = properties.searchAPIURLLAst+"publications";
@ -36,17 +32,14 @@ export class SearchPublicationsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
// .do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
}
searchPublicationById (id: string, properties:EnvProperties ):any {
let url = properties.searchAPIURLLAst+"publications/"+id+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseResults(res, properties));
.pipe(map(res => this.parseResults(res, properties)));
}
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
@ -65,8 +58,8 @@ export class SearchPublicationsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseRefineResults(id, res['refineResults']));
//.map(res => <any> res.json())
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])));
}
searchPublicationsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
@ -89,9 +82,9 @@ export class SearchPublicationsService {
url += "&page="+(page-1)+"&size="+size;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
}
advancedSearchPublications (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
@ -113,10 +106,9 @@ export class SearchPublicationsService {
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
searchPublicationsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
@ -126,16 +118,14 @@ export class SearchPublicationsService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
searchPublicationsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
/*
searchPublicationsCSV (params: string, refineParams:string, page: number, size: number):any {
@ -463,8 +453,8 @@ export class SearchPublicationsService {
numOfPublications(url: string, properties:EnvProperties): any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res.total);
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
}
numOfEntityPublications(id: string, entity: string, properties:EnvProperties):any {

View File

@ -1,20 +1,22 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
import {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class';
import{EnvProperties} from '../utils/properties/env-properties';
import {DOI, StringUtils} from '../utils/string-utils.class';
import {map} from "rxjs/operators";
@Injectable()
export class SearchSoftwareService {
private sizeOfDescription: number = 270;
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchSoftware (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any {
@ -34,9 +36,9 @@ export class SearchSoftwareService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]));
}
searchSoftwareById (id: string, properties:EnvProperties ):any {
@ -44,8 +46,7 @@ export class SearchSoftwareService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseResults(res, properties));
.pipe(map(res => this.parseResults(res, properties)));
}
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
@ -63,8 +64,8 @@ export class SearchSoftwareService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => this.parseRefineResults(id, res['refineResults']))
//.map(res => <any> res.json())
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])));
}
searchSoftwareByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
@ -86,9 +87,8 @@ export class SearchSoftwareService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "software")]));
}
advancedSearchSoftware (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL;
@ -109,17 +109,16 @@ export class SearchSoftwareService {
url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
searchSoftwareForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst;
let url = link+params+"/software"+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
searchSoftwareForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
@ -127,8 +126,7 @@ export class SearchSoftwareService {
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
}
parseResults(data: any, properties: EnvProperties): SearchResult[] {
@ -360,8 +358,8 @@ export class SearchSoftwareService {
numOfSoftware(url: string, properties:EnvProperties):any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
.map(res => res.total);
//.map(res => <any> res.json())
.pipe(map(res => res['total']));
}
numOfEntitySoftware(id: string, entity: string, properties:EnvProperties):any {

View File

@ -1,9 +1,10 @@
import { RequestOptions, Headers} from '@angular/http';
import {COOKIE} from '../../login/utils/helper.class';
import {HttpHeaders} from "@angular/common/http";
export class CustomOptions {
/*
public static getAuthOptionsWithBody(): RequestOptions {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
@ -11,12 +12,33 @@ export class CustomOptions {
const options = new RequestOptions({ headers: headers, withCredentials: true });
return options;
}
*/
public static getAuthOptionsWithBody():{} {
return {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id)
}), withCredentials: true
};
}
/*
public static getAuthOptions(): RequestOptions {
const headers = new Headers();
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
const options = new RequestOptions({ headers: headers, withCredentials: true });
return options;
}
*/
public static getAuthOptions():any {
const httpOptions = {
headers: new HttpHeaders({
'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id),
}), withCredentials: true
};
return httpOptions;
}
}

View File

@ -1,6 +1,6 @@
import { Component, Input } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import 'rxjs/Rx';
import 'rxjs';
import{MenuItem} from './menu';
import { ConfigurationService } from '../utils/configuration/configuration.service';
@ -34,8 +34,8 @@ constructor(private config: ConfigurationService, private route: ActivatedRoute
if(this.showMenuItems){
if( this.APIUrl && this.communityId ){
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
for(var i=0; i< data.pages.length; i++){
this.showPage[data.pages[i]["route"]] = data.pages[i]["isEnabled"];
for(var i=0; i< data['pages'].length; i++){
this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"];
}
// console.log(this.showPage)

View File

@ -14,14 +14,14 @@ import {
Input,
Output,
EventEmitter,
animate,
} from '@angular/core';
import { animate,
state,
trigger,
style,
transition,
AnimationTransitionEvent,
} from '@angular/core';
AnimationEvent
} from '@angular/animations';
import {
DomSanitizer,
SafeHtml,
@ -129,7 +129,7 @@ export class CookieLawComponent implements OnInit {
}
}
afterDismissAnimation(evt: AnimationTransitionEvent) {
afterDismissAnimation(evt: AnimationEvent) {
if (evt.toState === 'topOut' ||
evt.toState === 'bottomOut') {
this.isSeen = true;

View File

@ -1,7 +1,7 @@
import { Component, Input } from '@angular/core';
// import 'rxjs/Rx';
import {ActivatedRoute, Router} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Observable} from 'rxjs';
import {Session} from '../login/utils/helper.class';
import { ConfigurationService } from '../utils/configuration/configuration.service';
@ -63,12 +63,12 @@ export class NavigationBarComponent {
if( this.APIUrl && this.communityId ){
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
for(var i=0; i< data.entities.length; i++){
for(var i=0; i< data['entities'].length; i++){
this.showEntity[""+data.entities[i]["pid"]+""] = data.entities[i]["isEnabled"];
this.showEntity[""+data['entities'][i]["pid"]+""] = data['entities'][i]["isEnabled"];
}
for(var i=0; i< data.pages.length; i++){
this.showPage[data.pages[i]["route"]] = data.pages[i]["isEnabled"];
for(var i=0; i< data['pages'].length; i++){
this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"];
}

View File

@ -1,6 +1,5 @@
import {Component, ElementRef} from '@angular/core';
import { Subject } from 'rxjs/Subject';
import {Observable} from 'rxjs/Observable';
import { Subject , Observable} from 'rxjs';
import {SearchFields, FieldDetails} from '../utils/properties/searchFields';

View File

@ -1,20 +1,21 @@
import {Injectable} from '@angular/core';
import {Http, Response, Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/mapTo';
import 'rxjs/add/observable/of';
import {HttpClient} from "@angular/common/http";
import {Observable} from 'rxjs';
// import 'rxjs/add/operator/do';
// import 'rxjs/add/operator/share';
import { mapTo } from 'rxjs/operators';
import {map, mapTo} from 'rxjs/operators';
@Injectable()
export class ConfigurationService {
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
getCommunityInformation(APIUrl:string, community:string){
return this.http.get(APIUrl + "/communityFull/" + community)
.map(res => res.json());
return this.http.get(APIUrl + "/communityFull/" + community);
//.map(res => res.json());
}
isEntityEnabled(APIUrl:string, community:string,entity: string){
@ -26,32 +27,33 @@ export class ConfigurationService {
// }
// return Observable.of(new Object()).mapTo(true);
return this.http.get(APIUrl + "/page")
.map(res => true);
.pipe(map(res => true));
}
isPageEnabled(APIUrl:string, community:string,router: string){
return this.http.get(APIUrl + "/community/" + community+"/pages?page_route="+router)
.map(res => res.json()).map(res => {
//.map(res => res.json())
.pipe(map(res => {
let result = false;
if(res.length >0 && res[0].route == router){
if(res['length'] >0 && res[0].route == router){
result = res[0].isEnabled;
}
return result;
});//.do(res => {console.log("Route "+router +" is "+res)});
}));//.do(res => {console.log("Route "+router +" is "+res)});
}
getMainPageContent(APIUrl:string, community:string,){
return this.http.get(APIUrl + "/page")
.map(res => true);
.pipe(map(res => true));
}
getSpecialAnouncementContent(APIUrl:string, community:string,){
return this.http.get(APIUrl + "/page")
.map(res => "");
.pipe(map(res => ""));
}
getHelpPageContent(APIUrl:string, community:string, router:string){
return this.http.get(APIUrl + "/page")
.map(res => true);
.pipe(map(res => true));
}
// private handleError (error: Response) {
// // in a real world app, we may send the error to some remote logging infrastructure

View File

@ -1,5 +1,6 @@
import {Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import {Email} from './email';
import {CustomOptions} from '../../services/servicesUtils/customOptions.class';
import {EmailRecaptcha} from "../entities/EmailRecaptcha";
@ -7,22 +8,22 @@ import {EmailRecaptcha} from "../entities/EmailRecaptcha";
@Injectable()
export class EmailService {
constructor(private http:Http) {
constructor(private http:HttpClient) {
}
sendEmail(url: string, email: Email) {
let body = JSON.stringify(email);
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(request => request.json());
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody());
//.map(request => request.json());
}
contact(url: string, email: Email, recaptcha: string) {
const data: EmailRecaptcha = new EmailRecaptcha();
data.email = email;
data.recaptcha = recaptcha;
return this.http.post(url, data)
.map(request => request.json());
return this.http.post(url, data);
//.map(request => request.json());
}
}

View File

@ -1,11 +1,12 @@
import {switchMap, distinctUntilChanged, debounceTime} from 'rxjs/operators';
import {Component, ElementRef, Input, Output, EventEmitter, OnChanges, SimpleChange} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {Observable, Subject} from 'rxjs';
import {Value} from '../../searchPages/searchUtils/searchHelperClasses.class';
import {EntitiesSearchService} from './entitySearch.service';
import{EnvProperties} from '../properties/env-properties';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
//Usage example
//<static-autocomplete [(filtered)] =filtered [(selected)] =selected placeHolderMessage = "Search for countries" title = "Countries:" (keywordChange)="keywordChanged($event)"></static-autocomplete>
@ -100,36 +101,36 @@ export class EntitiesAutocompleteComponent {
this.showInput = true;
if(this.entityType == "project" && this.funderId ){
this.filtered = this.searchTermStream
.debounceTime(300).distinctUntilChanged()
.switchMap((term: string) => {
this.filtered = this.searchTermStream.pipe(
debounceTime(300),distinctUntilChanged(),
switchMap((term: string) => {
//console.log("funder"+this.funderId);
var results = this._search.searchProjectsByFunder(term, (this.funderId == "0"?"":encodeURIComponent(this.funderId)), this.properties);
this.showLoading = false;
this.results = results.length;
return results;
});
}),);
}else if(this.entityType == "organization" && this.depositType ){
this.filtered = this.searchTermStream
.debounceTime(300).distinctUntilChanged()
.switchMap((term: string) => {
this.filtered = this.searchTermStream.pipe(
debounceTime(300),distinctUntilChanged(),
switchMap((term: string) => {
var results = this._search.searchByDepositType(term, this.depositType, this.properties);
this.showLoading = false;
this.results = results.length;
return results;
});
}),);
}else{
this.filtered = this.searchTermStream
.debounceTime(300)
.distinctUntilChanged()
.switchMap((term: string) => {
this.filtered = this.searchTermStream.pipe(
debounceTime(300),
distinctUntilChanged(),
switchMap((term: string) => {
var results = this._search.searchByType(term, this.entityType, this.properties);
this.showLoading = false;
this.results = results.length;
return results;
});
}),);
this.getSelectedNameFromGivenId();
}

View File

@ -1,17 +1,19 @@
import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {Observable, throwError} from 'rxjs';
import {AutoCompleteValue} from '../../searchPages/searchUtils/searchHelperClasses.class';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import{EnvProperties} from '../properties/env-properties';
import {StringUtils} from '../string-utils.class';
import {catchError, map} from "rxjs/operators";
@Injectable()
export class EntitiesSearchService {
public ready:boolean = false;
constructor(private http: Http ) {}
constructor(private http: HttpClient ) {}
searchProjectsByFunder(keyword:string, funderId:string, properties:EnvProperties ):any {
this.ready = false;
@ -30,7 +32,8 @@ export class EntitiesSearchService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).toPromise()
.then(request =>
{
request = request.json().results;
//request = request.json().results;
request = request['results'];
this.ready = true;
return this.parse(request,"oaf:project","project");
}).catch((ex) => {
@ -71,7 +74,8 @@ export class EntitiesSearchService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).toPromise()
.then(request =>
{
request = request.json().results;
//request = request.json().results;
request = request['results'];
//console.log(request);
this.ready = true;
return this.parse(request,"oaf:organization","organization");
@ -124,15 +128,16 @@ private fetch (link,id,oafEntityType,type, properties:EnvProperties ){
this.ready = false;
let url = link+"/"+id+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(request => <any> request.json())
//.map(request => <any> request.json())
// .do(res => console.info(res))
.map(request => {
.pipe(map(request => {
this.ready = true;
return this.parse(request,oafEntityType,type);
}).catch((ex) => {
}))
.pipe(catchError((ex) => {
console.error('An error occured', ex);
return [{id:'-2',label:'Error'}];;
});
}));
}
private search (link,keyword,oafEntityType,type, properties:EnvProperties ){
@ -154,7 +159,8 @@ private fetch (link,id,oafEntityType,type, properties:EnvProperties ){
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).toPromise()
.then(request =>
{
request = request.json().results;
//request = request.json().results;
request = request['results'];
this.ready = true;
return this.parse(request,oafEntityType,type);
}).catch((ex) => {
@ -266,10 +272,10 @@ private fetch (link,id,oafEntityType,type, properties:EnvProperties ){
return array;
}
private handleError (error: Response) {
private handleError (error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.log(error);
return Observable.throw(error || 'Server error');
return throwError(error || 'Server error');
}
}

View File

@ -3,7 +3,7 @@ import { ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
import {DOI} from '../../utils/string-utils.class';
import {Subject} from 'rxjs/Subject';
import {Subject} from 'rxjs';
import{EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from '../../utils/string-utils.class';
export class FetchDatasets{

View File

@ -3,7 +3,7 @@ import { ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
import {DOI} from '../../utils/string-utils.class';
import {Subject} from 'rxjs/Subject';
import {Subject} from 'rxjs';
import{EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from '../../utils/string-utils.class';

Some files were not shown because too many files have changed in this diff Show More