[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 { ConfigurationService } from './utils/configuration/configuration.service';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import { EnvProperties } from './utils/properties/env-properties'; import { EnvProperties } from './utils/properties/env-properties';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import{EnvironmentSpecificService} from './utils/properties/environment-specific.service'; 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 { BrowserModule } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { APP_BASE_HREF, CommonModule } from '@angular/common'; 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 { RouterModule } from '@angular/router';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import {NavigationBarModule} from './sharedComponents/navigationBar.module'; import {NavigationBarModule} from './sharedComponents/navigationBar.module';
@ -69,10 +69,10 @@ import { AppRoutingModule } from './app-routing.module';
SharedModule, SharedModule,
NoopAnimationsModule, NoopAnimationsModule,
CommonModule, CommonModule,
CookieLawModule, BottomModule,
HttpModule,
NavigationBarModule,
CookieLawModule, CookieLawModule,
BottomModule,
HttpClientModule,
NavigationBarModule,
MainSearchModule, MainSearchModule,
ErrorModule, ErrorModule,
DepositDatasetsModule,DepositDatasetsResultsModule, DepositBySubjectResultsModule,DepositPublicationsModule , DepositPublicationsResultsModule, DepositDatasetsModule,DepositDatasetsResultsModule, DepositBySubjectResultsModule,DepositPublicationsModule , DepositPublicationsResultsModule,

View File

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

View File

@ -1,9 +1,7 @@
import {Component, Input,Output, ElementRef, EventEmitter, ViewChild} from '@angular/core'; 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 {SearchProjectsService} from '../../services/searchProjects.service';
import {ProjectService} from '../../landingPages/project/project.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'; import {ClaimProject} from './claimEntities.class';
declare var UIkit:any; declare var UIkit:any;
import{EnvProperties} from '../../utils/properties/env-properties'; 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 {Component, ViewChild, Input} from '@angular/core';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {Observable} from 'rxjs/Observable'; import {Observable, Subject} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Subject} from 'rxjs/Subject';
import {ClaimsService} from '../service/claims.service'; import {ClaimsService} from '../service/claims.service';
import {ModalLoading} from '../../../utils/modal/loading.component'; import {ModalLoading} from '../../../utils/modal/loading.component';
import {AlertModal} from '../../../utils/modal/alert'; import {AlertModal} from '../../../utils/modal/alert';
@ -58,8 +59,8 @@ private seoService: SEOService) {
this.setTypes(params['types']); // check the appropriate checkboxes this.setTypes(params['types']); // check the appropriate checkboxes
this.setSortby(params['sort']); this.setSortby(params['sort']);
this.getClaims(); this.getClaims();
this.searchTermStream this.searchTermStream.pipe(
.debounceTime(300).distinctUntilChanged() debounceTime(300),distinctUntilChanged(),)
.subscribe((term: string) => { .subscribe((term: string) => {
this.keyword = this.inputkeyword; this.keyword = this.inputkeyword;
//console.log("keyword: "+this.keyword + " VS inputkeyword: "+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 {Injectable} from '@angular/core';
import {URLSearchParams } from '@angular/http'; import {URLSearchParams } from '@angular/http';
import {Http, Response} 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 {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'; import { CustomOptions } from '../../../services/servicesUtils/customOptions.class';
@Injectable() @Injectable()
export class ClaimsService { export class ClaimsService {
constructor(private http: Http ) { constructor(private http: HttpClient ) {
} }
private getClaimRequest(size : number, page : number, url :string, fromCache:boolean):any { private getClaimRequest(size : number, page : number, url :string, fromCache:boolean):any {
//console.info('ClaimsService: Claims request: '+url); //console.info('ClaimsService: Claims request: '+url);
let key = url; let key = url;
return this.http.get(url, CustomOptions.getAuthOptions()) 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 )) //.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 { 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; 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 url = apiUrl +"claims/"+claimId;
// let headers = new Headers({ 'Content-Type': 'application/json' }); // let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers }); // 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" )) // .do(request => console.info("After delete" ))
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
deleteBulk(claimIds:string[], apiUrl:string):any{ deleteBulk(claimIds:string[], apiUrl:string):any{
@ -71,9 +75,9 @@ export class ClaimsService {
// let headers = new Headers({ 'Content-Type': 'application/json' }); // let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers }); // 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" )) // .do(request => console.info("After delete" ))
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
insertBulkClaims(claims, apiUrl:string):any{ insertBulkClaims(claims, apiUrl:string):any{
@ -84,9 +88,9 @@ export class ClaimsService {
// let headers = new Headers({ 'Content-Type': 'application/json' }); // let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers }); // let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody()) return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json()) //.map(res => res.json())
//.do(request => console.info("Insert Response:"+request.status) ) //.do(request => console.info("Insert Response:"+request.status) )
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
insertClaim(claim, apiUrl:string):any{ insertClaim(claim, apiUrl:string):any{
@ -96,9 +100,9 @@ export class ClaimsService {
// let headers = new Headers({ 'Content-Type': 'application/json' }); // let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers }); // let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody()) return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json()) //.map(res => res.json())
//.do(request => console.info("Insert Response:"+request.status) ) //.do(request => console.info("Insert Response:"+request.status) )
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
insertDirectRecords(records, apiUrl:string):any{ insertDirectRecords(records, apiUrl:string):any{
@ -109,26 +113,26 @@ export class ClaimsService {
// let headers = new Headers({ 'Content-Type': 'application/json' }); // let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers }); // let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody()) return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json()) //.map(res => res.json())
//.do(request => console.info("Insert Response:"+request) ) //.do(request => console.info("Insert Response:"+request) )
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
private handleError (error: Response) { private handleError (error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.log(error); console.log(error);
return Observable.throw(error || 'Server error'); return observableThrowError(error || 'Server error');
} }
getClaim(id:string, apiUrl:string):any { getClaim(id:string, apiUrl:string):any {
let url = apiUrl+"claims/"+id; let url = apiUrl+"claims/"+id;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.http.get(url) this.http.get(url)
.map(res => res.json()) //.map(res => res.json())
.subscribe( .subscribe(
data => { data => {
resolve(data.data); resolve(data['data']);
}, },
err => { err => {
reject(err); reject(err);

View File

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

View File

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

View File

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

View File

@ -2,60 +2,68 @@ import {Injectable} from '@angular/core';
import {URLSearchParams} from '@angular/http'; import {URLSearchParams} from '@angular/http';
import {Http, Response} from '@angular/http'; import {Http, Response} from '@angular/http';
import { Headers, RequestOptions } 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{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 { ClaimResult} from '../claimEntities.class';
import {map} from "rxjs/operators";
@Injectable() @Injectable()
export class SearchOrcidService { export class SearchOrcidService {
constructor( private http: Http ) {} constructor( private http: HttpClient ) {}
searchOrcidAuthor (term: string, authorIds: string[], authors, properties:EnvProperties, addId):any { searchOrcidAuthor (term: string, authorIds: string[], authors, properties:EnvProperties, addId):any {
var headers = new Headers(); //var headers = new Headers();
headers.append('Accept', 'application/orcid+json'); //headers.append('Accept', 'application/orcid+json');
let headers = new HttpHeaders({'Accept': 'application/orcid+json'});
let url = properties.searchOrcidURL + term+'/record'; let url = properties.searchOrcidURL + term+'/record';
let key = url; let key = url;
return this.http.get(url, { headers: headers }) return this.http.get(url, { headers: headers })
.map(res => res.json()['person']) //.map(res => res.json()['person'])
.map(res => [res['name']['given-names'], .pipe(map(res => res['person']))
.pipe(map(res => [res['name']['given-names'],
res['name']['family-name'], res['name']['family-name'],
res['name']]) res['name']]))
.map(res => this.parseOrcidAuthor(res, authorIds, authors, addId)); .pipe(map(res => this.parseOrcidAuthor(res, authorIds, authors, addId)));
} }
searchOrcidAuthors (term: string, authorIds: string[], searchOrcidAuthors (term: string, authorIds: string[],
properties:EnvProperties):any { properties:EnvProperties):any {
var headers = new Headers(); //var headers = new Headers();
headers.append('Accept', 'application/orcid+json'); //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 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; let key = url;
return this.http.get(url, { headers: headers }) return this.http.get(url, { headers: headers })
.map(res => res.json()['result']) //.map(res => res.json()['result'])
.map(res => this.parseOrcidAuthors(res, authorIds)); .pipe(map(res => res['result']))
.pipe(map(res => this.parseOrcidAuthors(res, authorIds)));
} }
searchOrcidPublications (id: string, properties:EnvProperties, parse:boolean = false):any { searchOrcidPublications (id: string, properties:EnvProperties, parse:boolean = false):any {
var headers = new Headers(); //var headers = new Headers();
headers.append('Accept', 'application/orcid+json'); //headers.append('Accept', 'application/orcid+json');
let headers = new HttpHeaders({'Accept': 'application/orcid+json'});
let url =properties.searchOrcidURL+id+'/works'; let url =properties.searchOrcidURL+id+'/works';
let key = url; let key = url;
return this.http.get(url, { headers: headers }) return this.http.get(url, { headers: headers })
.map(res => res.json()['group']) //.map(res => res.json()['group'])
.map(request => (parse?this.parse(id, request):request)); .pipe(map(res => res['group']))
.pipe(map(request => (parse?this.parse(id, request):request)));
//.map(res => res['orcid-work']); //.map(res => res['orcid-work']);
} }

View File

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

View File

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

View File

@ -1,15 +1,16 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http'; import {RequestOptions, Headers} from '@angular/http';
import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http'; import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http";
import {Observable} from 'rxjs/Observable'; import {throwError} from 'rxjs';
import 'rxjs/add/operator/do';
import { CustomOptions } from '../../services/servicesUtils/customOptions.class'; import { CustomOptions } from '../../services/servicesUtils/customOptions.class';
import {catchError} from "rxjs/operators";
@Injectable() @Injectable()
export class ClaimsByTokenService { export class ClaimsByTokenService {
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
getClaims(openaireId: string, apiURL:string):any { getClaims(openaireId: string, apiURL:string):any {
@ -18,9 +19,9 @@ export class ClaimsByTokenService {
let key = url; let key = url;
return this.http.get(url, CustomOptions.getAuthOptions()) return this.http.get(url, CustomOptions.getAuthOptions());
//.map(res => <any> res.text()) //.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 ); let body = JSON.stringify( claimsCurationInfo );
//console.warn('Json body: : '+body); //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()) return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json()) //.map(res => res.json())
//.do(request => console.info("Insert Response:"+request.status) ) //.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 ); let body = JSON.stringify( claimsCurationInfo );
//console.warn('Json body: : '+body); //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()) return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json()) //.map(res => res.json())
.catch(this.handleError); .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 // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.log(error); 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 {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';

View File

@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter,ViewChild} from '@angular/core'; 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 {SearchCrossrefService} from '../../claim-utils/service/searchCrossref.service';
import {SearchDataciteService} from '../../claim-utils/service/searchDatacite.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 {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {Router, ActivatedRoute} from '@angular/router'; import {Router, ActivatedRoute} from '@angular/router';
import {ClaimsService} from '../../claim-utils/service/claims.service'; import {ClaimsService} from '../../claim-utils/service/claims.service';

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,14 @@
import {map, filter, mergeMap} from 'rxjs/operators';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { import {
Router, Router,
CanActivate, CanActivate,
ActivatedRouteSnapshot, ActivatedRouteSnapshot,
RouterStateSnapshot, RouterStateSnapshot,
CanLoad, Route CanLoad, Route, UrlSegment
} from '@angular/router'; } from '@angular/router';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {Session} from '../../login/utils/helper.class'; import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {CommunityService} from '../community/community.service'; import {CommunityService} from '../community/community.service';
@ -25,10 +27,10 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) { if (Session.isPortalAdministrator() || Session.isCommunityCurator()) {
return true; return true;
} else { } 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()); 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'], { .subscribe(() => this.router.navigate(['/user-info'], {
queryParams: { queryParams: {
'errorCode': errorCode, 'errorCode': errorCode,
@ -49,7 +51,7 @@ export class ConnectAdminLoginGuard implements CanActivate, CanLoad {
return this.check(route.queryParams['communityId'], state.url); 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; const path = '/' + route.path + document.location.search;
return this.check(ConnectHelper.getCommunityFromPath(path), path); 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 { Injectable } from '@angular/core';
import { import {
Router, Router,
@ -7,13 +9,13 @@ import {
CanLoad, CanLoad,
Route Route
} from '@angular/router'; } from '@angular/router';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {CommunityService} from '../community/community.service'; import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper'; import {ConnectHelper} from '../connectHelper';
@Injectable() @Injectable()
export class ConnectCommunityGuard implements CanActivate, CanLoad { export class ConnectCommunityGuard implements CanActivate {
constructor(private router: Router, constructor(private router: Router,
private communityService: CommunityService, private communityService: CommunityService,
@ -21,10 +23,10 @@ export class ConnectCommunityGuard implements CanActivate, CanLoad {
} }
check(community: string): Observable<boolean> | boolean { 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); return this.communityService.isCommunityType(properties, properties['communityAPI'] + community);
}); }));
obs.filter(enabled => !enabled) obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate(['errorcommunity'])); .subscribe(() => this.router.navigate(['errorcommunity']));
return obs; return obs;
} }
@ -32,9 +34,4 @@ export class ConnectCommunityGuard implements CanActivate, CanLoad {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.queryParams['communityId']); 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 { Injectable } from '@angular/core';
import { import {
Router, Router,
@ -5,9 +7,9 @@ import {
ActivatedRouteSnapshot, ActivatedRouteSnapshot,
RouterStateSnapshot, RouterStateSnapshot,
CanLoad, CanLoad,
Route Route, UrlSegment
} from '@angular/router'; } from '@angular/router';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {CommunityService} from '../community/community.service'; import {CommunityService} from '../community/community.service';
import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service'; import { EnvironmentSpecificService} from '../../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connectHelper'; import {ConnectHelper} from '../connectHelper';
@ -21,10 +23,10 @@ export class ConnectRIGuard implements CanActivate, CanLoad {
} }
check(community: string): Observable<boolean> | boolean { 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); return this.communityService.isRIType(properties, properties['communityAPI'] + community);
}); }));
obs.filter(enabled => !enabled) obs.pipe(filter(enabled => !enabled))
.subscribe(() => this.router.navigate(['errorcommunity'])); .subscribe(() => this.router.navigate(['errorcommunity']));
return obs; return obs;
} }
@ -33,7 +35,7 @@ export class ConnectRIGuard implements CanActivate, CanLoad {
return this.check(route.queryParams['communityId']); 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; const path = '/' + route.path + document.location.search;
return this.check(ConnectHelper.getCommunityFromPath(path)); return this.check(ConnectHelper.getCommunityFromPath(path));
} }

View File

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

View File

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

View File

@ -1,9 +1,9 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {BehaviorSubject, Observable} from 'rxjs'; import {BehaviorSubject, Observable} from 'rxjs';
import {Curator} from '../../utils/entities/CuratorInfo'; import {Curator} from '../../utils/entities/CuratorInfo';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {COOKIE} from '../../login/utils/helper.class'; import {CustomOptions} from "../../services/servicesUtils/customOptions.class";
@Injectable() @Injectable()
export class CuratorService { export class CuratorService {
@ -34,20 +34,11 @@ export class CuratorService {
} }
public updateCurator(url: string, curator: Curator) { 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> { public getCurator(properties: EnvProperties, url: string): Observable<Curator> {
return this.http.get<Curator>((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url); 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 {Injectable} from '@angular/core';
import {Http} from '@angular/http'; import {Http} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import{EnvProperties} from '../../utils/properties/env-properties'; import{EnvProperties} from '../../utils/properties/env-properties';
@Injectable() @Injectable()
export class SearchCommunityProjectsService { export class SearchCommunityProjectsService {
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
searchProjects (properties:EnvProperties, communityId: string):any { searchProjects (properties:EnvProperties, communityId: string):any {
let url = properties.communityAPI+communityId+"/projects"; let url = properties.communityAPI+communityId+"/projects";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url);
.map(res => <any> res.json()) //.map(res => <any> res.json())
} }
} }

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@ import {Router} from '@angular/router';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {EnvProperties} from '../../utils/properties/env-properties'; 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 {Router, ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {EnvProperties} from '../utils/properties/env-properties'; 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 {Router, ActivatedRoute} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {ErrorCodes} from '../utils/properties/errorCodes'; import {ErrorCodes} from '../utils/properties/errorCodes';
import{EnvProperties} from '../utils/properties/env-properties'; 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 { Injectable } from '@angular/core';
import { import {
Router, Router,
@ -7,14 +11,13 @@ import {
RouterStateSnapshot, RouterStateSnapshot,
Route, Data Route, Data
} from '@angular/router'; } from '@angular/router';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/filter';
import { ConfigurationService } from '../utils/configuration/configuration.service'; import { ConfigurationService } from '../utils/configuration/configuration.service';
import { EnvironmentSpecificService} from '../utils/properties/environment-specific.service'; import { EnvironmentSpecificService} from '../utils/properties/environment-specific.service';
import {ConnectHelper} from '../connect/connectHelper'; import {ConnectHelper} from '../connect/connectHelper';
@Injectable() @Injectable()
export class IsRouteEnabled implements CanActivate, CanLoad { export class IsRouteEnabled implements CanActivate {
constructor(private router: Router, constructor(private router: Router,
private config: ConfigurationService, private config: ConfigurationService,
@ -26,18 +29,18 @@ export class IsRouteEnabled implements CanActivate, CanLoad {
community = data['community']; community = data['community'];
} }
const redirect = customRedirect ? customRedirect : '/error'; const redirect = customRedirect ? customRedirect : '/error';
const obs = this.propertiesService.subscribeEnvironment().map(res => { const obs = this.propertiesService.subscribeEnvironment().pipe(map(res => {
if (!community) { if (!community) {
community = ConnectHelper.getCommunityFromDomain(res.domain); community = ConnectHelper.getCommunityFromDomain(res.domain);
} }
return res['adminToolsAPIURL']; return res['adminToolsAPIURL'];
}).mergeMap(url => { }),mergeMap(url => {
if (!community) { // no community to check - return true 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)); 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}})); .subscribe(() => this.router.navigate([redirect], {queryParams: {'page': path}}));
return obs; return obs;
} }
@ -45,8 +48,4 @@ export class IsRouteEnabled implements CanActivate, CanLoad {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(route.data, route.queryParams['communityId'], state.url); 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 {Component, ViewChild} from '@angular/core';
import {Input} from '@angular/core'; import {Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; 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'; 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.LOADING ||
this.fetchAggregatorsOrps.searchUtils.status == this.errorCodes.DONE )) { 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( .subscribe(
data => {}, data => {},
err => {}, err => {},

View File

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

View File

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

View File

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

View File

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

View File

@ -1,12 +1,14 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http'; import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable'; import {HttpClient} from "@angular/common/http";
import 'rxjs/add/operator/do'; import {Observable} from 'rxjs';
import {map} from "rxjs/operators";
@Injectable() @Injectable()
export class HtmlProjectReportService { export class HtmlProjectReportService {
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
getHTML(id: string, size: number, type:string, csvAPIURL: string ):any { getHTML(id: string, size: number, type:string, csvAPIURL: string ):any {
@ -32,6 +34,9 @@ export class HtmlProjectReportService {
let key = url; let key = url;
return this.http.get(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 {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {EnvProperties} from '../../../utils/properties/env-properties'; import {EnvProperties} from '../../../utils/properties/env-properties';
import {DeletedByInferenceResult} from '../../../utils/entities/deletedByInferenceResult'; import {DeletedByInferenceResult} from '../../../utils/entities/deletedByInferenceResult';
@ -11,8 +11,8 @@ import {ErrorCodes} from '../../../utils/properties/errorCodes
import {DeletedByInferenceService} from './deletedByInference.service'; import {DeletedByInferenceService} from './deletedByInference.service';
//import {zip} from 'rxjs'; import {zip} from 'rxjs';
import 'rxjs/add/observable/zip';
@Component({ @Component({
selector: 'deletedByInference', selector: 'deletedByInference',
@ -152,7 +152,7 @@ export class DeletedByInferenceComponent {
allRequests.push(this._deletedByInferenceService.getDeletedByInferencePublications(id, this.properties)); 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( // this._deletedByInferenceService.getDeletedByInferencePublications(id, this.properties).subscribe(
data => { data => {
this.results = data; this.results = data;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,11 +1,19 @@
import { Injectable } from '@angular/core'; import {Injectable} from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router'; import {
import {Observable} from 'rxjs/Observable'; Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad,
Route,
UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class'; import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class'; import {LoginErrorCodes} from './utils/guardHelper.class';
@Injectable() @Injectable()
export class AdminLoginGuard implements CanActivate, CanLoad { export class AdminLoginGuard implements CanActivate{
constructor(private router: Router) { constructor(private router: Router) {
} }
@ -22,7 +30,12 @@ export class AdminLoginGuard implements CanActivate, CanLoad {
} }
} }
if (!loggedIn || !isAdmin) { 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; return loggedIn && isAdmin;
} }
@ -31,7 +44,4 @@ export class AdminLoginGuard implements CanActivate, CanLoad {
return this.check(state.url); 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 {Injectable} from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, CanLoad, Route} from '@angular/router'; import {
import {Observable} from 'rxjs/Observable'; Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
CanLoad,
Route,
UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class'; import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class'; import {LoginErrorCodes} from './utils/guardHelper.class';
@Injectable() @Injectable()
export class ClaimsCuratorGuard implements CanActivate, CanLoad { export class ClaimsCuratorGuard implements CanActivate {
constructor(private router: Router) { constructor(private router: Router) {
} }
@ -24,7 +32,12 @@ export class ClaimsCuratorGuard implements CanActivate, CanLoad {
} }
} }
if (!loggedIn || !isAuthorized) { 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; return loggedIn && isAuthorized;
} }
@ -33,7 +46,4 @@ export class ClaimsCuratorGuard implements CanActivate, CanLoad {
return this.check(state.url); 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, Route,
CanLoad CanLoad
} from '@angular/router'; } from '@angular/router';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {LoginErrorCodes} from './utils/guardHelper.class'; import {LoginErrorCodes} from './utils/guardHelper.class';
@Injectable() @Injectable()
export class FreeGuard implements CanActivate, CanLoad { export class FreeGuard implements CanActivate {
constructor(private router: Router) { constructor(private router: Router) {
} }
@ -28,7 +28,4 @@ export class FreeGuard implements CanActivate, CanLoad {
return this.check(state.url); 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 {Injectable} from '@angular/core';
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Route, CanLoad} from '@angular/router'; import {
import {Observable} from 'rxjs/Observable'; Router,
CanActivate,
ActivatedRouteSnapshot,
RouterStateSnapshot,
Route,
CanLoad,
UrlSegment
} from '@angular/router';
import {Observable} from 'rxjs';
import {Session} from './utils/helper.class'; import {Session} from './utils/helper.class';
import {LoginErrorCodes} from './utils/guardHelper.class'; import {LoginErrorCodes} from './utils/guardHelper.class';
@Injectable() @Injectable()
export class LoginGuard implements CanActivate, CanLoad { export class LoginGuard implements CanActivate {
constructor(private router: Router) { constructor(private router: Router) {
} }
@ -16,7 +24,12 @@ export class LoginGuard implements CanActivate, CanLoad {
loggedIn = true; loggedIn = true;
} }
if (!loggedIn) { 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; return loggedIn;
} }
@ -24,8 +37,4 @@ export class LoginGuard implements CanActivate, CanLoad {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
return this.check(state.url); 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 {Component, Input, ViewChild} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import { Router, ActivatedRoute} from '@angular/router'; import { Router, ActivatedRoute} from '@angular/router';
import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class';
import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {SearchDataprovidersService} from '../../services/searchDataproviders.service';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class'; import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class';
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.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 => { this.config.getCommunityInformation(this.properties.adminToolsAPIURL, (this.connectCommunityId)?this.connectCommunityId:this.properties.adminToolsCommunity ).subscribe(data => {
var showEntity = {}; 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.showPublications = showEntity["publication"];
this.showDatasets = showEntity["dataset"]; this.showDatasets = showEntity["dataset"];

View File

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

View File

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

View File

@ -1,33 +1,68 @@
import {Component, Input, Output, EventEmitter} from '@angular/core'; 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 { Filter, Value, DateValue} from './searchHelperClasses.class';
import {IMyOptions, IMyDateModel} from '../../utils/my-date-picker/interfaces/index'; import {IMyOptions, IMyDateModel} from '../../utils/my-date-picker/interfaces/index';
// import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface'; // import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface';
import {Dates} from '../../utils/string-utils.class'; import {Dates} from '../../utils/string-utils.class';
import {FormControl} from "@angular/forms";
import {MatDatepickerInputEvent} from "@angular/material";
@Component({ @Component({
selector: 'date-filter', selector: 'date-filter',
template: ` 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> <option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option>
</select> </select>
<div *ngIf="dateValue.type=='range' " class="-row dateFilter" > <div *ngIf="dateValue && dateValue.type=='range' ">
<table class=" uk-table uk-table-responsive" > <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 > <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> <option *ngFor="let type of dateValue.types let i = index" [value]="type" (click)="typeChanged(type)">{{dateValue.typesTitle[i]}}</option>
</select></td> </select>
</td>
<td> <td>
From</td><td style="width: 112px;"><my-date-picker name="from" [options]="myDatePickerOptions" From
[(ngModel)]="from" (dateChanged)="onFromDateChanged($event)" ></my-date-picker> </td>
</td> <td> <td class="uk-padding-remove-top" style="width: 112px;">
To </td><td style="width: 112px;"> <my-date-picker name="to" [options]="myDatePickerOptions" <mat-form-field style="max-width: 112px;">
[(ngModel)]="to" (dateChanged)="onToDateChanged($event)" ></my-date-picker></td></tr> <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> </table>
</div> </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). // Initialized to specific date (09.10.2018).
public from;//: Object = { date: { year: 2018, month: 10, day: 9 } }; public from;//: Object = { date: { year: 2018, month: 10, day: 9 } };
public to;//: Object = { date: { year: 2018, month: 10, day: 9 } }; public to;//: Object = { date: { year: 2018, month: 10, day: 9 } };
public fromDate;
public toDate;
constructor() { constructor() {
//this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to);
}
ngOnInit() {
this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to); this.updateDefaultRangeDates(this.dateValue.from,this.dateValue.to);
} }
updateDefaultRangeDates(df:Date,dt:Date){ updateDefaultRangeDates(df:Date,dt:Date){
this.from = { date: { year: df.getFullYear(), month: (df.getMonth()+1), day: df.getDate() } }; df.setMonth(df.getMonth()-1);
this.to = { date: { year: dt.getFullYear(), month: (dt.getMonth()+1), day: dt.getDate() } }; 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){ typeChanged(type:string){
this.dateValue.setDatesByType(type); this.dateValue.setDatesByType(type);
this.updateDefaultRangeDates(this.dateValue.from, this.dateValue.to); this.updateDefaultRangeDates(this.dateValue.from, this.dateValue.to);
} }
/*
onFromDateChanged(event: IMyDateModel) { onFromDateChanged(event: IMyDateModel) {
this.dateValue.from = Dates.getDateFromString(event.formatted); this.dateValue.from = Dates.getDateFromString(event.formatted);
this.validDateFrom = true; this.validDateFrom = true;
@ -72,4 +118,16 @@ onFromDateChanged(event: IMyDateModel) {
onToDateChanged(event: IMyDateModel) { onToDateChanged(event: IMyDateModel) {
this.dateValue.to = Dates.getDateFromString(event.formatted); this.dateValue.to = Dates.getDateFromString(event.formatted);
this.validDateTo = true; 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 { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common'; 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 { MyDatePickerModule } from '../../utils/my-date-picker/my-date-picker.module';
import {DateFilterComponent} from './dateFilter.component'; 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({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, MyDatePickerModule CommonModule, FormsModule, ReactiveFormsModule, MyDatePickerModule,
MatNativeDateModule, MatDatepickerModule, MatFormFieldModule, MatInputModule
], ],
declarations: [ declarations: [
DateFilterComponent DateFilterComponent

View File

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

View File

@ -1,5 +1,5 @@
import {Component, Input, Output, EventEmitter} from '@angular/core'; import {Component, Input, Output, EventEmitter} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs';
import { Filter, Value} from './searchHelperClasses.class'; import { Filter, Value} from './searchHelperClasses.class';
import {Open} from '../../utils/modal/open.component'; 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 {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser'; import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable'; import {Observable, Subject} from 'rxjs';
import {Subject} from 'rxjs/Subject';
import {DataTableDirective } from 'angular-datatables'; import {DataTableDirective } from 'angular-datatables';

View File

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

View File

@ -1,8 +1,7 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {CustomOptions} from './servicesUtils/customOptions.class'; import {CustomOptions} from './servicesUtils/customOptions.class';
import {HttpClient, HttpHeaders} from '@angular/common/http'; import {HttpClient} from '@angular/common/http';
import {COOKIE} from '../login/utils/helper.class';
@Injectable() @Injectable()
export class CuratorPhotoService { export class CuratorPhotoService {
@ -12,20 +11,11 @@ export class CuratorPhotoService {
uploadPhoto(url: string, photo: File): Observable<any> { uploadPhoto(url: string, photo: File): Observable<any> {
const formData = new FormData(); const formData = new FormData();
formData.append('photo', photo); formData.append('photo', photo);
return this.http.post(url, formData, this.getAuthOptions()); return this.http.post(url, formData, CustomOptions.getAuthOptions());
} }
deletePhoto(url: string) { 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 {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http'; 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 {CustomOptions} from './servicesUtils/customOptions.class';
import {catchError} from "rxjs/operators";
@Injectable() @Injectable()
export class LayoutService { export class LayoutService {
constructor(private http: Http) { constructor(private http: HttpClient) {
} }
static removeNulls(obj) { static removeNulls(obj) {
@ -22,26 +24,26 @@ export class LayoutService {
saveLayout(pid: string, url: string, layout: any) { saveLayout(pid: string, url: string, layout: any) {
LayoutService.removeNulls(layout); LayoutService.removeNulls(layout);
return this.http.post(url + 'community/' + pid + '/updateLayout', JSON.stringify(layout), CustomOptions.getAuthOptionsWithBody()) return this.http.post(url + 'community/' + pid + '/updateLayout', JSON.stringify(layout), CustomOptions.getAuthOptionsWithBody())
.map(res => res.json()) //.map(res => res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getLayout(pid: string, url: string) { getLayout(pid: string, url: string) {
return this.http.get(url + 'community/' + pid + '/layout') return this.http.get(url + 'community/' + pid + '/layout')
.map(res => res.json()) //.map(res => res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
loadDefaultLayout(pid: string, url: string) { loadDefaultLayout(pid: string, url: string) {
return this.http.post(url + 'community/' + pid + '/resetLayout', null, CustomOptions.getAuthOptionsWithBody()) return this.http.post(url + 'community/' + pid + '/resetLayout', null, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json()) //.map(res => res.json())
.catch(this.handleError); .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 // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); 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 {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http'; 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 {Metrics} from '../utils/entities/metrics';
import 'rxjs/add/operator/do';
import{EnvProperties} from '../utils/properties/env-properties'; import{EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable() @Injectable()
export class MetricsService { export class MetricsService {
metrics: Metrics; metrics: Metrics;
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
getMetrics (id: string, entityType: string, properties:EnvProperties):any { getMetrics (id: string, entityType: string, properties:EnvProperties):any {
let url = properties.metricsAPIURL+entityType+"/"+id+"/clicks"; let url = properties.metricsAPIURL+entityType+"/"+id+"/clicks";
let key = url; let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) //.map(res => <any> res.json())
.map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"], .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)); res["total_openaire_views"], res["total_openaire_downloads"], res["pageviews"], properties)));
} }

View File

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

View File

@ -1,16 +1,18 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http'; 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 {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 {RefineResultsUtils} from './servicesUtils/refineResults.class';
import{EnvProperties} from '../utils/properties/env-properties'; import{EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable() @Injectable()
export class RefineFieldResultsService { export class RefineFieldResultsService {
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
getRefineFieldsResultsByEntityName(fields:string[], entityName:string, properties:EnvProperties, communityQuery=null):any{ 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"; let url = properties.searchAPIURLLAst + this.getSearchAPIURLForEntity(entityName)+"?format=json&refine=true&page=1&size=0";
for(var i=0; i < fields.length; i++){ 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) 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{ getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{
@ -36,9 +38,9 @@ export class RefineFieldResultsService {
let url = link+"&refine=true&page=1&size=0"; let url = link+"&refine=true&page=1&size=0";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) //.map(res => <any> res.json())
.map(res => res['refineResults']) .pipe(map(res => res['refineResults']))
.map(res => this.parse(res,fieldName)); .pipe(map(res => this.parse(res,fieldName)));
} }
parse(data: any,fieldName:string):any { parse(data: any,fieldName:string):any {
@ -78,10 +80,10 @@ export class RefineFieldResultsService {
} }
return suffix; 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 // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.log(error); 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 {Injectable} from '@angular/core';
import {Http, Response, Headers} from '@angular/http'; import {Http, Response, Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable'; import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import 'rxjs/add/observable/of'; import {Observable, throwError} from 'rxjs';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import {map, tap} from "rxjs/operators";
@Injectable() @Injectable()
export class ReportsService { 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"; // 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 //text/html
//On the service: //On the service:
downloadCSVFile(url: string){ downloadCSVFile(url: string){
var headers = new Headers(); //var headers = new Headers();
headers.append('responseType', 'arraybuffer'); //headers.append('responseType', 'arraybuffer');
return this.http.get(url) 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){ getCSVResponse(url: string){
var headers = new Headers(); //var headers = new Headers();
headers.append('responseType', 'arraybuffer'); //headers.append('responseType', 'arraybuffer');
return this.http.get(url) return this.http.get(url)
.map(res => res['_body']); .pipe(map(res => res['_body']));
} }
downloadHTMLFile(url: string, info: string){ downloadHTMLFile(url: string, info: string){
var headers = new Headers(); //var headers = new Headers();
headers.append('responseType', 'arraybuffer'); //headers.append('responseType', 'arraybuffer');
return this.http.get(url) return this.http.get(url)
.map(res => this.addInfo(res, info)) .pipe(map(res => this.addInfo(res, info)))
.map(res => new Blob([res['_body']], { type: 'text/html' })) .pipe(map(res => new Blob([res['_body']], { type: 'text/html' })))
.do(res => console.log(res)) .pipe(tap(res => console.log(res)))
} }
addInfo(res:any, info:string) { addInfo(res:any, info:string) {
@ -43,11 +45,11 @@ export class ReportsService {
return res; 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 // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.log(error); 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 {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http'; 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 {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; 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 {StringUtils} from '../utils/string-utils.class';
import{EnvProperties} from '../utils/properties/env-properties'; import{EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators";
@Injectable() @Injectable()
export class SearchDataprovidersService { 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 { 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) 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)) //.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")) //((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties ):any { 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"; url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) 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)) //.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 { 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()) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json())
.map(res => res['meta'].total); .pipe(map(res => res['meta'].total));
} }
searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { 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"; url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) 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)) //.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 { 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()) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => res['meta'].total); //.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 { 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"; url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) 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)) //.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 { 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 += '?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"; url += "&page=0&size=0&format=json";
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())
.map(res => res['meta'].total); .pipe(map(res => res['meta'].total));
} }
searchJournals (params: string,refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties):any { 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"; url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) 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)) //.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 { 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) 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'])]));
} }
searchDataProvidersBySubjects(keyword:string, type:string, page: number, size: number, properties:EnvProperties):any { searchDataProvidersBySubjects(keyword:string, type:string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchResourcesAPIURL; let link = properties.searchResourcesAPIURL;
@ -173,8 +176,8 @@ export class SearchDataprovidersService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) 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'])]));
} }
@ -191,16 +194,16 @@ export class SearchDataprovidersService {
url += "&page="+(page-1)+"&size="+size+"&format=json"; url += "&page="+(page-1)+"&size="+size+"&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) 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'])]));
} }
searchDataprovidersForEntity (params: string, page: number, size: number, properties:EnvProperties):any { searchDataprovidersForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst; let link = properties.searchAPIURLLAst;
let url = link+params+"/datasources?format=json"; let url = link+params+"/datasources?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) 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'])]));
} }
/* /*
searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any { 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"; //let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) //.map(res => <any> res.json())
.map(res => res.total); .pipe(map(res => res['total']));
} }
numOfEntityDataproviders(id: string, entity: string, properties:EnvProperties):any { 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()) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json())
.map(res => res['meta'].total); .pipe(map(res => res['meta'].total));
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,20 +1,22 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http'; 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 {SearchResult} from '../utils/entities/searchResult';
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; 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 { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class';
import{EnvProperties} from '../utils/properties/env-properties'; import{EnvProperties} from '../utils/properties/env-properties';
import {DOI, StringUtils} from '../utils/string-utils.class'; import {DOI, StringUtils} from '../utils/string-utils.class';
import {map} from "rxjs/operators";
@Injectable() @Injectable()
export class SearchSoftwareService { export class SearchSoftwareService {
private sizeOfDescription: number = 270; private sizeOfDescription: number = 270;
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); 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 { 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) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.do(res => console.info(res)) //.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 { searchSoftwareById (id: string, properties:EnvProperties ):any {
@ -44,8 +46,7 @@ export class SearchSoftwareService {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) .pipe(map(res => this.parseResults(res, properties)));
.map(res => this.parseResults(res, properties));
} }
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any { 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) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) //.map(res => <any> res.json())
.map(res => this.parseRefineResults(id, res['refineResults'])) .pipe(map(res => this.parseRefineResults(id, res['refineResults'])));
} }
searchSoftwareByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { 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) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json())
//.do(res => console.info(res)) //.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 { advancedSearchSoftware (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
let url = properties.searchResourcesAPIURL; let url = properties.searchResourcesAPIURL;
@ -109,17 +109,16 @@ export class SearchSoftwareService {
url += "&format=json"; url += "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
//.do(res => console.info(res))
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
} }
searchSoftwareForEntity (params: string, page: number, size: number, properties:EnvProperties):any { searchSoftwareForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
let link = properties.searchAPIURLLAst; let link = properties.searchAPIURLLAst;
let url = link+params+"/software"+"?format=json"; let url = link+params+"/software"+"?format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
} }
searchSoftwareForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any { 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"; let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
} }
parseResults(data: any, properties: EnvProperties): SearchResult[] { parseResults(data: any, properties: EnvProperties): SearchResult[] {
@ -360,8 +358,8 @@ export class SearchSoftwareService {
numOfSoftware(url: string, properties:EnvProperties):any { numOfSoftware(url: string, properties:EnvProperties):any {
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <any> res.json()) //.map(res => <any> res.json())
.map(res => res.total); .pipe(map(res => res['total']));
} }
numOfEntitySoftware(id: string, entity: string, properties:EnvProperties):any { 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 { COOKIE } from '../../login/utils/helper.class'; import {HttpHeaders} from "@angular/common/http";
export class CustomOptions { export class CustomOptions {
/*
public static getAuthOptionsWithBody(): RequestOptions { public static getAuthOptionsWithBody(): RequestOptions {
const headers = new Headers(); const headers = new Headers();
headers.append('Content-Type', 'application/json'); headers.append('Content-Type', 'application/json');
@ -11,12 +12,33 @@ export class CustomOptions {
const options = new RequestOptions({ headers: headers, withCredentials: true }); const options = new RequestOptions({ headers: headers, withCredentials: true });
return options; 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 { public static getAuthOptions(): RequestOptions {
const headers = new Headers(); const headers = new Headers();
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id)); headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
const options = new RequestOptions({ headers: headers, withCredentials: true }); const options = new RequestOptions({ headers: headers, withCredentials: true });
return options; 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 { Component, Input } from '@angular/core';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute} from '@angular/router';
import 'rxjs/Rx'; import 'rxjs';
import{MenuItem} from './menu'; import{MenuItem} from './menu';
import { ConfigurationService } from '../utils/configuration/configuration.service'; import { ConfigurationService } from '../utils/configuration/configuration.service';
@ -34,8 +34,8 @@ constructor(private config: ConfigurationService, private route: ActivatedRoute
if(this.showMenuItems){ if(this.showMenuItems){
if( this.APIUrl && this.communityId ){ if( this.APIUrl && this.communityId ){
this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => { this.config.getCommunityInformation(this.APIUrl, this.communityId ).subscribe(data => {
for(var i=0; i< data.pages.length; i++){ for(var i=0; i< data['pages'].length; i++){
this.showPage[data.pages[i]["route"]] = data.pages[i]["isEnabled"]; this.showPage[data['pages'][i]["route"]] = data['pages'][i]["isEnabled"];
} }
// console.log(this.showPage) // console.log(this.showPage)

View File

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

View File

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

View File

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

View File

@ -1,20 +1,21 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response, Headers} from '@angular/http'; import {Http, Response, Headers} from '@angular/http';
import {Observable} from 'rxjs/Observable'; import {HttpClient} from "@angular/common/http";
import 'rxjs/add/operator/mapTo'; import {Observable} from 'rxjs';
import 'rxjs/add/observable/of';
// import 'rxjs/add/operator/do'; // import 'rxjs/add/operator/do';
// import 'rxjs/add/operator/share'; // import 'rxjs/add/operator/share';
import { mapTo } from 'rxjs/operators'; import {map, mapTo} from 'rxjs/operators';
@Injectable() @Injectable()
export class ConfigurationService { export class ConfigurationService {
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
getCommunityInformation(APIUrl:string, community:string){ getCommunityInformation(APIUrl:string, community:string){
return this.http.get(APIUrl + "/communityFull/" + community) return this.http.get(APIUrl + "/communityFull/" + community);
.map(res => res.json()); //.map(res => res.json());
} }
isEntityEnabled(APIUrl:string, community:string,entity: string){ isEntityEnabled(APIUrl:string, community:string,entity: string){
@ -26,32 +27,33 @@ export class ConfigurationService {
// } // }
// return Observable.of(new Object()).mapTo(true); // return Observable.of(new Object()).mapTo(true);
return this.http.get(APIUrl + "/page") return this.http.get(APIUrl + "/page")
.map(res => true); .pipe(map(res => true));
} }
isPageEnabled(APIUrl:string, community:string,router: string){ isPageEnabled(APIUrl:string, community:string,router: string){
return this.http.get(APIUrl + "/community/" + community+"/pages?page_route="+router) 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; let result = false;
if(res.length >0 && res[0].route == router){ if(res['length'] >0 && res[0].route == router){
result = res[0].isEnabled; result = res[0].isEnabled;
} }
return result; return result;
});//.do(res => {console.log("Route "+router +" is "+res)}); }));//.do(res => {console.log("Route "+router +" is "+res)});
} }
getMainPageContent(APIUrl:string, community:string,){ getMainPageContent(APIUrl:string, community:string,){
return this.http.get(APIUrl + "/page") return this.http.get(APIUrl + "/page")
.map(res => true); .pipe(map(res => true));
} }
getSpecialAnouncementContent(APIUrl:string, community:string,){ getSpecialAnouncementContent(APIUrl:string, community:string,){
return this.http.get(APIUrl + "/page") return this.http.get(APIUrl + "/page")
.map(res => ""); .pipe(map(res => ""));
} }
getHelpPageContent(APIUrl:string, community:string, router:string){ getHelpPageContent(APIUrl:string, community:string, router:string){
return this.http.get(APIUrl + "/page") return this.http.get(APIUrl + "/page")
.map(res => true); .pipe(map(res => true));
} }
// private handleError (error: Response) { // private handleError (error: Response) {
// // in a real world app, we may send the error to some remote logging infrastructure // // 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 {Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions} from '@angular/http'; import {Http, Response, Headers, RequestOptions} from '@angular/http';
import {HttpClient} from "@angular/common/http";
import {Email} from './email'; import {Email} from './email';
import {CustomOptions} from '../../services/servicesUtils/customOptions.class'; import {CustomOptions} from '../../services/servicesUtils/customOptions.class';
import {EmailRecaptcha} from "../entities/EmailRecaptcha"; import {EmailRecaptcha} from "../entities/EmailRecaptcha";
@ -7,22 +8,22 @@ import {EmailRecaptcha} from "../entities/EmailRecaptcha";
@Injectable() @Injectable()
export class EmailService { export class EmailService {
constructor(private http:Http) { constructor(private http:HttpClient) {
} }
sendEmail(url: string, email: Email) { sendEmail(url: string, email: Email) {
let body = JSON.stringify(email); let body = JSON.stringify(email);
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody()) return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody());
.map(request => request.json()); //.map(request => request.json());
} }
contact(url: string, email: Email, recaptcha: string) { contact(url: string, email: Email, recaptcha: string) {
const data: EmailRecaptcha = new EmailRecaptcha(); const data: EmailRecaptcha = new EmailRecaptcha();
data.email = email; data.email = email;
data.recaptcha = recaptcha; data.recaptcha = recaptcha;
return this.http.post(url, data) return this.http.post(url, data);
.map(request => request.json()); //.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 {Component, ElementRef, Input, Output, EventEmitter, OnChanges, SimpleChange} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable, Subject} from 'rxjs';
import {Subject} from 'rxjs/Subject';
import {Value} from '../../searchPages/searchUtils/searchHelperClasses.class'; import {Value} from '../../searchPages/searchUtils/searchHelperClasses.class';
import {EntitiesSearchService} from './entitySearch.service'; import {EntitiesSearchService} from './entitySearch.service';
import{EnvProperties} from '../properties/env-properties'; import{EnvProperties} from '../properties/env-properties';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
//Usage example //Usage example
//<static-autocomplete [(filtered)] =filtered [(selected)] =selected placeHolderMessage = "Search for countries" title = "Countries:" (keywordChange)="keywordChanged($event)"></static-autocomplete> //<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; this.showInput = true;
if(this.entityType == "project" && this.funderId ){ if(this.entityType == "project" && this.funderId ){
this.filtered = this.searchTermStream this.filtered = this.searchTermStream.pipe(
.debounceTime(300).distinctUntilChanged() debounceTime(300),distinctUntilChanged(),
.switchMap((term: string) => { switchMap((term: string) => {
//console.log("funder"+this.funderId); //console.log("funder"+this.funderId);
var results = this._search.searchProjectsByFunder(term, (this.funderId == "0"?"":encodeURIComponent(this.funderId)), this.properties); var results = this._search.searchProjectsByFunder(term, (this.funderId == "0"?"":encodeURIComponent(this.funderId)), this.properties);
this.showLoading = false; this.showLoading = false;
this.results = results.length; this.results = results.length;
return results; return results;
}); }),);
}else if(this.entityType == "organization" && this.depositType ){ }else if(this.entityType == "organization" && this.depositType ){
this.filtered = this.searchTermStream this.filtered = this.searchTermStream.pipe(
.debounceTime(300).distinctUntilChanged() debounceTime(300),distinctUntilChanged(),
.switchMap((term: string) => { switchMap((term: string) => {
var results = this._search.searchByDepositType(term, this.depositType, this.properties); var results = this._search.searchByDepositType(term, this.depositType, this.properties);
this.showLoading = false; this.showLoading = false;
this.results = results.length; this.results = results.length;
return results; return results;
}); }),);
}else{ }else{
this.filtered = this.searchTermStream this.filtered = this.searchTermStream.pipe(
.debounceTime(300) debounceTime(300),
.distinctUntilChanged() distinctUntilChanged(),
.switchMap((term: string) => { switchMap((term: string) => {
var results = this._search.searchByType(term, this.entityType, this.properties); var results = this._search.searchByType(term, this.entityType, this.properties);
this.showLoading = false; this.showLoading = false;
this.results = results.length; this.results = results.length;
return results; return results;
}); }),);
this.getSelectedNameFromGivenId(); this.getSelectedNameFromGivenId();
} }

View File

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

View File

@ -3,7 +3,7 @@ import { ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component'; import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class'; import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
import {DOI} from '../../utils/string-utils.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{EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from '../../utils/string-utils.class'; import {StringUtils} from '../../utils/string-utils.class';

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