options for more memory in package.json |Claims: add root community in the list of concepts , add fields/parsing for direct index claim, create direct index claim record | Create Guards for routes that need authentication or admin roles | scroll in browse results| login component that works with guards

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@46737 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2017-04-07 15:35:39 +00:00
parent e5ddfc8955
commit 12aa6406eb
41 changed files with 600 additions and 272 deletions

View File

@ -7,7 +7,7 @@
"url": "https://github.com/angular/universal-starter.git" "url": "https://github.com/angular/universal-starter.git"
}, },
"scripts": { "scripts": {
"watch": "webpack --watch", "watch": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --watch",
"watch:dev": "npm run server & npm run watch", "watch:dev": "npm run server & npm run watch",
"clean:dist": "rimraf dist", "clean:dist": "rimraf dist",
"clean:ngc": "rimraf **/*.ngfactory.ts **/*.css.shim.ts", "clean:ngc": "rimraf **/*.ngfactory.ts **/*.css.shim.ts",
@ -15,13 +15,13 @@
"build": "webpack --progress", "build": "webpack --progress",
"build:prod:ngc": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod", "build:prod:ngc": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod",
"build:prod:ngc:json": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod:json", "build:prod:ngc:json": "npm run clean:ngc && npm run ngc && npm run clean:dist && npm run build:prod:json",
"build:prod": "webpack --config webpack.prod.config.ts", "build:prod": "node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js --config webpack.prod.config.ts",
"build:prod:json": "webpack --config webpack.prod.config.ts --json | webpack-bundle-size-analyzer", "build:prod:json": "webpack --config webpack.prod.config.ts --json | webpack-bundle-size-analyzer",
"ngc": "ngc -p tsconfig.aot.json", "ngc": "ngc -p tsconfig.aot.json",
"prestart": "npm run build", "prestart": "npm run build",
"minify": "uglifyjs dist/client/main.bundle.js --screw-ie8 --compress --mangle --output dist/client/main.bundle.min.js", "minify": "uglifyjs dist/client/main.bundle.js --screw-ie8 --compress --mangle --output dist/client/main.bundle.min.js",
"minify-test": "uglifyjs dist/client/main.bundle.js --output dist/client/main.xmin.js", "minify-test": "uglifyjs dist/client/main.bundle.js --output dist/client/main.xmin.js",
"server": "nodemon dist/server/index.js", "server": "nodemon dist/server/index.js",
"debug:server": "node-nightly --inspect --debug-brk dist/server/index.js", "debug:server": "node-nightly --inspect --debug-brk dist/server/index.js",
"start": "npm run server", "start": "npm run server",
"debug:start": "npm run build && npm run debug:server", "debug:start": "npm run build && npm run debug:server",
@ -57,6 +57,7 @@
"angular2-platform-node": "~2.1.0-rc.1", "angular2-platform-node": "~2.1.0-rc.1",
"angular2-universal": "~2.1.0-rc.1", "angular2-universal": "~2.1.0-rc.1",
"angular2-universal-polyfills": "~2.1.0-rc.1", "angular2-universal-polyfills": "~2.1.0-rc.1",
"base64url": "^2.0.0",
"body-parser": "^1.15.2", "body-parser": "^1.15.2",
"citation-js": "^0.3.0-2", "citation-js": "^0.3.0-2",
"clipboard": "^1.5.16", "clipboard": "^1.5.16",
@ -65,9 +66,9 @@
"js.clone": "0.0.3", "js.clone": "0.0.3",
"methods": "~1.1.2", "methods": "~1.1.2",
"morgan": "^1.7.0", "morgan": "^1.7.0",
"mydatepicker": "^1.7.3",
"preboot": "~4.5.2", "preboot": "~4.5.2",
"rxjs": "5.0.0-beta.12", "rxjs": "5.0.0-beta.12",
"ts-md5": "^1.2.0",
"webfontloader": "^1.6.26", "webfontloader": "^1.6.26",
"zone.js": "~0.6.26" "zone.js": "~0.6.26"
}, },

View File

@ -119,18 +119,19 @@ export function getLinkingModule() {
return System.import('./claims/linking/linkingGeneric.module' + (process.env.AOT ? '.ngfactory' : '')) return System.import('./claims/linking/linkingGeneric.module' + (process.env.AOT ? '.ngfactory' : ''))
.then(mod => mod[(process.env.AOT ? 'LinkingGenericModuleNgFactory' : 'LinkingGenericModule')]); .then(mod => mod[(process.env.AOT ? 'LinkingGenericModuleNgFactory' : 'LinkingGenericModule')]);
} }
// export function getBulkLinkingModule() {
// return System.import('./claims/linking/bulkLinking.module' + (process.env.AOT ? '.ngfactory' : ''))
// .then(mod => mod[(process.env.AOT ? 'BulkLinkingModuleNgFactory' : 'BulkLinkingModule')]);
// }
export function getDirectLinkingModule() { export function getDirectLinkingModule() {
return System.import('./claims/directLinking/directLinking.module' + (process.env.AOT ? '.ngfactory' : '')) return System.import('./claims/directLinking/directLinking.module' + (process.env.AOT ? '.ngfactory' : ''))
.then(mod => mod[(process.env.AOT ? 'DirectLinkingModuleNgFactory' : 'DirectLinkingModule')]); .then(mod => mod[(process.env.AOT ? 'DirectLinkingModuleNgFactory' : 'DirectLinkingModule')]);
} }
export function getUserModule() {
return System.import('./login/user.module' + (process.env.AOT ? '.ngfactory' : ''))
.then(mod => mod[(process.env.AOT ? 'UserModuleNgFactory' : 'UserModule')]);
}
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', redirectTo: '/search/find', pathMatch: 'full' }, { path: '', redirectTo: '/search/find', pathMatch: 'full'},
{ path: 'search/publication', loadChildren: getPublicationModule }, { path: 'search/publication', loadChildren: getPublicationModule },
{ path: 'search/dataset', loadChildren: getDatasetModule }, { path: 'search/dataset', loadChildren: getDatasetModule },
{ path: 'search/person', loadChildren: getPersonModule }, { path: 'search/person', loadChildren: getPersonModule },
@ -141,25 +142,14 @@ export function getDirectLinkingModule() {
{ path: 'participate/deposit-datasets-result', loadChildren: getDepositDatasetsResultsModule }, { path: 'participate/deposit-datasets-result', loadChildren: getDepositDatasetsResultsModule },
{ path: 'participate/deposit-publications', loadChildren: getDepositPublicationsModule }, { path: 'participate/deposit-publications', loadChildren: getDepositPublicationsModule },
{ path: 'participate/deposit-publications-result', loadChildren: getDepositPublicationsResultsModule }, { path: 'participate/deposit-publications-result', loadChildren: getDepositPublicationsResultsModule },
{ path: 'search/find', loadChildren: getMainSearchModule , data: { { path: 'search/find', loadChildren: getMainSearchModule },
meta: {
title: 'Home page',
description: 'Description of the home page'
}
}},
{ path: 'search/find/publications', loadChildren: getSearchPublicationsModule }, { path: 'search/find/publications', loadChildren: getSearchPublicationsModule },
{ path: 'search/find/datasets', loadChildren: getSearchDatasetsModule }, { path: 'search/find/datasets', loadChildren: getSearchDatasetsModule },
{ path: 'search/find/projects', loadChildren: getSearchProjectsModule }, { path: 'search/find/projects', loadChildren: getSearchProjectsModule },
{ path: 'search/find/dataproviders', loadChildren: getSearchDataProvidersModule }, { path: 'search/find/dataproviders', loadChildren: getSearchDataProvidersModule },
{ path: 'search/find/organizations', loadChildren: getSearchOrganizationsModule }, { path: 'search/find/organizations', loadChildren: getSearchOrganizationsModule },
{ path: 'search/find/people', loadChildren: getSearchPeopleModule }, { path: 'search/find/people', loadChildren: getSearchPeopleModule },
{ path: 'search/data-providers', loadChildren: getCompatibleDataProvidersModule, { path: 'search/data-providers', loadChildren: getCompatibleDataProvidersModule },
data: {
meta: {
title: 'Home page',
description: 'Description of the home page'
}
}},
{ path: 'search/entity-registries', loadChildren: getEntityRegistriesModule }, { path: 'search/entity-registries', loadChildren: getEntityRegistriesModule },
{ path: 'search/advanced/publications', loadChildren: getAdvancedSearchPublicationsModule }, { path: 'search/advanced/publications', loadChildren: getAdvancedSearchPublicationsModule },
{ path: 'search/advanced/datasets', loadChildren: getAdvancedSearchDatasetsModule }, { path: 'search/advanced/datasets', loadChildren: getAdvancedSearchDatasetsModule },
@ -170,9 +160,10 @@ export function getDirectLinkingModule() {
{ path: 'project-report', loadChildren: gethtmlProjectReportModule }, { path: 'project-report', loadChildren: gethtmlProjectReportModule },
{ path: 'myclaims', loadChildren: getMyClaimsModule }, { path: 'myclaims', loadChildren: getMyClaimsModule },
{ path: 'claims', loadChildren: getClaimsAdminModule }, { path: 'claims', loadChildren: getClaimsAdminModule },
// { path: 'participate/bulk-claim', loadChildren: getBulkLinkingModule },
{ path: 'participate/claim', loadChildren: getLinkingModule }, { path: 'participate/claim', loadChildren: getLinkingModule },
{ path: 'participate/direct-claim', loadChildren: getDirectLinkingModule }, { path: 'participate/direct-claim', loadChildren: getDirectLinkingModule },
{ path: 'user-info', loadChildren: getUserModule },
]) ])
], ],
}) })

View File

@ -6,7 +6,6 @@ import { SharedModule } from './shared/shared.module';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
import { AppComponent, XLargeDirective } from './app.component'; import { AppComponent, XLargeDirective } from './app.component';
import {SharedComponentsModule} from './sharedComponents/sharedComponents.module'; //navbar import {SharedComponentsModule} from './sharedComponents/sharedComponents.module'; //navbar
import { ErrorModule } from './error/error.module'; import { ErrorModule } from './error/error.module';
import { CacheService } from './shared/cache.service'; import { CacheService } from './shared/cache.service';
@ -20,8 +19,11 @@ import { CookieLawModule } from './sharedComponents/cookie-law/cookie-law.module
SharedComponentsModule, SharedComponentsModule,
AppRoutingModule, AppRoutingModule,
ErrorModule, ErrorModule,
CookieLawModule CookieLawModule,
], exports:[], providers:[CacheService]
], exports:[],
providers:[CacheService]
}) })
export class AppModule { export class AppModule {
} }

View File

@ -1,22 +0,0 @@
// import { NgModule } from '@angular/core';
// import { RouterModule } from '@angular/router';
//
// import {ClaimsAdminComponent} from './claims/claimsAdmin.component';
// import {ClaimComponent} from './claim/claim.component';
// import {MyClaimsComponent} from './myClaims/myClaims.component';
// import { LinkingComponent } from './linking/linking.component';
// import { BulkLinkingComponent } from './linking/bulkLinking.component';
//
// @NgModule({
// imports: [
// RouterModule.forChild([
// { path: 'claims', component: ClaimsAdminComponent },
// { path: 'myclaims', component: MyClaimsComponent },
// { path: 'claim', component: ClaimComponent },
// { path: 'linking', component: LinkingComponent },
// { path: 'bulk-linking', component: BulkLinkingComponent},
//
// ])
// ]
// })
// export class ClaimRoutingModule { }

View File

@ -20,7 +20,7 @@ declare var UIkit:any;
<option *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" [value]="communities.id" >{{communities.label}}</option> <option *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" [value]="communities.id" >{{communities.label}}</option>
</select> </select>
</td> </td>
<td *ngIf="selectedCommunityId != 0 && categories.length > 0"><select class="custom-select-mini" name="select_funder" > <td *ngIf="selectedCommunityId != '0' && categories.length > 0"><select class="custom-select-mini" name="select_funder" >
<option value="0" (click)="categoryChanged('0','Category:')">Select Category:</option> <option value="0" (click)="categoryChanged('0','Category:')">Select Category:</option>
<option *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" [value]="category.id" >{{category.label}}</option> <option *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" [value]="category.id" >{{category.label}}</option>
</select> </select>
@ -29,7 +29,7 @@ declare var UIkit:any;
</td></tr> </td></tr>
</table> </table>
<div *ngIf="loading" class="uk-alert uk-alert-info" role="alert">Loading...</div> <div *ngIf="loading" class="uk-alert uk-alert-info" role="alert">Loading communities information...</div>
<div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div> <div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
<div *ngIf="infoMessage.length > 0" class="uk-alert uk-alert-info" role="alert">{{infoMessage}}</div> <div *ngIf="infoMessage.length > 0" class="uk-alert uk-alert-info" role="alert">{{infoMessage}}</div>
</div> </div>
@ -123,6 +123,7 @@ getCommunities () {
data => { data => {
this.categories = data.category; this.categories = data.category;
this.concepts = []; this.concepts = [];
this.addCommunityInConcepts();
this.filteredList = []; this.filteredList = [];
if (this.query !== ""){ if (this.query !== ""){
var event = {value: ""}; var event = {value: ""};
@ -140,10 +141,12 @@ getCommunities () {
getConcepts () { getConcepts () {
this.loading = true; this.loading = true;
if(this.selectedCategoryId != '0'){ if(this.selectedCategoryId != '0'){
this.concepts = [];
this.addCommunityInConcepts();
this._contextService.getConcepts(this.selectedCategoryId, "").subscribe( this._contextService.getConcepts(this.selectedCategoryId, "").subscribe(
data => { data => {
this.concepts = data; this.concepts = data;
this.autocomplete.updateList(this.concepts); this.addCommunityInConcepts();
if (this.query !== ""){ if (this.query !== ""){
var event = {value: ""}; var event = {value: ""};
event.value = this.query; event.value = this.query;
@ -167,8 +170,6 @@ getCommunities () {
this.warningMessage = ""; this.warningMessage = "";
this.infoMessage = ""; this.infoMessage = "";
if(this.selectedCommunityId != communityId){ if(this.selectedCommunityId != communityId){
console.log( " here");
this.selectedCommunityId = communityId; this.selectedCommunityId = communityId;
this.selectedCommunityLabel = communityLabel; this.selectedCommunityLabel = communityLabel;
this.getCategories(); this.getCategories();
@ -185,5 +186,9 @@ getCommunities () {
} }
} }
addCommunityInConcepts(){
this.concepts.push({"id":this.selectedCommunityId, "label":this.selectedCommunityLabel});
this.autocomplete.updateList(this.concepts);
}
} }

View File

@ -9,7 +9,10 @@ export class ClaimResult{
public accessRights: string = "OPEN"; public accessRights: string = "OPEN";
public embargoEndDate: string; public embargoEndDate: string;
public date: string; public date: string;
public authors: string[] =[];
public publisher: string;
public description: string;
public resourceType:string;
} }
export class ClaimProject{ export class ClaimProject{
public funderId: string; public funderId: string;
@ -19,6 +22,10 @@ export class ClaimProject{
public projectAcronym: string; public projectAcronym: string;
public startDate: string; public startDate: string;
public endDate: string; public endDate: string;
public code: string;
public jurisdiction: string;
public fundingLevel0: string;
} }
@ -26,5 +33,5 @@ export class ClaimContext{
public community: string; public community: string;
public category: string; public category: string;
public concept:any; public concept:any;
} }

View File

@ -92,7 +92,18 @@ select(item){
this.query = ""; this.query = "";
// this.searchTermStream.next(this.query); //clear // this.searchTermStream.next(this.query); //clear
item = item.value; item = item.value;
var project: ClaimProject = { funderId: (this.selectedFunderId=="0")?item.funderId:this.selectedFunderId,funderName: (this.selectedFunderId=="0")?item.funderName:this.selectedFunderName, projectId: item.id, projectName: item.projectName , projectAcronym: item.projectAcronym, startDate: item.startDate, endDate: item.endDate }; var project: ClaimProject = new ClaimProject();
project.funderId = (this.selectedFunderId=="0")?item.funderId:this.selectedFunderId;
project.funderName = (this.selectedFunderId=="0")?item.funderName:this.selectedFunderName;
project.projectId = item.id;
project.projectName = item.projectName;
project.projectAcronym = item.projectAcronym;
project.startDate = item.startDate;
project.endDate = item.endDate;
project.code = item.code;
project.jurisdiction = item.jurisdiction;
project.fundingLevel0 = item.fundingLevel0;
console.log(item); console.log(item);

View File

@ -40,11 +40,11 @@ export class ClaimResultSearchFormComponent {
// searchType ="publication"; // searchType ="publication";
@Input() public select:boolean = true ; @Input() public select:boolean = true ;
@Input() public keyword:string = ''; @Input() public keyword:string = '';
@Input() public selectedResults = [] ; @Input() public selectedResults:ClaimResult[];
// @Output() datasetsChange = new EventEmitter(); // @Output() datasetsChange = new EventEmitter();
// @Output() publicationsChange = new EventEmitter(); // @Output() publicationsChange = new EventEmitter();
@Output() resultsChange = new EventEmitter(); // @Output() resultsChange = new EventEmitter();
public errorCodes:ErrorCodes = new ErrorCodes(); public errorCodes:ErrorCodes = new ErrorCodes();
@ -500,34 +500,75 @@ openaireDataPageChange($event) {
add(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode){ add(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode){
console.log(' adding ' + itemType + " From " + itemSource+" "+ itemTitle); console.log(' adding ' + itemType + " From " + itemSource+" "+ itemTitle);
var result: ClaimResult ; var result: ClaimResult = new ClaimResult();
result.id = itemId;
result.type = itemType;
result.source = itemSource;
result.title = Array.isArray(itemTitle && itemTitle.length > 0 )?itemTitle[0]:itemTitle;
result.url = itemUrl;
result.accessRights = 'OPEN';
result.embargoEndDate = this.nextDate;
result.date = date;
result.result = item;
if(item.publisher){
result.publisher = item.publisher;
}
if(itemSource == 'datacite'){ if(itemSource == 'datacite'){
result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date}; if(item.creator){
result.authors =[]
for(var i=0; i< item.creator.length; i++){
result.authors.push(item.creator[i]);
}
}
// result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date};
}else if (itemSource == 'openaire'){ }else if (itemSource == 'openaire'){
//TODO put right access rights //TODO put right access rights
// result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: this.nextDate, date: date}; // result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: this.nextDate, date: date};
result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessmode, embargoEndDate: this.nextDate, date : date}; // result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessmode, embargoEndDate: this.nextDate, date : date};
result.embargoEndDate = accessmode;
}else if(itemSource == 'crossref'){ }else if(itemSource == 'crossref'){
date = (date == null) ? null : date.substring(0,10); date = (date == null) ? null : date.substring(0,10);
result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date}; result.date = date;
result.resourceType = item.type;
result.description = item.abstract;
if(item.author){
result.authors =[]
for(var i=0; i< item.author.length; i++){
result.authors.push(item.author[i].family +" "+ item.author[i].given );
}
}
// result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
}else if (itemSource == 'orcid'){ }else if (itemSource == 'orcid'){
date = (date == null) ? null : date + "-01.-01" date = (date == null) ? null : date + "-01.-01"
result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date}; result.date = date;
if(item['work-type']){
result.resourceType = item.type;
}
if(item.contributors){
result.authors =[]
for(var i=0; i< item.contributors.length; i++){
result.authors.push(item.contributors[i]);
}
}
// result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
} }
var found:boolean = this.isSelected( result.id); var found:boolean = this.isSelected( result.id);
this.warningMessage = ""; this.warningMessage = "";
if (!found) { if (!found) {
this.selectedResults.push(result); this.selectedResults.push(result);
this.resultsChange.emit({ // this.resultsChange.emit({
value: this.selectedResults // value: this.selectedResults
}); // });
}else{ }else{
this.warningMessage = "Dataset already in selected list"; this.warningMessage = "Dataset already in selected list";
} }
} }
Pag
} }

View File

@ -1,12 +1,13 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { AdminLoginGuard} from'../../login/adminLoginGuard.guard';
import { ClaimsAdminComponent } from './claimsAdmin.component'; import { ClaimsAdminComponent } from './claimsAdmin.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: ClaimsAdminComponent}, { path: '', component: ClaimsAdminComponent, canActivate: [AdminLoginGuard]},
]) ])
] ]

View File

@ -5,6 +5,7 @@ import { ClaimsAdminComponent } from './claimsAdmin.component';
import { ClaimsAdminRoutingModule } from './claimsAdmin-routing.module'; import { ClaimsAdminRoutingModule } from './claimsAdmin-routing.module';
// import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; // import{ClaimServiceModule} from '../claim-utils/service/claimsService.module';
import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module';
import { AdminLoginGuard} from'../../login/adminLoginGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -14,6 +15,7 @@ import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.mo
DisplayClaimsModule DisplayClaimsModule
], ],
providers:[AdminLoginGuard],
declarations: [ declarations: [
ClaimsAdminComponent ClaimsAdminComponent
] ]

View File

@ -1,12 +1,13 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { LoginGuard} from'../../login/loginGuard.guard';
import { DirectLinkingComponent } from './directLinking.component'; import { DirectLinkingComponent } from './directLinking.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: DirectLinkingComponent}, { path: '', component: DirectLinkingComponent, canActivate: [LoginGuard]},
]) ])
] ]

View File

@ -142,7 +142,18 @@ export class DirectLinkingComponent {
data => { data => {
console.log(data); console.log(data);
var item =data[0]; var item =data[0];
var project: ClaimProject = { funderId: item.funderId,funderName: item.funderName, projectId: id, projectName: item.projectName , projectAcronym: item.projectAcronym, startDate: item.startDate, endDate: item.endDate }; var project: ClaimProject = new ClaimProject();
project.funderId = item.funderId;
project.funderName = item.funderName;
project.projectId = id;
project.projectName = item.projectName;
project.projectAcronym = item.projectAcronym;
project.startDate = item.startDate;
project.endDate = item.endDate;
project.code = item.code;
project.jurisdiction = item.jurisdiction;
project.fundingLevel0 = item.fundingLevel0;
this.projects.push( project); this.projects.push( project);
this.validInput = this.isValidInput(project); this.validInput = this.isValidInput(project);
@ -157,7 +168,15 @@ export class DirectLinkingComponent {
this.sub = this.publicationsSearch.searchPublicationById(id).subscribe( this.sub = this.publicationsSearch.searchPublicationById(id).subscribe(
data => { data => {
var item =data[0]; var item =data[0];
var result: ClaimResult = {id: id, type :"publication", source : "openaire", title: item['title'].name, url: item['title'].url, result: item, accessRights:item['title'].accessMode, embargoEndDate: null, date: item.year}; var result: ClaimResult = new ClaimResult();
result.id=id;
result.type="publication";
result.source="openaire";
result.title = item['title'].name;
result.url= item['title'].url;
result.result = item;
result.accessRights = item['title'].accessMode;
result.date = item.year;
this.displayedResult = result; this.displayedResult = result;
if(isInlineResult){ if(isInlineResult){
this.inlineResult = result; this.inlineResult = result;
@ -175,8 +194,15 @@ export class DirectLinkingComponent {
this.sub = this.datasetsSearch.searchDatasetById(id).subscribe( this.sub = this.datasetsSearch.searchDatasetById(id).subscribe(
data => { data => {
var item =data[0]; var item =data[0];
var result: ClaimResult = {id: id, type : "dataset", source : "openaire", title: item['title'].name, url: item['title'].url, result: item, accessRights:item['title'].accessMode, embargoEndDate: null, date: item.year}; var result: ClaimResult = new ClaimResult();
this.displayedResult = result; result.id=id;
result.type="dataset";
result.source="openaire";
result.title = item['title'].name;
result.url= item['title'].url;
result.result = item;
result.accessRights = item['title'].accessMode;
result.date = item.year; this.displayedResult = result;
if(isInlineResult){ if(isInlineResult){
this.inlineResult = result; this.inlineResult = result;
}else{ }else{

View File

@ -13,6 +13,7 @@ import {StartOverModule} from '../claim-utils/startOver.module';
import {EntitySearchServiceModule} from '../../utils/entitiesAutoComplete/entitySearchService.module'; import {EntitySearchServiceModule} from '../../utils/entitiesAutoComplete/entitySearchService.module';
import {PublicationsServiceModule} from '../../services/publicationsService.module'; import {PublicationsServiceModule} from '../../services/publicationsService.module';
import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module';
import {LoginGuard} from'../../login/loginGuard.guard';
@ -24,6 +25,7 @@ import {DatasetsServiceModule} from '../../services/datasetsService.module';
], ],
providers:[LoginGuard],
declarations: [ declarations: [
DirectLinkingComponent DirectLinkingComponent
], exports:[DirectLinkingComponent] ], exports:[DirectLinkingComponent]

View File

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

View File

@ -4,7 +4,7 @@ import {Router} from '@angular/router';
import {ClaimsService} from '../../claim-utils/service/claims.service'; 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';
@Component({ @Component({
selector: 'claim-insert', selector: 'claim-insert',
@ -63,12 +63,15 @@ private insert(){
var user="argirok@di.uoa.gr" var user="argirok@di.uoa.gr"
this.loading.open(); this.loading.open();
var claims = []; var claims = [];
var directclaims = [];
if(this.results){ if(this.results){
console.info("results: "+this.results.length); console.info("results: "+this.results.length);
for (var i = 0; i < this.results.length; i++) { for (var i = 0; i < this.results.length; i++) {
var result=this.results[i]; var result=this.results[i];
if(["crosreff","datacite","orcid"].indexOf(result.source) != -1){
directclaims.push(this.createDirectClaim(result,this.projects,this.contexts));
}
if(this.contexts){ if(this.contexts){
for (var j = 0; j < this.contexts.length; j++) { for (var j = 0; j < this.contexts.length; j++) {
var context = this.contexts[j]; var context = this.contexts[j];
@ -202,26 +205,61 @@ private errorsInClaimsInsertion(insertedIds, errorInClaims){
} }
createDirectClaim(result, projects, contexts){ createDirectClaim(result, projects, contexts){
var entity = {}; var entity = {};
entity["originalId"]=""; var md5_id = Md5.hashStr(result.id);
entity["title"]=""; entity["originalId"]="user:claim__"+md5_id;
entity["authors"]=[]; entity["title"]=result.title;
entity["publisher"]=""; if(result.authors && result.authors.length > 0){
entity["description"]=""; entity["authors"]=result.authors;
entity["language"]=""; }
if(result.publisher){
entity["publisher"]=result.publisher;
}
if(result.description){
entity["description"]=result.description;
}
// entity["language"]=""; no info
entity["type"]=result.type; entity["type"]=result.type;
entity["pids"]= [];//{type:string, value:string}[]; if(result.source == "crossref" || result.source == "datacite"){
entity["pids"]= [];//{type:string, value:string}[];
entity["pids"].push({type:"DOI",value:result.id})
}
entity["licenseCode"]=result.accessRights; entity["licenseCode"]=result.accessRights;
if(result.accessRights == "EMBARGO"){ if(result.accessRights == "EMBARGO"){
entity["embargoEndDate"]=result.embargoEndDate; entity["embargoEndDate"]=result.embargoEndDate;
} }
entity["resourceType"]=""; if(result.type =="publication"){
entity["url"]=""; entity["resourceType"]="0001";
entity["collectedFromId"]=""; }else{
entity["linksToProjects"]=[]; entity["resourceType"]="0021";
entity["contexts"]=[];
for(var i =0; i < contexts.length; i++){
entity["contexts"].push(contexts[i].concept.id);
} }
entity["url"]=result.url;
entity["hostedById"]="openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
if(result.source == "crossref"){
entity["collectedFromId"]="openaire____::crossref";
}else if(result.source == "datacite"){
entity["collectedFromId"]="openaire____::datacite";
}else if(result.source == "orcid"){
entity["collectedFromId"]="openaire____::orcid";
}else if(result.source == "orpenaire"){
entity["collectedFromId"]="openaire____::driver";
}
if(projects.length>0){
entity["linksToProjects"]=[];
for(var i =0; i < projects.length; i++){
// "info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
entity["linksToProjects"].push("info:eu-repo/grantAgreement/"+projects[i].funderName+"/"+projects[i].fundingLevel0+"/"+projects[i].code+"/"+projects[i].jurisdiction+"/"+projects[i].projectName+"/"+projects[i].projectAcronym);
}
}
if(contexts.length > 0){
entity["contexts"]=[];
for(var i =0; i < contexts.length; i++){
entity["contexts"].push(contexts[i].concept.id);
}
}
var json = JSON.stringify(entity);
console.log("\nJSON:\n"+json);
return json;
/* /*
{ {

View File

@ -1,12 +1,13 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { LoginGuard} from'../../login/loginGuard.guard';
import { LinkingGenericComponent } from './linkingGeneric.component'; import { LinkingGenericComponent } from './linkingGeneric.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: LinkingGenericComponent}, { path: '', component: LinkingGenericComponent, canActivate: [LoginGuard]},
]) ])
] ]

View File

@ -11,14 +11,16 @@ import {PublicationsServiceModule} from '../../services/publicationsService.modu
import {DatasetsServiceModule} from '../../services/datasetsService.module'; import {DatasetsServiceModule} from '../../services/datasetsService.module';
import { LinkingRoutingModule } from './linking-routing.module'; import { LinkingRoutingModule } from './linking-routing.module';
import {StartOverModule} from '../claim-utils/startOver.module'; import {StartOverModule} from '../claim-utils/startOver.module';
import {LoginGuard} from'../../login/loginGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
SharedModule, SelectedProjectsModule, SelectedContextsModule, SharedModule, SelectedProjectsModule, SelectedContextsModule,
SelectedPublicationsModule, SelectedPublicationsModule,
InsertClaimsModule, InsertClaimsModule,
EntitySearchServiceModule, PublicationsServiceModule, DatasetsServiceModule, LinkingRoutingModule, StartOverModule EntitySearchServiceModule, PublicationsServiceModule, DatasetsServiceModule, LinkingRoutingModule, StartOverModule,
], ],
providers:[LoginGuard],
declarations: [ declarations: [
LinkingGenericComponent LinkingGenericComponent
], exports:[ ], exports:[

View File

@ -13,7 +13,7 @@ import {ClaimContext} from '../../claim-utils/claimEntities.class';
<claim-contexts-search-form *ngIf=" showsearch " [selectedList]="contexts" (contextSelected)="contextSelected($event)" > </claim-contexts-search-form> <claim-contexts-search-form *ngIf=" showsearch " [selectedList]="contexts" (contextSelected)="contextSelected($event)" > </claim-contexts-search-form>
<ul class="uk-list uk-list-line"> <ul class="uk-list uk-list-line">
<li class="list-group-item" *ngFor="let context of contexts" > <li class="list-group-item" *ngFor="let context of contexts" >
<span >{{context.community }} > {{context.category}} > {{context.concept.label}} </span> <span *ngIf="context.community != context.concept.label">{{context.community }} > {{context.category}} ></span><span> {{context.concept.label}} </span>
<span (click)="removeContext(context)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span> <span (click)="removeContext(context)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
</li> </li>

View File

@ -1,7 +1,9 @@
import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core'; import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core';
import {AlertModal} from '../../../utils/modal/alert'; import {AlertModal} from '../../../utils/modal/alert';
import {ClaimResult} from '../../claim-utils/claimEntities.class'; import {ClaimResult} from '../../claim-utils/claimEntities.class';
import {IMyOptions, IMyDateModel} from 'mydatepicker'; // import {IMyOptions} from '../../../utils/my-date-picker/interfaces/my-options.interface';
// import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface';
import {IMyOptions, IMyDateModel} from '../../../utils/my-date-picker/interfaces/index';
import {Dates} from '../../../utils/string-utils.class'; import {Dates} from '../../../utils/string-utils.class';
@Component({ @Component({
@ -17,8 +19,8 @@ import {Dates} from '../../../utils/string-utils.class';
<div class="uk-clearfix"><button (click)="bulkMode = !bulkMode;" class="uk-button uk-animation uk-float-right"> <div class="uk-clearfix"><button (click)="bulkMode = !bulkMode;" class="uk-button uk-animation uk-float-right">
<span *ngIf="!bulkMode">Bulk mode <i class="uk-icon-upload"></i></span> <span *ngIf="!bulkMode">Bulk mode <i class="uk-icon-upload"></i></span>
<span *ngIf="bulkMode">Search mode <i class="uk-icon-search"></i></span> <span *ngIf="bulkMode">Search mode <i class="uk-icon-search"></i></span>
</button></div> </button></div><!-- (resultsChange)="resultsChanged($event)" -->
<claim-result-search-form *ngIf="!bulkMode" [selectedResults]="results" (resultsChange)="resultsChanged($event)" > </claim-result-search-form> <claim-result-search-form *ngIf="!bulkMode" [selectedResults]="results" > </claim-result-search-form>
<bulk-claim *ngIf="bulkMode" [publications]="results" > </bulk-claim> <bulk-claim *ngIf="bulkMode" [publications]="results" > </bulk-claim>
</div> </div>
<div [ngClass]="showAccessRights && !showSearch?'uk-width-1-1':'uk-width-1-2'"> <div [ngClass]="showAccessRights && !showSearch?'uk-width-1-1':'uk-width-1-2'">
@ -101,7 +103,7 @@ export class ClaimSelectedResultsComponent {
@Input() title:string = "Research Results"; @Input() title:string = "Research Results";
@Input() showAccessRights:boolean = false; @Input() showAccessRights:boolean = false;
@Input() bulkMode:boolean = false; @Input() bulkMode:boolean = false;
@Output()resultsChange = new EventEmitter(); // @Output()resultsChange = new EventEmitter();
@Input() showSearch:boolean = false; @Input() showSearch:boolean = false;
nextDate = {}; nextDate = {};
@ViewChild(AlertModal) alertApplyAll; @ViewChild(AlertModal) alertApplyAll;
@ -125,9 +127,9 @@ private myDatePickerOptions: IMyOptions = {
if (index > -1) { if (index > -1) {
this.results.splice(index, 1); this.results.splice(index, 1);
} }
this.resultsChange.emit({ // this.resultsChange.emit({
value: this.results // value: this.results
}); // });
} }
@ -140,12 +142,12 @@ private myDatePickerOptions: IMyOptions = {
} }
} }
resultsChanged($event) { // resultsChanged($event) {
this.results=$event.value; // this.results=$event.value;
this.resultsChange.emit({ // this.resultsChange.emit({
value: this.results // value: this.results
}); // });
} // }
/* The following methods: /* The following methods:
*typeChanged *typeChanged
*confirmOpen *confirmOpen

View File

@ -1,12 +1,13 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
import { LoginGuard} from'../../login/loginGuard.guard';
import { MyClaimsComponent } from './myClaims.component'; import { MyClaimsComponent } from './myClaims.component';
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', component: MyClaimsComponent}, { path: '', component: MyClaimsComponent, canActivate: [LoginGuard]},
]) ])
] ]

View File

@ -5,6 +5,7 @@ import { MyClaimsComponent } from './myClaims.component';
import { MyClaimsRoutingModule } from './myClaims-routing.module'; import { MyClaimsRoutingModule } from './myClaims-routing.module';
// import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; // import{ClaimServiceModule} from '../claim-utils/service/claimsService.module';
import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module';
import {LoginGuard} from'../../login/loginGuard.guard';
@NgModule({ @NgModule({
imports: [ imports: [
@ -14,6 +15,7 @@ import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.mo
DisplayClaimsModule DisplayClaimsModule
], ],
providers:[LoginGuard],
declarations: [ declarations: [
MyClaimsComponent MyClaimsComponent
] ]

View File

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

View File

@ -10,6 +10,7 @@ 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} from '../utils/entities/user';
@Injectable() @Injectable()
export class LoginService { export class LoginService {
@ -37,15 +38,27 @@ export class LoginService {
}); });
} }
private validateJWTFormat(data){
if(data == null || (data.indexOf(".") !=-1 && data.split('.').length != 3)){
return false;
}
return true;
}
private getPayload(data){
var payload = data.split('.')[1];
return atob(payload);
}
private parseUserInfo(data: any/*, user: User*/): User { private parseUserInfo(data: any/*, user: User*/): User {
if(this.validateJWTFormat(data)){
var info = JSON.parse(this.getPayload(data));
}
var user: User = new User(); var user: User = new User();
user.username = data.username; user.username = info.sub;
user.email = data.email; user.email = info.email;
user.id = data.id; user.id = info.userId;
user.fullname = data.fullname; user.fullname = info.fullname;
localStorage.setItem("user", JSON.stringify(user)); localStorage.setItem("user", JSON.stringify(user));
return user; return user;

View File

@ -0,0 +1,27 @@
import { Injectable } from '@angular/core';
import { Router,CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable';
@Injectable()
export class LoginGuard implements CanActivate {
constructor(private router: Router) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | 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;
}
}
if(!loggedIn){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": 1, "redirectUrl": state.url } });
return false;
}else{
return true;
}
}
}

View File

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

View File

@ -0,0 +1,136 @@
import {Component, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router';
import {LoginService} from './login.service';
import {User} from '../utils/entities/user';
@Component({
selector: 'user',
template: `
<div class="uk-margin-top">
<div *ngIf="errorCode == '1'" class="uk-alert uk-alert-warning">
The requested page requires authentication. Please login.
</div>
<div *ngIf="errorCode == '2'" class="uk-alert uk-alert-warning">
You are not authorized to use the requested page
</div>
<form *ngIf="!loggedIn" class="uk-form uk-flex ">
<fieldset>
<legend>Login Form</legend>
<div class="uk-form-row">
<input placeholder="Text input" type="text" name="username" [(ngModel)]="username">
</div>
<div class="uk-form-row">
<input placeholder="Password input" type="password" name="password" [(ngModel)]="password">
</div>
<div class="uk-form-row">
<button (click)="login()" class="uk-button">Login</button>
</div>
</fieldset>
</form>
<div *ngIf="!loggedIn && errorMessage.length > 0" class="uk-alert uk-alert-danger">{{errorMessage}}</div>
<div *ngIf="loggedIn">
<div class="uk-alert uk-alert-success">
Hello {{user.fullname}}!
</div>
<button (click)="logout()" class="uk-button">Log out</button>
</div>
</div>
`
})
export class UserComponent {
public user: User;
public loggedIn: boolean = false;
public errorMessage: string;
public username: string = "";
public password: string = "";
private sub:any;private sublogin:any;
public errorCode: string = "";
public redirectUrl: string = "";
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;
}
}
}
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.errorMessage = "";
});
}
ngOnDestroy(){
this.sub.unsubscribe();
if(this.sublogin){
this.sublogin.unsubscribe();
}
}
logout(){
localStorage.removeItem("user");
this.loggedIn = false;
this.user = new User();
this.username = "";
this.password = "";
this.redirect();
}
redirect(){
if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != ""){
this.router.navigate([this.redirectUrl]);
}else{
this.router.navigate(['/user-info']);
}
}
login() {
this.sublogin =this._loginService.authenticate(/*this.user*/this.username, this.password).subscribe(
data => {
this.user = data;
this.loggedIn = true;
this.username = "";
this.password = "";
this.errorCode = "";
this.redirect();
},
err => {
console.log(err);
if(err.status == "404") {
this.errorMessage = "Wrong username";
} else if(err.status == "401") {
this.errorMessage = "Wrong password";
}
this.username = "";
this.password = "";
this.errorCode = "";
}
);
}
}

View File

@ -0,0 +1,20 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {UserComponent } from './user.component';
import { UserRoutingModule } from './user-routing.module';
import {LoginService} from './login.service';
@NgModule({
imports: [
CommonModule, FormsModule,
UserRoutingModule
],
providers:[LoginService],
declarations: [
UserComponent
]
})
export class UserModule { }

View File

@ -0,0 +1,59 @@
import {Component, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {LoginService} from './login.service';
import {User} from '../utils/entities/user';
@Component({
selector: 'user-mini',
template: `
<div class="uk-margin-top uk-margin-right uk-float-right">
<span *ngIf="loggedIn" >Hello {{user.fullname}}!</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>
</div>
`
})
export class UserMiniComponent {
public user: User;
public loggedIn: boolean = false;
public redirectUrl: string = "";
sub:any;
constructor( private router: Router, private route: ActivatedRoute, private location: Location) {}
ngOnInit() {
this.initialize();
this.sub = this.route.queryParams.subscribe(params => {
this.initialize();
});
}
ngOnDestroy(){
this.sub.unsubscribe();
}
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;
}
}else{
this.loggedIn = false;
}
}
}

View File

@ -20,7 +20,7 @@ import {SearchUtilsClass} from '../searchUtils/searchUtils.class';
<div *ngIf="status == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger uk-animation-fade" role="alert">Service not available</div> <div *ngIf="status == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger uk-animation-fade" role="alert">Service not available</div>
<div class ="uk-grid"> <div class ="uk-grid">
<div *ngFor= "let filter of filters" class = "uk-margin-top uk-width-large-1-5 uk-width-medium-1-4 uk-width-small-1-2"> <div *ngFor= "let filter of filters" class = "uk-margin-top uk-width-large-1-4 uk-width-medium-1-3 uk-width-small-1-2">
<browse-statistic [baseUrl]=baseUrl [filter]=filter ></browse-statistic> <browse-statistic [baseUrl]=baseUrl [filter]=filter ></browse-statistic>
</div> </div>
</div> </div>

View File

@ -2,7 +2,8 @@ import {Component, Input, Output, EventEmitter} from '@angular/core';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import { Filter, Value, DateValue} from './searchHelperClasses.class'; import { Filter, Value, DateValue} from './searchHelperClasses.class';
import {IMyOptions, IMyDateModel} from 'mydatepicker'; import {IMyOptions, IMyDateModel} from '../../utils/my-date-picker/interfaces/index';
// import {IMyDateModel} from '../../../utils/my-date-picker/interfaces/my-date-model.interface';
import {Dates} from '../../utils/string-utils.class'; import {Dates} from '../../utils/string-utils.class';
@Component({ @Component({

View File

@ -113,18 +113,20 @@ export class CookieLawComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.animation = this.position === 'bottom' ? 'bottomIn' : 'topIn'; if (typeof document !== 'undefined') {
this.animation = this.position === 'bottom' ? 'bottomIn' : 'topIn';
this.closeSvg = '<i class="uk-icon-close"></i>' ; this.closeSvg = '<i class="uk-icon-close"></i>' ;
if (this.cookieLawSeen) { if (this.cookieLawSeen) {
this.isSeen = true; this.isSeen = true;
}
this.currentStyles = {
'top': this.position === 'top' ? '0' : null,
'bottom': this.position === 'top' ? 'initial' : null,
};
} }
this.currentStyles = {
'top': this.position === 'top' ? '0' : null,
'bottom': this.position === 'top' ? 'initial' : null,
};
} }
afterDismissAnimation(evt: AnimationTransitionEvent) { afterDismissAnimation(evt: AnimationTransitionEvent) {

View File

@ -1,108 +0,0 @@
import {Component, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {LoginService} from '../services/login.service';
import {User} from '../utils/entities/user';
@Component({
selector: 'login',
template: `
<!--form *ngIf="!loggedIn" class="uk-form uk-width-medium-1-3"-->
<form *ngIf="!loggedIn" class="uk-form uk-flex uk-flex-center">
<fieldset>
<legend>Login Form</legend>
<div class="uk-form-row">
<input placeholder="Text input" type="text" name="username" [(ngModel)]="username">
</div>
<div class="uk-form-row">
<input placeholder="Password input" type="password" name="password" [(ngModel)]="password">
</div>
<div class="uk-form-row">
<button (click)="login()" class="uk-button">Login</button>
</div>
</fieldset>
</form>
<div *ngIf="!loggedIn && errorMessage.length > 0" class="uk-alert uk-alert-danger">{{errorMessage}}</div>
<div *ngIf="loggedIn" class="uk-alert uk-alert-success">
Hello {{user.fullname}}!
</div>
<!--div class="container-fluid">
<div *ngIf="!loggedIn">
<div *ngIf="errorMessage.length > 0" class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
{{errorMessage}}
</div>
<div class="row">
<div class="input-group">
<label>Username:</label>
<input [(ngModel)]="user.username" type="username">
</div>
</div>
<div class="row">
<div class="input-group">
<label for="password">Password:</label>
<input [(ngModel)]="user.password" type="password">
</div>
</div>
<button class="btn" (click)="login()"
type="submit">Login
</button>
</div>
<div *ngIf="loggedIn">
Hello {{user.fullname}}!
</div>
</div-->
`
})
export class LoginComponent {
private user: User;
private loggedIn: boolean;
private errorMessage: string;
private username: string = "";
private password: string = "";
constructor( private _loginService: LoginService ) {}
ngOnInit() {
this.loggedIn = false;
if( typeof localStorage !== 'undefined') {
if(localStorage.getItem("user")) {
this.user = JSON.parse(localStorage.getItem("user"));
this.loggedIn = true;
}
}
/*if(this.loggedIn == undefined) {
this.user = new User();
this.loggedIn = false;
}*/
this.errorMessage = "";
}
login() {
this._loginService.authenticate(/*this.user*/this.username, this.password).subscribe(
data => {
this.user = data;
this.loggedIn = true;
},
err => {
console.log(err);
if(err.status == "404") {
this.errorMessage = "Wrong username";
} else if(err.status == "401") {
this.errorMessage = "Wrong password";
}
}
);
}
}

View File

@ -74,21 +74,20 @@ import 'rxjs/Rx';
</div> </div>
</li> </li>
<!--li class="uk-parent" data-uk-dropdown="" aria-haspopup="true" aria-expanded="false"> <li class="uk-parent" data-uk-dropdown="" aria-haspopup="true" aria-expanded="false">
<a routerLinkActive="router-link-active" routerLink="/participate/claim" >Linking</a> <a routerLinkActive="router-link-active" routerLink="/participate/claim" >Linking</a>
<div class="uk-dropdown uk-dropdown-navbar uk-dropdown-bottom" aria-hidden="true" style="top: 40px; left: 0px;" tabindex=""> <div class="uk-dropdown uk-dropdown-navbar uk-dropdown-bottom" aria-hidden="true" style="top: 40px; left: 0px;" tabindex="">
<ul class="uk-nav uk-nav-navbar"> <ul class="uk-nav uk-nav-navbar">
<li><a routerLinkActive="router-link-active" routerLink="/participate/claim">Linking</a></li> <li><a routerLinkActive="router-link-active" routerLink="/participate/claim">Linking</a></li>
<li><a routerLinkActive="router-link-active" routerLink="/bulk-linking">Bulk Linking</a></li>
<li><a routerLinkActive="router-link-active" routerLink="/claims">Claims Admin</a></li> <li><a routerLinkActive="router-link-active" routerLink="/claims">Claims Admin</a></li>
</ul> </ul>
</div> </div>
</li--> </li>
</ul> </ul>
<user-mini></user-mini>
<a href="#offcanvas-mainmenu" class="uk-navbar-toggle uk-visible-small" data-uk-offcanvas="{mode:'slide'}"></a> <a href="#offcanvas-mainmenu" class="uk-navbar-toggle uk-visible-small" data-uk-offcanvas="{mode:'slide'}"></a>
<div class="uk-navbar-brand uk-navbar-center uk-visible-small"><img src="assets/newlogo.png" class="uk-responsive-height" title="OpenAIRE" alt="OpenAIRE" ></div> <div class="uk-navbar-brand uk-navbar-center uk-visible-small"><img src="assets/newlogo.png" class="uk-responsive-height" title="OpenAIRE" alt="OpenAIRE" ></div>

View File

@ -6,7 +6,7 @@ import { RouterModule } from "@angular/router";
import {NavigationBarComponent} from './navigationBar.component'; import {NavigationBarComponent} from './navigationBar.component';
import {BottomComponent} from './bottom.component'; import {BottomComponent} from './bottom.component';
import {LoginComponent} from './login.component'; import {UserMiniComponent} from '../login/userMini.component';
@NgModule({ @NgModule({
@ -16,13 +16,11 @@ import {LoginComponent} from './login.component';
], ],
declarations: [ declarations: [
NavigationBarComponent, NavigationBarComponent,
BottomComponent, BottomComponent,UserMiniComponent
LoginComponent
], ],
exports: [ exports: [
NavigationBarComponent, NavigationBarComponent,
BottomComponent, BottomComponent,UserMiniComponent
LoginComponent
] ]
}) })
export class SharedComponentsModule{ } export class SharedComponentsModule{ }

View File

@ -60,10 +60,9 @@ export class EntitiesAutocompleteComponent {
@Input() public keyword = ''; @Input() public keyword = '';
@Input() public fieldId:string ; @Input() public fieldId:string ;
public currentFieldId: string ; public currentFieldId: string ;
public currentFunderId: string ;
public warningMessage = ""; public warningMessage = "";
public infoMessage = ""; public infoMessage = "";
public tries = 0; public tries = 0;
public showInput = true; public showInput = true;
public sub; public sub;
@ -80,6 +79,7 @@ export class EntitiesAutocompleteComponent {
public focus:boolean = false; public focus:boolean = false;
constructor (public _search:EntitiesSearchService, private myElement: ElementRef) { constructor (public _search:EntitiesSearchService, private myElement: ElementRef) {
this.currentFieldId=this.fieldId; this.currentFieldId=this.fieldId;
this.currentFunderId=this.funderId;
this.initialize(); this.initialize();
} }
@ -87,6 +87,9 @@ export class EntitiesAutocompleteComponent {
if(this.currentFieldId!=this.fieldId){ //this is going to be called when if(this.currentFieldId!=this.fieldId){ //this is going to be called when
this.currentFieldId=this.fieldId; this.currentFieldId=this.fieldId;
this.initialize(); this.initialize();
}else if(this.currentFunderId!=this.funderId){
this.currentFunderId=this.funderId;
this.initialize();
} }
} }
private initialize(){ private initialize(){

View File

@ -188,8 +188,31 @@ private fetch (link,id,oafEntityType,type){
value.projectName = value.label; value.projectName = value.label;
value.endDate = null; value.endDate = null;
value.startDate = null; value.startDate = null;
value.funderId = (resData['fundingtree'] && resData['fundingtree']['funder'] && resData['fundingtree']['funder']['id'] )?resData['fundingtree']['funder']['id']:""; value.funderId = "";
value.funderName = (resData['fundingtree'] && resData['fundingtree']['funder'] && resData['fundingtree']['funder']['shortname'] )?resData['fundingtree']['funder']['shortname']:""; value.funderName = "";
value.jurisdiction = "";
value.fundingLevel0 = "";
value.code = resData['code'];
if(resData['fundingtree'] && resData['fundingtree']['funder']){
value.funderId = (resData['fundingtree']['funder']['id'] )?resData['fundingtree']['funder']['id']:"";
value.funderName = (resData['fundingtree']['funder']['shortname'] )?resData['fundingtree']['funder']['shortname']:"";
value.jurisdiction = (resData['fundingtree']['funder']['jurisdiction'] )?resData['fundingtree']['funder']['jurisdiction']:"";
if(resData['fundingtree']['funding_level_2']){
value.fundingLevel0 = (resData['fundingtree']['funding_level_2'] && resData['fundingtree']['funding_level_2']['parent'] &&
resData['fundingtree']['funding_level_2']['parent']['funding_level_1'] && resData['fundingtree']['funding_level_2']['parent']['funding_level_1']['parent']
&& resData['fundingtree']['funding_level_2']['parent']['funding_level_1']['parent']['funding_level_0'])?
resData['fundingtree']['funding_level_2']['parent']['funding_level_1']['parent']['funding_level_0']['name']:"";
}else if(resData['fundingtree']['funding_level_1']){
value.fundingLevel0 = (resData['fundingtree']['funding_level_1'] && resData['fundingtree']['funding_level_1']['parent'] && resData['fundingtree']['funding_level_1']['parent']['funding_level_0'])?
resData['fundingtree']['funding_level_1']['parent']['funding_level_0']['name']:"";
}else if(resData['fundingtree']['funding_level_0']){
value.fundingLevel0 = (resData['fundingtree']['funding_level_0'] )?resData['fundingtree']['funding_level_0']['name']:"";
}else {
value.fundingLevel0="";
}
}
if(resData.hasOwnProperty("startdate")) { if(resData.hasOwnProperty("startdate")) {
value.startDate = resData.startdate.split('-')[0]; value.startDate = resData.startdate.split('-')[0];
} }
@ -198,7 +221,7 @@ private fetch (link,id,oafEntityType,type){
} }
} }
console.info("add:"+value.label+" "+value.id); // console.info("add:"+value.label+" "+value.id);
array.push(value); array.push(value);
} }

View File

@ -6,8 +6,8 @@ import { UtilService } from "./services/my-date-picker.util.service";
// webpack1_ // webpack1_
declare var require: any; declare var require: any;
const myDpStyles: string = require("./my-date-picker.component.css"); // declare var myDpStyles: string = require("./my-date-picker.component.css");
const myDpTpl: string = require("./my-date-picker.component.html"); // declare var myDpTpl: string = require("./my-date-picker.component.html");
// webpack2_ // webpack2_
export const MYDP_VALUE_ACCESSOR: any = { export const MYDP_VALUE_ACCESSOR: any = {
@ -18,8 +18,8 @@ export const MYDP_VALUE_ACCESSOR: any = {
@Component({ @Component({
selector: "my-date-picker", selector: "my-date-picker",
styles: [myDpStyles], styleUrls: ['my-date-picker.component.css'],
template: myDpTpl, templateUrl: 'my-date-picker.component.html',
providers: [LocaleService, UtilService, MYDP_VALUE_ACCESSOR], providers: [LocaleService, UtilService, MYDP_VALUE_ACCESSOR],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })

View File

@ -53,7 +53,7 @@ export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE';
{ provide: 'res', useFactory: getResponse }, { provide: 'res', useFactory: getResponse },
{ provide: 'LRU', useFactory: getLRU, deps: [] }, { provide: 'LRU', useFactory: getLRU, deps: [] },
CacheService, CacheService,
Meta, Meta
// { provide: AUTO_PREBOOT, useValue: false } // turn off auto preboot complete // { provide: AUTO_PREBOOT, useValue: false } // turn off auto preboot complete
] ]

View File

@ -25,7 +25,7 @@
<!-- tabs/switcher --> <!-- tabs/switcher -->
<script src="assets/uikit-2.27.2/js/core/tab.min.js" type="text/javascript"></script> <script src="assets/uikit-2.27.2/js/core/tab.min.js" type="text/javascript"></script>
<script src="assets/uikit-2.27.2/js/core/switcher.min.js" type="text/javascript"></script> <script src="assets/uikit-2.27.2/js/core/switcher.min.js" type="text/javascript"></script>
<!-- toggle --> <!-- toggle -->
<script src="assets/uikit-2.27.2/js/core/toggle.min.js" type="text/javascript"></script> <script src="assets/uikit-2.27.2/js/core/toggle.min.js" type="text/javascript"></script>
<!-- Progress Bar --> <!-- Progress Bar -->
<link href="assets/uikit-2.27.2/css/components/progress.almost-flat.min.css" rel="stylesheet" type="text/css" /> <link href="assets/uikit-2.27.2/css/components/progress.almost-flat.min.css" rel="stylesheet" type="text/css" />
@ -93,10 +93,10 @@
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1); text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1);
} }
.custom-autocomplete .uk-nav-navbar > li > a { .custom-autocomplete .uk-nav-navbar > li > a {
color: #444; color: #444;
} }
.custom-description-list-horizontal{ line-height:200%} .custom-description-list-horizontal{ line-height:200%}
.uk-alert-default { .uk-alert-default {
background: #fff none repeat scroll 0 0; background: #fff none repeat scroll 0 0;
border: 1px solid #ddd; border: 1px solid #ddd;
@ -177,6 +177,11 @@
.filterItem span div { .filterItem span div {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
}
.browseFilters{
overflow-y: auto;
overflow-x: hidden;
max-height:200px;
} }
</style> </style>

View File

@ -48,7 +48,7 @@ export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE';
CacheService, CacheService,
Meta, Meta
] ]
}) })
export class MainModule { export class MainModule {

View File

@ -17,7 +17,7 @@ export const routes: string[] = [
'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/bulk-claim',
'test', 'test', 'user-info',
'error', 'login' 'error'
]; ];