diff --git a/portal-2/src/app/claims/claim-utils/claimResultSearchForm.component.html b/portal-2/src/app/claims/claim-utils/claimResultSearchForm.component.html index 6b39411d..ae5fc80d 100644 --- a/portal-2/src/app/claims/claim-utils/claimResultSearchForm.component.html +++ b/portal-2/src/app/claims/claim-utils/claimResultSearchForm.component.html @@ -84,8 +84,8 @@ - authorIds + diff --git a/portal-2/src/app/claims/claim-utils/claimResultSearchForm.component.ts b/portal-2/src/app/claims/claim-utils/claimResultSearchForm.component.ts index 185be89b..b5b60c68 100644 --- a/portal-2/src/app/claims/claim-utils/claimResultSearchForm.component.ts +++ b/portal-2/src/app/claims/claim-utils/claimResultSearchForm.component.ts @@ -270,7 +270,7 @@ private getCrossrefResults (term: string, size : number, page : number) { this.authorGivenNames, this.authorFamilyNames).subscribe( data => { if(data != null && data == true) { - this.getOrcidResultsById(0); + this.getOrcidResultsByIndex(0); } this.orcidStatus = this.errorCodes.NONE; @@ -299,7 +299,7 @@ private getCrossrefResults (term: string, size : number, page : number) { this.authorGivenNames, this.authorFamilyNames).subscribe( data => { if(data != null && data == true) { - this.getOrcidResultsById(0); + this.getOrcidResultsByIndex(0); }else{ 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) { this.orcidStatus = this.errorCodes.LOADING; let id = this.authorIds[index]; this.authorGivenName = this.authorGivenNames[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; console.info("getOrcidResultsById: "+id); this._searchOrcidService.searchOrcidPublications(id).subscribe( @@ -352,7 +360,7 @@ private getCrossrefResults (term: string, size : number, page : number) { } ); - } + } /* diff --git a/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts b/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts index 5ca26bf6..e1ccb100 100644 --- a/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts +++ b/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts @@ -5,6 +5,7 @@ import {ActivatedRoute, Router} from '@angular/router'; import {ClaimsService} from '../service/claims.service'; import {ModalLoading} from '../../../utils/modal/loading.component'; import {AlertModal} from '../../../utils/modal/alert'; +import {Session} from '../../../login/utils/helper.class'; @Component({ @@ -19,14 +20,15 @@ export class DisplayClaimsComponent { ngOnInit() { this.sub = this.route.queryParams.subscribe(params => { - if( this.myClaims == 'true' ){ + if( this.myClaims){ this.fetchBy = "User"; + this.fetchId = Session.getUserEmail(); }else{ this.fetchBy = params['fetchBy']; this.fetchBy = (this.types.indexOf(this.fetchBy) != -1)? this.fetchBy:'All'; 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.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() { this.sub.unsubscribe(); } sub: any; //string because comes as input from component directive - @Input() enableDelete: string = 'false'; - @Input() myClaims: string= 'false' ; - @Input() isAdmin:string = 'false'; + @Input() enableDelete: boolean = false; + @Input() myClaims: boolean= false ; + @Input() isAdmin:boolean = false; page : number; size:number; sizes = [10,20,30,50]; @@ -198,9 +169,15 @@ export class DisplayClaimsComponent { this.getClaims(); } 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; } + getParametersString(){ var params=''; params+=(this.page==1?"":(params.length>0?'&':'')+"page="+this.page); @@ -212,7 +189,7 @@ export class DisplayClaimsComponent { } 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.fetchId==''?"":(params.length>0?'&':'')+"fetchId="+this.fetchId); } @@ -294,24 +271,6 @@ export class DisplayClaimsComponent { 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(); } setTypes(types:string){ diff --git a/portal-2/src/app/claims/claimsAdmin/claimsAdmin.component.ts b/portal-2/src/app/claims/claimsAdmin/claimsAdmin.component.ts index 06717a09..9420cf44 100644 --- a/portal-2/src/app/claims/claimsAdmin/claimsAdmin.component.ts +++ b/portal-2/src/app/claims/claimsAdmin/claimsAdmin.component.ts @@ -5,20 +5,15 @@ import {Observable} from 'rxjs/Observable'; @Component({ selector: 'claims-admin', template: ` -
+
- +
- - -
- TODO login -
`, }) @@ -26,11 +21,6 @@ export class ClaimsAdminComponent { constructor ( ) { } -user:string="argirok@di.uoa.gr"; ngOnInit() { - - } - - } diff --git a/portal-2/src/app/claims/directLinking/directLinking.component.ts b/portal-2/src/app/claims/directLinking/directLinking.component.ts index 97cfea5b..7c48572e 100644 --- a/portal-2/src/app/claims/directLinking/directLinking.component.ts +++ b/portal-2/src/app/claims/directLinking/directLinking.component.ts @@ -51,7 +51,7 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service'; (showChange)="showChange($event)" >
+ [bulkMode]=false> diff --git a/portal-2/src/app/claims/linking/insertClaim/insertClaim.component.ts b/portal-2/src/app/claims/linking/insertClaim/insertClaim.component.ts index 7ba0aa50..37b4a319 100644 --- a/portal-2/src/app/claims/linking/insertClaim/insertClaim.component.ts +++ b/portal-2/src/app/claims/linking/insertClaim/insertClaim.component.ts @@ -5,7 +5,7 @@ import {ClaimsService} from '../../claim-utils/service/claims.service'; import {ModalLoading} from '../../../utils/modal/loading.component'; import {AlertModal} from '../../../utils/modal/alert'; import {Md5} from 'ts-md5/dist/md5'; - +import {Session} from '../../../login/utils/helper.class'; @Component({ selector: 'claim-insert', template: ` @@ -19,7 +19,7 @@ import {Md5} from 'ts-md5/dist/md5'; - + ` }) export class ClaimInsertComponent { @@ -60,7 +60,8 @@ public validateInsertions(){ } private insert(){ this.claiming = true; - var user="argirok@di.uoa.gr" + var user=Session.getUserEmail(); + var jwt=Session.getUserJwt(); this.loading.open(); var claims = []; var directclaims = []; @@ -161,6 +162,7 @@ private validateDates(){ } private afterclaimsInsertion(insertedIds, errorInClaims){ this.loading.close(); + this.claiming = false; if(errorInClaims.length == 0 && insertedIds.length > 0 ){ // if(this.inline){ // this.show = "end"; @@ -178,6 +180,8 @@ private errorsInClaimsInsertion(insertedIds, errorInClaims){ this.errorMessage = "An Error Occured."; this.loading.close(); this.error = true; + this.claiming = false; + this.showButton = true; // if(this.inline){ // this.show = "error"; // this.showChange.emit({ diff --git a/portal-2/src/app/claims/linking/selected/selectedResults.component.ts b/portal-2/src/app/claims/linking/selected/selectedResults.component.ts index a1601461..3a563795 100644 --- a/portal-2/src/app/claims/linking/selected/selectedResults.component.ts +++ b/portal-2/src/app/claims/linking/selected/selectedResults.component.ts @@ -39,18 +39,18 @@ import {Dates} from '../../../utils/string-utils.class'; Publisher: {{pub.result.publisher}}({{pub.date.substring(0,4)}}) -
Authors: {{author.family}} {{author.given}}{{(i < (pub.result.author.length-1))?"; ":""}}
-
Editors: {{author.family}} {{author.given}}{{(i < (pub.result.editor.length-1))?"; ":""}}
+
Authors: {{author.family}} {{author.given}}{{(i < (pub.result.author.slice(0,10).length-1))?"; ":""}}
+
Editors: {{author.family}} {{author.given}}{{(i < (pub.result.editor.slice(0,10).length-1))?"; ":""}}
-
Authors: {{author.name}}{{(i < (pub.result.authors.length-1))?"; ":""}}
+
Authors: {{author.name}}{{(i < (pub.result.authors.slice(0,10).length-1))?"; ":""}}
Journal: {{pub.result['journal-title'].value}} -
Authors: {{author}}{{(i < (pub.result.contributors.length-1))?"; ":""}}
+
Authors: {{author}}{{(i < (pub.result.contributors.slice(0,10).length-1))?"; ":""}}
-
Authors: {{author}}{{(i < (pub.result.creator.length-1))?"; ":""}}
- +
Authors: {{author}}{{(i < (pub.result.creator.slice(0,10).length-1))?"; ":""}}
+
****sliced***
diff --git a/portal-2/src/app/claims/myClaims/myClaims.component.ts b/portal-2/src/app/claims/myClaims/myClaims.component.ts index d5e6c13e..d4d1177a 100644 --- a/portal-2/src/app/claims/myClaims/myClaims.component.ts +++ b/portal-2/src/app/claims/myClaims/myClaims.component.ts @@ -6,27 +6,22 @@ import {Observable} from 'rxjs/Observable'; @Component({ selector: 'my-claims', template: ` -
+
- +
- -
- TODO login -
` }) export class MyClaimsComponent { constructor () { } - user:string="argirok@di.uoa.gr"; ngOnInit() { } diff --git a/portal-2/src/app/deposit/datasets/depositDatasets-routing.module.ts b/portal-2/src/app/deposit/datasets/depositDatasets-routing.module.ts index d976262c..6c139e2b 100644 --- a/portal-2/src/app/deposit/datasets/depositDatasets-routing.module.ts +++ b/portal-2/src/app/deposit/datasets/depositDatasets-routing.module.ts @@ -3,11 +3,12 @@ import { RouterModule } from '@angular/router'; import { DepositDatasetsComponent } from './depositDatasets.component'; import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DepositDatasetsComponent } + { path: '', component: DepositDatasetsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/deposit/datasets/depositDatasets.module.ts b/portal-2/src/app/deposit/datasets/depositDatasets.module.ts index ae2630a4..e37a282f 100644 --- a/portal-2/src/app/deposit/datasets/depositDatasets.module.ts +++ b/portal-2/src/app/deposit/datasets/depositDatasets.module.ts @@ -7,6 +7,7 @@ import { DepositDatasetsResultComponent } from './depositDatasetsResult.componen import {DepositDatasetsRoutingModule} from './depositDatasets-routing.module'; import {DepoditModule} from '../deposit.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -22,7 +23,7 @@ import {DepoditModule} from '../deposit.module'; exports: [ DepositDatasetsComponent, ], - providers: [ + providers: [FreeGuard ] }) export class DepositDatasetsModule { } diff --git a/portal-2/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts b/portal-2/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts index 8356b40a..158810f0 100644 --- a/portal-2/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts +++ b/portal-2/src/app/deposit/datasets/depositDatasetsResults-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { DepositDatasetsResultComponent } from './depositDatasetsResult.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DepositDatasetsResultComponent } + { path: '', component: DepositDatasetsResultComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/deposit/datasets/depositDatasetsResults.module.ts b/portal-2/src/app/deposit/datasets/depositDatasetsResults.module.ts index 428e7327..d4704b5b 100644 --- a/portal-2/src/app/deposit/datasets/depositDatasetsResults.module.ts +++ b/portal-2/src/app/deposit/datasets/depositDatasetsResults.module.ts @@ -6,6 +6,7 @@ import { DepositDatasetsResultComponent } from './depositDatasetsResult.componen import {DepositDatasetsResultsRoutingModule} from './depositDatasetsResults-routing.module'; import {DepoditModule} from '../deposit.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -21,7 +22,7 @@ import {DepoditModule} from '../deposit.module'; exports: [ DepositDatasetsResultComponent, ], - providers: [ + providers: [FreeGuard ] }) export class DepositDatasetsResultsModule { } diff --git a/portal-2/src/app/deposit/depositResult.component.ts b/portal-2/src/app/deposit/depositResult.component.ts index adf484fb..3ee3e580 100644 --- a/portal-2/src/app/deposit/depositResult.component.ts +++ b/portal-2/src/app/deposit/depositResult.component.ts @@ -114,7 +114,6 @@ export class DepositResultComponent { private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService, private _organizationService: OrganizationService, private _meta: Meta) { - console.info("depositResult constructor"); this.zenodo = OpenaireProperties.getZenodoURL(); this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); diff --git a/portal-2/src/app/deposit/publications/depositPublications-routing.module.ts b/portal-2/src/app/deposit/publications/depositPublications-routing.module.ts index 81f6ca9f..e7fbcc84 100644 --- a/portal-2/src/app/deposit/publications/depositPublications-routing.module.ts +++ b/portal-2/src/app/deposit/publications/depositPublications-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { DepositPublicationsComponent } from './depositPublications.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DepositPublicationsComponent } + { path: '', component: DepositPublicationsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/deposit/publications/depositPublications.module.ts b/portal-2/src/app/deposit/publications/depositPublications.module.ts index b0197f34..77ccc00e 100644 --- a/portal-2/src/app/deposit/publications/depositPublications.module.ts +++ b/portal-2/src/app/deposit/publications/depositPublications.module.ts @@ -7,6 +7,7 @@ import { DepositPublicationsComponent } from './depositPublications.component'; import {DepositPublicationsRoutingModule} from './depositPublications-routing.module'; import {DepoditModule} from '../deposit.module'; import {IFrameModule} from '../../utils/iframe.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -22,7 +23,7 @@ import {IFrameModule} from '../../utils/iframe.module'; exports: [ DepositPublicationsComponent, ], - providers: [ + providers: [FreeGuard ] }) export class DepositPublicationsModule { } diff --git a/portal-2/src/app/deposit/publications/depositPublicationsResult-routing.module.ts b/portal-2/src/app/deposit/publications/depositPublicationsResult-routing.module.ts index 0a700b89..bdd8a8f2 100644 --- a/portal-2/src/app/deposit/publications/depositPublicationsResult-routing.module.ts +++ b/portal-2/src/app/deposit/publications/depositPublicationsResult-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { DepositPublicationsResultComponent } from './depositPublicationsResult.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DepositPublicationsResultComponent } + { path: '', component: DepositPublicationsResultComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/deposit/publications/depositPublicationsResults.module.ts b/portal-2/src/app/deposit/publications/depositPublicationsResults.module.ts index 07c37156..d5f5bb90 100644 --- a/portal-2/src/app/deposit/publications/depositPublicationsResults.module.ts +++ b/portal-2/src/app/deposit/publications/depositPublicationsResults.module.ts @@ -6,6 +6,7 @@ import { DepositPublicationsResultComponent } from './depositPublicationsResult. import {DepositPublicationsResultRoutingModule} from './depositPublicationsResult-routing.module'; import {DepoditModule} from '../deposit.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -21,7 +22,7 @@ import {DepoditModule} from '../deposit.module'; exports: [ DepositPublicationsResultComponent, ], - providers: [ + providers: [FreeGuard ] }) export class DepositPublicationsResultsModule { } diff --git a/portal-2/src/app/home/home-routing.module.ts b/portal-2/src/app/home/home-routing.module.ts deleted file mode 100644 index e47e1f4d..00000000 --- a/portal-2/src/app/home/home-routing.module.ts +++ /dev/null @@ -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 { } diff --git a/portal-2/src/app/home/home.component.ts b/portal-2/src/app/home/home.component.ts deleted file mode 100644 index 1d29bc22..00000000 --- a/portal-2/src/app/home/home.component.ts +++ /dev/null @@ -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:` - -
- -
-
- - -
-
-
- - -` - }) - -export class HomeComponent { - - constructor ( private _router: Router, private location: Location) { - - } - ngOnInit() { -} - - searchTerm(term: string) { - window.location.href="/search/find?keyword="+term; - } -} diff --git a/portal-2/src/app/home/home.module.ts b/portal-2/src/app/home/home.module.ts deleted file mode 100644 index 0b53d3b0..00000000 --- a/portal-2/src/app/home/home.module.ts +++ /dev/null @@ -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 { } diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider-routing.module.ts b/portal-2/src/app/landingPages/dataProvider/dataProvider-routing.module.ts index e12569ae..5911e19e 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider-routing.module.ts +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { DataProviderComponent } from './dataProvider.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DataProviderComponent } + { path: '', component: DataProviderComponent, canActivate: [FreeGuard] } ]) ] }) diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider.module.ts b/portal-2/src/app/landingPages/dataProvider/dataProvider.module.ts index 20e43faf..47d43f11 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider.module.ts +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider.module.ts @@ -26,22 +26,18 @@ import {ProjectsServiceModule} from '../../services/projectsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module'; import { DataProviderRoutingModule } from './dataProvider-routing.module'; - - +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ - imports: [ - CommonModule, FormsModule, RouterModule,DataProviderRoutingModule, - TabResultModule, IFrameModule, MetricsModule, LandingModule, DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, PublicationsServiceModule - - ], - declarations: [ - - PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, OrganizationsTabComponent, + imports: + [CommonModule, FormsModule, RouterModule,DataProviderRoutingModule, + TabResultModule, IFrameModule, MetricsModule, LandingModule, DataProvidersServiceModule, DatasetsServiceModule, ProjectsServiceModule, PublicationsServiceModule], + declarations: + [PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, OrganizationsTabComponent, RelatedDatasourcesTabComponent, DataProviderComponent ], providers:[ - DataProviderService + DataProviderService, FreeGuard ], exports: [ DataProviderComponent diff --git a/portal-2/src/app/landingPages/dataset/dataset-routing.module.ts b/portal-2/src/app/landingPages/dataset/dataset-routing.module.ts index 2b2205d2..9a8ce7d5 100644 --- a/portal-2/src/app/landingPages/dataset/dataset-routing.module.ts +++ b/portal-2/src/app/landingPages/dataset/dataset-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { DatasetComponent } from './dataset.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: DatasetComponent } + { path: '', component: DatasetComponent, canActivate: [FreeGuard] } ]) ] }) diff --git a/portal-2/src/app/landingPages/dataset/dataset.module.ts b/portal-2/src/app/landingPages/dataset/dataset.module.ts index 3b2f20ca..68252bc3 100644 --- a/portal-2/src/app/landingPages/dataset/dataset.module.ts +++ b/portal-2/src/app/landingPages/dataset/dataset.module.ts @@ -15,6 +15,7 @@ import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module'; import { ResultLandingModule } from '../resultLanding.module'; import { LandingModule } from '../landing.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -26,7 +27,7 @@ import { LandingModule } from '../landing.module'; DatasetComponent ], providers:[ - DatasetService + DatasetService, FreeGuard ], exports: [ DatasetComponent diff --git a/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts b/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts index 4659c99a..8d7db9ef 100644 --- a/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts +++ b/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { HtmlProjectReportComponent } from './htmlProjectReport.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: HtmlProjectReportComponent } + { path: '', component: HtmlProjectReportComponent , canActivate: [FreeGuard]} ]) ] }) diff --git a/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport.module.ts b/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport.module.ts index 11341130..00218772 100644 --- a/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport.module.ts +++ b/portal-2/src/app/landingPages/htmlProjectReport/htmlProjectReport.module.ts @@ -8,6 +8,7 @@ import { CacheService } from '../../shared/cache.service'; import {HtmlProjectReportService} from './htmlProjectReport.service'; import {HtmlProjectReportComponent} from './htmlProjectReport.component'; import { HtmlProjectReportRoutingModule } from './htmlProjectReport-routing.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -17,7 +18,7 @@ import { HtmlProjectReportRoutingModule } from './htmlProjectReport-routing.modu HtmlProjectReportComponent ], providers:[ - HtmlProjectReportService,CacheService + HtmlProjectReportService,CacheService, FreeGuard ], exports: [ HtmlProjectReportComponent diff --git a/portal-2/src/app/landingPages/organization/organization-routing.module.ts b/portal-2/src/app/landingPages/organization/organization-routing.module.ts index decd93d9..aaf1fa89 100644 --- a/portal-2/src/app/landingPages/organization/organization-routing.module.ts +++ b/portal-2/src/app/landingPages/organization/organization-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { OrganizationComponent } from './organization.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: OrganizationComponent } + { path: '', component: OrganizationComponent, canActivate: [FreeGuard] } ]) ] }) diff --git a/portal-2/src/app/landingPages/organization/organization.component.ts b/portal-2/src/app/landingPages/organization/organization.component.ts index b928fd74..87885498 100644 --- a/portal-2/src/app/landingPages/organization/organization.component.ts +++ b/portal-2/src/app/landingPages/organization/organization.component.ts @@ -64,7 +64,6 @@ export class OrganizationComponent { private _searchPublicationsService: SearchPublicationsService, private _searchProjectsService: SearchProjectsService, private _meta: Meta) { - console.info('organization constructor'); this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService); } diff --git a/portal-2/src/app/landingPages/organization/organization.module.ts b/portal-2/src/app/landingPages/organization/organization.module.ts index 1440ebbb..d7f4a2a8 100644 --- a/portal-2/src/app/landingPages/organization/organization.module.ts +++ b/portal-2/src/app/landingPages/organization/organization.module.ts @@ -19,6 +19,7 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu import {ProjectsServiceModule} from '../../services/projectsService.module'; import { SearchingProjectsTabModule} from '../searchingProjectsInTab.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -40,6 +41,7 @@ import { SearchingProjectsTabModule} from '../searchingProjectsInTab.module'; OrganizationComponent, ], providers:[ + FreeGuard ], exports: [ OrganizationComponent diff --git a/portal-2/src/app/landingPages/person/person-routing.module.ts b/portal-2/src/app/landingPages/person/person-routing.module.ts index ee064156..224f2c86 100644 --- a/portal-2/src/app/landingPages/person/person-routing.module.ts +++ b/portal-2/src/app/landingPages/person/person-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { PersonComponent } from './person.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: PersonComponent } + { path: '', component: PersonComponent, canActivate: [FreeGuard] } ]) ] }) diff --git a/portal-2/src/app/landingPages/person/person.component.ts b/portal-2/src/app/landingPages/person/person.component.ts index 37cd935b..e9cdfc4c 100644 --- a/portal-2/src/app/landingPages/person/person.component.ts +++ b/portal-2/src/app/landingPages/person/person.component.ts @@ -40,7 +40,6 @@ export class PersonComponent { private _searchPublicationsService: SearchPublicationsService, private _searchDatasetsService: SearchDatasetsService, private _meta: Meta) { - console.info('person constructor'); this.fetchPublications = new FetchPublications( this._searchPublicationsService); this.fetchDatasets = new FetchDatasets( this._searchDatasetsService); // this.scrollUp = this._route.events.subscribe((path) => { diff --git a/portal-2/src/app/landingPages/person/person.module.ts b/portal-2/src/app/landingPages/person/person.module.ts index 0d0a514c..8fd98ecc 100644 --- a/portal-2/src/app/landingPages/person/person.module.ts +++ b/portal-2/src/app/landingPages/person/person.module.ts @@ -11,6 +11,7 @@ import { LandingModule } from '../landing.module'; import {TabResultModule } from '../../searchPages/searchUtils/tabResult.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -24,7 +25,7 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu PersonComponent ], providers:[ - PersonService + PersonService, FreeGuard ], exports: [ PersonComponent diff --git a/portal-2/src/app/landingPages/publication/publication-routing.module.ts b/portal-2/src/app/landingPages/publication/publication-routing.module.ts index 98f7c625..d2d40638 100644 --- a/portal-2/src/app/landingPages/publication/publication-routing.module.ts +++ b/portal-2/src/app/landingPages/publication/publication-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { PublicationComponent } from './publication.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: PublicationComponent } + { path: '', component: PublicationComponent, canActivate: [FreeGuard] } ]) ] }) diff --git a/portal-2/src/app/landingPages/publication/publication.module.ts b/portal-2/src/app/landingPages/publication/publication.module.ts index 909d2719..1c4dd98a 100644 --- a/portal-2/src/app/landingPages/publication/publication.module.ts +++ b/portal-2/src/app/landingPages/publication/publication.module.ts @@ -16,6 +16,7 @@ import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module'; import { ResultLandingModule } from '../resultLanding.module'; import { LandingModule } from '../landing.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -26,7 +27,7 @@ import { LandingModule } from '../landing.module'; PublicationComponent ], providers:[ - PublicationService + PublicationService, FreeGuard ], exports: [ PublicationComponent diff --git a/portal-2/src/app/landingPages/showAuthors.component.ts b/portal-2/src/app/landingPages/showAuthors.component.ts index 817b5f40..454957e2 100644 --- a/portal-2/src/app/landingPages/showAuthors.component.ts +++ b/portal-2/src/app/landingPages/showAuthors.component.ts @@ -41,7 +41,6 @@ export class ShowAuthorsComponent { private showAll: boolean = false; constructor () { - console.info('showAuthors constructor'); } ngOnInit() { diff --git a/portal-2/src/app/landingPages/showIdentifiers.component.ts b/portal-2/src/app/landingPages/showIdentifiers.component.ts index 533a5b3e..744c1962 100644 --- a/portal-2/src/app/landingPages/showIdentifiers.component.ts +++ b/portal-2/src/app/landingPages/showIdentifiers.component.ts @@ -32,7 +32,6 @@ export class ShowIdentifiersComponent { pmcURL: string; constructor () { - console.info('showIdentifiers constructor'); this.doiURL = OpenaireProperties.getDoiURL(); this.pmcURL = OpenaireProperties.getPmcURL(); } diff --git a/portal-2/src/app/landingPages/showSubjects.component.ts b/portal-2/src/app/landingPages/showSubjects.component.ts index 6890e913..f5cc25cb 100644 --- a/portal-2/src/app/landingPages/showSubjects.component.ts +++ b/portal-2/src/app/landingPages/showSubjects.component.ts @@ -62,7 +62,6 @@ export class ShowSubjectsComponent { private showClassifiedSbj: boolean = false; constructor () { - console.info('showSubjects constructor'); } ngOnInit() { diff --git a/portal-2/src/app/landingPages/showTitle.component.ts b/portal-2/src/app/landingPages/showTitle.component.ts index 7a933f57..33202d15 100644 --- a/portal-2/src/app/landingPages/showTitle.component.ts +++ b/portal-2/src/app/landingPages/showTitle.component.ts @@ -41,7 +41,6 @@ export class ShowTitleComponent { @Input() title: { [key: string]: string }; constructor () { - console.info('title constructor'); } ngOnInit() { diff --git a/portal-2/src/app/landingPages/tabPaging.component.ts b/portal-2/src/app/landingPages/tabPaging.component.ts index f1afeab4..f0671764 100644 --- a/portal-2/src/app/landingPages/tabPaging.component.ts +++ b/portal-2/src/app/landingPages/tabPaging.component.ts @@ -17,7 +17,6 @@ export class TabPagingComponent { @Output() changeShowAll: EventEmitter = new EventEmitter(); constructor () { - console.info('publication:paging constructor'); } ngOnInit() { diff --git a/portal-2/src/app/landingPages/tabTable.component.ts b/portal-2/src/app/landingPages/tabTable.component.ts index b4bfe63c..05be3f1e 100644 --- a/portal-2/src/app/landingPages/tabTable.component.ts +++ b/portal-2/src/app/landingPages/tabTable.component.ts @@ -63,11 +63,9 @@ export class TabTableComponent { public searchLinkToDataset: string; constructor () { - console.info('tabTable constructor'); } ngOnInit() { - console.info('tabTable ngOnInit'); this.searchLinkToPublication = OpenaireProperties.getsearchLinkToPublication(); this.searchLinkToDataset = OpenaireProperties.getsearchLinkToDataset(); } diff --git a/portal-2/src/app/login/adminLoginGuard.guard.ts b/portal-2/src/app/login/adminLoginGuard.guard.ts index 0fb9451c..eb08b95e 100644 --- a/portal-2/src/app/login/adminLoginGuard.guard.ts +++ b/portal-2/src/app/login/adminLoginGuard.guard.ts @@ -1,33 +1,39 @@ 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 AdminLoginGuard implements CanActivate { constructor(private router: Router) {} canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { - console.log("AAA inside the AdminLoginGuard!") var user; var loggedIn = false; var isAdmin = false; + var errorCode = 1; - if( typeof localStorage !== 'undefined') { - if(localStorage.getItem("user")) { - loggedIn = true; - user = JSON.parse(localStorage.getItem("user")); - if(user.role == 2){ - isAdmin = true; - } + if(Session.isLoggedIn()){ + loggedIn = true; + if(!Session.isValidAndRemove()){ + loggedIn = false; + errorCode = 3; + }else { + isAdmin = Session.isAdminUser(); + if(!isAdmin){ + errorCode = 2; } + } + }else{ + errorCode =1; } + 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; }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; }else{ return true; diff --git a/portal-2/src/app/login/freeGuard.guard.ts b/portal-2/src/app/login/freeGuard.guard.ts new file mode 100644 index 00000000..4d455706 --- /dev/null +++ b/portal-2/src/app/login/freeGuard.guard.ts @@ -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 { + 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; + + } +} diff --git a/portal-2/src/app/login/login.service.ts b/portal-2/src/app/login/login.service.ts index d6e17102..76fb2400 100644 --- a/portal-2/src/app/login/login.service.ts +++ b/portal-2/src/app/login/login.service.ts @@ -1,5 +1,5 @@ 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 'rxjs/add/observable/of'; import 'rxjs/add/operator/do'; @@ -8,7 +8,7 @@ import 'rxjs/add/operator/share'; import { CacheService } from '../shared/cache.service'; import {PersonInfo} from '../utils/entities/personInfo'; import {OpenaireProperties} from '../utils/properties/openaireProperties'; -import {User} from '../utils/entities/user'; +import {User,Session,MyJWT} from './utils/helper.class'; @Injectable() @@ -16,51 +16,28 @@ export class LoginService { 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 options = new RequestOptions({ headers: headers }); + let body = JSON.stringify( {"username":username, "password":password} ); - return this.http.post(this.heroesUrl, { name }, options) - .map(this.extractData) - .catch(this.handleError); -*/ - let url = OpenaireProperties.getLoginAPIURL()+username+"&password="+password; - let key = url; - if (this._cache.has(key)) { - return Observable.of(this._cache.get(key)); - } - return this.http.get(url) - .map(res => res.json()) - .map(res => this.parseUserInfo(res['data'])) - .do(res => { - this._cache.set(key, res); - }); + return this.http.post(OpenaireProperties.getLoginAPIURL(), body,options) + .map(res => 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 => res.json()) + // .map(res =>this.parse(res['data'])); } - private validateJWTFormat(data){ - if(data == null || (data.indexOf(".") !=-1 && data.split('.').length != 3)){ - return false; - } - return true; + parse(data:any){ + return MyJWT.parseUserInfo(data); } - 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; - } } diff --git a/portal-2/src/app/login/loginGuard.guard.ts b/portal-2/src/app/login/loginGuard.guard.ts index cb0d7fdb..17c63c81 100644 --- a/portal-2/src/app/login/loginGuard.guard.ts +++ b/portal-2/src/app/login/loginGuard.guard.ts @@ -1,6 +1,7 @@ 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 LoginGuard implements CanActivate { @@ -8,17 +9,21 @@ export class LoginGuard implements CanActivate { constructor(private router: Router) {} canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean { - console.log("AAA inside the LoginGuard!") var user; var loggedIn = false; - if( typeof localStorage !== 'undefined') { - if(localStorage.getItem("user")) { - user = JSON.parse(localStorage.getItem("user")); - loggedIn = true; - } + var errorCode = 1; + + if(Session.isLoggedIn()){ + loggedIn = true; + if(!Session.isValidAndRemove()){ + loggedIn = false; + errorCode = 3; + } + }else{ + errorCode = 1; } 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; }else{ return true; diff --git a/portal-2/src/app/login/user.component.ts b/portal-2/src/app/login/user.component.ts index 50e6f068..5435c80f 100644 --- a/portal-2/src/app/login/user.component.ts +++ b/portal-2/src/app/login/user.component.ts @@ -3,27 +3,30 @@ import {Observable} from 'rxjs/Observable'; import {ActivatedRoute, Router} from '@angular/router'; 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({ selector: 'user', template: ` -
+
The requested page requires authentication. Please login.
You are not authorized to use the requested page
+
+ The session has expired. Please log in again or continue browsing as a guest. +
Login Form
- +
- +
@@ -40,48 +43,35 @@ import {User} from '../utils/entities/user';
- - ` }) export class UserComponent { public user: User; public loggedIn: boolean = false; + public server: boolean = true; public errorMessage: string; public username: string = ""; public password: string = ""; private sub:any;private sublogin:any; public errorCode: string = ""; public redirectUrl: string = ""; + public routerHelper:RouterHelper = new RouterHelper(); constructor( private router: Router, private _loginService: LoginService, private route: ActivatedRoute ) {} ngOnInit() { - if( typeof localStorage !== 'undefined') { - if(localStorage.getItem("user")) { - this.user = JSON.parse(localStorage.getItem("user")); - if(this.user && this.user.id){ - this.loggedIn = true; - }else{ - this.loggedIn = false; - } - } + if( typeof document !== 'undefined') { + this.server = false; } + this.loggedIn = Session.isLoggedIn(); + this.user = Session.getUser(); this.errorMessage = ""; this.sub = this.route.queryParams.subscribe(params => { this.errorCode = params["errorCode"]; this.redirectUrl = params["redirectUrl"]; - if( typeof localStorage !== 'undefined') { - if(localStorage.getItem("user")) { - 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 = ""; }); } @@ -92,20 +82,39 @@ export class UserComponent { } } logout(){ - localStorage.removeItem("user"); + if(Session.isLoggedIn()){ + Session.removeUser(); + } this.loggedIn = false; this.user = new User(); this.username = ""; this.password = ""; - - this.redirect(); + this.redirect(); } redirect(){ 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{ - this.router.navigate(['/user-info']); + this.router.navigate(['/search/find']); } } login() { diff --git a/portal-2/src/app/login/userMini.component.ts b/portal-2/src/app/login/userMini.component.ts index b3f6a442..f9fb8a74 100644 --- a/portal-2/src/app/login/userMini.component.ts +++ b/portal-2/src/app/login/userMini.component.ts @@ -3,35 +3,40 @@ import {Observable} from 'rxjs/Observable'; import {ActivatedRoute, Router} from '@angular/router'; import {Location} from '@angular/common'; 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({ selector: 'user-mini', template: ` -
- Hello {{user.fullname}}! - Log outLog in +
+ Hello {{user.fullname}}! + Hello Guest! + Log in
- - ` }) export class UserMiniComponent { public user: User; public loggedIn: boolean = false; + public server: boolean = true; + public routerHelper:RouterHelper = new RouterHelper(); public redirectUrl: string = ""; + private baseUrl = "user-info"; sub:any; constructor( private router: Router, private route: ActivatedRoute, private location: Location) {} ngOnInit() { + if( typeof document !== 'undefined') { + this.server = false; + } this.initialize(); this.sub = this.route.queryParams.subscribe(params => { - - this.initialize(); + this.initialize(); }); } ngOnDestroy(){ @@ -39,21 +44,28 @@ export class UserMiniComponent { } initialize(){ this.redirectUrl = this.location.path(); - if( typeof localStorage !== 'undefined') { - if(localStorage.getItem("user")) { - this.user = JSON.parse(localStorage.getItem("user")); - if(this.user && this.user.id){ - this.loggedIn = true; - }else{ - this.loggedIn = false; - } - }else{ - this.loggedIn = false; - } + if(Session.isLoggedIn()){ + if(Session.isUserValid()){ + this.loggedIn = Session.isLoggedIn(); + this.user = Session.getUser(); }else{ + Session.removeUser(); 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]); + } } - } diff --git a/portal-2/src/app/login/utils/helper.class.ts b/portal-2/src/app/login/utils/helper.class.ts new file mode 100644 index 00000000..a00a9b47 --- /dev/null +++ b/portal-2/src/app/login/utils/helper.class.ts @@ -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; + } + + +} diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts index 981e2fbf..4c3fb074 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchDataProvidersComponent } + { path: '', component: AdvancedSearchDataProvidersComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.module.ts index 22dff9a1..b9f00af4 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.module.ts @@ -8,6 +8,7 @@ import{AdvancedSearchDataProvidersComponent} from './advancedSearchDataProviders import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -19,7 +20,7 @@ import {DataProvidersServiceModule} from '../../services/dataProvidersService.mo declarations: [ AdvancedSearchDataProvidersComponent ], - providers:[ + providers:[FreeGuard ], exports: [ AdvancedSearchDataProvidersComponent diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts index d3c04537..700d65f3 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchDatasetsComponent } + { path: '', component: AdvancedSearchDatasetsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.module.ts index 3f4b53fe..5a38795c 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDatasets.module.ts @@ -8,6 +8,7 @@ import{AdvancedSearchDatasetsComponent} from './advancedSearchDatasets.component import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -19,7 +20,7 @@ import {DatasetsServiceModule} from '../../services/datasetsService.module'; declarations: [ AdvancedSearchDatasetsComponent ], - providers:[ + providers:[FreeGuard ], exports: [ AdvancedSearchDatasetsComponent diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts index 73bf1720..c04401bc 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchOrganizationsComponent } + { path: '', component: AdvancedSearchOrganizationsComponent , canActivate: [FreeGuard]} ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.module.ts index dce63f08..aff4b1c7 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchOrganizations.module.ts @@ -8,6 +8,7 @@ import{AdvancedSearchOrganizationsComponent} from './advancedSearchOrganizations import {OrganizationsServiceModule} from '../../services/organizationsService.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -19,7 +20,7 @@ import {OrganizationsServiceModule} from '../../services/organizationsService.mo declarations: [ AdvancedSearchOrganizationsComponent ], - providers:[ + providers:[FreeGuard ], exports: [ AdvancedSearchOrganizationsComponent diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPeople-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPeople-routing.module.ts index 76ab818f..5bd4d9a5 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPeople-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPeople-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{AdvancedSearchPeopleComponent} from './advancedSearchPeople.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchPeopleComponent } + { path: '', component: AdvancedSearchPeopleComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPeople.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPeople.module.ts index 8192f3c1..7500f792 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPeople.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPeople.module.ts @@ -8,6 +8,7 @@ import{AdvancedSearchPeopleComponent} from './advancedSearchPeople.component'; import {PeopleServiceModule} from '../../services/peopleService.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -19,7 +20,7 @@ import {PeopleServiceModule} from '../../services/peopleService.module'; declarations: [ AdvancedSearchPeopleComponent ], - providers:[ + providers:[FreeGuard ], exports: [ AdvancedSearchPeopleComponent diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts index 2948f8da..edf916e8 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchProjects-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchProjectsComponent } + { path: '', component: AdvancedSearchProjectsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchProjects.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchProjects.module.ts index caa7787d..6357286b 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchProjects.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchProjects.module.ts @@ -8,6 +8,7 @@ import{AdvancedSearchProjectsComponent} from './advancedSearchProjects.component import {ProjectsServiceModule} from '../../services/projectsService.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -19,7 +20,7 @@ import {ProjectsServiceModule} from '../../services/projectsService.module'; declarations: [ AdvancedSearchProjectsComponent ], - providers:[ + providers:[FreeGuard ], exports: [ AdvancedSearchProjectsComponent diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts index 97a2fda8..f56f4348 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPublications-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: AdvancedSearchPublicationsComponent } + { path: '', component: AdvancedSearchPublicationsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.module.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.module.ts index c6f0cfcd..35f5ac18 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.module.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.module.ts @@ -8,6 +8,7 @@ import{AdvancedSearchPublicationsComponent} from './advancedSearchPublications.c import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {AdvancedSearchPageModule} from '../searchUtils/advancedSearchPage.module'; + import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -19,7 +20,7 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu declarations: [ AdvancedSearchPublicationsComponent ], - providers:[ + providers:[FreeGuard ], exports: [ AdvancedSearchPublicationsComponent diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts index 4e474f98..58111a67 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchCompatibleDataprovidersComponent} from './compatibleDataProviders.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchCompatibleDataprovidersComponent } + { path: '', component: SearchCompatibleDataprovidersComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.module.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.module.ts index d5497968..ecf4518f 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.module.ts @@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + @NgModule({ imports: [ CommonModule, FormsModule, @@ -20,7 +22,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module'; declarations: [ SearchCompatibleDataprovidersComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchCompatibleDataprovidersComponent diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts index ab2bb1ab..46ea5b44 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistries-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchEntityRegistriesComponent} from './entityRegistries.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchEntityRegistriesComponent } + { path: '', component: SearchEntityRegistriesComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistries.module.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistries.module.ts index 0512597c..a05f1dd4 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistries.module.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistries.module.ts @@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + @NgModule({ imports: [ CommonModule, FormsModule, @@ -20,7 +22,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module'; declarations: [ SearchEntityRegistriesComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchEntityRegistriesComponent diff --git a/portal-2/src/app/searchPages/find/mainSearch-routing.module.ts b/portal-2/src/app/searchPages/find/mainSearch-routing.module.ts index 362ef038..ab4c3d22 100644 --- a/portal-2/src/app/searchPages/find/mainSearch-routing.module.ts +++ b/portal-2/src/app/searchPages/find/mainSearch-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchComponent} from './search.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchComponent } + { path: '', component: SearchComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/find/mainSearch.module.ts b/portal-2/src/app/searchPages/find/mainSearch.module.ts index b2faad07..4d63b1b3 100644 --- a/portal-2/src/app/searchPages/find/mainSearch.module.ts +++ b/portal-2/src/app/searchPages/find/mainSearch.module.ts @@ -16,6 +16,7 @@ import {OrganizationsServiceModule} from '../../services/organizationsService.mo import {PeopleServiceModule} from '../../services/peopleService.module'; import {BrowseEntitiesModule} from '../searchUtils/browseEntities.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ @@ -28,7 +29,7 @@ import {SearchFormModule} from '../searchUtils/searchForm.module'; declarations: [ SearchComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchComponent diff --git a/portal-2/src/app/searchPages/simple/searchDataProviders-routing.module.ts b/portal-2/src/app/searchPages/simple/searchDataProviders-routing.module.ts index 70ce05a6..fefe1cc3 100644 --- a/portal-2/src/app/searchPages/simple/searchDataProviders-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchDataProviders-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchDataprovidersComponent} from './searchDataproviders.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchDataprovidersComponent } + { path: '', component: SearchDataprovidersComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchDataProviders.module.ts b/portal-2/src/app/searchPages/simple/searchDataProviders.module.ts index 21cb9fd6..03e24660 100644 --- a/portal-2/src/app/searchPages/simple/searchDataProviders.module.ts +++ b/portal-2/src/app/searchPages/simple/searchDataProviders.module.ts @@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module'; import {DataProvidersServiceModule} from '../../services/dataProvidersService.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + @NgModule({ imports: [ CommonModule, FormsModule, @@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module'; declarations: [ SearchDataprovidersComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchDataprovidersComponent diff --git a/portal-2/src/app/searchPages/simple/searchDatasets-routing.module.ts b/portal-2/src/app/searchPages/simple/searchDatasets-routing.module.ts index 8eaaabff..a3f3e976 100644 --- a/portal-2/src/app/searchPages/simple/searchDatasets-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchDatasets-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchDatasetsComponent} from './searchDatasets.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchDatasetsComponent } + { path: '', component: SearchDatasetsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchDatasets.module.ts b/portal-2/src/app/searchPages/simple/searchDatasets.module.ts index 63cf2ee7..d686200d 100644 --- a/portal-2/src/app/searchPages/simple/searchDatasets.module.ts +++ b/portal-2/src/app/searchPages/simple/searchDatasets.module.ts @@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + @NgModule({ imports: [ CommonModule, FormsModule, @@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module'; declarations: [ SearchDatasetsComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchDatasetsComponent diff --git a/portal-2/src/app/searchPages/simple/searchOrganizations-routing.module.ts b/portal-2/src/app/searchPages/simple/searchOrganizations-routing.module.ts index f1dda3f6..cb8ff00d 100644 --- a/portal-2/src/app/searchPages/simple/searchOrganizations-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchOrganizations-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchOrganizationsComponent} from './searchOrganizations.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchOrganizationsComponent } + { path: '', component: SearchOrganizationsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchOrganizations.module.ts b/portal-2/src/app/searchPages/simple/searchOrganizations.module.ts index ba4d802f..4f50fe2a 100644 --- a/portal-2/src/app/searchPages/simple/searchOrganizations.module.ts +++ b/portal-2/src/app/searchPages/simple/searchOrganizations.module.ts @@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module'; import {OrganizationsServiceModule} from '../../services/organizationsService.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + @NgModule({ imports: [ CommonModule, FormsModule, @@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module'; declarations: [ SearchOrganizationsComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchOrganizationsComponent diff --git a/portal-2/src/app/searchPages/simple/searchPeople-routing.module.ts b/portal-2/src/app/searchPages/simple/searchPeople-routing.module.ts index 26d6a609..210130c7 100644 --- a/portal-2/src/app/searchPages/simple/searchPeople-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchPeople-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchPeopleComponent} from './searchPeople.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchPeopleComponent } + { path: '', component: SearchPeopleComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchPeople.module.ts b/portal-2/src/app/searchPages/simple/searchPeople.module.ts index 746d398f..2cdc30de 100644 --- a/portal-2/src/app/searchPages/simple/searchPeople.module.ts +++ b/portal-2/src/app/searchPages/simple/searchPeople.module.ts @@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module'; import {PeopleServiceModule} from '../../services/peopleService.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + @NgModule({ imports: [ CommonModule, FormsModule, @@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module'; declarations: [ SearchPeopleComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchPeopleComponent diff --git a/portal-2/src/app/searchPages/simple/searchProjects-routing.module.ts b/portal-2/src/app/searchPages/simple/searchProjects-routing.module.ts index 46a2f5cd..11f2e575 100644 --- a/portal-2/src/app/searchPages/simple/searchProjects-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchProjects-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchProjectsComponent} from './searchProjects.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchProjectsComponent } + { path: '', component: SearchProjectsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchProjects.module.ts b/portal-2/src/app/searchPages/simple/searchProjects.module.ts index f7642d80..083f430e 100644 --- a/portal-2/src/app/searchPages/simple/searchProjects.module.ts +++ b/portal-2/src/app/searchPages/simple/searchProjects.module.ts @@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module'; import {ProjectsServiceModule} from '../../services/projectsService.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + @NgModule({ imports: [ CommonModule, FormsModule, @@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module'; declarations: [ SearchProjectsComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchProjectsComponent diff --git a/portal-2/src/app/searchPages/simple/searchPublications-routing.module.ts b/portal-2/src/app/searchPages/simple/searchPublications-routing.module.ts index 9ac5a5db..ace89403 100644 --- a/portal-2/src/app/searchPages/simple/searchPublications-routing.module.ts +++ b/portal-2/src/app/searchPages/simple/searchPublications-routing.module.ts @@ -2,11 +2,12 @@ import { NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import{SearchPublicationsComponent} from './searchPublications.component'; +import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ RouterModule.forChild([ - { path: '', component: SearchPublicationsComponent } + { path: '', component: SearchPublicationsComponent, canActivate: [FreeGuard] } ]) ] diff --git a/portal-2/src/app/searchPages/simple/searchPublications.module.ts b/portal-2/src/app/searchPages/simple/searchPublications.module.ts index 7cd16867..20ea399e 100644 --- a/portal-2/src/app/searchPages/simple/searchPublications.module.ts +++ b/portal-2/src/app/searchPages/simple/searchPublications.module.ts @@ -10,6 +10,8 @@ import {SearchResultsModule } from '../searchUtils/searchResults.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {SearchFormModule} from '../searchUtils/searchForm.module'; import {SearchPageModule} from '../searchUtils/searchPage.module'; +import {FreeGuard} from'../../login/freeGuard.guard'; + @NgModule({ imports: [ CommonModule, FormsModule, @@ -21,7 +23,7 @@ import {SearchPageModule} from '../searchUtils/searchPage.module'; declarations: [ SearchPublicationsComponent ], - providers:[ + providers:[FreeGuard ], exports: [ SearchPublicationsComponent diff --git a/portal-2/src/app/utils/entities/user.ts b/portal-2/src/app/utils/entities/user.ts deleted file mode 100644 index aaed5ab0..00000000 --- a/portal-2/src/app/utils/entities/user.ts +++ /dev/null @@ -1,6 +0,0 @@ -export class User { - email:string; - username: string; - id: string; - fullname: string; -} diff --git a/portal-2/src/app/utils/exportCSV.class.ts b/portal-2/src/app/utils/exportCSV.class.ts index ca4f4918..c5e39a33 100644 --- a/portal-2/src/app/utils/exportCSV.class.ts +++ b/portal-2/src/app/utils/exportCSV.class.ts @@ -55,7 +55,6 @@ export class ExportCSVComponent { linkname: string = "Download CSV"; constructor () { - console.info('export constructor'); } ngOnInit() { diff --git a/portal-2/src/app/utils/properties/openaireProperties.ts b/portal-2/src/app/utils/properties/openaireProperties.ts index 8bdd8eef..429864c6 100644 --- a/portal-2/src/app/utils/properties/openaireProperties.ts +++ b/portal-2/src/app/utils/properties/openaireProperties.ts @@ -31,7 +31,7 @@ export class OpenaireProperties { private static metricsAPIURL = "http://vatopedi.di.uoa.gr:8080/stats/"; 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/" private static claimsAPIURL = "http://scoobydoo.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/"; diff --git a/portal-2/src/app/utils/showDataProviders.component.ts b/portal-2/src/app/utils/showDataProviders.component.ts index 853a8b1f..a4f88fc2 100644 --- a/portal-2/src/app/utils/showDataProviders.component.ts +++ b/portal-2/src/app/utils/showDataProviders.component.ts @@ -59,7 +59,6 @@ export class ShowDataProvidersComponent { "organizations": {"name": string, "url": string}[]}[]; constructor () { - console.info('showDataProviders constructor'); } ngOnInit() {} diff --git a/portal-2/src/server.routes.ts b/portal-2/src/server.routes.ts index 8ca19d00..9b08ec01 100644 --- a/portal-2/src/server.routes.ts +++ b/portal-2/src/server.routes.ts @@ -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', 'participate/deposit-publications','participate/deposit-datasets','participate/deposit-publications-result','participate/deposit-datasets-result', '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', - 'error' + '**','error' ];