login through AAI - claims API uses AAI authentication | remove cookies locally when logout is clicked | use images for the search forms | fix issue with org landing page where projects tab didn't reload

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@48552 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2017-07-12 15:17:26 +00:00
parent f81fe6515e
commit 997e3b5020
51 changed files with 403 additions and 331 deletions

View File

@ -30,7 +30,6 @@ export class XLargeDirective {
<div id="tm-main" class=" uk-section uk-margin-large-top tm-middle custom-main-content" >
<div class="uk-container ">
<div uk-grid uk-grid>
<div class="tm-main uk-width-1-1@s uk-width-1-1@m uk-width-1-1@l uk-row-first ">
@ -49,7 +48,6 @@ export class XLargeDirective {
<!-- end of sidebar -->
</div>
</div>
</div>
<cookie-law *ngIf= "isClient" position="bottom">
OpenAIRE uses cookies in order to function properly.<br>

View File

@ -10,6 +10,7 @@ import {SharedComponentsModule} from './sharedComponents/sharedComponents.module
import { ErrorModule } from './error/error.module';
import { CacheService } from './shared/cache.service';
import { CookieLawModule } from './sharedComponents/cookie-law/cookie-law.module';
import { XSRFStrategy, CookieXSRFStrategy, RequestOptions } from '@angular/http';
@NgModule({
declarations: [ AppComponent, XLargeDirective ],
@ -22,10 +23,19 @@ import { CookieLawModule } from './sharedComponents/cookie-law/cookie-law.module
CookieLawModule,
], exports:[],
providers:[CacheService]
providers:[CacheService,
// { provide: XSRFStrategy, useFactory: cookieStrategy },
// { provide: RequestOptions, useClass: ExRequestOptions}
]
})
export class AppModule {
}
export { AppComponent } from './app.component';
export function cookieStrategy() {
// return new CookieXSRFStrategy('X-Csrf-Token','X-XSRF-TOKEN');
// return new CookieXSRFStrategy('lalala','lalala');
}

View File

@ -20,7 +20,7 @@ import {ErrorCodes} from '../../login/utils/guardHelper.class';
<td >
<select class="custom-select-mini" name="select_funder" >
<option value="0" (click)="communityChanged('0','Community:')">Select Community:</option>
<option *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" [value]="communities.id" >{{communities.label}}</option>
<option *ngFor="let community of communities" (click)="communityChanged(community.id, community.label)" [value]="community.id" >{{community.label}}</option>
</select>
</td>
<td *ngIf="selectedCommunityId != '0' && categories.length > 0"><select class="custom-select-mini" name="select_funder" >
@ -181,9 +181,10 @@ getCommunities () {
}else{
this.loading = true;
var token=Session.getUserJwt();
this._contextService.getCommunities(token).subscribe(
this._contextService.getCommunities().subscribe(
data => {
this.communities = data.communities;
console.log(this.communities);
this.loading = false;
},
err => {
@ -204,7 +205,7 @@ getCommunities () {
}else{
var token=Session.getUserJwt();
this._contextService.getCategories(this.selectedCommunityId, token).subscribe(
this._contextService.getCategories(this.selectedCommunityId).subscribe(
data => {
this.categories = data.category;
this.concepts = [];
@ -233,7 +234,7 @@ getCommunities () {
this.concepts = [];
this.addCommunityInConcepts();
var token=Session.getUserJwt();
this._contextService.getConcepts(this.selectedCategoryId, "",token,true).subscribe(
this._contextService.getConcepts(this.selectedCategoryId, "",true).subscribe(
data => {
this.concepts = data;
this.addCommunityInConcepts();
@ -277,7 +278,7 @@ getCommunities () {
this.conceptsClass[categoryId] = [];
var token=Session.getUserJwt();
this.conceptsCategoryLoading[categoryId] = true;
this._contextService.getConcepts(categoryId, "",token,false).subscribe(
this._contextService.getConcepts(categoryId, "",false).subscribe(
data => {
for(var i=0;i<data.length; i++){
console.log("Data"+data[i]);

View File

@ -108,7 +108,7 @@ export class DisplayClaimsComponent {
types+=(types.length>0?'&':'')+"types="+type;
}
if(this.fetchBy =="Project" ){
this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe(
data => {
this.claims = data.data;
this.resultsNum= data.total;
@ -118,7 +118,7 @@ export class DisplayClaimsComponent {
}
);
}else if(this.fetchBy =="User"){
this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe(
data => {
this.claims = data.data;
this.resultsNum= data.total;
@ -128,7 +128,7 @@ export class DisplayClaimsComponent {
}
);
}else if(this.fetchBy =="Result"){
this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe(
data => {
this.claims = data.data;
this.resultsNum= data.total;
@ -138,7 +138,7 @@ export class DisplayClaimsComponent {
}
);
}else if(this.fetchBy =="Context"){
this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types,token).subscribe(
this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe(
data => {
this.claims = data.data;
this.resultsNum= null;
@ -149,7 +149,7 @@ export class DisplayClaimsComponent {
}
);
}else{
this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, types,token).subscribe(
this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, types).subscribe(
data => {
this.claims = data.data;
this.resultsNum = null;
@ -409,7 +409,7 @@ handleErrors(err){
var token=Session.getUserJwt();
console.log("Deleting claim with id:"+id);
// this._claimService.deleteClaimById(id);
this._claimService.deleteClaimById(id,token).subscribe(
this._claimService.deleteClaimById(id).subscribe(
res => {
console.log('Delete response'+res.code );
console.log("Deleted claim with id:"+ id);
@ -441,7 +441,7 @@ handleErrors(err){
}else{
var token=Session.getUserJwt();
console.warn("Deleting claim with ids:"+ids);
this._claimService.deleteBulk(ids,token).subscribe(
this._claimService.deleteBulk(ids).subscribe(
res => {
console.info('Delete response'+res.code );
console.warn("Deleted ids:"+ res.deletedIds);
@ -471,6 +471,11 @@ handleErrors(err){
if(res.notFoundIds.length>0){
this.deleteMessage=this.deleteMessage+'<div class = "uk-alert uk-alert-warning " >'+res.notFoundIds.length+' claim(s) couldn\'t be deleted.</div>';
}
}, err => {
console.log(err);
this.showErrorMessage = true;
this.loading.close();
});
}
}

View File

@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http';
import {Jsonp, URLSearchParams } from '@angular/http';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
// import {Claim} from '../claim';
@ -8,7 +8,7 @@ import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { CacheService } from '../../../shared/cache.service';
import { CustomOptions } from './customOptions.class';
@Injectable()
export class ClaimsService {
private baseUrl;
@ -16,13 +16,13 @@ export class ClaimsService {
this.baseUrl = OpenaireProperties.getClaimsAPIURL();
}
private getClaimRequest(size : number, page : number, url :string, fromCache:boolean,token:string):any {
private getClaimRequest(size : number, page : number, url :string, fromCache:boolean):any {
console.info('ClaimsService: Claims request: '+url);
let key = url;
if (fromCache && this._cache.has(key)) {
return Observable.of(this._cache.get(key));
}
return this.http.get( url+"&token="+token)
return this.http.get( url, CustomOptions.getAuthOptions())
.map(request => <any> request.json())
.do(request => console.info("Get claims: offset = "+(size*(page-1)) + " limit ="+size ))
.catch(this.handleError)
@ -30,48 +30,48 @@ export class ClaimsService {
this._cache.set(key, res);
});
}
getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string):any {
console.info('ClaimsService: getClaims ' );
console.info('ClaimsService: Types : '+types );
let url = this.baseUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
return this.getClaimRequest(size,page,url,true,token);
return this.getClaimRequest(size,page,url,true);
}
getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string):any {
console.info('ClaimsService: getClaims for user : '+user);
let url = this.baseUrl +"users/"+user+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
return this.getClaimRequest(size,page,url,false,token);
let url = this.baseUrl +"users/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
return this.getClaimRequest(size,page,url,false);
}
getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string ):any {
console.info('ClaimsService: getClaims for context : '+contextId);
let url = this.baseUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
return this.getClaimRequest(size,page,url,true,token);
return this.getClaimRequest(size,page,url,true);
}
getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string ):any {
console.info('ClaimsService: getClaims for result : '+resultId);
let url = this.baseUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
return this.getClaimRequest(size,page,url,true,token);
return this.getClaimRequest(size,page,url,true);
}
getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string,token:string):any {
getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string ):any {
console.info('ClaimsService: getClaims for project : '+projectId);
let url = this.baseUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
return this.getClaimRequest(size,page,url,true,token);
return this.getClaimRequest(size,page,url,true);
}
deleteClaimById(claimId:string,token:string):any{
deleteClaimById(claimId:string ):any{
console.warn('Trying to delete claim with id : '+claimId);
let url = this.baseUrl +"claims/"+claimId+"?token="+token;
let url = this.baseUrl +"claims/"+claimId;
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.delete( url, this.getOptions()).map(request => <any> request.json())
return this.http.delete( url, CustomOptions.getAuthOptionsWithBody()).map(request => <any> request.json())
// .do(request => console.info("After delete" ))
.catch(this.handleError);
}
deleteBulk(claimIds:string[],token:string):any{
deleteBulk(claimIds:string[]):any{
console.warn('Trying to delete claims with ids : '+claimIds);
var url = "";
@ -79,47 +79,48 @@ export class ClaimsService {
for(var claimId of claimIds){
url=url+(url.length >0 ?"&":"")+"claimId="+claimId;
}
url= this.baseUrl +"claims/bulk?"+url+"&token="+token;
url= this.baseUrl +"claims/bulk?"+url;
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.delete( url, this.getOptions()).map(request => <any> request.json())
return this.http.delete( url, CustomOptions.getAuthOptions()).map(request => <any> request.json())
// .do(request => console.info("After delete" ))
.catch(this.handleError);
}
insertBulkClaims(claims,token:string):any{
insertBulkClaims(claims):any{
console.warn('Trying toinsert claims : '+claims);
let url = this.baseUrl +"claims/bulk"+"?token="+token;
let url = this.baseUrl +"claims/bulk";
let body = JSON.stringify( claims );
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, this.getOptions())
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
.do(request => console.info("Insert Response:"+request.status) )
.catch(this.handleError);
}
insertClaim(claim,token:string):any{
insertClaim(claim):any{
console.warn('Trying toinsert claim : '+claim);
let url = this.baseUrl +"claims"+"?token="+token;
let url = this.baseUrl +"claims";
let body = JSON.stringify( claim );
// let headers = new Headers({ 'Content-Type': 'application/json' });
// let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, this.getOptions())
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
.do(request => console.info("Insert Response:"+request.status) )
.catch(this.handleError);
}
insertDirectRecords(records,token:string):any{
insertDirectRecords(records):any{
console.warn('Trying to feedrecords : '+records);
let url = this.baseUrl +"feed/bulk"+"?token="+token;
let url = this.baseUrl +"feed/bulk";
let body = JSON.stringify( records );
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, this.getOptions())
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
.do(request => console.info("Insert Response:"+request) )
.catch(this.handleError);
@ -132,8 +133,8 @@ export class ClaimsService {
return Observable.throw(error || 'Server error');
}
getClaim(id:string,token:string):any {
let url = this.baseUrl+"claims/"+id+"?token="+token;
getClaim(id:string):any {
let url = this.baseUrl+"claims/"+id;
return new Promise((resolve, reject) => {
this.http.get(url)
.map(res => res.json())
@ -149,11 +150,5 @@ export class ClaimsService {
});
}
private getOptions(){
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let options = new RequestOptions({ headers: headers });
return options;
}
}

View File

@ -1,5 +1,5 @@
import {Injectable} from '@angular/core';
import {Jsonp, URLSearchParams,ResponseOptions} from '@angular/http';
import {Jsonp, URLSearchParams, RequestOptions, Headers} from '@angular/http';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import {Claim} from '../claim';
@ -9,7 +9,7 @@ import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { CacheService } from '../../../shared/cache.service';
import { COOKIE } from '../../../login/utils/helper.class';
@Injectable()
export class ContextsService {
private baseUrl;
@ -17,7 +17,7 @@ export class ContextsService {
this.baseUrl = OpenaireProperties.getClaimsAPIURL();
}
public getCommunities(token:string):any {
public getCommunities():any {
let url = this.baseUrl + 'communities';
let key = url;
if (this._cache.has(key)) {
@ -25,7 +25,7 @@ export class ContextsService {
}
console.info('ContextsService: request communities '+url);
return this.http.get( url+"?token="+token)
return this.http.get( url, this.getAuthOptions())
.map(request => <any> request.json().data)
// .do(request => console.info("Get claims: offset = "))
.catch(this.handleError)
@ -33,7 +33,7 @@ export class ContextsService {
this._cache.set(key, res);
});
}
public getCategories(communityId :string,token:string):any {
public getCategories(communityId :string):any {
console.info('ContextsService: request categories for community with id '+communityId);
let url= this.baseUrl + 'communities/' + communityId + '/categories';
let key = url;
@ -41,7 +41,7 @@ export class ContextsService {
return Observable.of(this._cache.get(key));
}
return this.http.get( url+"?token="+token)
return this.http.get( url, this.getAuthOptions())
.map(request => <any> request.json().data)
// .do(request => console.info("Get claims: offset = " ))
.catch(this.handleError)
@ -49,7 +49,7 @@ export class ContextsService {
this._cache.set(key, res);
});
}
public getConcepts(categoryId :string, keyword: string,token:string,parsing:boolean):any {
public getConcepts(categoryId :string, keyword: string, parsing:boolean):any {
console.info('ContextsService: request concept for category with id '+categoryId + ' and keyword '+ keyword);
let url= this.baseUrl + 'categories/' + categoryId+ "/concepts";
let key = url+"_parsing="+parsing;
@ -57,7 +57,7 @@ export class ContextsService {
return Observable.of(this._cache.get(key));
}
return this.http.get( url+"?token="+token)
return this.http.get( url, this.getAuthOptions())
.map(request => <any> request.json().data)
.map(res => (parsing)?this.parse(res.concept):res.concept)
.do(res => console.info(res ))
@ -85,4 +85,10 @@ export class ContextsService {
console.log(error);
return Observable.throw(error || 'Server error');
}
private getAuthOptions():RequestOptions{
let headers = new Headers();
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
let options = new RequestOptions({ headers: headers, withCredentials:true });
return options;
}
}

View File

@ -0,0 +1,19 @@
import { RequestOptions, Headers} from '@angular/http';
import { COOKIE } from '../../../login/utils/helper.class';
export class CustomOptions{
public static getAuthOptionsWithBody():RequestOptions{
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
let options = new RequestOptions({ headers: headers, withCredentials:true });
return options;
}
public static getAuthOptions():RequestOptions{
let headers = new Headers();
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
let options = new RequestOptions({ headers: headers, withCredentials:true });
return options;
}
}

View File

@ -6,9 +6,9 @@ import { Meta} from '../../../angular2-meta';
@Component({
selector: 'claims-admin',
template: `
<div class="container">
<div class="uk-container">
<div class="page-header">
<h1> Claims Administrator </h1>
<h2> Claims Administrator </h2>
</div>
<div>
<div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div>

View File

@ -18,7 +18,7 @@ import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
@Component({
selector: 'claims-project-manager',
template: `
<div class="uk-container">
<!--div *ngIf="accessStatus=='empty'" class="uk-margin-top uk-width-medium-2-3 uk-container-center">
<div class="uk-block uk-block-primary uk-block-large uk-contrast uk-text-center">
<p class="uk-text-large">Please enter your email and then press 'See Claims' button.</p>
@ -174,6 +174,8 @@ import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
<!--modal-select (alertOutput)="curatorSelected($event)"></modal-select-->
<modal-loading [message]= "'Loading...'"></modal-loading>
</div>
</div>
`,
})
@ -367,7 +369,7 @@ public sortByTitle2= (claim: any) => {
console.info("Changes Saved!");
var jwtToken=Session.getUserJwt();
this.claimsByTokenService.updateClaimsCuration(jwtToken, this.selectedRight, this.selectedWrong).subscribe(
this.claimsByTokenService.updateClaimsCuration(this.selectedRight, this.selectedWrong).subscribe(
data => {
console.info(data);
},

View File

@ -5,6 +5,8 @@ import {Observable} from 'rxjs/Observable';
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
import 'rxjs/add/operator/do';
import { CacheService } from '../../shared/cache.service';
import { CustomOptions } from '../claim-utils/service/customOptions.class';
@Injectable()
export class ClaimsByTokenService {
@ -13,13 +15,13 @@ export class ClaimsByTokenService {
getClaims(token: string, jwtToken: string):any {
console.info("getClaims in service");
let url = OpenaireProperties.getClaimsAPIURL()+"project/claims?token="+jwtToken+"&projectToken="+token;
let url = OpenaireProperties.getClaimsAPIURL()+"project/claims?projectToken="+token;
let key = url;
//if (this._cache.has(key)) {
// return Observable.of(this._cache.get(key));
//}
return this.http.get(url)
return this.http.get(url, CustomOptions.getAuthOptions())
//.map(res => <any> res.text())
.map(request => <any> request.json());
//.do(res => {
@ -42,8 +44,8 @@ export class ClaimsByTokenService {
}
*/
updateClaimsCuration(jwtToken: string, selectedRight: Set<string>, selectedWrong: Set<string>) {
let url = OpenaireProperties.getClaimsAPIURL() + "curate/bulk?token="+jwtToken;
updateClaimsCuration( selectedRight: Set<string>, selectedWrong: Set<string>) {
let url = OpenaireProperties.getClaimsAPIURL() + "curate/bulk";
let claimsCurationInfo: any = []; //e.g.: [{"id":"2","approved":true},{"id":"1","approved":true}]
selectedRight.forEach(function(selected) {
@ -64,7 +66,7 @@ export class ClaimsByTokenService {
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, options)
return this.http.post(url, body, CustomOptions.getAuthOptionsWithBody())
.map(res => res.json())
.do(request => console.info("Insert Response:"+request.status) )
.catch(this.handleError);

View File

@ -10,9 +10,9 @@ import { Meta} from '../../../angular2-meta';
@Component({
selector: 'directLinking',
template: `
<div class="container uk-margin-top">
<div class="uk-container uk-margin-top">
<div class="page-header">
<h1>Linking</h1>
<h2>Linking</h2>
</div>
<div *ngIf="validInput != null && !validInput" class="uk-alert uk-alert-warning" role="alert">No valid arguments provided in order to start linking openAIRE entities. </div>
<div *ngIf="validInput != null && validInput">

View File

@ -87,8 +87,7 @@ private insertActions(){
}else{
this.claiming = true;
var user=Session.getUserEmail();
var token=Session.getUserJwt();
this.loading.open();
this.loading.open();
var claims = [];
var directclaims = [];
if(this.results){
@ -122,12 +121,12 @@ private insertActions(){
}
//first call direct index service - when call is done (success or error) call isertBulkClaims method to insert claims in DB
console.info("\n\ndirectclaims: "+directclaims.length+"\n\n");
this.claimService.insertDirectRecords(directclaims,token).subscribe(
this.claimService.insertDirectRecords(directclaims).subscribe(
data => {
this.insertedRecords = data.insertedIds;
this.errorInRecords = data.errorInClaims;
this.isertBulkClaims(claims,token);
this.isertBulkClaims(claims);
},
err => {
err=err.json();
@ -137,7 +136,7 @@ private insertActions(){
if(err.errorInClaims && err.errorInClaims.length >0){
this.errorInRecords = err.errorInClaims;
}
this.isertBulkClaims(claims,token);
this.isertBulkClaims(claims);
}
);
@ -145,9 +144,9 @@ private insertActions(){
}
private isertBulkClaims(claims,token){
private isertBulkClaims(claims){
console.info("try to insert "+claims.length+" claims");
this.claimService.insertBulkClaims(claims,token).subscribe(
this.claimService.insertBulkClaims(claims).subscribe(
data => {
this.insertedClaims = data.insertedIds;
this.errorInClaims = data.errorInClaims;

View File

@ -11,7 +11,7 @@ declare var UIkit:any;
@Component({
selector: 'linking-generic',
template: `
<div class="container uk-margin-top">
<div class="uk-container uk-margin-top">
<div class="page-header">
<h1>Linking</h1>
</div>

View File

@ -6,9 +6,9 @@ import { Meta} from '../../../angular2-meta';
@Component({
selector: 'my-claims',
template: `
<div class="container uk-margin-top">
<div class="uk-container uk-margin-top">
<div class="page-header">
<h1> My Linked research resutls</h1>
<h2> My Linked research resutls</h2>
</div>
<div>
<div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div>

View File

@ -8,7 +8,7 @@ import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openairePro
@Component({
selector: 'deposit-by-subject',
template: `
<div class="container uk-margin-top">
<div class="uk-margin-top">
<h3>Or search for Data providers via Classifications</h3>

View File

@ -14,7 +14,7 @@ import {RouterHelper} from '../../utils/routerHelper.class';
@Component({
selector: 'deposit-by-subject-result',
template: `
<div class="container uk-margin-top">
<div class="uk-container uk-margin-top">
<div class="page-header" >
<h2>Deposit {{requestFor}}</h2>
</div>
@ -28,7 +28,7 @@ import {RouterHelper} from '../../utils/routerHelper.class';
</button>
</form>
<div *ngIf="subject.length > 0" class=" uk-text-center ">
<span>Keywords: <span><a class="uk-icon-button" (click) = "subject = ''"><span aria-hidden="true" class=" clickable "><span class="clickable uk-icon">
<span>Keywords: {{subject}}<span><a class="uk-icon-button" (click) = "subject = ''"><span aria-hidden="true" class=" clickable "><span class="clickable uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></span></a></span>
</span>

View File

@ -3,8 +3,10 @@ import {Component} from '@angular/core';
@Component({
selector: 'deposit-datasets',
template: `
<div class="uk-container">
<deposit [compatibility]="'openaire____::21f8a223b9925c2f87c404096080b046||Registry of Research Data Repository'" [requestFor]="'Research Data'"></deposit>
<deposit-by-subject [compatibility]="'openaire____::21f8a223b9925c2f87c404096080b046||Registry of Research Data Repository'" [requestFor]="'Research Data'" ></deposit-by-subject>
<div>
`
})

View File

@ -8,7 +8,7 @@ import { Meta} from '../../angular2-meta';
@Component({
selector: 'deposit',
template: `
<div class="container uk-margin-top">
<div class="uk-margin-top">
<div class="page-header" >
<h2>Deposit {{requestFor}}</h2>
</div>

View File

@ -14,7 +14,7 @@ import {RouterHelper} from '../utils/routerHelper.class';
@Component({
selector: 'deposit-result',
template: `
<div class="container uk-margin-top">
<div class="uk-container uk-margin-top">
<div class="page-header" >
<h2>Deposit {{requestFor}}</h2>
</div>

View File

@ -3,11 +3,13 @@ import {Component} from '@angular/core';
@Component({
selector: 'deposit-publications',
template: `
<div class="uk-container">
<deposit [compatibility]="'openaire____::47ce9e9f4fad46e732cff06419ecaabb||OpenDOAR'" [requestFor]="'Publications'"></deposit>
<h3>Or locate data provider in map</h3>
<div class="uk-margin-top">
<i-frame [url]="mapUrl"width="100%" height="900"></i-frame>
</div>
</div>
`
})

View File

@ -6,9 +6,9 @@ import { Meta} from '../../angular2-meta';
selector: 'error',
template: `
<div class="container">
<h1>
<h2>
Bad karma: we can't find that page!
</h1>
</h2>
<br>
<p>

View File

@ -9,14 +9,7 @@
<div class="uk-text-large " *ngIf="organizationInfo.title.name && organizationInfo.title.name != organizationInfo.name ">{{organizationInfo.name}}</div>
<span class="uk-label custom-label label-blue " title="Type">Organization</span>
<span *ngIf="organizationInfo.country" class="uk-label custom-label label-grey " title="Country">{{organizationInfo.country}}</span>
<!--dl class="uk-description-list">
<dt *ngIf="organizationInfo.name">Name: </dt>
<dd *ngIf="organizationInfo.name">{{organizationInfo.name}}</dd>
<dt *ngIf="organizationInfo.country">Country: </dt>
<dd *ngIf="organizationInfo.country">{{organizationInfo.country}}</dd>
</dl-->
<ul class="uk-tab uk-visible@m" uk-tab="connect: #tab-content">
<li (click)="activeTab='Publications'">
<a>
@ -31,7 +24,7 @@
Projects
<span class="uk-badge uk-badge-notification">
<!--{{(searchingProjectsTabComponent)?searchingProjectsTabComponent.fetchProjects.totalResults:0}}-->
{{fetchProjects.totalResults}}
{{fetchProjects.searchUtils.totalResultsNoFilters}}
</span>
</a>
</li>
@ -66,7 +59,7 @@
<a>
Projects
<span class="uk-badge uk-badge-notification">
{{fetchProjects.totalResults}}
{{fetchProjects.searchUtils.totalResultsNoFilters}}
</span>
</a>
</li>
@ -101,7 +94,7 @@
</div>
</li>
<li class="uk-animation-fade">
<searchingProjectsTab *ngIf="projectsClicked" [fetchProjects]="fetchProjects"></searchingProjectsTab>
<searchingProjectsTab *ngIf="projectsClicked" [(fetchProjects)]="fetchProjects" [organizationId]="organizationId"></searchingProjectsTab>
</li>
<li class="uk-animation-fade">

View File

@ -88,6 +88,7 @@ export class OrganizationComponent {
this.organizationInfo=null;
this.updateTitle("Organization");
this.updateDescription("Organization, country, projects, search, repositories, open access");
this.projectsClicked = false;
this.organizationId = params['organizationId'];
console.info("Id is :"+this.organizationId);
@ -135,13 +136,8 @@ export class OrganizationComponent {
var refineFields:string [] = ["funderid"];
this.searchPublications();
//this.fetchProjects.getNumForEntity("organization", this.organizationId);
this.fetchProjects.getResultsForOrganizations(this.organizationId, "", 1, 0,refineFields);
if(this.fetchProjects.searchUtils.totalResults > 0) {
//this.activeTab = "Projects";
} else {
//this.searchDataprovidersInit();
}
this.fetchProjects.getResultsForOrganizations(this.organizationId, "", 1, 0,refineFields);
this.fetchDataproviders.getNumForEntity("organization", this.organizationId);
@ -296,7 +292,7 @@ export class OrganizationComponent {
}
} else {
title = true;
this._reportsService.getCSVResponse(url).subscribe(
data =>
{

View File

@ -20,10 +20,10 @@ import {RouterHelper} from '../utils/routerHelper.class';
<div *ngIf="fetchProjects.searchUtils.status == errorCodes.LOADING" class="uk-alert uk-alert-primary uk-animation-fade" role="alert">Loading...</div>
<div *ngIf="fetchProjects.searchUtils.totalResults > 0">
<div class = "uk-text-right" *ngIf = "fetchProjects.totalResults > 10">
<div class = "uk-text-right" *ngIf = "fetchProjects.searchUtils.totalResultsNoFilters > 10">
<a [queryParams]="routerHelper.createQueryParams(['organizationId', 'or'], [organizationId, 'and'])"
routerLinkActive="router-link-active" [routerLink]="linkToSearchProjects">
View all {{fetchProjects.totalResults}} results
View all {{fetchProjects.searchUtils.totalResultsNoFilters}} results
</a>
</div>
<div class= "searchPaging uk-panel uk-margin-top">
@ -41,7 +41,7 @@ import {RouterHelper} from '../utils/routerHelper.class';
</span>
</li>
<li *ngIf = "fetchProjects.searchUtils.totalResults !=fetchProjects.totalResults "> Filtered {{fetchProjects.searchUtils.totalResults}} results of {{fetchProjects.totalResults}} total results</li>
<li *ngIf = "fetchProjects.searchUtils.totalResults !=fetchProjects.searchUtils.totalResultsNoFilters "> Filtered {{fetchProjects.searchUtils.totalResults}} results of {{fetchProjects.searchUtils.totalResultsNoFilters}} total results</li>
<li></li>
</ul>
@ -55,12 +55,11 @@ import {RouterHelper} from '../utils/routerHelper.class';
export class SearchingProjectsTabComponent {
@Input() fetchProjects : FetchProjects;
public organizationId:string = "";
@Input() organizationId:string = "";
public page :number = 1;
public size :number = 10;
public linkToSearchProjects;
private filterQuery:string = "";
private sub: any;
public routerHelper:RouterHelper = new RouterHelper();
public errorCodes:ErrorCodes = new ErrorCodes();
@ -71,23 +70,15 @@ export class SearchingProjectsTabComponent {
ngOnInit() {
this.sub = this.route.queryParams.subscribe(params => {
this.organizationId = params['organizationId'];
if(this.organizationId) {
//this.fetchProjects = new FetchProjects(this._searchProjectsService);
this.linkToSearchProjects = OpenaireProperties.getLinkToAdvancedSearchProjects();//+"?organization="+this.organizationId+"or=and";;
if(this.fetchProjects.searchUtils.totalResults > 0) {
this.search(false,"");
}
}
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
search(refine:boolean, filterQuery:string){
var refineFields:string [] = ["funderid"];

View File

@ -1,42 +0,0 @@
import {Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions, URLSearchParams} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import { CacheService } from '../shared/cache.service';
import {OpenaireProperties} from '../utils/properties/openaireProperties';
import {User,Session,MyJWT} from './utils/helper.class';
@Injectable()
export class LoginService {
constructor(private http: Http, public _cache: CacheService) {}
authenticate (username: string, password: string):any {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
let body = JSON.stringify( {"username":username, "password":password} );
return this.http.post(OpenaireProperties.getLoginAPIURL(), body,options)
.map(res => <any> res.json())
.map(res =>this.parse(res['data']));
// let url = OpenaireProperties.getLoginAPIURL()+"?username="+username+"&password="+password;
// let key = url;
// return this.http.get(url)
// .map(res => <any> res.json())
// .map(res =>this.parse(res['data']));
}
parse(data:any){
return MyJWT.parseUserInfo(data);
}
}

View File

@ -13,7 +13,6 @@ export class LoginGuard implements CanActivate {
var user;
var loggedIn = false;
var errorCode = ErrorCodes.NOT_LOGGIN;
if(Session.isLoggedIn()){
loggedIn = true;
if(!Session.isValidAndRemove()){

View File

@ -2,10 +2,11 @@ import {Component, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router';
import {LoginService} from './login.service';
// import {LoginService} from './login.service';
import {User,Session} from './utils/helper.class';
import {RouterHelper} from '../utils/routerHelper.class';
import { Meta} from '../../angular2-meta';
import {OpenaireProperties} from '../utils/properties/openaireProperties';
@Component({
selector: 'user',
@ -14,7 +15,7 @@ import { Meta} from '../../angular2-meta';
<div *ngIf="!server" class="uk-margin-top uk-container uk-container-small uk-position-relative">
<form *ngIf="!loggedIn" class=" ">
<!--form *ngIf="!loggedIn" class=" ">
<h3>Welcome to OpenAIRE's Discover/ Share Portal</h3>
@ -32,15 +33,21 @@ import { Meta} from '../../angular2-meta';
<div class="uk-margin">
<button (click)="login()" class=" uk-button uk-button-primary">Login</button>
</div>
</form>
</form-->
<div *ngIf="errorCode == '1'" class="uk-alert uk-alert-warning">
The requested page requires authentication. Please login.
The requested page requires authentication. Please sign in.
<span *ngIf="!loggedIn">
<a class="loginLink" [href]="loginUrl" >Sign in</a>
</span>
</div>
<div *ngIf="errorCode == '2'" class="uk-alert uk-alert-warning">
You are not authorized to use the requested page
</div>
<div *ngIf="errorCode == '3'" class="uk-alert uk-alert-warning">
The session has expired. Please log in again or continue <a (click)="redirect();">browsing as a guest</a>.
The session has expired. Please sign in again or continue <a (click)="redirect();">browsing as a guest</a>.
<span *ngIf="!loggedIn">
<a class="loginLink" [href]="loginUrl" >Sign in</a>
</span>
</div>
<div *ngIf="!loggedIn && errorMessage.length > 0" class="uk-alert uk-alert-danger">{{errorMessage}}</div>
@ -65,8 +72,9 @@ export class UserComponent {
public errorCode: string = "";
public redirectUrl: string = "";
public routerHelper:RouterHelper = new RouterHelper();
public loginUrl= OpenaireProperties.getLoginURL();
constructor( private router: Router, private _loginService: LoginService,
constructor( private router: Router,
private route: ActivatedRoute, private _meta: Meta ) {
this._meta.setTitle("Login | OpenAIRE");
}
@ -128,29 +136,29 @@ export class UserComponent {
this.router.navigate(['/search/find']);
}
}
login() {
this.sublogin =this._loginService.authenticate(/*this.user*/this.username, this.password).subscribe(
data => {
this.user = data;
this.loggedIn = true;
this.username = "";
this.password = "";
this.errorCode = "";
this.redirect();
},
err => {
console.log(err);
if(err.status == "404") {
this.errorMessage = "Wrong username";
} else if(err.status == "401") {
this.errorMessage = "Wrong password";
}
this.username = "";
this.password = "";
this.errorCode = "";
}
);
}
// login() {
// this.sublogin =this._loginService.authenticate(/*this.user*/this.username, this.password).subscribe(
// data => {
// this.user = data;
// this.loggedIn = true;
// this.username = "";
// this.password = "";
// this.errorCode = "";
// this.redirect();
//
// },
// err => {
// console.log(err);
// if(err.status == "404") {
// this.errorMessage = "Wrong username";
// } else if(err.status == "401") {
// this.errorMessage = "Wrong password";
// }
// this.username = "";
// this.password = "";
// this.errorCode = "";
//
// }
// );
// }
}

View File

@ -4,14 +4,14 @@ import { FormsModule } from '@angular/forms';
import {UserComponent } from './user.component';
import { UserRoutingModule } from './user-routing.module';
import {LoginService} from './login.service';
// import {LoginService} from './login.service';
@NgModule({
imports: [
CommonModule, FormsModule,
UserRoutingModule
],
providers:[LoginService],
// providers:[LoginService],
declarations: [
UserComponent

View File

@ -2,17 +2,25 @@ import {Component, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {LoginService} from './login.service';
// import {LoginService} from './login.service';
import {User,Session} from './utils/helper.class';
import {RouterHelper} from '../utils/routerHelper.class';
import {OpenaireProperties} from '../utils/properties/openaireProperties';
@Component({
selector: 'user-mini',
template: `
<div *ngIf="!server" class=" custom-user-mini-panel uk-margin-top uk-margin-right uk-float-right">
<span *ngIf="loggedIn" ><a (click)="gotoUserPage();" >{{user.fullname}}</a></span>
<a *ngIf="!loggedIn" class="loginLink" (click)="gotoUserPage();" >Sign in</a>
<span *ngIf="loggedIn" >
<!--a (click)="gotoUserPage();" >{{user.fullname}}</a-->
<span>{{user.fullname}}</span> | <a class="loginLink" (click)="logOut();" >Log out</a>
</span>
<!--a *ngIf="!loggedIn" class="loginLink" (click)="gotoUserPage();" >Sign in</a-->
<span *ngIf="!loggedIn">
<a class="loginLink" [href]="loginUrl" >Sign in</a>
| <a class="loginLink" [href]="loginUrl" >Register</a>
</span>
</div>
`
@ -23,6 +31,7 @@ export class UserMiniComponent {
public loggedIn: boolean = false;
public server: boolean = true;
public routerHelper:RouterHelper = new RouterHelper();
public loginUrl= OpenaireProperties.getLoginURL();
public redirectUrl: string = "";
private baseUrl = "user-info";
@ -66,5 +75,12 @@ export class UserMiniComponent {
this.router.navigate([this.baseUrl]);
}
}
logOut(){
if(Session.isLoggedIn()){
Session.removeUser();
}
this.loggedIn = false;
this.user = new User();
}
}

View File

@ -16,3 +16,4 @@ export class ErrorCodes {
public static NOT_VALID:number =3;
}

View File

@ -1,6 +1,11 @@
import {StringUtils} from '../../utils/string-utils.class';
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
export class User {
email:string;
username: string;
firstname: string;
lastname: string;
id: string;
fullname: string;
expirationDate: number;
@ -10,16 +15,16 @@ export class User {
}
export class Session{
public static setUser(user:User): User {
localStorage.setItem("user", JSON.stringify(user));
return user;
}
// public static setUser(user:User): User {
//
// localStorage.setItem("user", JSON.stringify(user));
//
// return user;
// }
public static removeUser() {
if(Session.isLoggedIn()){
localStorage.removeItem("user");
COOKIE.deleteCookie(COOKIE.cookieName_id)
}
}
public static getUser():User {
@ -30,24 +35,53 @@ export class Session{
}
}
public static isLoggedIn(): boolean {
var loggedIn:boolean = false;
var user:User = null;
var cookie= COOKIE.getCookie(COOKIE.cookieName_u);
if( typeof localStorage !== 'undefined') {
if(localStorage.getItem("user")) {
user = JSON.parse(localStorage.getItem("user"));
if(user && user.id){
if(user && (user.fullname != null || user.lastname !=null || user.firstname !=null)){
loggedIn = true;
}else if(cookie != null && this.getUserFromCookie()!= null){
loggedIn = true
}else{
loggedIn = false;
}
}else{
if(cookie != null && this.getUserFromCookie()!= null){
loggedIn = true
}else{
loggedIn = false;
}
}
}else{
loggedIn = false;
loggedIn = false;
}
return loggedIn;
}
public static getUserFromCookie():User{
var cookie= COOKIE.getCookie(COOKIE.cookieName_u);
if(cookie != null){
var user:User = MyJWT.parseUserInfo(cookie);
if( typeof localStorage !== 'undefined') {
localStorage.setItem("user", JSON.stringify(user));
if(user && user.email){
COOKIE.deleteCookie(COOKIE.cookieName_u); // delete cookie to avoid transfer through requests
return user;
}else{
return null;
}
}else{
return null;
}
}else{
return null;
}
}
public static getUserJwt():string {
if(Session.isLoggedIn()){
return Session.getUser().jwt;
@ -74,7 +108,7 @@ export class Session{
if(Session.isLoggedIn()){
var expires = Session.getUser().expirationDate;
var now = new Date().getTime() / 1000;
console.log(" is still valid ? "+(now +0 < expires) +" Remaining:"+ (expires - (now+0))+ " now is:"+now + "expires at:"+expires);
// console.log(" is still valid ? "+(now +0 < expires) +" Remaining:"+ (expires - (now+0))+ " now is:"+now + "expires at:"+expires);
return now +0 < expires;
}
return false;
@ -95,32 +129,65 @@ export class Session{
}
export class MyJWT{
private static validateJWTFormat(data){
if(data == null || (data.indexOf(".") !=-1 && data.split('.').length != 3)){
return false;
if(data != null && (data.indexOf(".") !=-1 && data.split('.').length == 3)){
return true;
}
return true;
return false;
}
private static getPayload(data){
var payload = data.split('.')[1];
return atob(payload);
return StringUtils.b64DecodeUnicode(payload);
}
public static parseUserInfo(data: any): User {
if(this.validateJWTFormat(data)){
var info = JSON.parse(this.getPayload(data));
}else{
return null;
}
var user: User = new User();
user.username = info.sub;
user.firstname = (StringUtils.URIDecode(info.firstname)).replace("+"," ");
user.lastname = (StringUtils.URIDecode(info.lastname)).replace("+"," ");
user.email = info.email;
user.id = info.userId;
user.fullname = info.fullname;
user.role = info.role;
// user.id = info.userId;
user.fullname = (StringUtils.URIDecode(info.fullname)).replace("+"," ");
user.role = info.role;;
user.jwt = data;
user.expirationDate = info.exp;
localStorage.setItem("user", JSON.stringify(user));
return user;
}
}
export class COOKIE{
public static cookieName_u:string="XCsrfToken";
public static cookieName_id:string="AccessToken";
public static getCookie(name: string) : string {
if(typeof document == 'undefined'){
return null;
}
let ca: Array<string> = document.cookie.split(';');
let caLen: number = ca.length;
let cookieName = `${name}=`;
let c: string;
for (let i: number = 0; i < caLen; i += 1) {
c = ca[i].replace(/^\s+/g, '');
if (c.indexOf(cookieName) == 0) {
return c.substring(cookieName.length, c.length);
}
}
return null;
}
public static deleteCookie(name) {
this.setCookie(name, '', -1);
}
public static setCookie(name: string, value: string, expireDays: number, path: string = '/') {
let d:Date = new Date();
d.setTime(d.getTime() + expireDays * 24 * 60 * 60 * 1000);
let expires:string = `expires=${d.toUTCString()}`;
// let cpath:string = path ? `; path=${path}` : '';
document.cookie = name+'='+value+'; path='+path+'; domain='+OpenaireProperties.getCookieDomain()+';';
}
}

View File

@ -16,6 +16,7 @@ import {ExportCSVComponent} from '../../utils/exportCSV.class';
template: `
<search-page pageTitle="OpenAIRE Content Providers"
formPlaceholderText = "Search for OpenAIRE Content Providers"
type="datasources" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" [showResultCount]=false

View File

@ -16,6 +16,7 @@ import {ExportCSVComponent} from '../../utils/exportCSV.class';
template: `
<search-page pageTitle="Entity Registries"
formPlaceholderText = "Search for Entity Registries"
type="datasources" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" [showResultCount]=false

View File

@ -16,6 +16,7 @@ import {ExportCSVComponent} from '../../utils/exportCSV.class';
template: `
<search-page pageTitle="OpenAIRE Journals"
formPlaceholderText = "Search for OpenAIRE Journals"
type="datasources" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" [showResultCount]=false

View File

@ -27,17 +27,16 @@ import {RouterHelper} from '../../utils/routerHelper.class';
encapsulation: ViewEncapsulation.Emulated,
selector: 'search-find',
template: `
<div class="uk-margin-top">
<div class="page-header">
<h1>{{pageTitle}}</h1>
</div>
<div >
<div class="">
<div class="uk-width-1-1 uk-margin uk-padding uk-panel uk-background-muted">
<search-form [(keyword)]=keyword (keywordChange)="keywordChanged($event)"></search-form>
<div class="uk-width-1-1 ">
<div class="uk-background-norepeat uk-background-cover uk-section uk-flex uk-flex-middle" style="background-image: url('./assets/formImageLight.jpg'); box-sizing: border-box; height: 250px">
<div class="uk-width-1-1">
<search-form [(keyword)]=keyword (keywordChange)="keywordChanged($event)" placeholderText="Search for research results, projects, content providers, organizations in OpenAIRE information space"></search-form>
</div>
</div>
</div>
<div class=" uk-margin-top uk-width-1-1">
<div class=" uk-margin-large-top uk-container">
<ul class=" uk-tab uk-visible@m" uk-tab="connect: #searchtabs; animation: uk-animation-fade">
<li (click)="searchPublications()" >
@ -229,8 +228,7 @@ import {RouterHelper} from '../../utils/routerHelper.class';
</div>
</div>
`
`
})
export class SearchComponent {
public sub: any;
@ -289,19 +287,10 @@ public subPub;public subData;public subProjects;public subOrg; public subDataPr;
this._meta.updateProperty("og:description", description);
this._meta.updateProperty("og:title", title);
this._meta.updateProperty("og:url", url);
// console.log("Constr PORT:"+process.env.PORT);
// if (typeof document !== 'undefined') {
//
// console.log("Constr Cookie:"+document.cookie);
// }
}
public ngOnInit() {
// console.log("init PORT:"+process.env.PORT);
// if (typeof document !== 'undefined') {
//
// console.log("Init Cookie:"+document.cookie);
// }
this.sub = this.route.queryParams.subscribe(params => {
this.keyword = (params['keyword'])?params['keyword']:"";
if(this.keyword !=null && this.keyword.length > 0){

View File

@ -14,9 +14,9 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
selector: 'advanced-search-page',
template: `
<div class="uk-margin-top">
<div class="uk-container uk-margin-top">
<div class="page-header">
<h1>{{pageTitle}}</h1>
<h2>{{pageTitle}}</h2>
</div>
<div>
<a *ngIf = "simpleSearchLink && simpleSearchLink.length > 0" routerLinkActive="router-link-active" [routerLink]=simpleSearchLink [class]="(disableForms)?'uk-float-right uk-disabled uk-link-muted':'uk-float-right'" >Simple search <span class="uk-icon">

View File

@ -4,18 +4,23 @@ import {Observable} from 'rxjs/Observable';
@Component({
selector: 'search-form',
template: `
<form [class]="(isDisabled)?'uk-margin uk-text-center uk-margin-top uk-disabled':'uk-margin uk-text-center uk-margin-top'">
<input type="text" class="uk-input uk-width-1-2" placeholder="Type keywords..." aria-describedby="sizing-addon2" [(ngModel)]="keyword" name="keyword" >
<input type="text" class="uk-input uk-width-1-2" [placeholder]="placeholderText" aria-describedby="sizing-addon2" [(ngModel)]="keyword" name="keyword" >
<button (click)="keywordChanged()" type="submit" class=" uk-button uk-button-default"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="search" ratio="1"><circle fill="none" stroke="#000" stroke-width="1.1" cx="9" cy="9" r="7"></circle><path fill="none" stroke="#000" stroke-width="1.1" d="M14,14 L18,18 L14,14 Z"></path></svg>
</span>Search</button>
</form>
`
})
export class SearchFormComponent {
@Input() isDisabled: boolean = false;
@Input() keyword: string = '';
@Input() generalSearch: boolean = false;
@Input() placeholderText: string = "Type keywords";
@Output() keywordChange = new EventEmitter();

View File

@ -18,49 +18,54 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
selector: 'search-page',
template: `
<div class="uk-margin-top">
<div class="page-header">
<h1>{{pageTitle}}</h1>
</div>
<div>
<div *ngIf="showRefine" >
<div class="uk-width-1-1 uk-margin uk-padding uk-panel uk-background-muted">
<search-form [isDisabled]="disableForms" [(keyword)]="searchUtils.keyword" (keywordChange)="keywordChanged($event)"></search-form>
<div *ngIf="isFiltered()" class = " uk-text-center ">
<span *ngIf = "searchUtils.keyword.length > 0">Keywords: <span [innerHtml]="searchUtils.keyword"></span><a (click) = "clearKeywords() " [class]="(disableForms)?'uk-icon-button uk-disabled':'uk-icon-button'"><span class=" clickable " aria-hidden="true"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></span></a>
</span>
<span *ngFor="let filter of filters " >
<span *ngIf = "filter.countSelectedValues > 0"> {{filter.title}}:
<span *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " ><span [innerHtml]="value.name"></span><a (click) = "removeFilter(value, filter) " [class]="(disableForms)?'uk-icon-button uk-disabled':'uk-icon-button'"><span class=" clickable" aria-hidden="true"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></span></a>
<span *ngIf="!end">, </span>
<div class="">
<!--div class="page-header">
<h2>{{pageTitle}}</h2>
</div-->
<!--div class="uk-width-1-1 uk-margin uk-padding uk-panel uk-background-muted"-->
<div class="uk-background-norepeat uk-background-cover uk-section uk-flex uk-flex-middle" style="background-image: url('./assets/formImage.jpg'); box-sizing: border-box; height: 250px">
<div class="uk-width-1-1">
<div class="uk-width-1-1">
<search-form [isDisabled]="disableForms" [(keyword)]="searchUtils.keyword" (keywordChange)="keywordChanged($event)" [placeholderText]="formPlaceholderText"s></search-form>
</div>
<div class="uk-width-1-1 uk-light">
<!--link to advanced search -->
<a *ngIf = "advancedSearchLink && advancedSearchLink.length > 0" routerLinkActive="router-link-active" [class]="(disableForms)?'uk-float-right uk-light uk-disabled uk-link-muted':'uk-float-right uk-light'" [routerLink]=advancedSearchLink >More search options <span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
</span>
</a>
<div *ngIf="isFiltered()" class = " uk-text-center ">
<span *ngIf = "searchUtils.keyword.length > 0">Keywords: <span [innerHtml]="searchUtils.keyword"></span><a (click) = "clearKeywords() " [class]="(disableForms)?'uk-icon-button uk-disabled':'uk-icon-button'"><span class=" clickable " aria-hidden="true"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></span></a>
</span>
<span *ngFor="let filter of filters " >
<span *ngIf = "filter.countSelectedValues > 0"> {{filter.title}}:
<span *ngFor="let value of getSelectedValues(filter); let i = index; let end = last; " ><span [innerHtml]="value.name"></span><a (click) = "removeFilter(value, filter) " [class]="(disableForms)?'uk-icon-button uk-disabled':'uk-icon-button'"><span class=" clickable" aria-hidden="true"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></span></a>
<span *ngIf="!end">, </span>
</span>
</span>
</span>
</span>
<!--span>
Clear All
<a (click)="clearFilters()" class="uk-icon-button uk-text-right"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></a></span-->
<a (click)="clearFilters()" [class]="(disableForms)?'uk-disabled uk-link-muted':''">
Clear All
</a>
</div>
<div *ngIf= "showUnknownFilters" class = " uk-text-center ">
<a (click) = "clearFilters() " >Try new Query</a>
</div>
<a *ngIf = "advancedSearchLink && advancedSearchLink.length > 0" routerLinkActive="router-link-active" [class]="(disableForms)?'uk-float-right uk-disabled uk-link-muted':'uk-float-right'" [routerLink]=advancedSearchLink >More search options <span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="chevron-right" ratio="1"><polyline fill="none" stroke="#000" stroke-width="1.03" points="7 4 13 10 7 16"></polyline></svg>
</span></a>
</div>
<a (click)="clearFilters()" [class]="(disableForms)?'uk-disabled uk-link-muted':''">
Clear All
</a>
</div>
</div>
<div *ngIf= "showUnknownFilters" class = " uk-text-center uk-light">
<a (click) = "clearFilters() " >Try new Query</a>
</div>
</div>
</div>
<div class="uk-container">
<div class="uk-grid uk-width-1-1 uk-margin">
<div class="uk-offcanvas-content uk-hidden@m">
<div *ngIf="showRefine" class="uk-offcanvas-content uk-hidden@m">
<a href="#offcanvas-usage" uk-toggle><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"><rect x="6" y="4" width="12" height="1"></rect><rect x="6" y="9" width="12" height="1"></rect><rect x="6" y="14" width="12" height="1"></rect><rect x="2" y="4" width="2" height="1"></rect><rect x="2" y="9" width="2" height="1"></rect><rect x="2" y="14" width="2" height="1"></rect></svg></a>
@ -75,19 +80,14 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
</div>
<div class=" search-filters uk-width-1-4@l uk-width-1-4@m uk-width-1-1@s uk-visible@m">
<div *ngIf="showRefine" class=" search-filters uk-width-1-4@l uk-width-1-4@m uk-width-1-1@s uk-visible@m">
<search-filter *ngFor="let filter of filters " [isDisabled]="disableForms" [filter]="filter" [showResultCount]=showResultCount (change)="filterChanged($event)" (toggleModal)="toggleModal($event)"></search-filter>
</div>
<div class="uk-width-3-4@m uk-width-3-4@l uk-width-1-1@s uk-first-column" >
<div [class]="(showRefine)?'uk-width-3-4@m uk-width-3-4@l uk-width-1-1@s uk-first-column':''" >
<search-paging [type]="type" [(searchUtils)] = "searchUtils" [(results)] = "results" [(baseUrl)] = "baseUrl" [(parameterNames)] = "parameterNames" [(parameterValues)] = "parameterValues" ></search-paging>
<search-download [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults" (downloadClick)="downloadClicked($event)"></search-download>
<!--p class="uk-text-right" *ngIf="totalResults <= 10000">
<span class="clickable" (click)="downloadfile(downloadURLAPI+type+'?format=csv&page=0&size='+totalResults+csvParams,type+'-report-'+totalResults)">
<span aria-hidden="true" class="glyphicon glyphicon-download"></span>
<span class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="download" ratio="1"><polyline fill="none" stroke="#000" points="14,10 9.5,14.5 5,10"></polyline><rect x="3" y="17" width="13" height="1"></rect><line fill="none" stroke="#000" x1="9.5" y1="13.91" x2="9.5" y2="3"></line></svg></span> Results (CSV)
</span>
</p-->
<p *ngIf="tableViewLink" class="uk-text-right">
<a routerLinkActive="router-link-active" [class]="(disableForms)?'uk-disabled uk-link-muted':''" [routerLink]=tableViewLink >
<span class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="table" ratio="1"><rect x="1" y="3" width="18" height="1"></rect><rect x="1" y="7" width="18" height="1"></rect><rect x="1" y="11" width="18" height="1"></rect><rect x="1" y="15" width="18" height="1"></rect></svg></span>
@ -101,47 +101,20 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
[type]="entityType" [urlParam]="urlParam"
[showLoading]="true">
</search-result>
<!--table-view *ngIf="tableView"
[results]="results"
[status]=searchUtils.status
[type]="entityType" [urlParam]="urlParam"
[showLoading]="true">
</table-view-->
</div>
</div>
</div>
</div>
<div *ngIf="!showRefine" >
<search-form [isDisabled]="disableForms" [(keyword)]="searchUtils.keyword" (keywordChange)="keywordChanged($event)"></search-form>
<search-paging [type]="type" [(searchUtils)] = "searchUtils" [(results)] = "results" [(baseUrl)] = "baseUrl" [(parameterNames)] = "parameterNames" [(parameterValues)] = "parameterValues"></search-paging>
<search-download [type]="csvPath" [csvParams]="csvParams" [totalResults]="searchUtils.totalResults" (downloadClick)="downloadClicked($event)"></search-download>
<search-result *ngIf="!tableView"
[results]="results"
[status]=searchUtils.status
[type]="entityType" [urlParam]="urlParam"
[showLoading]="true">
</search-result>
<!--table-view *ngIf="tableView"
[results]="results"
[status]=searchUtils.status
[type]="entityType" [urlParam]="urlParam"
[showLoading]="true">
</table-view-->
</div>
</div>
</div>
<!--modal-loading [message]= "'Loading results...'"></modal-loading-->
<!--modal-search-filter [filter]="currentFilter" [showResultCount]=showResultCount (modalChange)="filterChanged($event)"></modal-search-filter-->
`
})
export class SearchPageComponent {
@Input() pageTitle = "";
@Input() formPlaceholderText = "Type Keywords...";
@Input() results = [];
@Input() filters = [];
@Input() type:string = "";

View File

@ -18,9 +18,9 @@ import {ContentProvidersDatatablePipe} from '../../utils/pipes/contentProvidersD
selector: 'search-page-table',
template: `
<div class="uk-margin-top">
<div class="uk-container uk-margin-top">
<div class="page-header">
<h1>{{pageTitle}}</h1>
<h2>{{pageTitle}}</h2>
</div>
<div>
<div *ngIf="showRefine" >

View File

@ -5,5 +5,6 @@ export class SearchUtilsClass{
keyword:string = "";
baseUrl:string = "";
totalResults = 0;
totalResultsNoFilters:number; // for organization landing - tab with projects
}

View File

@ -14,7 +14,8 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
selector: 'search-dataproviders',
template: `
<search-page pageTitle="Search Dataproviders"
<search-page pageTitle="Search Content Providers"
formPlaceholderText = "Search for Content Providers"
type="data providers" entityType="dataprovider" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils" [baseUrl] = "baseUrl"
(queryChange)="queryChanged($event)" (downloadClick)="downloadClicked($event)"

View File

@ -15,7 +15,8 @@ import {DOI} from '../../utils/string-utils.class';
selector: 'search-datasets',
template: `
<search-page pageTitle="Search Datasets"
<search-page pageTitle="Search Research Data"
formPlaceholderText = "Search for Research Data"
type="datasets" entityType="dataset" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"

View File

@ -14,6 +14,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
template: `
<search-page pageTitle="Search Organizations"
formPlaceholderText = "Search for Organizations"
type="organizations" entityType="organization" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"

View File

@ -14,6 +14,7 @@ import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
template: `
<search-page pageTitle="Search Projects"
formPlaceholderText = "Search for Projects"
type="projects" entityType="project" [(filters)] = "filters"
[(results)] = "results" [(searchUtils)] = "searchUtils"
[baseUrl] = "baseUrl" (queryChange)="queryChanged($event)"

View File

@ -18,6 +18,7 @@ import {DOI} from '../../utils/string-utils.class';
template: `
<search-page pageTitle="Search Publications"
formPlaceholderText = "Search for Publications"
type="publications" entityType="publication"
[(filters)] = "filters" [(results)] = "results"
[(searchUtils)] = "searchUtils" [(baseUrl)] = baseUrl

View File

@ -43,9 +43,9 @@ import {Session} from '../login/utils/helper.class';
</ul>
</li>
<li class="uk-nav-header uk-parent">
Data Providers
Content Providers
<ul class="uk-nav-sub">
<li><a routerLinkActive="uk-link" routerLink="/search/content-providers" class="uk-offcanvas-close custom-offcanvas-close" >Compatible Data Providers</a></li>
<li><a routerLinkActive="uk-link" routerLink="/search/content-providers" class="uk-offcanvas-close custom-offcanvas-close" >OpenAIRE Content Providers</a></li>
<li><a routerLinkActive="uk-link" routerLink="/search/entity-registries" class="uk-offcanvas-close custom-offcanvas-close" >Entity Registries</a></li>
<li><a routerLinkActive="uk-link" routerLink="/search/journals" class="uk-offcanvas-close custom-offcanvas-close" >Journals</a></li>
</ul>
@ -140,12 +140,12 @@ import {Session} from '../login/utils/helper.class';
</div>
</li>
<li class="uk-parent">
<a routerLinkActive="uk-link" routerLink="/search/content-providers" class="" aria-expanded="false">Data Providers</a>
<a routerLinkActive="uk-link" routerLink="/search/content-providers" class="" aria-expanded="false">Content Providers</a>
<div class="uk-navbar-dropdown uk-navbar-dropdown-bottom-left" style="top: 80px; left: 113px;" id="dpMenu" (click)="onClick('dpMenu')">
<div class="uk-navbar-dropdown-grid uk-child-width-1-1 uk-grid uk-grid-stack" uk-grid="">
<div class="uk-first-column">
<ul class="uk-nav uk-navbar-dropdown-nav">
<li><a routerLinkActive="uk-link" routerLink="/search/content-providers">Compatible Data Providers</a></li>
<li><a routerLinkActive="uk-link" routerLink="/search/content-providers">OpenAIRE Content Providers</a></li>
<li><a routerLinkActive="uk-link" routerLink="/search/entity-registries">Entity Registries</a></li>
<li><a routerLinkActive="uk-link" routerLink="/search/journals">Journals</a></li>
</ul>

View File

@ -6,7 +6,6 @@ export class FetchProjects{
public results =[];
public filters; // for getResultsForOrganizations
public totalResults; // for getResultsForOrganizations // this is total results with the initial query - before filtering
public funders:any = []; // for getResultsForOrganizations // this is filled with the initial query - before filtering
public sub: any;
@ -144,8 +143,8 @@ export class FetchProjects{
}
}
if(!this.totalResults && filterquery == ""){
this.totalResults = this.searchUtils.totalResults;
if(filterquery == ""){
this.searchUtils.totalResultsNoFilters = this.searchUtils.totalResults;
this.funders = [];
for(var i = 0; i < this.filters.length; i++){
console.log("this.filters[i].filterId:"+this.filters[i].filterId);

View File

@ -89,6 +89,12 @@ export class OpenaireProperties {
private static vocabulariesAPI ="https://beta.services.openaire.eu/provision/mvc/vocabularies/";
private static loginUrl ="http://mpagasas.di.uoa.gr:8080/uoa-user-management-1.0.0-SNAPSHOT/openid_connect_login";
private static loginUrl_pm ="https://beta.services.openaire.eu/uoa-user-management/openid_connect_login";
private static cookieDomain =".di.uoa.gr";
private static cookieDomain_pm =".openaire.eu";
public static getBaseLink():string{
return this.baseLink;
}
@ -308,6 +314,20 @@ export class OpenaireProperties {
public static getVocabulariesAPI():string{
return this.vocabulariesAPI;
}
public static getLoginURL():string{
if(this.productionMode){
return this.loginUrl_pm;
}else{
return this.loginUrl;
}
}
public static getCookieDomain():string{
if(this.productionMode){
return this.cookieDomain_pm;
}else{
return this.cookieDomain;
}
}
}
export class ErrorCodes {
public LOADING = 0;

View File

@ -119,4 +119,11 @@ export class StringUtils{
public static URIDecode(params: string):string {
return decodeURIComponent(params);
}
public static b64DecodeUnicode(str) {
return decodeURIComponent(Array.prototype.map.call(atob(str), function(c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB