fix dropdown change in orcid tab of claim| add free guard in every route with no authentication required | add '*' route in server in order to show erro page not json-no contnet| Claims: get user mail from Session -jwt,tidy up display claims component (myclaims, claims)| remove folder src/app/home | LOgin: change login method to post, redirect after login/logout using queryparams of the current page, add Session helper class

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@46792 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2017-04-12 12:22:17 +00:00
parent 12aa6406eb
commit 490752b08e
82 changed files with 438 additions and 354 deletions

View File

@ -84,8 +84,8 @@
<span class="dropdown"> <span class="dropdown">
<select [(ngModel)]="authorId" name="select_author" >authorIds <select [(ngModel)]="authorId" name="select_author" (ngModelChange)="getOrcidResultsById(authorId)" >authorIds
<option *ngFor=" let item of authorIds let i = index" [value]="authorIds[i]" (click)="getOrcidResultsById(i)" >{{authorGivenNames[i]}} {{authorFamilyNames[i]}} : {{item}} </option> <option *ngFor=" let item of authorIds let i = index" [value]="authorIds[i]">{{authorGivenNames[i]}} {{authorFamilyNames[i]}} : {{item}} </option> <!-- (click)="getOrcidResultsById(i)" -->
</select> </select>
</span> </span>

View File

@ -270,7 +270,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
this.authorGivenNames, this.authorFamilyNames).subscribe( this.authorGivenNames, this.authorFamilyNames).subscribe(
data => { data => {
if(data != null && data == true) { if(data != null && data == true) {
this.getOrcidResultsById(0); this.getOrcidResultsByIndex(0);
} }
this.orcidStatus = this.errorCodes.NONE; this.orcidStatus = this.errorCodes.NONE;
@ -299,7 +299,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
this.authorGivenNames, this.authorFamilyNames).subscribe( this.authorGivenNames, this.authorFamilyNames).subscribe(
data => { data => {
if(data != null && data == true) { if(data != null && data == true) {
this.getOrcidResultsById(0); this.getOrcidResultsByIndex(0);
}else{ }else{
this.orcidStatus = this.errorCodes.ERROR; this.orcidStatus = this.errorCodes.ERROR;
} }
@ -313,12 +313,20 @@ private getCrossrefResults (term: string, size : number, page : number) {
} }
private getOrcidResultsById (index:number) { private getOrcidResultsByIndex (index:number) {
if(this.authorIds.length > index) { if(this.authorIds.length > index) {
this.orcidStatus = this.errorCodes.LOADING; this.orcidStatus = this.errorCodes.LOADING;
let id = this.authorIds[index]; let id = this.authorIds[index];
this.authorGivenName = this.authorGivenNames[index]; this.authorGivenName = this.authorGivenNames[index];
this.authorFamilyName = this.authorFamilyNames[index]; this.authorFamilyName = this.authorFamilyNames[index];
this.getOrcidResultsById(id);
}
}
private getOrcidResultsById (id:string) {
var index = this.authorIds.indexOf(id);
this.authorGivenName = this.authorGivenNames[index];
this.authorFamilyName = this.authorFamilyNames[index];
this.authorId = id; this.authorId = id;
console.info("getOrcidResultsById: "+id); console.info("getOrcidResultsById: "+id);
this._searchOrcidService.searchOrcidPublications(id).subscribe( this._searchOrcidService.searchOrcidPublications(id).subscribe(
@ -352,7 +360,7 @@ private getCrossrefResults (term: string, size : number, page : number) {
} }
); );
}
} }
/* /*

View File

@ -5,6 +5,7 @@ import {ActivatedRoute, Router} from '@angular/router';
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';
import {Session} from '../../../login/utils/helper.class';
@Component({ @Component({
@ -19,14 +20,15 @@ export class DisplayClaimsComponent {
ngOnInit() { ngOnInit() {
this.sub = this.route.queryParams.subscribe(params => { this.sub = this.route.queryParams.subscribe(params => {
if( this.myClaims == 'true' ){ if( this.myClaims){
this.fetchBy = "User"; this.fetchBy = "User";
this.fetchId = Session.getUserEmail();
}else{ }else{
this.fetchBy = params['fetchBy']; this.fetchBy = params['fetchBy'];
this.fetchBy = (this.types.indexOf(this.fetchBy) != -1)? this.fetchBy:'All'; this.fetchBy = (this.types.indexOf(this.fetchBy) != -1)? this.fetchBy:'All';
this.fetchId = params['fetchId']; this.fetchId = params['fetchId'];
this.fetchId=this.fetchId?this.fetchId:''; this.fetchId = this.fetchId?this.fetchId:'';
} }
@ -43,47 +45,16 @@ export class DisplayClaimsComponent {
this.getClaims(); this.getClaims();
}); });
// this.sub = this.route.params.subscribe(params => {
// console.info(this.isAdmin+" "+this.myClaims+" Fetch by: "+this.fetchBy+" Fetch id: "+this.fetchId);
// if( this.myClaims == 'true' ){
// console.info("Is myclaims");
// this.fetchBy = "User";
// }else{
// console.info("Is admin");
//
// console.info(this.isAdmin);
//
// this.fetchBy = params['fetchBy'];
// this.fetchBy = (this.types.indexOf(this.fetchBy) != -1)? this.fetchBy:'All';
// this.fetchId = params['fetchId'];
// console.info("Fetch by:"+this.fetchBy+"Fetch id:"+this.fetchId);
// this.fetchId=this.fetchId?this.fetchId:'';
//
// }
//
// console.info(this.isAdmin+" "+this.myClaims+" Fetch by: "+this.fetchBy+" Fetch id: "+this.fetchId);
// let page = (params['page']=== undefined)?1:+params['page'];
// let size = (params['size']=== undefined)?10:+params['size'];
//
// this.keyword = (params['keyword']?params['keyword']:"");
// this.inputkeyword = this.keyword;
// this.page = ( page <= 0 ) ? 1 : page;
// this.size = ( size <= 0 ) ? 10 : size;
// this.entityTypes = []//(params['types']?params['types']:[]);
// this.setTypes(params['types']); // check the appropriate checkboxes
// this.setSortby(params['sort']);
// this.getClaims();
// console.info("params: "+params['page']+" page "+page +" this.page: "+this.page );
// });
} }
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
sub: any; sub: any;
//string because comes as input from component directive //string because comes as input from component directive
@Input() enableDelete: string = 'false'; @Input() enableDelete: boolean = false;
@Input() myClaims: string= 'false' ; @Input() myClaims: boolean= false ;
@Input() isAdmin:string = 'false'; @Input() isAdmin:boolean = false;
page : number; page : number;
size:number; size:number;
sizes = [10,20,30,50]; sizes = [10,20,30,50];
@ -198,9 +169,15 @@ export class DisplayClaimsComponent {
this.getClaims(); this.getClaims();
} }
getParameters(){ getParameters(){
let params={ page: this.page, size: this.size, types: this.entityTypes, fetchBy: this.fetchBy, fetchId:this.fetchId, keyword : this.keyword, sort: this.getSortby() }; var params = {}
if(this.myClaims){
params={ page: this.page, size: this.size, types: this.entityTypes, keyword : this.keyword, sort: this.getSortby() };
}else{
params={ page: this.page, size: this.size, types: this.entityTypes, fetchBy: this.fetchBy, fetchId:this.fetchId, keyword : this.keyword, sort: this.getSortby() };
}
return params; return params;
} }
getParametersString(){ getParametersString(){
var params=''; var params='';
params+=(this.page==1?"":(params.length>0?'&':'')+"page="+this.page); params+=(this.page==1?"":(params.length>0?'&':'')+"page="+this.page);
@ -212,7 +189,7 @@ export class DisplayClaimsComponent {
} }
params+=(types.length>0)?"types="+types:""; params+=(types.length>0)?"types="+types:"";
if(this.isAdmin === 'true'){ if(this.isAdmin ){
params+=(this.fetchBy=='All'?"":(params.length>0?'&':'')+"fetchBy="+this.fetchBy); params+=(this.fetchBy=='All'?"":(params.length>0?'&':'')+"fetchBy="+this.fetchBy);
params+=(this.fetchId==''?"":(params.length>0?'&':'')+"fetchId="+this.fetchId); params+=(this.fetchId==''?"":(params.length>0?'&':'')+"fetchId="+this.fetchId);
} }
@ -294,24 +271,6 @@ export class DisplayClaimsComponent {
this.entityTypes.push('context'); this.entityTypes.push('context');
} }
// if(this.publicationCB == true && this.datasetCB == true && this.contextCB == true && this.projectCB == true ){
// this.entityTypes="";
// }else{
// this.entityTypes = "";
// if(this.publicationCB == true){
// this.entityTypes = "publication";
// }
// if(this.datasetCB == true){
// this.entityTypes += (this.entityTypes.length > 0?",":"")+"dataset";
// }
// if(this.contextCB == true){
// this.entityTypes += (this.entityTypes.length > 0?",":"")+"context";
// }
// if(this.projectCB == true){
// this.entityTypes += (this.entityTypes.length > 0?",":"")+"project";
// }
// }
// console.debug("Type changed: "+this.entityTypes+" "+this.publicationCB+ this.datasetCB + this.contextCB + this.projectCB);
this.goTo(); this.goTo();
} }
setTypes(types:string){ setTypes(types:string){

View File

@ -5,20 +5,15 @@ import {Observable} from 'rxjs/Observable';
@Component({ @Component({
selector: 'claims-admin', selector: 'claims-admin',
template: ` template: `
<div *ngIf="user" class="container"> <div class="container">
<div class="page-header"> <div class="page-header">
<h1> Claims Administrator </h1> <h1> Claims Administrator </h1>
</div> </div>
<div> <div>
<div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div> <div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div>
<displayClaims enableDelete="false" myClaims="false" isAdim="true"></displayClaims> <displayClaims [enableDelete]=false [myClaims]=false [isAdmin]=true></displayClaims>
</div> </div>
</div> </div>
<div *ngIf="!user" class="container">
TODO login
</div>
`, `,
}) })
@ -26,11 +21,6 @@ export class ClaimsAdminComponent {
constructor ( ) { constructor ( ) {
} }
user:string="argirok@di.uoa.gr";
ngOnInit() { ngOnInit() {
} }
} }

View File

@ -51,7 +51,7 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service';
(showChange)="showChange($event)" > </claim-selected-projects> (showChange)="showChange($event)" > </claim-selected-projects>
</div> </div>
<claim-selected-results *ngIf=" linkTo =='result' " title="with other Research Results" [results]="results" [showSearch]="show=='claim'? false: true" [showAccessRights]="show=='claim'? true: false" <claim-selected-results *ngIf=" linkTo =='result' " title="with other Research Results" [results]="results" [showSearch]="show=='claim'? false: true" [showAccessRights]="show=='claim'? true: false"
bulkMode=false> [bulkMode]=false>
</claim-selected-results> </claim-selected-results>
</div> </div>

View File

@ -5,7 +5,7 @@ import {ClaimsService} from '../../claim-utils/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';
import {Md5} from 'ts-md5/dist/md5'; import {Md5} from 'ts-md5/dist/md5';
import {Session} from '../../../login/utils/helper.class';
@Component({ @Component({
selector: 'claim-insert', selector: 'claim-insert',
template: ` template: `
@ -19,7 +19,7 @@ import {Md5} from 'ts-md5/dist/md5';
<modal-loading [message]= "'Please wait...'"></modal-loading> <modal-loading [message]= "'Please wait...'"></modal-loading>
<modal-alert (alertOutput)="confirmClose($event)"> <modal-alert (alertOutput)="confirmClose($event)">
</modal-alert> </modal-alert>
<button *ngIf="claiming == false && showButton == true" (click)="validateInsertions()" class="uk-button uk-button-primary uk-align-right" >Finish</button> <button *ngIf="!claiming && showButton" (click)="validateInsertions()" class="uk-button uk-button-primary uk-align-right" >Finish</button>
` `
}) })
export class ClaimInsertComponent { export class ClaimInsertComponent {
@ -60,7 +60,8 @@ public validateInsertions(){
} }
private insert(){ private insert(){
this.claiming = true; this.claiming = true;
var user="argirok@di.uoa.gr" var user=Session.getUserEmail();
var jwt=Session.getUserJwt();
this.loading.open(); this.loading.open();
var claims = []; var claims = [];
var directclaims = []; var directclaims = [];
@ -161,6 +162,7 @@ private validateDates(){
} }
private afterclaimsInsertion(insertedIds, errorInClaims){ private afterclaimsInsertion(insertedIds, errorInClaims){
this.loading.close(); this.loading.close();
this.claiming = false;
if(errorInClaims.length == 0 && insertedIds.length > 0 ){ if(errorInClaims.length == 0 && insertedIds.length > 0 ){
// if(this.inline){ // if(this.inline){
// this.show = "end"; // this.show = "end";
@ -178,6 +180,8 @@ private errorsInClaimsInsertion(insertedIds, errorInClaims){
this.errorMessage = "An Error Occured."; this.errorMessage = "An Error Occured.";
this.loading.close(); this.loading.close();
this.error = true; this.error = true;
this.claiming = false;
this.showButton = true;
// if(this.inline){ // if(this.inline){
// this.show = "error"; // this.show = "error";
// this.showChange.emit({ // this.showChange.emit({

View File

@ -39,18 +39,18 @@ import {Dates} from '../../../utils/string-utils.class';
</div> </div>
<!-- Crossref --> <!-- Crossref -->
<span *ngIf="pub.result.publisher" class="uk-article-meta">Publisher: {{pub.result.publisher}}</span><span *ngIf="pub.date" class="uk-article-meta" >({{pub.date.substring(0,4)}})</span> <span *ngIf="pub.result.publisher" class="uk-article-meta">Publisher: {{pub.result.publisher}}</span><span *ngIf="pub.date" class="uk-article-meta" >({{pub.date.substring(0,4)}})</span>
<div *ngIf="pub.result.author && pub.result.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.author let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.author.length-1))?"; ":""}}</span></div> <div *ngIf="pub.result.author && pub.result.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.author.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.author.slice(0,10).length-1))?"; ":""}}</span></div>
<div *ngIf="pub.result.editor && pub.result.editor.length" class="uk-article-meta">Editors: <span *ngFor="let author of pub.result.editor let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.editor.length-1))?"; ":""}}</span></div> <div *ngIf="pub.result.editor && pub.result.editor.length" class="uk-article-meta">Editors: <span *ngFor="let author of pub.result.editor.slice(0,10) let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.editor.slice(0,10).length-1))?"; ":""}}</span></div>
<!-- Openaire --> <!-- Openaire -->
<div *ngIf="pub.result.authors && pub.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.authors let i = index">{{author.name}}{{(i < (pub.result.authors.length-1))?"; ":""}}</span></div> <div *ngIf="pub.result.authors && pub.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.authors.slice(0,10) let i = index">{{author.name}}{{(i < (pub.result.authors.slice(0,10).length-1))?"; ":""}}</span></div>
<!-- Orcid --> <!-- Orcid -->
<span *ngIf="pub.result['journal-title'] && pub.result['journal-title'].value " class="uk-article-meta">Journal: {{pub.result['journal-title'].value}}</span> <span *ngIf="pub.result['journal-title'] && pub.result['journal-title'].value " class="uk-article-meta">Journal: {{pub.result['journal-title'].value}}</span>
<div *ngIf="pub.result.contributors && pub.result.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.contributors let i = index">{{author}}{{(i < (pub.result.contributors.length-1))?"; ":""}}</span></div> <div *ngIf="pub.result.contributors && pub.result.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.contributors.slice(0,10) let i = index">{{author}}{{(i < (pub.result.contributors.slice(0,10).length-1))?"; ":""}}</span></div>
<!-- Datacite --> <!-- Datacite -->
<div *ngIf="pub.result.creator" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.creator let i = index">{{author}}{{(i < (pub.result.creator.length-1))?"; ":""}}</span></div> <div *ngIf="pub.result.creator" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.creator.slice(0,10) let i = index">{{author}}{{(i < (pub.result.creator.slice(0,10).length-1))?"; ":""}}</span></div>
<br>****sliced***<br>
</div> </div>
<div *ngIf="showAccessRights && pub.source != 'openaire' " class = "uk-width-3-10"> <div *ngIf="showAccessRights && pub.source != 'openaire' " class = "uk-width-3-10">
<span *ngIf="showAccessRights && pub.source != 'openaire' " class="dropdown"> <span *ngIf="showAccessRights && pub.source != 'openaire' " class="dropdown">

View File

@ -6,27 +6,22 @@ import {Observable} from 'rxjs/Observable';
@Component({ @Component({
selector: 'my-claims', selector: 'my-claims',
template: ` template: `
<div *ngIf="user" class="container uk-margin-top"> <div class="container uk-margin-top">
<div class="page-header"> <div class="page-header">
<h1> My Linked research resutls</h1> <h1> My Linked research resutls</h1>
</div> </div>
<div> <div>
<div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div> <div class="uk-text-right"><a routerLink="/participate/claim">Add more Links?</a></div>
<displayClaims enableDelete="false" myClaims="true" isAdmin="false" [fetchId]="user" ></displayClaims> <displayClaims [enableDelete]=false [myClaims]=true [isAdmin]=false ></displayClaims>
</div> </div>
</div> </div>
<div *ngIf="!user" class="container">
TODO login
</div>
` `
}) })
export class MyClaimsComponent { export class MyClaimsComponent {
constructor () { constructor () {
} }
user:string="argirok@di.uoa.gr";
ngOnInit() { ngOnInit() {
} }

View File

@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router';
import { DepositDatasetsComponent } from './depositDatasets.component'; import { DepositDatasetsComponent } from './depositDatasets.component';
import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; import { DepositDatasetsResultComponent } from './depositDatasetsResult.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: DepositDatasetsComponent } { path: '', component: DepositDatasetsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -7,6 +7,7 @@ import { DepositDatasetsResultComponent } from './depositDatasetsResult.componen
import {DepositDatasetsRoutingModule} from './depositDatasets-routing.module'; import {DepositDatasetsRoutingModule} from './depositDatasets-routing.module';
import {DepoditModule} from '../deposit.module'; import {DepoditModule} from '../deposit.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -22,7 +23,7 @@ import {DepoditModule} from '../deposit.module';
exports: [ exports: [
DepositDatasetsComponent, DepositDatasetsComponent,
], ],
providers: [ providers: [FreeGuard
] ]
}) })
export class DepositDatasetsModule { } export class DepositDatasetsModule { }

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; import { DepositDatasetsResultComponent } from './depositDatasetsResult.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: DepositDatasetsResultComponent } { path: '', component: DepositDatasetsResultComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -6,6 +6,7 @@ import { DepositDatasetsResultComponent } from './depositDatasetsResult.componen
import {DepositDatasetsResultsRoutingModule} from './depositDatasetsResults-routing.module'; import {DepositDatasetsResultsRoutingModule} from './depositDatasetsResults-routing.module';
import {DepoditModule} from '../deposit.module'; import {DepoditModule} from '../deposit.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -21,7 +22,7 @@ import {DepoditModule} from '../deposit.module';
exports: [ exports: [
DepositDatasetsResultComponent, DepositDatasetsResultComponent,
], ],
providers: [ providers: [FreeGuard
] ]
}) })
export class DepositDatasetsResultsModule { } export class DepositDatasetsResultsModule { }

View File

@ -114,7 +114,6 @@ export class DepositResultComponent {
private route: ActivatedRoute, private route: ActivatedRoute,
private _searchDataprovidersService: SearchDataprovidersService, private _searchDataprovidersService: SearchDataprovidersService,
private _organizationService: OrganizationService, private _meta: Meta) { private _organizationService: OrganizationService, private _meta: Meta) {
console.info("depositResult constructor");
this.zenodo = OpenaireProperties.getZenodoURL(); this.zenodo = OpenaireProperties.getZenodoURL();
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { DepositPublicationsComponent } from './depositPublications.component'; import { DepositPublicationsComponent } from './depositPublications.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: DepositPublicationsComponent } { path: '', component: DepositPublicationsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -7,6 +7,7 @@ import { DepositPublicationsComponent } from './depositPublications.component';
import {DepositPublicationsRoutingModule} from './depositPublications-routing.module'; import {DepositPublicationsRoutingModule} from './depositPublications-routing.module';
import {DepoditModule} from '../deposit.module'; import {DepoditModule} from '../deposit.module';
import {IFrameModule} from '../../utils/iframe.module'; import {IFrameModule} from '../../utils/iframe.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -22,7 +23,7 @@ import {IFrameModule} from '../../utils/iframe.module';
exports: [ exports: [
DepositPublicationsComponent, DepositPublicationsComponent,
], ],
providers: [ providers: [FreeGuard
] ]
}) })
export class DepositPublicationsModule { } export class DepositPublicationsModule { }

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { DepositPublicationsResultComponent } from './depositPublicationsResult.component'; import { DepositPublicationsResultComponent } from './depositPublicationsResult.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: DepositPublicationsResultComponent } { path: '', component: DepositPublicationsResultComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -6,6 +6,7 @@ import { DepositPublicationsResultComponent } from './depositPublicationsResult.
import {DepositPublicationsResultRoutingModule} from './depositPublicationsResult-routing.module'; import {DepositPublicationsResultRoutingModule} from './depositPublicationsResult-routing.module';
import {DepoditModule} from '../deposit.module'; import {DepoditModule} from '../deposit.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -21,7 +22,7 @@ import {DepoditModule} from '../deposit.module';
exports: [ exports: [
DepositPublicationsResultComponent, DepositPublicationsResultComponent,
], ],
providers: [ providers: [FreeGuard
] ]
}) })
export class DepositPublicationsResultsModule { } export class DepositPublicationsResultsModule { }

View File

@ -1,14 +0,0 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {HomeComponent} from './home.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: 'home', component: HomeComponent },
])
]
})
export class HomeRoutingModule { }

View File

@ -1,37 +0,0 @@
import {Component} from '@angular/core';
import {Router} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Location} from '@angular/common';
@Component({
selector: 'home',
template:`
<div class="uk-margin-top">
<div class="page-header">
<h1>Openaire Search</h1>
</div>
<div>
<form class="uk-form">
<input #term type="text" class="uk-form-medium uk-width-1-2" placeholder="Search for..." name="keyword" >
<button class="uk-button" type="submit" (click)="searchTerm(term.value)" >Search</button>
</form>
</div>
</div>
`
})
export class HomeComponent {
constructor ( private _router: Router, private location: Location) {
}
ngOnInit() {
}
searchTerm(term: string) {
window.location.href="/search/find?keyword="+term;
}
}

View File

@ -1,21 +0,0 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {HomeComponent} from './home.component';
import { HomeRoutingModule } from './home-routing.module';
@NgModule({
imports: [
CommonModule, FormsModule,
HomeRoutingModule
],
declarations: [
HomeComponent
],
exports: [
HomeComponent
]
})
export class HomeModule { }

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { DataProviderComponent } from './dataProvider.component'; import { DataProviderComponent } from './dataProvider.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: DataProviderComponent } { path: '', component: DataProviderComponent, canActivate: [FreeGuard] }
]) ])
] ]
}) })

View File

@ -26,22 +26,18 @@ import {ProjectsServiceModule} from '../../services/projectsService.module';
import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module';
import { DataProviderRoutingModule } from './dataProvider-routing.module'; import { DataProviderRoutingModule } from './dataProvider-routing.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports:
CommonModule, FormsModule, RouterModule,DataProviderRoutingModule, [CommonModule, FormsModule, RouterModule,DataProviderRoutingModule,
TabResultModule, IFrameModule, MetricsModule, LandingModule, DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, PublicationsServiceModule TabResultModule, IFrameModule, MetricsModule, LandingModule, DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, PublicationsServiceModule],
declarations:
], [PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, OrganizationsTabComponent,
declarations: [
PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, OrganizationsTabComponent,
RelatedDatasourcesTabComponent, DataProviderComponent RelatedDatasourcesTabComponent, DataProviderComponent
], ],
providers:[ providers:[
DataProviderService DataProviderService, FreeGuard
], ],
exports: [ exports: [
DataProviderComponent DataProviderComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { DatasetComponent } from './dataset.component'; import { DatasetComponent } from './dataset.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: DatasetComponent } { path: '', component: DatasetComponent, canActivate: [FreeGuard] }
]) ])
] ]
}) })

View File

@ -15,6 +15,7 @@ import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module';
import { ResultLandingModule } from '../resultLanding.module'; import { ResultLandingModule } from '../resultLanding.module';
import { LandingModule } from '../landing.module'; import { LandingModule } from '../landing.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -26,7 +27,7 @@ import { LandingModule } from '../landing.module';
DatasetComponent DatasetComponent
], ],
providers:[ providers:[
DatasetService DatasetService, FreeGuard
], ],
exports: [ exports: [
DatasetComponent DatasetComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { HtmlProjectReportComponent } from './htmlProjectReport.component'; import { HtmlProjectReportComponent } from './htmlProjectReport.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: HtmlProjectReportComponent } { path: '', component: HtmlProjectReportComponent , canActivate: [FreeGuard]}
]) ])
] ]
}) })

View File

@ -8,6 +8,7 @@ import { CacheService } from '../../shared/cache.service';
import {HtmlProjectReportService} from './htmlProjectReport.service'; import {HtmlProjectReportService} from './htmlProjectReport.service';
import {HtmlProjectReportComponent} from './htmlProjectReport.component'; import {HtmlProjectReportComponent} from './htmlProjectReport.component';
import { HtmlProjectReportRoutingModule } from './htmlProjectReport-routing.module'; import { HtmlProjectReportRoutingModule } from './htmlProjectReport-routing.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -17,7 +18,7 @@ import { HtmlProjectReportRoutingModule } from './htmlProjectReport-routing.modu
HtmlProjectReportComponent HtmlProjectReportComponent
], ],
providers:[ providers:[
HtmlProjectReportService,CacheService HtmlProjectReportService,CacheService, FreeGuard
], ],
exports: [ exports: [
HtmlProjectReportComponent HtmlProjectReportComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { OrganizationComponent } from './organization.component'; import { OrganizationComponent } from './organization.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: OrganizationComponent } { path: '', component: OrganizationComponent, canActivate: [FreeGuard] }
]) ])
] ]
}) })

View File

@ -64,7 +64,6 @@ export class OrganizationComponent {
private _searchPublicationsService: SearchPublicationsService, private _searchPublicationsService: SearchPublicationsService,
private _searchProjectsService: SearchProjectsService, private _meta: Meta) { private _searchProjectsService: SearchProjectsService, private _meta: Meta) {
console.info('organization constructor');
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
} }

View File

@ -19,6 +19,7 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu
import {ProjectsServiceModule} from '../../services/projectsService.module'; import {ProjectsServiceModule} from '../../services/projectsService.module';
import { SearchingProjectsTabModule} from '../searchingProjectsInTab.module'; import { SearchingProjectsTabModule} from '../searchingProjectsInTab.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -40,6 +41,7 @@ import { SearchingProjectsTabModule} from '../searchingProjectsInTab.module';
OrganizationComponent, OrganizationComponent,
], ],
providers:[ providers:[
FreeGuard
], ],
exports: [ exports: [
OrganizationComponent OrganizationComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { PersonComponent } from './person.component'; import { PersonComponent } from './person.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: PersonComponent } { path: '', component: PersonComponent, canActivate: [FreeGuard] }
]) ])
] ]
}) })

View File

@ -40,7 +40,6 @@ export class PersonComponent {
private _searchPublicationsService: SearchPublicationsService, private _searchPublicationsService: SearchPublicationsService,
private _searchDatasetsService: SearchDatasetsService, private _meta: Meta) { private _searchDatasetsService: SearchDatasetsService, private _meta: Meta) {
console.info('person constructor');
this.fetchPublications = new FetchPublications( this._searchPublicationsService); this.fetchPublications = new FetchPublications( this._searchPublicationsService);
this.fetchDatasets = new FetchDatasets( this._searchDatasetsService); this.fetchDatasets = new FetchDatasets( this._searchDatasetsService);
// this.scrollUp = this._route.events.subscribe((path) => { // this.scrollUp = this._route.events.subscribe((path) => {

View File

@ -11,6 +11,7 @@ import { LandingModule } from '../landing.module';
import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module';
import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module';
import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -24,7 +25,7 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu
PersonComponent PersonComponent
], ],
providers:[ providers:[
PersonService PersonService, FreeGuard
], ],
exports: [ exports: [
PersonComponent PersonComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { PublicationComponent } from './publication.component'; import { PublicationComponent } from './publication.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: PublicationComponent } { path: '', component: PublicationComponent, canActivate: [FreeGuard] }
]) ])
] ]
}) })

View File

@ -16,6 +16,7 @@ import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module';
import { ResultLandingModule } from '../resultLanding.module'; import { ResultLandingModule } from '../resultLanding.module';
import { LandingModule } from '../landing.module'; import { LandingModule } from '../landing.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -26,7 +27,7 @@ import { LandingModule } from '../landing.module';
PublicationComponent PublicationComponent
], ],
providers:[ providers:[
PublicationService PublicationService, FreeGuard
], ],
exports: [ exports: [
PublicationComponent PublicationComponent

View File

@ -41,7 +41,6 @@ export class ShowAuthorsComponent {
private showAll: boolean = false; private showAll: boolean = false;
constructor () { constructor () {
console.info('showAuthors constructor');
} }
ngOnInit() { ngOnInit() {

View File

@ -32,7 +32,6 @@ export class ShowIdentifiersComponent {
pmcURL: string; pmcURL: string;
constructor () { constructor () {
console.info('showIdentifiers constructor');
this.doiURL = OpenaireProperties.getDoiURL(); this.doiURL = OpenaireProperties.getDoiURL();
this.pmcURL = OpenaireProperties.getPmcURL(); this.pmcURL = OpenaireProperties.getPmcURL();
} }

View File

@ -62,7 +62,6 @@ export class ShowSubjectsComponent {
private showClassifiedSbj: boolean = false; private showClassifiedSbj: boolean = false;
constructor () { constructor () {
console.info('showSubjects constructor');
} }
ngOnInit() { ngOnInit() {

View File

@ -41,7 +41,6 @@ export class ShowTitleComponent {
@Input() title: { [key: string]: string }; @Input() title: { [key: string]: string };
constructor () { constructor () {
console.info('title constructor');
} }
ngOnInit() { ngOnInit() {

View File

@ -17,7 +17,6 @@ export class TabPagingComponent {
@Output() changeShowAll: EventEmitter<any> = new EventEmitter(); @Output() changeShowAll: EventEmitter<any> = new EventEmitter();
constructor () { constructor () {
console.info('publication:paging constructor');
} }
ngOnInit() { ngOnInit() {

View File

@ -63,11 +63,9 @@ export class TabTableComponent {
public searchLinkToDataset: string; public searchLinkToDataset: string;
constructor () { constructor () {
console.info('tabTable constructor');
} }
ngOnInit() { ngOnInit() {
console.info('tabTable ngOnInit');
this.searchLinkToPublication = OpenaireProperties.getsearchLinkToPublication(); this.searchLinkToPublication = OpenaireProperties.getsearchLinkToPublication();
this.searchLinkToDataset = OpenaireProperties.getsearchLinkToDataset(); this.searchLinkToDataset = OpenaireProperties.getsearchLinkToDataset();
} }

View File

@ -1,33 +1,39 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {Session} from './utils/helper.class';
@Injectable() @Injectable()
export class AdminLoginGuard implements CanActivate { export class AdminLoginGuard implements CanActivate {
constructor(private router: Router) {} constructor(private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
console.log("AAA inside the AdminLoginGuard!")
var user; var user;
var loggedIn = false; var loggedIn = false;
var isAdmin = false; var isAdmin = false;
var errorCode = 1;
if( typeof localStorage !== 'undefined') { if(Session.isLoggedIn()){
if(localStorage.getItem("user")) { loggedIn = true;
loggedIn = true; if(!Session.isValidAndRemove()){
user = JSON.parse(localStorage.getItem("user")); loggedIn = false;
if(user.role == 2){ errorCode = 3;
isAdmin = true; }else {
} isAdmin = Session.isAdminUser();
if(!isAdmin){
errorCode = 2;
} }
}
}else{
errorCode =1;
} }
if(!loggedIn){ if(!loggedIn){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": 1, "redirectUrl": state.url } }); this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
return false; return false;
}else if(!isAdmin){ }else if(!isAdmin){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": 2, "redirectUrl": state.url } }); this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
return false; return false;
}else{ }else{
return true; return true;

View File

@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {Session} from './utils/helper.class';
@Injectable()
export class FreeGuard implements CanActivate {
constructor(private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
var user;
var valid = true;
var loggedIn = false;
var errorCode = 1;
if(Session.isLoggedIn()){
loggedIn = true;
if(!Session.isValidAndRemove()){
loggedIn = false;
valid = false;
errorCode = 3;
}
}
if(!valid){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
return false;
}
return true;
}
}

View File

@ -1,5 +1,5 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions} from '@angular/http'; import {Http, Response, Headers, RequestOptions, URLSearchParams} from '@angular/http';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of'; import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do'; import 'rxjs/add/operator/do';
@ -8,7 +8,7 @@ import 'rxjs/add/operator/share';
import { CacheService } from '../shared/cache.service'; import { CacheService } from '../shared/cache.service';
import {PersonInfo} from '../utils/entities/personInfo'; import {PersonInfo} from '../utils/entities/personInfo';
import {OpenaireProperties} from '../utils/properties/openaireProperties'; import {OpenaireProperties} from '../utils/properties/openaireProperties';
import {User} from '../utils/entities/user'; import {User,Session,MyJWT} from './utils/helper.class';
@Injectable() @Injectable()
@ -16,51 +16,28 @@ export class LoginService {
constructor(private http: Http, public _cache: CacheService) {} constructor(private http: Http, public _cache: CacheService) {}
authenticate (/*user: User*/username: string, password: string):any { authenticate (username: string, password: string):any {
/*
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 });
let body = JSON.stringify( {"username":username, "password":password} );
return this.http.post(this.heroesUrl, { name }, options) return this.http.post(OpenaireProperties.getLoginAPIURL(), body,options)
.map(this.extractData) .map(res => <any> res.json())
.catch(this.handleError); .map(res =>this.parse(res['data']));
*/
let url = OpenaireProperties.getLoginAPIURL()+username+"&password="+password;
let key = url; // let url = OpenaireProperties.getLoginAPIURL()+"?username="+username+"&password="+password;
if (this._cache.has(key)) { // let key = url;
return Observable.of(this._cache.get(key)); // return this.http.get(url)
} // .map(res => <any> res.json())
return this.http.get(url) // .map(res =>this.parse(res['data']));
.map(res => <any> res.json())
.map(res => this.parseUserInfo(res['data']))
.do(res => {
this._cache.set(key, res);
});
} }
private validateJWTFormat(data){
if(data == null || (data.indexOf(".") !=-1 && data.split('.').length != 3)){ parse(data:any){
return false; return MyJWT.parseUserInfo(data);
}
return true;
} }
private getPayload(data){
var payload = data.split('.')[1];
return atob(payload);
}
private parseUserInfo(data: any/*, user: User*/): User {
if(this.validateJWTFormat(data)){
var info = JSON.parse(this.getPayload(data));
}
var user: User = new User();
user.username = info.sub;
user.email = info.email;
user.id = info.userId;
user.fullname = info.fullname;
localStorage.setItem("user", JSON.stringify(user));
return user;
}
} }

View File

@ -1,6 +1,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router'; import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {Session} from './utils/helper.class';
@Injectable() @Injectable()
export class LoginGuard implements CanActivate { export class LoginGuard implements CanActivate {
@ -8,17 +9,21 @@ export class LoginGuard implements CanActivate {
constructor(private router: Router) {} constructor(private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
console.log("AAA inside the LoginGuard!")
var user; var user;
var loggedIn = false; var loggedIn = false;
if( typeof localStorage !== 'undefined') { var errorCode = 1;
if(localStorage.getItem("user")) {
user = JSON.parse(localStorage.getItem("user")); if(Session.isLoggedIn()){
loggedIn = true; loggedIn = true;
} if(!Session.isValidAndRemove()){
loggedIn = false;
errorCode = 3;
}
}else{
errorCode = 1;
} }
if(!loggedIn){ if(!loggedIn){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": 1, "redirectUrl": state.url } }); this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": state.url } });
return false; return false;
}else{ }else{
return true; return true;

View File

@ -3,27 +3,30 @@ import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {LoginService} from './login.service'; import {LoginService} from './login.service';
import {User} from '../utils/entities/user'; import {User,Session} from './utils/helper.class';
import {RouterHelper} from '../utils/routerHelper.class';
@Component({ @Component({
selector: 'user', selector: 'user',
template: ` template: `
<div class="uk-margin-top"> <div *ngIf="!server" class="uk-margin-top">
<div *ngIf="errorCode == '1'" class="uk-alert uk-alert-warning"> <div *ngIf="errorCode == '1'" class="uk-alert uk-alert-warning">
The requested page requires authentication. Please login. The requested page requires authentication. Please login.
</div> </div>
<div *ngIf="errorCode == '2'" class="uk-alert uk-alert-warning"> <div *ngIf="errorCode == '2'" class="uk-alert uk-alert-warning">
You are not authorized to use the requested page You are not authorized to use the requested page
</div> </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>.
</div>
<form *ngIf="!loggedIn" class="uk-form uk-flex "> <form *ngIf="!loggedIn" class="uk-form uk-flex ">
<fieldset> <fieldset>
<legend>Login Form</legend> <legend>Login Form</legend>
<div class="uk-form-row"> <div class="uk-form-row">
<input placeholder="Text input" type="text" name="username" [(ngModel)]="username"> <input placeholder="Username" type="text" name="username" [(ngModel)]="username">
</div> </div>
<div class="uk-form-row"> <div class="uk-form-row">
<input placeholder="Password input" type="password" name="password" [(ngModel)]="password"> <input placeholder="Password" type="password" name="password" [(ngModel)]="password">
</div> </div>
<div class="uk-form-row"> <div class="uk-form-row">
<button (click)="login()" class="uk-button">Login</button> <button (click)="login()" class="uk-button">Login</button>
@ -40,48 +43,35 @@ import {User} from '../utils/entities/user';
<button (click)="logout()" class="uk-button">Log out</button> <button (click)="logout()" class="uk-button">Log out</button>
</div> </div>
</div> </div>
` `
}) })
export class UserComponent { export class UserComponent {
public user: User; public user: User;
public loggedIn: boolean = false; public loggedIn: boolean = false;
public server: boolean = true;
public errorMessage: string; public errorMessage: string;
public username: string = ""; public username: string = "";
public password: string = ""; public password: string = "";
private sub:any;private sublogin:any; private sub:any;private sublogin:any;
public errorCode: string = ""; public errorCode: string = "";
public redirectUrl: string = ""; public redirectUrl: string = "";
public routerHelper:RouterHelper = new RouterHelper();
constructor( private router: Router, private _loginService: LoginService, private route: ActivatedRoute ) {} constructor( private router: Router, private _loginService: LoginService, private route: ActivatedRoute ) {}
ngOnInit() { ngOnInit() {
if( typeof localStorage !== 'undefined') { if( typeof document !== 'undefined') {
if(localStorage.getItem("user")) { this.server = false;
this.user = JSON.parse(localStorage.getItem("user"));
if(this.user && this.user.id){
this.loggedIn = true;
}else{
this.loggedIn = false;
}
}
} }
this.loggedIn = Session.isLoggedIn();
this.user = Session.getUser();
this.errorMessage = ""; this.errorMessage = "";
this.sub = this.route.queryParams.subscribe(params => { this.sub = this.route.queryParams.subscribe(params => {
this.errorCode = params["errorCode"]; this.errorCode = params["errorCode"];
this.redirectUrl = params["redirectUrl"]; this.redirectUrl = params["redirectUrl"];
if( typeof localStorage !== 'undefined') { this.loggedIn = Session.isLoggedIn();
if(localStorage.getItem("user")) { this.user = Session.getUser();
this.user = JSON.parse(localStorage.getItem("user"));
if(this.user && this.user.id){
this.loggedIn = true;
}else{
this.loggedIn = false;
}
}
}
this.errorMessage = ""; this.errorMessage = "";
}); });
} }
@ -92,20 +82,39 @@ export class UserComponent {
} }
} }
logout(){ logout(){
localStorage.removeItem("user"); if(Session.isLoggedIn()){
Session.removeUser();
}
this.loggedIn = false; this.loggedIn = false;
this.user = new User(); this.user = new User();
this.username = ""; this.username = "";
this.password = ""; this.password = "";
this.redirect();
this.redirect();
} }
redirect(){ redirect(){
if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != ""){ if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != ""){
this.router.navigate([this.redirectUrl]); this.redirectUrl = decodeURIComponent(this.redirectUrl);
var baseUrl = this.redirectUrl;
var queryParams = "";
var paramsArray =[];
var valuesArray =[];
if(this.redirectUrl.indexOf('?') != -1){
baseUrl = this.redirectUrl.split('?')[0];
queryParams = this.redirectUrl.split('?')[1];
}
if(queryParams != ""){
var queryParamsArray = queryParams.split('&');
for(var i = 0; i < queryParamsArray.length; i++){
paramsArray.push(queryParamsArray[i].split("=")[0]);
valuesArray.push(queryParamsArray[i].split("=")[1]);
}
this.router.navigate([baseUrl], { queryParams: this.routerHelper.createQueryParams(paramsArray,valuesArray)});
}else{
this.router.navigate([baseUrl]);
}
}else{ }else{
this.router.navigate(['/user-info']); this.router.navigate(['/search/find']);
} }
} }
login() { login() {

View File

@ -3,35 +3,40 @@ import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common'; import {Location} from '@angular/common';
import {LoginService} from './login.service'; import {LoginService} from './login.service';
import {User} from '../utils/entities/user'; import {User,Session} from './utils/helper.class';
import {RouterHelper} from '../utils/routerHelper.class';
@Component({ @Component({
selector: 'user-mini', selector: 'user-mini',
template: ` template: `
<div class="uk-margin-top uk-margin-right uk-float-right"> <div *ngIf="!server" class="uk-margin-top uk-margin-right uk-float-right">
<span *ngIf="loggedIn" >Hello {{user.fullname}}!</span> <span *ngIf="loggedIn" >Hello <a (click)="gotoUserPage();" >{{user.fullname}}</a>!</span>
<a routerLinkActive="router-link-active" routerLink="/user-info" [queryParams]="{redirectUrl: redirectUrl}" ><span *ngIf="loggedIn">Log out</span><span *ngIf="!loggedIn">Log in</span></a> <span *ngIf="!loggedIn" >Hello Guest!</span>
<a *ngIf="!loggedIn" (click)="gotoUserPage();" >Log in</a>
</div> </div>
` `
}) })
export class UserMiniComponent { export class UserMiniComponent {
public user: User; public user: User;
public loggedIn: boolean = false; public loggedIn: boolean = false;
public server: boolean = true;
public routerHelper:RouterHelper = new RouterHelper();
public redirectUrl: string = ""; public redirectUrl: string = "";
private baseUrl = "user-info";
sub:any; sub:any;
constructor( private router: Router, private route: ActivatedRoute, private location: Location) {} constructor( private router: Router, private route: ActivatedRoute, private location: Location) {}
ngOnInit() { ngOnInit() {
if( typeof document !== 'undefined') {
this.server = false;
}
this.initialize(); this.initialize();
this.sub = this.route.queryParams.subscribe(params => { this.sub = this.route.queryParams.subscribe(params => {
this.initialize();
this.initialize();
}); });
} }
ngOnDestroy(){ ngOnDestroy(){
@ -39,21 +44,28 @@ export class UserMiniComponent {
} }
initialize(){ initialize(){
this.redirectUrl = this.location.path(); this.redirectUrl = this.location.path();
if( typeof localStorage !== 'undefined') { if(Session.isLoggedIn()){
if(localStorage.getItem("user")) { if(Session.isUserValid()){
this.user = JSON.parse(localStorage.getItem("user")); this.loggedIn = Session.isLoggedIn();
if(this.user && this.user.id){ this.user = Session.getUser();
this.loggedIn = true;
}else{
this.loggedIn = false;
}
}else{
this.loggedIn = false;
}
}else{ }else{
Session.removeUser();
this.loggedIn = false; this.loggedIn = false;
this.user = null;
} }
}else {
this.loggedIn = false;
this.user = null;
}
}
gotoUserPage(){
this.redirectUrl = this.location.path();
if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != "" && this.redirectUrl !="user-info"){
this.router.navigate([this.baseUrl], { queryParams: this.routerHelper.createQueryParam("redirectUrl",this.redirectUrl )});
}else{
this.router.navigate([this.baseUrl]);
}
} }
} }

View File

@ -0,0 +1,123 @@
export class User {
email:string;
username: string;
id: string;
fullname: string;
expirationDate: number;
role:string;
jwt:string;
}
export class Session{
public static setUser(user:User): User {
localStorage.setItem("user", JSON.stringify(user));
return user;
}
public static removeUser() {
if(Session.isLoggedIn()){
localStorage.removeItem("user");
}
}
public static getUser():User {
if(Session.isLoggedIn()){
return JSON.parse(localStorage.getItem("user"));
}else{
return null;
}
}
public static isLoggedIn(): boolean {
var loggedIn:boolean = false;
var user:User = null;
if( typeof localStorage !== 'undefined') {
if(localStorage.getItem("user")) {
user = JSON.parse(localStorage.getItem("user"));
if(user && user.id){
loggedIn = true;
}else{
loggedIn = false;
}
}else{
loggedIn = false;
}
}else{
loggedIn = false;
}
return loggedIn;
}
public static getUserJwt():string {
if(Session.isLoggedIn()){
return Session.getUser().jwt;
}else{
return null;
}
}
public static getUserEmail():string {
if(Session.isLoggedIn()){
return Session.getUser().email;
}else{
return null;
}
}
public static isAdminUser():boolean {
if(Session.isLoggedIn()){
return (Session.getUser().role == '2');
}
}
public static isUserValid() {
if(Session.isLoggedIn()){
var expires = Session.getUser().expirationDate;
var now = new Date().getTime() / 1000;
console.log(" is still valid ? "+(now < expires) + " now is:"+now + "expires at:"+expires);
return now < expires;
}
return false;
}
public static isValidAndRemove() {
if(Session.isLoggedIn()){
if(!Session.isUserValid()){
Session.removeUser();
return false;
}
}
return true;
}
}
export class MyJWT{
private static validateJWTFormat(data){
if(data == null || (data.indexOf(".") !=-1 && data.split('.').length != 3)){
return false;
}
return true;
}
private static getPayload(data){
var payload = data.split('.')[1];
return atob(payload);
}
public static parseUserInfo(data: any): User {
if(this.validateJWTFormat(data)){
var info = JSON.parse(this.getPayload(data));
}
var user: User = new User();
user.username = info.sub;
user.email = info.email;
user.id = info.userId;
user.fullname = info.fullname;
user.role = info.role;
user.jwt = data;
user.expirationDate = info.exp;
localStorage.setItem("user", JSON.stringify(user));
return user;
}
}

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders.component'; import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: AdvancedSearchDataProvidersComponent } { path: '', component: AdvancedSearchDataProvidersComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -8,6 +8,7 @@ import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders
import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module';
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -19,7 +20,7 @@ import {DataProvidersServiceModule} from '../../services/dataProvidersService.mo
declarations: [ declarations: [
AdvancedSearchDataProvidersComponent AdvancedSearchDataProvidersComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
AdvancedSearchDataProvidersComponent AdvancedSearchDataProvidersComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component'; import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: AdvancedSearchDatasetsComponent } { path: '', component: AdvancedSearchDatasetsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -8,6 +8,7 @@ import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component
import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module';
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -19,7 +20,7 @@ import {DatasetsServiceModule} from '../../services/datasetsService.module';
declarations: [ declarations: [
AdvancedSearchDatasetsComponent AdvancedSearchDatasetsComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
AdvancedSearchDatasetsComponent AdvancedSearchDatasetsComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations.component'; import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: AdvancedSearchOrganizationsComponent } { path: '', component: AdvancedSearchOrganizationsComponent , canActivate: [FreeGuard]}
]) ])
] ]

View File

@ -8,6 +8,7 @@ import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations
import {OrganizationsServiceModule} from '../../services/organizationsService.module'; import {OrganizationsServiceModule} from '../../services/organizationsService.module';
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -19,7 +20,7 @@ import {OrganizationsServiceModule} from '../../services/organizationsService.mo
declarations: [ declarations: [
AdvancedSearchOrganizationsComponent AdvancedSearchOrganizationsComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
AdvancedSearchOrganizationsComponent AdvancedSearchOrganizationsComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{AdvancedSearchPeopleComponent} from './advancedSearchPeople.component'; import{AdvancedSearchPeopleComponent} from './advancedSearchPeople.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: AdvancedSearchPeopleComponent } { path: '', component: AdvancedSearchPeopleComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -8,6 +8,7 @@ import{AdvancedSearchPeopleComponent} from './advancedSearchPeople.component';
import {PeopleServiceModule} from '../../services/peopleService.module'; import {PeopleServiceModule} from '../../services/peopleService.module';
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -19,7 +20,7 @@ import {PeopleServiceModule} from '../../services/peopleService.module';
declarations: [ declarations: [
AdvancedSearchPeopleComponent AdvancedSearchPeopleComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
AdvancedSearchPeopleComponent AdvancedSearchPeopleComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component'; import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: AdvancedSearchProjectsComponent } { path: '', component: AdvancedSearchProjectsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -8,6 +8,7 @@ import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component
import {ProjectsServiceModule} from '../../services/projectsService.module'; import {ProjectsServiceModule} from '../../services/projectsService.module';
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -19,7 +20,7 @@ import {ProjectsServiceModule} from '../../services/projectsService.module';
declarations: [ declarations: [
AdvancedSearchProjectsComponent AdvancedSearchProjectsComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
AdvancedSearchProjectsComponent AdvancedSearchProjectsComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.component'; import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: AdvancedSearchPublicationsComponent } { path: '', component: AdvancedSearchPublicationsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -8,6 +8,7 @@ import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.c
import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module';
import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -19,7 +20,7 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu
declarations: [ declarations: [
AdvancedSearchPublicationsComponent AdvancedSearchPublicationsComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
AdvancedSearchPublicationsComponent AdvancedSearchPublicationsComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component'; import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchCompatibleDataprovidersComponent } { path: '', component: SearchCompatibleDataprovidersComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {SearchPageModule} from '../searchUtils/searchPage.module'; import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
@ -20,7 +22,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module';
declarations: [ declarations: [
SearchCompatibleDataprovidersComponent SearchCompatibleDataprovidersComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchCompatibleDataprovidersComponent SearchCompatibleDataprovidersComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchEntityRegistriesComponent} from './entityRegistries.component'; import{SearchEntityRegistriesComponent} from './entityRegistries.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchEntityRegistriesComponent } { path: '', component: SearchEntityRegistriesComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {SearchPageModule} from '../searchUtils/searchPage.module'; import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
@ -20,7 +22,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module';
declarations: [ declarations: [
SearchEntityRegistriesComponent SearchEntityRegistriesComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchEntityRegistriesComponent SearchEntityRegistriesComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchComponent} from './search.component'; import{SearchComponent} from './search.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchComponent } { path: '', component: SearchComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -16,6 +16,7 @@ import {OrganizationsServiceModule} from '../../services/organizationsService.mo
import {PeopleServiceModule} from '../../services/peopleService.module'; import {PeopleServiceModule} from '../../services/peopleService.module';
import {BrowseEntitiesModule} from '../searchUtils/browseEntities.module'; import {BrowseEntitiesModule} from '../searchUtils/browseEntities.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -28,7 +29,7 @@ import {SearchFormModule} from '../searchUtils/searchForm.module';
declarations: [ declarations: [
SearchComponent SearchComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchComponent SearchComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchDataprovidersComponent} from './searchDataproviders.component'; import{SearchDataprovidersComponent} from './searchDataproviders.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchDataprovidersComponent } { path: '', component: SearchDataprovidersComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {SearchPageModule} from '../searchUtils/searchPage.module'; import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module';
declarations: [ declarations: [
SearchDataprovidersComponent SearchDataprovidersComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchDataprovidersComponent SearchDataprovidersComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchDatasetsComponent} from './searchDatasets.component'; import{SearchDatasetsComponent} from './searchDatasets.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchDatasetsComponent } { path: '', component: SearchDatasetsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {SearchPageModule} from '../searchUtils/searchPage.module'; import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module';
declarations: [ declarations: [
SearchDatasetsComponent SearchDatasetsComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchDatasetsComponent SearchDatasetsComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchOrganizationsComponent} from './searchOrganizations.component'; import{SearchOrganizationsComponent} from './searchOrganizations.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchOrganizationsComponent } { path: '', component: SearchOrganizationsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {OrganizationsServiceModule} from '../../services/organizationsService.module'; import {OrganizationsServiceModule} from '../../services/organizationsService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {SearchPageModule} from '../searchUtils/searchPage.module'; import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module';
declarations: [ declarations: [
SearchOrganizationsComponent SearchOrganizationsComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchOrganizationsComponent SearchOrganizationsComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchPeopleComponent} from './searchPeople.component'; import{SearchPeopleComponent} from './searchPeople.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchPeopleComponent } { path: '', component: SearchPeopleComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {PeopleServiceModule} from '../../services/peopleService.module'; import {PeopleServiceModule} from '../../services/peopleService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {SearchPageModule} from '../searchUtils/searchPage.module'; import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module';
declarations: [ declarations: [
SearchPeopleComponent SearchPeopleComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchPeopleComponent SearchPeopleComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchProjectsComponent} from './searchProjects.component'; import{SearchProjectsComponent} from './searchProjects.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchProjectsComponent } { path: '', component: SearchProjectsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {ProjectsServiceModule} from '../../services/projectsService.module'; import {ProjectsServiceModule} from '../../services/projectsService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {SearchPageModule} from '../searchUtils/searchPage.module'; import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module';
declarations: [ declarations: [
SearchProjectsComponent SearchProjectsComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchProjectsComponent SearchProjectsComponent

View File

@ -2,11 +2,12 @@ import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import{SearchPublicationsComponent} from './searchPublications.component'; import{SearchPublicationsComponent} from './searchPublications.component';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: SearchPublicationsComponent } { path: '', component: SearchPublicationsComponent, canActivate: [FreeGuard] }
]) ])
] ]

View File

@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module';
import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module';
import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchFormModule} from '../searchUtils/searchForm.module';
import {SearchPageModule} from '../searchUtils/searchPage.module'; import {SearchPageModule} from '../searchUtils/searchPage.module';
import {FreeGuard} from'../../login/freeGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module';
declarations: [ declarations: [
SearchPublicationsComponent SearchPublicationsComponent
], ],
providers:[ providers:[FreeGuard
], ],
exports: [ exports: [
SearchPublicationsComponent SearchPublicationsComponent

View File

@ -1,6 +0,0 @@
export class User {
email:string;
username: string;
id: string;
fullname: string;
}

View File

@ -55,7 +55,6 @@ export class ExportCSVComponent {
linkname: string = "Download CSV"; linkname: string = "Download CSV";
constructor () { constructor () {
console.info('export constructor');
} }
ngOnInit() { ngOnInit() {

View File

@ -31,7 +31,7 @@ export class OpenaireProperties {
private static metricsAPIURL = "http://vatopedi.di.uoa.gr:8080/stats/"; private static metricsAPIURL = "http://vatopedi.di.uoa.gr:8080/stats/";
private static framesAPIURL = "http://vatopedi.di.uoa.gr/stats2/"; private static framesAPIURL = "http://vatopedi.di.uoa.gr/stats2/";
private static loginAPIURL = "http://mpagasas.di.uoa.gr:8080/uoa-user-management-1.0.0-SNAPSHOT/api/users/authenticate?username="; private static loginAPIURL = "http://mpagasas.di.uoa.gr:8080/uoa-user-management-1.0.0-SNAPSHOT/api/users/authenticates";
// public claimsAPIURL = "http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/" // public claimsAPIURL = "http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/"
private static claimsAPIURL = "http://scoobydoo.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/"; private static claimsAPIURL = "http://scoobydoo.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/";

View File

@ -59,7 +59,6 @@ export class ShowDataProvidersComponent {
"organizations": {"name": string, "url": string}[]}[]; "organizations": {"name": string, "url": string}[]}[];
constructor () { constructor () {
console.info('showDataProviders constructor');
} }
ngOnInit() {} ngOnInit() {}

View File

@ -16,8 +16,8 @@ export const routes: string[] = [
'search/advanced/people','search/advanced/publications','search/advanced/projects','search/advanced/datasets','search/advanced/dataproviders','search/advanced/organizations', 'search/advanced/people','search/advanced/publications','search/advanced/projects','search/advanced/datasets','search/advanced/dataproviders','search/advanced/organizations',
'participate/deposit-publications','participate/deposit-datasets','participate/deposit-publications-result','participate/deposit-datasets-result', 'participate/deposit-publications','participate/deposit-datasets','participate/deposit-publications-result','participate/deposit-datasets-result',
'search/data-providers','search/entity-registries', 'project-report', 'search/data-providers','search/entity-registries', 'project-report',
'claims','myclaims','participate/claim', 'participate/bulk-claim', 'claims','myclaims','participate/claim', 'participate/direct-claim',
'test', 'user-info', 'test', 'user-info',
'error' '**','error'
]; ];