From 731003e0508862fcedd353b8c6854ad073c9ed98 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Fri, 17 Feb 2017 15:56:33 +0000 Subject: [PATCH] get back claim Pages | create lazy routes for admin, myclaims, linking | fix the layout with uikit | gets work fine | delete and inserts don't git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@45951 d315682c-612b-4755-9ff5-7f18f6832af3 --- portal-2/src/app/app-routing.module.ts | 19 +- .../src/app/claims/claim-routing.module.ts | 22 + portal-2/src/app/claims/claim-utils/claim.ts | 15 + .../claim-utils/claimContext.component.ts | 215 ++++++++ .../claims/claim-utils/claimContext.module.ts | 19 + .../claim-utils/claimDataset.component.ts | 247 +++++++++ .../claims/claim-utils/claimEntities.class.ts | 30 ++ .../claim-utils/claimProject.component.ts | 179 +++++++ .../claims/claim-utils/claimProject.module.ts | 25 + .../claimPublication.component.html | 121 +++++ .../claim-utils/claimPublication.component.ts | 401 ++++++++++++++ .../claim-utils/claimResult.component.ts | 107 ++++ .../claims/claim-utils/claimResult.module.ts | 31 ++ .../displayClaims.component.html | 88 ++++ .../displayClaims/displayClaims.component.ts | 491 ++++++++++++++++++ .../displayClaims/displayClaims.module.ts | 28 + .../claimEntityFormatter.component.ts | 36 ++ .../claimEntityFormatter.module.ts | 23 + .../projectTitleFormatter.component.ts | 2 +- .../publicationTitleFormatter.component.ts | 0 .../claim-utils/service/claims.service.ts | 140 +++++ .../service/claimsService.module.ts | 20 + .../claim-utils/service/contexts.service.ts | 88 ++++ .../service/contextsService.module.ts | 20 + .../service}/searchCrossref.service.ts | 4 +- .../service/searchCrossrefService.module.ts | 20 + .../service}/searchDatacite.service.ts | 4 +- .../service}/searchOrcid.service.ts | 5 +- portal-2/src/app/claims/claim.module.ts | 68 +++ .../src/app/claims/claim/claim.component.html | 10 + .../src/app/claims/claim/claim.component.ts | 43 ++ .../claimsAdmin/claimsAdmin-routing.module.ts | 14 + .../claimsAdmin/claimsAdmin.component.ts | 36 ++ .../claims/claimsAdmin/claimsAdmin.module.ts | 21 + .../inlineClaimContext.component.ts | 94 ++++ .../inlineClaimProject.component.ts | 107 ++++ .../inlineClaimResult.component.ts | 117 +++++ .../linking/bulkClaim/bulkClaim.component.ts | 206 ++++++++ .../linking/bulkClaim/bulkClaim.module.ts | 15 + .../claims/linking/bulkLinking.component.ts | 16 + .../insertClaim/insertClaim.component.ts | 264 ++++++++++ .../linking/insertClaim/insertClaim.module.ts | 17 + .../claims/linking/linking-routing.module.ts | 14 + .../app/claims/linking/linking.component.ts | 16 + .../src/app/claims/linking/linking.module.ts | 19 + .../linking/linkingGeneric.component.ts | 223 ++++++++ .../claims/linking/linkingGeneric.module.ts | 33 ++ .../claims/linking/linkingHome.component.ts | 51 ++ .../linking/selected/selected.component.ts | 209 ++++++++ .../selected/selectedContexts.component.ts | 66 +++ .../selected/selectedContexts.module.ts | 13 + .../selected/selectedDatasets.component.ts | 133 +++++ .../selected/selectedDatasets.module.ts | 14 + .../selected/selectedProjects.component.ts | 72 +++ .../selected/selectedProjects.module.ts | 13 + .../selectedPublications.component.ts | 138 +++++ .../selected/selectedPublications.module.ts | 14 + .../selected/selectedResults.component.ts | 91 ++++ .../selected/selectedResults.module.ts | 17 + .../myClaims/myClaims-routing.module.ts | 14 + .../app/claims/myClaims/myClaims.component.ts | 34 ++ .../app/claims/myClaims/myClaims.module.ts | 21 + .../src/app/claims/myClaimsDemo.component.ts | 51 ++ .../publication/publication.component.html | 2 +- .../src/app/searchPages/search.component.ts | 75 --- .../entitiesAutoComplete.component.ts | 5 +- portal-2/src/app/utils/modal/alert.ts | 21 +- .../utils/pagingFormatterNoLoad.component.ts | 8 +- .../utils/properties/openaireProperties.ts | 2 +- .../ISVocabularies.service.ts | 2 +- portal-2/src/index.html | 4 +- 71 files changed, 4700 insertions(+), 103 deletions(-) create mode 100644 portal-2/src/app/claims/claim-routing.module.ts create mode 100644 portal-2/src/app/claims/claim-utils/claim.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimContext.component.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimContext.module.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimDataset.component.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimEntities.class.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimProject.component.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimProject.module.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimPublication.component.html create mode 100644 portal-2/src/app/claims/claim-utils/claimPublication.component.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimResult.component.ts create mode 100644 portal-2/src/app/claims/claim-utils/claimResult.module.ts create mode 100644 portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.html create mode 100644 portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts create mode 100644 portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.module.ts create mode 100644 portal-2/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.component.ts create mode 100644 portal-2/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts rename portal-2/src/app/{utils => claims/claim-utils/entityFormatter}/projectTitleFormatter.component.ts (87%) rename portal-2/src/app/{utils => claims/claim-utils/entityFormatter}/publicationTitleFormatter.component.ts (100%) create mode 100644 portal-2/src/app/claims/claim-utils/service/claims.service.ts create mode 100644 portal-2/src/app/claims/claim-utils/service/claimsService.module.ts create mode 100644 portal-2/src/app/claims/claim-utils/service/contexts.service.ts create mode 100644 portal-2/src/app/claims/claim-utils/service/contextsService.module.ts rename portal-2/src/app/{services => claims/claim-utils/service}/searchCrossref.service.ts (95%) create mode 100644 portal-2/src/app/claims/claim-utils/service/searchCrossrefService.module.ts rename portal-2/src/app/{services => claims/claim-utils/service}/searchDatacite.service.ts (91%) rename portal-2/src/app/{services => claims/claim-utils/service}/searchOrcid.service.ts (97%) create mode 100644 portal-2/src/app/claims/claim.module.ts create mode 100644 portal-2/src/app/claims/claim/claim.component.html create mode 100644 portal-2/src/app/claims/claim/claim.component.ts create mode 100644 portal-2/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts create mode 100644 portal-2/src/app/claims/claimsAdmin/claimsAdmin.component.ts create mode 100644 portal-2/src/app/claims/claimsAdmin/claimsAdmin.module.ts create mode 100644 portal-2/src/app/claims/inlineClaims/inlineClaimContext.component.ts create mode 100644 portal-2/src/app/claims/inlineClaims/inlineClaimProject.component.ts create mode 100644 portal-2/src/app/claims/inlineClaims/inlineClaimResult.component.ts create mode 100644 portal-2/src/app/claims/linking/bulkClaim/bulkClaim.component.ts create mode 100644 portal-2/src/app/claims/linking/bulkClaim/bulkClaim.module.ts create mode 100644 portal-2/src/app/claims/linking/bulkLinking.component.ts create mode 100644 portal-2/src/app/claims/linking/insertClaim/insertClaim.component.ts create mode 100644 portal-2/src/app/claims/linking/insertClaim/insertClaim.module.ts create mode 100644 portal-2/src/app/claims/linking/linking-routing.module.ts create mode 100644 portal-2/src/app/claims/linking/linking.component.ts create mode 100644 portal-2/src/app/claims/linking/linking.module.ts create mode 100644 portal-2/src/app/claims/linking/linkingGeneric.component.ts create mode 100644 portal-2/src/app/claims/linking/linkingGeneric.module.ts create mode 100644 portal-2/src/app/claims/linking/linkingHome.component.ts create mode 100644 portal-2/src/app/claims/linking/selected/selected.component.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedContexts.component.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedContexts.module.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedDatasets.component.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedDatasets.module.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedProjects.component.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedProjects.module.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedPublications.component.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedPublications.module.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedResults.component.ts create mode 100644 portal-2/src/app/claims/linking/selected/selectedResults.module.ts create mode 100644 portal-2/src/app/claims/myClaims/myClaims-routing.module.ts create mode 100644 portal-2/src/app/claims/myClaims/myClaims.component.ts create mode 100644 portal-2/src/app/claims/myClaims/myClaims.module.ts create mode 100644 portal-2/src/app/claims/myClaimsDemo.component.ts delete mode 100644 portal-2/src/app/searchPages/search.component.ts diff --git a/portal-2/src/app/app-routing.module.ts b/portal-2/src/app/app-routing.module.ts index 88c82374..df9cbd5f 100644 --- a/portal-2/src/app/app-routing.module.ts +++ b/portal-2/src/app/app-routing.module.ts @@ -106,7 +106,19 @@ export function gethtmlProjectReportModule() { return System.import('./landingPages/htmlProjectReport/htmlProjectReport.module' + (process.env.AOT ? '.ngfactory' : '')) .then(mod => mod[(process.env.AOT ? 'HtmlProjectReportModuleNgFactory' : 'HtmlProjectReportModule')]); } +export function getMyClaimsModule() { + return System.import('./claims/myClaims/myClaims.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'MyClaimsModuleNgFactory' : 'MyClaimsModule')]); +} +export function getClaimsAdminModule() { + return System.import('./claims/claimsAdmin/claimsAdmin.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'ClaimsAdminModuleNgFactory' : 'ClaimsAdminModule')]); +} +export function getLinkingModule() { + return System.import('./claims/linking/linking.module' + (process.env.AOT ? '.ngfactory' : '')) + .then(mod => mod[(process.env.AOT ? 'LinkingModuleNgFactory' : 'LinkingModule')]); +} @NgModule({ imports: [ RouterModule.forChild([ @@ -136,7 +148,12 @@ export function gethtmlProjectReportModule() { { path: 'search/advanced/dataproviders', loadChildren: getAdvancedSearchDataProvidersModule }, { path: 'search/advanced/projects', loadChildren: getAdvancedSearchProjectsModule }, { path: 'search/advanced/people', loadChildren: getAdvancedSearchPeopleModule }, - { path: 'project-report', loadChildren: gethtmlProjectReportModule } + { path: 'project-report', loadChildren: gethtmlProjectReportModule }, + { path: 'myclaims', loadChildren: getMyClaimsModule }, + { path: 'claims', loadChildren: getClaimsAdminModule }, + { path: 'linking', loadChildren: getLinkingModule } + + ]) diff --git a/portal-2/src/app/claims/claim-routing.module.ts b/portal-2/src/app/claims/claim-routing.module.ts new file mode 100644 index 00000000..5749d0a3 --- /dev/null +++ b/portal-2/src/app/claims/claim-routing.module.ts @@ -0,0 +1,22 @@ +// 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 { } diff --git a/portal-2/src/app/claims/claim-utils/claim.ts b/portal-2/src/app/claims/claim-utils/claim.ts new file mode 100644 index 00000000..b5378c5f --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claim.ts @@ -0,0 +1,15 @@ +export class Claim { + id: string; + sourceType: string; + targetType: string; + sourceId: string; + targetId: string; + date: string; + DOI: string; + project: Project + userMail: string; + +} +export class Project{ + +} diff --git a/portal-2/src/app/claims/claim-utils/claimContext.component.ts b/portal-2/src/app/claims/claim-utils/claimContext.component.ts new file mode 100644 index 00000000..7bbdb837 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimContext.component.ts @@ -0,0 +1,215 @@ +import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ContextsService} from './service/contexts.service'; +import {ClaimContext} from './claimEntities.class'; +import { StaticAutoCompleteComponent } from '../../utils/staticAutoComplete/staticAutoComplete.component'; +declare var UIkit:any; + +@Component({ + // moduleId: module.id, + selector: 'claim-contexts', + template: ` +
+ +
+ + +
+ + + + + + +
+
+
+
+
+
+ + +
+
+ + +
+ + +
+
+ + + + ` + +}) +export class ClaimContextComponent { +@Input() public inline:boolean = false ; // for claimed started from landing pages +@Input() public showComponent:boolean = true ; // for claimed started from landing pages +@Input() public selectedList = []; +@Input() public selectedCommunityId:string = "0"; +@Input() public selectedCategoryId:string ="0"; +@Output() cselectedCommunityChange = new EventEmitter(); +@Output() selectedCategoryChange = new EventEmitter(); +@ViewChild (StaticAutoCompleteComponent) autocomplete : StaticAutoCompleteComponent ; + +public query = ''; +public filteredList = []; +public communities:string[]; +public selectedCommunityLabel:string = "Community:"; + +public categories:string[]; +public selectedCategoryLabel:string ="Category:"; +public concepts = []; +public warningMessage = ""; +public infoMessage = ""; + +ngOnInit() { + this.getCommunities(); +} +constructor(private _contextService: ContextsService) { + +} + +select($event){ + var item = $event.value; + + var context: ClaimContext= { community: this.selectedCommunityLabel, category: this.selectedCategoryLabel, concept: item }; + var found:boolean = false; + this.warningMessage = ""; + for (var _i = 0; _i < this.selectedList.length; _i++) { + let item = this.selectedList[_i]; + if(item.concept.id == context.concept.id){ + found=true; + // this.warningMessage = "Concept already in selected list"; + } + } + // var UIkit:any; + if (!found) { + this.selectedList.push(context); + UIkit.notify({ + message : 'A context is selected.', + status : 'info', + timeout : 1000, + pos : 'top-center' + }); + + }else{ + UIkit.notify({ + message : 'The context is already on your list.', + status : 'warning', + timeout : 1000, + pos : 'top-center' + }); + } +} + +getCommunities () { + this._contextService.getCommunities().subscribe( + data => { + this.communities = data.communities; + }, + err => console.log(err) + ); + } + getCategories () { + console.log(" Getting Categories... "); + + this.categories=[]; + if(this.selectedCommunityId != '0'){ + this._contextService.getCategories(this.selectedCommunityId).subscribe( + data => { + this.categories = data.category; + this.concepts = []; + this.filteredList = []; + if (this.query !== ""){ + var event = {value: ""}; + event.value = this.query; + } + + }, + err => console.log(err) + ); + } + } + getConcepts () { + if(this.selectedCategoryId != '0'){ + this._contextService.getConcepts(this.selectedCategoryId, "").subscribe( + data => { + this.concepts = data; + this.autocomplete.updateList(this.concepts); + if (this.query !== ""){ + var event = {value: ""}; + event.value = this.query; + // this.filter(event); + } + }, + err => console.log(err) + ); + }else{ + this.concepts=[]; + } + } + communityChanged(communityId:string, communityLabel:string){ + console.log(communityId +" "+communityLabel); + console.log(this.selectedCommunityId +" "); + this.warningMessage = ""; + this.infoMessage = ""; + if(this.selectedCommunityId != communityId){ + console.log( " here"); + + this.selectedCommunityId = communityId; + this.selectedCommunityLabel = communityLabel; + this.getCategories(); + } + + } + categoryChanged(categoryId:string, categoryLabel:string){ + this.warningMessage = ""; + this.infoMessage = ""; + if(this.selectedCategoryId != categoryId){ + this.selectedCategoryId = categoryId; + this.selectedCategoryLabel = categoryLabel; + this.getConcepts(); + } + + } + +} diff --git a/portal-2/src/app/claims/claim-utils/claimContext.module.ts b/portal-2/src/app/claims/claim-utils/claimContext.module.ts new file mode 100644 index 00000000..4b5a7605 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimContext.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { ClaimContextComponent } from './claimContext.component'; + import{ContextsServiceModule} from './service/contextsService.module'; + import {StaticAutocompleteModule} from '../../utils/staticAutoComplete/staticAutoComplete.module'; + +@NgModule({ + imports: [ + SharedModule, + ContextsServiceModule, + StaticAutocompleteModule + + ], + declarations: [ + ClaimContextComponent + ], exports: [ClaimContextComponent ] +}) +export class ClaimContextModule { } diff --git a/portal-2/src/app/claims/claim-utils/claimDataset.component.ts b/portal-2/src/app/claims/claim-utils/claimDataset.component.ts new file mode 100644 index 00000000..a8a1b83b --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimDataset.component.ts @@ -0,0 +1,247 @@ +import { Component, Input, Output, EventEmitter} from '@angular/core'; +import { SearchDataciteService } from '../claim-utils/service/searchDatacite.service'; +import {SearchDatasetsService} from '../../services/searchDatasets.service'; +import {ClaimResult} from '../claim-utils/claimEntities.class'; +import { ErrorCodes} from '../../utils/properties/openaireProperties'; +import{DOI} from '../../utils/string-utils.class'; + + +@Component({ + selector: 'claim-dataset', + template: ` + + + +
+
+ + +
    +
  • +
    +
    +
    + +
    +
    + +
    +
      +
    • +
      + {{item.title}} + {{item.title}} + + +
      + + + +
    • +
    + +
    +
    +
  • +
  • +
    +
    +
    + +
    +
    +
    +
      +
    • +
      + {{result['title'].name}} + {{result['title'].name}} + + + +
      + ({{result.year}}) + + +
    • +
    +
    No results found
    +
    +
    +
  • +
+
+ + ` +}) +export class ClaimDatasetComponent { + constructor (private _searchDataciteService: SearchDataciteService, private _searchDatasetsService:SearchDatasetsService){ + var myDate = new Date(); + this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate = (myDate.getFullYear()+100)+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ; + + } + ngOnInit() { + if(this.keyword !=null && this.keyword.length > 0){ + this.search(this.keyword,this.size,1); + } +} + +@Input() public select:boolean = true ; +@Input() public keyword:string = ''; +@Input() public selectedDatasets = [] ; +@Output() datasetsChange = new EventEmitter(); + public size:number = 10; + public navigateTo: string = "Search"; + public source: string = "datacite"; + public type : string = "dataset"; + public errorCodes:ErrorCodes = new ErrorCodes(); + + dataciteResults=[]; + dataciteResultsNum:number = null; + // dataciteResultsNum : Observable = null; + dataciteStatus = this.errorCodes.NONE; + datacitePage : number = 1; + + openaireResults=[]; + openaireResultsNum:number = 0 ; + openaireStatus = this.errorCodes.NONE; + openairePage : number = 1; + + public warningMessage = ""; + public infoMessage = ""; + + public todayDate = ''; + public nextDate = ''; + public DOIs:string[] = []; + + public search(term: string, size : number, page : number){ + this.DOIs = DOI.getDOIsFromString(term); + this.searchDatacite(term,10,1); + this.searchOpenaire(term,10,1); + } + private searchDatacite (term: string, size : number, page : number) { + this.getDataciteResults(term,size,page); + this.warningMessage = ""; + this.infoMessage = ""; + + } + private searchOpenaire (term: string, size : number, page : number) { + if(this.DOIs.length > 0 ){ + this.openaireStatus = this.errorCodes.LOADING; + this._searchDatasetsService.searchDatasetsByDois(this.DOIs, null, page, size, []).subscribe( + data => { + if(data != null) { + this.openairePage=page; + this.openaireResultsNum = data[0]; + this.openaireResults = data[1]; + this.openaireStatus = this.errorCodes.DONE; + if(this.openaireResultsNum == 0){ + this.openaireStatus = this.errorCodes.NONE; + } + } + }, + err => { + this.openaireStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + }else{ + this._searchDatasetsService.searchDatasets('q="'+term+'"', null, page, size, []).subscribe( + data => { + if(data != null) { + this.openairePage=page; + this.openaireResultsNum = data[0]; + this.openaireResults = data[1]; + this.openaireStatus = this.errorCodes.DONE; + if(this.openaireResultsNum == 0){ + this.openaireStatus = this.errorCodes.NONE; + } + } + }, + err => { + this.openaireStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + } + this.warningMessage = ""; + this.infoMessage = ""; + + } + private getDataciteResults (term: string, size : number, page : number) { + this._searchDataciteService.searchDataciteResults(term, size, page).subscribe( + data => { + this.dataciteResults = data.docs; + this.datacitePage=page; + this.dataciteResultsNum = data.numFound; + this.dataciteStatus = this.errorCodes.DONE; + + + }, + err => { + this.dataciteStatus = this.errorCodes.ERROR; + console.log(err); + } + + ); + } + + add(item, itemId,itemType,itemSource,itemTitle, itemUrl, date, accessmode){ + console.log(' adding dataset '+ itemSource+" "+ itemTitle); + var result: ClaimResult ; + if(itemSource == 'datacite'){ + result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date}; + }else if (itemSource == 'openaire'){ + //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}; + } + var found:boolean = this.isSelected( result.id); + this.warningMessage = ""; + if (!found) { + this.selectedDatasets.push(result); + this.datasetsChange.emit({ + value: this.selectedDatasets + }); + }else{ + this.warningMessage = "Dataset already in selected list"; + } + + } + + + datacitePageChange($event) { + this.datacitePage=$event.value; + this.dataciteResults=[]; + this.searchDatacite(this.keyword,10,this.datacitePage); + this.warningMessage = ""; + this.infoMessage = ""; + + } + openairePageChange($event) { + this.openairePage=$event.value; + this.openaireResults=[]; + this.searchOpenaire(this.keyword,10,this.openairePage); + this.warningMessage = ""; + this.infoMessage = ""; + + } + isSelected(id:string){ + + var found:boolean = false; + this.warningMessage = ""; + for (var _i = 0; _i < this.selectedDatasets.length; _i++) { + let item = this.selectedDatasets[_i]; + if(item.id == id){ + found=true; + break; + } + } + return found; + } +} diff --git a/portal-2/src/app/claims/claim-utils/claimEntities.class.ts b/portal-2/src/app/claims/claim-utils/claimEntities.class.ts new file mode 100644 index 00000000..8af32621 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimEntities.class.ts @@ -0,0 +1,30 @@ +//Classes used in linking / inlinelinking when selecting an entity +export class ClaimResult{ + public id: string; + public type: string; + public source: string; + public title: string; + public url: string; + public result: any; + public accessRights: string = "OPEN"; + public embargoEndDate: string; + public date: string; + +} +export class ClaimProject{ + public funderId: string; + public funderName: string; + public projectId: string; + public projectName: string; + public projectAcronym: string; + public startDate: string; + public endDate: string; + +} + +export class ClaimContext{ + public community: string; + public category: string; + public concept:any; + +} diff --git a/portal-2/src/app/claims/claim-utils/claimProject.component.ts b/portal-2/src/app/claims/claim-utils/claimProject.component.ts new file mode 100644 index 00000000..583b69b8 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimProject.component.ts @@ -0,0 +1,179 @@ +import {Component, Input,Output, ElementRef, EventEmitter, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {SearchProjectsService} from '../../services/searchProjects.service'; +import {ProjectService} from '../../landingPages/project/project.service'; +import {ModalLoading} from '../../utils/modal/loading.component'; +import { Subject } from 'rxjs/Subject'; +import {ClaimProject} from './claimEntities.class'; +declare var UIkit:any; +@Component({ + selector: 'claim-projects', + // styleUrls: ['/autoComplete.component.css'], + + template: ` +
+
+
+ + +
+ +
+ + + +
+ + + ` + +}) +export class ClaimProjectsComponent { + ngOnInit() { + this.getFunders(); + } + @ViewChild (ModalLoading) loading : ModalLoading ; + + @Input() public inline: boolean = false ; // for claimed started from landing pages + public query = ''; + @Input() public selectedProjects=[] ; + public elementRef; + + public funders:string[]; + @Input() public selectedFunderId:string ="0"; + selectedFunderName:string ="Select funder:"; + @Output() cselectedFunderChange = new EventEmitter(); + + public projects:string[]; + public warningMessage = ""; + public infoMessage = ""; + + public searchTermStream = new Subject(); + filtered: Observable<{}> = this.searchTermStream + .debounceTime(300).distinctUntilChanged() + .switchMap((term: string) => this._projectService.searchForProjectsObs(term, this.selectedFunderId)); + public tries:number = 0 ; + public keywordlimit = 3; + +constructor(private _service: ProjectService, private _projectService: SearchProjectsService, myElement: ElementRef) { + this.elementRef = myElement; +} + + +search() { + console.info("heeere "+this.query ); + this.infoMessage = ""; + // this.filtered = []; + if(this.query == ""){ + this.tries = 0; + this.warningMessage = ""; + } else if(this.query && this.query.length < this.keywordlimit){ + this.tries++; + if(this.tries == this.keywordlimit -1 ){ + this.warningMessage = "Type at least " + this.keywordlimit + " characters"; + this.tries = 0; + } + }else{ + console.info("doo the search "+this.query ); + + this.tries = 0; + this.warningMessage = ""; + this.searchTermStream.next(this.query); + + } + +} +select(item){ + this.query = ""; + this.searchTermStream.next(this.query); //clear + item = item.value; + var project: ClaimProject = { funderId: this.selectedFunderId,funderName: this.selectedFunderName, projectId: item.id, projectName: item.projectName , projectAcronym: item.projectAcronym, startDate: item.startDate, endDate: item.endDate }; + console.log(item); + + + // this._service.getProjectDates(project.projectId).subscribe( + // data => { + // project.startDate = data.startDate; + // project.endDate = data.endDate; + // }, + // err => console.log(err) + // ); + var index:number =this.selectedProjects.indexOf(project); + var found:boolean = false; + this.warningMessage = ""; + + for (var _i = 0; _i < this.selectedProjects.length; _i++) { + let item = this.selectedProjects[_i]; + if(item.projectId == project.projectId){ + found=true; + this.warningMessage = "Project already in selected list"; + } + } + + if (!found) { + this.selectedProjects.push(project); + UIkit.notify({ + message : 'A project "'+item.projectName+'" is selected.', + status : 'info', + timeout : 1000, + pos : 'top-center' + }); + }else{ + UIkit.notify({ + message : 'The project is already on your list.', + status : 'warning', + timeout : 1000, + pos : 'top-center' + }); + } + +} +showItem(item):string{ + return ((item.field[1]['@value'])?item.field[1]['@value']+" - ":"" ) + item.field[3]['@value']; +} +remove(item){ + var index:number =this.selectedProjects.indexOf(item); + if (index > -1) { + this.selectedProjects.splice(index, 1); + } + +} +handleClick(event){ + var clickedComponent = event.target; + var inside = false; + do { + if (clickedComponent === this.elementRef.nativeElement) { + inside = true; + } + clickedComponent = clickedComponent.parentNode; + } while (clickedComponent); + +} +getFunders () { + console.info("Getting Funders...."); + this._projectService.getFunders().subscribe( + data => { + this.funders = data[1]; + + }, + err => console.log(err) + ); + } + + getProjects () { + if(this.selectedFunderId != '0'){ + + } + } +funderChanged(funderId:string, funderName:string){ + this.selectedFunderId = funderId; + this.selectedFunderName = funderName; + console.info("Selected funder:"+this.selectedFunderId+ ' name:'+funderName ); + +} + +} diff --git a/portal-2/src/app/claims/claim-utils/claimProject.module.ts b/portal-2/src/app/claims/claim-utils/claimProject.module.ts new file mode 100644 index 00000000..0a26efff --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimProject.module.ts @@ -0,0 +1,25 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { CommonModule } from '@angular/common'; + +import {ClaimProjectsComponent} from './claimProject.component'; +import {LoadingModalModule} from '../../utils/modal/loadingModal.module'; + +import {ProjectServiceModule} from '../../landingPages/project/projectService.module'; +import {ProjectsServiceModule} from '../../services/projectsService.module'; +import {EntitiesAutocompleteModule} from '../../utils/entitiesAutoComplete/entitiesAutoComplete.module'; + + @NgModule({ + imports: [ + SharedModule, CommonModule, LoadingModalModule, ProjectServiceModule, ProjectsServiceModule, EntitiesAutocompleteModule + ], + providers:[ + ], + declarations: [ + ClaimProjectsComponent + + ], + exports: [ClaimProjectsComponent ] +}) +export class ClaimProjectModule { } diff --git a/portal-2/src/app/claims/claim-utils/claimPublication.component.html b/portal-2/src/app/claims/claim-utils/claimPublication.component.html new file mode 100644 index 00000000..98a71b4f --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimPublication.component.html @@ -0,0 +1,121 @@ + +
+ + + +
    +
  • +
    + + + + +
    +
    + +
    +
    +
    +
      +
    • +
      + {{item.title}} + {{item.title}} + +
      + + + + +
    • +
    +
    +
    +
  • +
  • +
    + + + + +
    +
    + +
    +
    +
    +
      +
    • +
      + {{result['title'].name}} + {{result['title'].name}} + +
      + + + +
    • +
    +
    +
    +
  • +
  • +
    + + + +
    No results found
    + +
    +
    Not the right author? Choose one of these: + + + + + + + +
    + Results for + {{authorGivenName}} {{authorFamilyName}} - {{authorId}} : + + +
    +
    + +
    + +
    +
    +
      +
    • +
      + {{item['work-title']['title'].value}} + +
      + + + +
    • +
    +
    No results found
    +
    +
    +
    +
  • +
+
diff --git a/portal-2/src/app/claims/claim-utils/claimPublication.component.ts b/portal-2/src/app/claims/claim-utils/claimPublication.component.ts new file mode 100644 index 00000000..d8242f28 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimPublication.component.ts @@ -0,0 +1,401 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; +import {SearchCrossrefService} from '../claim-utils/service/searchCrossref.service'; +import {SearchOrcidService} from '../claim-utils/service/searchOrcid.service'; +import {SearchPublicationsService} from '../../services/searchPublications.service'; +import { ErrorCodes} from '../../utils/properties/openaireProperties'; +import {ClaimResult} from '../claim-utils/claimEntities.class'; +import{DOI} from '../../utils/string-utils.class'; + +@Component({ + selector: 'claim-publication', + templateUrl: 'claimPublication.component.html', + +}) +export class ClaimPublicationComponent { + constructor (private _searchCrossrefService: SearchCrossrefService,private _searchOrcidService: SearchOrcidService, private _searchPublicationsService: SearchPublicationsService, + private route: ActivatedRoute) { + var myDate = new Date(); + this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate = (myDate.getFullYear()+100)+ "-01-01" ; + + } + ngOnInit() { + this.sub = this.route.params.subscribe(params => { + if(this.keyword !=null && this.keyword.length > 0){ + this.search(this.keyword); + } + }); + +} +ngOnDestroy() { + this.sub.unsubscribe(); +} +@Input() public keyword:string = ""; +@Input() public select:boolean = true ; +@Input() public selectedPublications = [] ; +@Output() publicationsChange = new EventEmitter(); + sub: any; + size:number = 10; + source: string = "crossref"; + type : string = "publication"; + errorCodes:ErrorCodes = new ErrorCodes(); + + crossrefResults=[]; + crossrefResultsNum : number = null; + crossrefPage : number = 1; + crossrefStatus:number = this.errorCodes.NONE; + + openaireResults = []; + openaireResultsNum: number ; + openairePage : number = 1; + openaireStatus:number = this.errorCodes.NONE; + + orcidResults: string[]; + orcidResultsNum: number ; + totalPages: number; + orcidResultsToShow: string[]; + orcidPage : number = 1; + orcidStatus:number = this.errorCodes.NONE; + authorId: string; + authorGivenName: string; + authorFamilyName: string; + + authorIds: string[]; + authorGivenNames: string[]; + authorFamilyNames: string[]; + + authorsNum : number ; + + public warningMessage = ""; + public infoMessage = ""; + + todayDate = ''; + nextDate = ''; +private DOIs:string[] = []; + +public search(term: string){ + this.warningMessage = ""; + this.infoMessage = ""; + this.DOIs = DOI.getDOIsFromString(term); + this.getCrossrefResults(term, this.size,1); + this.searchOrcid(term); + this.searchOpenaire(term, this.size, 1); +} + + +private getCrossrefResults (term: string, size : number, page : number) { + this.crossrefStatus = this.errorCodes.LOADING; + if( this.DOIs.length > 0 ){ + this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs).subscribe( + data => { + if(data != null) { + this.crossrefResults = data.items; + this.crossrefPage=page; + this.crossrefResultsNum = data['total-results']; + if(data.items == 0){ + this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe( + data => { + if(data != null) { + this.crossrefResults = data.items; + this.crossrefPage=page; + this.crossrefResultsNum = data['total-results']; + this.crossrefStatus = this.errorCodes.DONE; + + }else{ + this.crossrefStatus = this.errorCodes.ERROR; + } + }, + err =>{ + console.log(err.status); + this.crossrefStatus = this.errorCodes.ERROR; + } + + ); + }else{ + this.crossrefStatus = this.errorCodes.DONE; + } + } + }, + err => { + //console.log(err); + this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe( + data => { + this.crossrefResults = data.items; + this.crossrefPage=page; + this.crossrefResultsNum = data['total-results']; + this.crossrefStatus = this.errorCodes.DONE; + + }, + err => { + console.log(err.status); + this.crossrefStatus = this.errorCodes.ERROR; + } + + ); + } + ); + + }else{ + + + this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe( + data => { + if(data != null) { + this.crossrefResults = data.items; + this.crossrefPage=page; + this.crossrefResultsNum = data['total-results']; + this.crossrefStatus = this.errorCodes.DONE; + + }else{ + this.crossrefStatus = this.errorCodes.ERROR; + } + + }, + err => { + console.log(err.status); + this.crossrefStatus = this.errorCodes.ERROR; + } + ); + } + } + private searchOpenaire(term: string, size : number, page : number) { + + if(this.DOIs.length > 0 ){ + this.openaireStatus = this.errorCodes.LOADING; + this._searchPublicationsService.searchPublicationsByDois(this.DOIs, null, page, size, []).subscribe( + data => { + if(data != null) { + this.openairePage=page; + this.openaireResultsNum = data[0]; + this.openaireResults = data[1]; + this.openaireStatus = this.errorCodes.DONE; + if(this.openaireResultsNum == 0){ + this.openaireStatus = this.errorCodes.NONE; + } + }else { + this.openaireStatus = this.errorCodes.ERROR; + } + }, + err => { + this.openaireStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + }else{ + this.openaireStatus = this.errorCodes.LOADING; + this._searchPublicationsService.searchPublications('q="'+term+'"', null, page, size, []).subscribe( + data => { + if(data != null) { + this.openairePage=page; + this.openaireResultsNum = data[0]; + this.openaireResults = data[1]; + this.openaireStatus = this.errorCodes.DONE; + if(this.openaireResultsNum == 0){ + this.openaireStatus = this.errorCodes.NONE; + } + }else { + this.openaireStatus = this.errorCodes.ERROR; + } + }, + err => { + this.openaireStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + } + } + + private searchOrcid (term: string) { + if(this.DOIs.length > 0){ + this.orcidStatus = this.errorCodes.NONE; + return; + } + this.orcidStatus = this.errorCodes.LOADING; + this.authorIds = new Array(); + this.authorGivenNames = new Array(); + this.authorFamilyNames = new Array(); + + this.getOrcidAuthor(term); + + console.info('searchOrcid in searchOrcid file'); + } + + private readData(data: any) { + this.authorIds.push(data[2].path); + + if(data[0] != null) { + this.authorGivenNames.push(data[0].value); + } else { + this.authorGivenNames.push(""); + } + if(data[1] != null) { + this.authorFamilyNames.push(data[1].value); + } else { + this.authorFamilyNames.push(""); + } + } + + private getOrcidAuthor (term: string) { + this.orcidResultsNum = null; + + //passing structures in order to fill them in service + this._searchOrcidService.searchOrcidAuthor(term, this.authorIds, + this.authorGivenNames, this.authorFamilyNames).subscribe( + data => { + if(data != null && data == true) { + this.getOrcidResultsById(0); + } + + this.orcidStatus = this.errorCodes.NONE; + + }, + err => this.errorHandler(err, term) + + ); + } + + private errorHandler(err: any, term: string) { + if(err.status == 404){ + this.getOrcidAuthors(term); + } else { + this.orcidStatus = this.errorCodes.ERROR; + console.log(err.status); + + } + } + + private getOrcidAuthors (term: string) { + this.orcidResultsNum = null; + + //passing structures in order to fill them in service + this._searchOrcidService.searchOrcidAuthors(term, this.authorIds, + this.authorGivenNames, this.authorFamilyNames).subscribe( + data => { + if(data != null && data == true) { + this.getOrcidResultsById(0); + }else{ + this.orcidStatus = this.errorCodes.ERROR; + } + + }, + err => { + this.orcidStatus = this.errorCodes.ERROR; + console.log(err.status); + } + ); + } + + + private getOrcidResultsById (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.authorId = id; + console.info("getOrcidResultsById: "+id); + this._searchOrcidService.searchOrcidPublications(id).subscribe( + data => { + if(data != null) { + this.orcidResults=data['orcid-work']; + this.orcidResultsNum = data['orcid-work'].length; + this.orcidPage = 1; + if((this.orcidResultsNum % this.size) == 0){ + this.totalPages=parseInt(''+(this.orcidResultsNum/this.size)); + } else{ + this.totalPages=parseInt(''+(this.orcidResultsNum/this.size+1)); + } + + this.orcidResultsToShow = this.orcidResults.slice(0,10); + + this.orcidStatus = this.errorCodes.DONE; + if(this.orcidResultsNum == 0){ + this.orcidStatus = this.errorCodes.NONE; + } + } else { + this.orcidResultsNum = 0; + this.totalPages=0; + this.orcidStatus = this.errorCodes.NONE; + } + + }, + err => { + console.log(err.status); + this.orcidStatus = this.errorCodes.ERROR; + } + ); + + } + } + private add(item, id, itemSource, itemType, itemUrl, itemTitle, date, accessMode){ + var result: ClaimResult ; + if(itemSource == 'crossref'){ + date = (date == null) ? null : date.substring(0,10); + result = {id: id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date}; + }else if (itemSource == 'orcid'){ + date = (date == null) ? null : date + "-01.-01" + result = {id:id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date}; + }else if (itemSource == 'openaire'){ + //TODO put right access rights + result = {id:id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: null, date}; + + } + console.info("Added result:"+result.date); + var found:boolean = this.isSelected(result.id); + this.warningMessage = ""; + if (!found) { + this.selectedPublications.push(result); + this.publicationsChange.emit({ + value: this.selectedPublications + }); + }else{ + this.warningMessage = "Publication already in selected list"; + } + + } + private remove(item){ + this.warningMessage = ""; + this.infoMessage = ""; + var index:number =this.selectedPublications.indexOf(item); + item.selected=false; + if (index > -1) { + this.selectedPublications.splice(index, 1); + this.publicationsChange.emit({ + value: this.selectedPublications + }); + } + + } +private crossrefPageChange($event) { + this.crossrefPage=$event.value; + this.crossrefResults=[]; + console.log("Crossref chaenged "+this.crossrefPage); + this.getCrossrefResults(this.keyword,this.size,this.crossrefPage); +} +private orcidPageChange($event) { + this.orcidPage=$event.value; + this.orcidResultsToShow=[]; + this.orcidResultsToShow = this.orcidResults.slice(($event.value-1)*this.size, $event.value*this.size); +} +private openairePageChange($event) { + this.openairePage=$event.value; + this.searchOpenaire(this.keyword,this.size,this.openairePage); +} + + private isSelected(id:string){ + + var found:boolean = false; + this.warningMessage = ""; + for (var _i = 0; _i < this.selectedPublications.length; _i++) { + let item = this.selectedPublications[_i]; + if(item.id == id){ + found=true; + this.warningMessage = "Publication already in selected list"; + } + } + return found; + + + } +} diff --git a/portal-2/src/app/claims/claim-utils/claimResult.component.ts b/portal-2/src/app/claims/claim-utils/claimResult.component.ts new file mode 100644 index 00000000..737c4539 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimResult.component.ts @@ -0,0 +1,107 @@ +import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import {ClaimPublicationComponent} from './claimPublication.component'; +import {ClaimDatasetComponent} from './claimDataset.component'; + +@Component({ + selector: 'claim-result', + template: ` + + +
+
+
+ + +
+ + + + + + + + + + + +
+
+
+
+
+
+ +
+
+ +
+
+ + `, +}) +export class ClaimResultComponent { + constructor () { + var myDate = new Date(); + this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate = (myDate.getFullYear()+100)+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ; + + } + ngOnInit() { + // if(this.keyword !=null && this.keyword.length > 0){ + // this.searchDatacite(this.keyword,this.size,this.page); + // } +} + @ViewChild (ClaimPublicationComponent) claimPublicationComponent : ClaimPublicationComponent ; + @ViewChild (ClaimDatasetComponent) claimDatasetComponent : ClaimDatasetComponent ; + + page : number = 1; + size:number = 10; + navigateTo: string = "Search"; + source: string = "datacite"; + type : string = "dataset"; + searchType ="publication"; + @Input() public select:boolean = true ; + @Input() public keyword:string = ''; + @Input() public selectedDatasets = [] ; + @Input() public selectedPublications = [] ; + @Output() datasetsChange = new EventEmitter(); + @Output() publicationsChange = new EventEmitter(); + + todayDate = ''; + nextDate = ''; + search(){ + if(this.searchType=='dataset'){ + this.claimDatasetComponent.search(this.keyword,10,1); + }else{ + this.claimPublicationComponent.search(this.keyword); + } + } + + typeChanged(type:string) { + this.searchType = type; + } + publicationsChanged($event) { + this.selectedPublications=$event.value; + this.publicationsChange.emit({ + value: this.selectedPublications + }); + + } + datasetsChanged($event) { + this.selectedDatasets=$event.value; + this.datasetsChange.emit({ + value: this.selectedDatasets + }); + } +} diff --git a/portal-2/src/app/claims/claim-utils/claimResult.module.ts b/portal-2/src/app/claims/claim-utils/claimResult.module.ts new file mode 100644 index 00000000..a264475d --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/claimResult.module.ts @@ -0,0 +1,31 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { CommonModule } from '@angular/common'; + +import {ClaimPublicationComponent} from './claimPublication.component'; +import {ClaimDatasetComponent} from './claimDataset.component'; +import {ClaimResultComponent} from './claimResult.component'; + +import {SearchDataciteService} from './service/searchDatacite.service'; +import {SearchCrossrefServiceModule} from './service/searchCrossrefService.module'; +import {SearchOrcidService} from './service/searchOrcid.service'; + +import {PublicationsServiceModule} from '../../services/publicationsService.module'; +import {DatasetsServiceModule} from '../../services/datasetsService.module'; +import {PagingModule } from '../../utils/paging.module'; + + @NgModule({ + imports: [ + SharedModule, CommonModule, PublicationsServiceModule, DatasetsServiceModule, PagingModule, SearchCrossrefServiceModule + ], + providers:[ + SearchDataciteService, SearchOrcidService + ], + declarations: [ + ClaimPublicationComponent, ClaimDatasetComponent, ClaimResultComponent + + ], + exports: [ClaimResultComponent ] +}) +export class ClaimResultModule { } diff --git a/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.html b/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.html new file mode 100644 index 00000000..77e13ef9 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.html @@ -0,0 +1,88 @@ + +
+ + +
+ Filter By: +
+
+ + + + +
+ +
+
+ +
+ +
+ +
+ Show + + + Showing {{(size*page - size +1)}} to {{(size*page>resultsNum)?resultsNum:(size*page)}} of {{resultsNum}} claims + +
+
+ + +
+ An Error occured. +
+ + + + +
+
+
+ You have selected {{selected.length}} claim(s) +
+
+
+ +
+ +
+
+ + +
+
No entries found.
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Research Result Link to Claimed by Claimed Date
{{claim.userMail}}{{claim.date}}
+ + + + 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 new file mode 100644 index 00000000..b7a78410 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.component.ts @@ -0,0 +1,491 @@ +import {Component, ViewChild, Input} from '@angular/core'; +import {Location} from '@angular/common'; +import {Observable} from 'rxjs/Observable'; +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'; + + +@Component({ + selector: 'displayClaims', + templateUrl: 'displayClaims.component.html', + providers:[ ClaimsService] + +}) +export class DisplayClaimsComponent { + constructor (private _claimService: ClaimsService, private route: ActivatedRoute, private _router:Router, private location: Location) { + } + + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + if( this.myClaims == 'true' ){ + this.fetchBy = "User"; + }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:''; + + } + + 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(); + + }); + // 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'; + page : number; + size:number; + sizes = [10,20,30,50]; + keyword:string; // the keyword string to give to the request as parameter + inputkeyword:string; // the string written in the input field (keyword=inputkeyword when its length is bigger than 3 and the user stops typing) + lengths = [10,20,30,50]; + types = ["All","Project","Context","Result","User"]; + @Input() fetchBy:string; + @Input() fetchId:string; + + navigateTo: string = "Claims"; + resultsNum: number ; + claims: string[]; + + @ViewChild (ModalLoading) loading : ModalLoading ; + + //checkboxes: + publicationCB = false; + datasetCB = false; + contextCB = false; + projectCB = false; + entityTypes : string[] =[] ; + + descending = true; + sortby = "date"; + + selected=[]; + deleteMessage:string = ""; + showErrorMessage:boolean = false; + + //params for pagingFormatter to use when navigate to page + params; + @ViewChild(AlertModal) alert; + + claimsDeleted:number = 0; + + getClaims () { + this.selected=[]; + var types = ''; + this.showErrorMessage = false; + for (var type of this.entityTypes){ + types+=(types.length>0?'&':'')+"types="+type; + } + if(this.fetchBy =="Project" ){ + this._claimService.getClaimsByProject(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe( + data => { + this.claims = data.data; + this.resultsNum= data.total; + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + }else if(this.fetchBy =="User"){ + this._claimService.getClaimsByUser(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe( + data => { + this.claims = data.data; + this.resultsNum= data.total; + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + }else if(this.fetchBy =="Result"){ + this._claimService.getClaimsByResult(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe( + data => { + this.claims = data.data; + this.resultsNum= data.total; + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + }else if(this.fetchBy =="Context"){ + this._claimService.getClaimsBycontext(this.size,this.page,this.fetchId,this.keyword,this.sortby,this.descending, types).subscribe( + data => { + this.claims = data.data; + this.resultsNum= null; + this.resultsNum= data.total;//data.length; //TODO get the total results num + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + }else{ + this._claimService.getClaims(this.size,this.page,this.keyword,this.sortby,this.descending, types).subscribe( + data => { + this.claims = data.data; + this.resultsNum = null; + this.resultsNum= data.total;//data.length; //TODO get the total results num + }, + err => { + console.log(err); + this.showErrorMessage = true; + } + ); + } + } + + goToClaim(claimId: number){ + this._router.navigate( ['Claim', { id: claimId}] ); + } + goTo(page:number = 1){ + + this.page = page; + + this.location.go(location.pathname,this.getParametersString()); + 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() }; + return params; + } + getParametersString(){ + var params=''; + params+=(this.page==1?"":(params.length>0?'&':'')+"page="+this.page); + params+=(this.size==10?"":(params.length>0?'&':'')+"size="+this.size); + // params+=(this.entityTypes==''?"":(params.length>0?'&':'')+"types="+this.entityTypes); + var types=""; + for (var type of this.entityTypes){ + types+=(types.length>0?',':'')+type; + } + params+=(types.length>0)?"types="+types:""; + + if(this.isAdmin === 'true'){ + params+=(this.fetchBy=='All'?"":(params.length>0?'&':'')+"fetchBy="+this.fetchBy); + params+=(this.fetchId==''?"":(params.length>0?'&':'')+"fetchId="+this.fetchId); + } + params+=(this. getSortby()=='datedesc'?"":(params.length>0?'&':'')+"sort="+this. getSortby()); + params+=(this.keyword==''?"":(params.length>0?'&':'')+"keyword="+this.keyword); + return params; + } + changeSize(size: number ){ + this.size = size; + this.goTo(); + } + + clearFilters(){ + this.keyword = ''; + this.inputkeyword = ''; + this.publicationCB = false; + this.projectCB = false; + this.datasetCB = false; + this.contextCB = false; + this.entityTypes = []; + this.goTo(); + } + changeOrderby(sortby:string){ + if(sortby==this.sortby){ + this.descending = !this.descending; + }else{ + this.sortby = sortby; + this.descending = false; + } + this.goTo(); + } + setSortby(sortby:string){ + if(!sortby|| sortby == "datedesc"){ + this.descending = true; + this.sortby = "date"; + }else if(sortby == "dateasc"){ + this.descending = false; + this.sortby = "date"; + }else if(sortby == "userasc"){ + this.descending = false; + this.sortby = "user"; + }else if(sortby == "userdesc"){ + this.descending = true; + this.sortby = "user"; + }if(sortby =="sourceasc"){ + this.descending = false; + this.sortby = "source"; + }else if(sortby == "sourcedesc"){ + this.descending = true; + this.sortby = "source"; + }else if(sortby == "targetasc"){ + this.descending = false; + this.sortby = "target"; + }else if(sortby == "targetdesc"){ + this.descending = true; + this.sortby = "target"; + } + } + getSortby():string{ + if(this.descending){ + return this.sortby+"desc"; + }else{ + return this.sortby+"asc"; + } + + } + changeType(){ + this.entityTypes = []; + if(this.publicationCB){ + this.entityTypes.push('publication'); + } + if(this.datasetCB){ + this.entityTypes.push('dataset'); + } + if(this.projectCB){ + this.entityTypes.push('project'); + } + if(this.contextCB){ + 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){ + if(!types){ + return; + } + if(types.length > 0){ + this.entityTypes = []; + if(types.indexOf("publication")!=-1){ + this.publicationCB = true; + this.entityTypes.push("publication"); + } + if(types.indexOf("dataset")!=-1){ + this.datasetCB = true; + this.entityTypes.push("dataset"); + } + if(types.indexOf("project")!=-1){ + this.projectCB = true; + this.entityTypes.push("project"); + } + if(types.indexOf("context")!=-1){ + this.contextCB = true; + this.entityTypes.push("context"); + } + } + if(this.publicationCB && this.datasetCB && this.contextCB && this.projectCB){ + this.entityTypes=[]; + } + } + changekeyword(){ + + if(this.inputkeyword.length >= 3 || this.inputkeyword.length == 0 ){ + this.keyword = this.inputkeyword; + this.page = 1; + this.goTo(); + } + + } + select(item:any,event){ + this.deleteMessage=""; + var value = event.currentTarget.checked; + if(value){ + this.selected.push(item); + }else{ + for (var _i = 0; _i < this.selected.length; _i++) { + let claim = this.selected[_i]; + if(claim['id'] == item.id){ + this.selected.splice(_i, 1); + } + } + + + } + } + selectAll(){ + this.selected = []; + for (var _i = 0; _i < this.claims.length; _i++) { + let claim = this.claims[_i]; + this.selected.push(claim); + } + this.deleteMessage = ""; + } + deselectAll(){ + this.selected = []; + this.deleteMessage=""; + } + isSelected(id:string){ + for (var _i = 0; _i < this.selected.length; _i++) { + let claim = this.selected[_i]; + if(claim['id'] == id){ + return true; + } + } + return false; + } + + + confirmOpen(){ + if(this.selected.length <= 0){ + + }else{ + this.alert.cancelButton = true; + this.alert.okButton = true; + this.alert.alertTitle = "Delete "+this.selected.length+" claim(s)"; + this.alert.message = this.selected.length+" claims will be deleted. Do you want to proceed? "; + this.alert.okButtonText = "Yes"; + this.alert.cancelButtonText = "No"; + this.alert.open(); + } + } + confirmClose(data){ + this.delete(); + } + delete(){ + this.deleteMessage=""; + this.loading.open(); + this.claimsDeleted = 0; + var ids = []; + for (var i = 0; i < this.selected.length; i++){ + var id =this.selected[i].id; + ids.push(id); + // var selected =this.selected[i].id; + // console.warn("Deleting claim with id:"+id); + // this.deleteById(id); + //TODO for multiple concurrent + } + this.batchDeleteById(ids); + } + + deleteById(id:string){ + + console.warn("Deleting claim with id:"+id); + // this._claimService.deleteClaimById(id); + this._claimService.deleteClaimById(id).subscribe( + res => { + console.info('Delete response'+res.code ); + console.warn("Deleted claim with id:"+ id); + //remove this claim from the + let newClaims=this.claims; + for (var _i = 0; _i < this.claims.length; _i++) { + let claim = this.claims[_i]; + if(claim['id'] == id){ + newClaims.splice(_i, 1); + } + } + //TODO should call getClaims??? + this.claimsDeleted++; + this.claims = newClaims; + if(this.claimsDeleted == this.selected.length){ + this.resultsNum = this.resultsNum - this.selected.length; + this.loading.close(); + this.selected = []; + } + + + }); + } + batchDeleteById(ids:string[]){ + + console.warn("Deleting claim with ids:"+ids); + this._claimService.deleteBulk(ids).subscribe( + res => { + console.info('Delete response'+res.code ); + console.warn("Deleted ids:"+ res.deletedIds); + console.warn("Not found ids:"+ res.notFoundIds); + //remove this claim from the + let newClaims=this.claims; + for(var id of res.deletedIds){ + for (var _i = 0; _i < this.claims.length; _i++) { + let claim = this.claims[_i]; + if(claim['id'] == id){ + newClaims.splice(_i, 1); + } + } + for (var _i = 0; _i < this.selected.length; _i++) { + let claim = this.selected[_i]; + if(claim['id'] == id){ + this.selected.splice(_i, 1); + } + } + } + this.claims = newClaims; + this.resultsNum = this.resultsNum - res.deletedIds.length; + this.loading.close(); + if(res.deletedIds.length>0){ + this.deleteMessage=this.deleteMessage+'
'+res.deletedIds.length+' claim(s) successfully deleted.
'; + } + if(res.notFoundIds.length>0){ + this.deleteMessage=this.deleteMessage+'
'+res.notFoundIds.length+' claim(s) couldn\'t be deleted.
'; + } + }); + } + pageChange($event) { + var page:number = +$event.value + this.goTo(page); + } +} diff --git a/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.module.ts b/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.module.ts new file mode 100644 index 00000000..095ab6c7 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/displayClaims/displayClaims.module.ts @@ -0,0 +1,28 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import {ClaimServiceModule} from '../service/claimsService.module'; +import {DisplayClaimsComponent} from './displayClaims.component'; +import {LoadingModalModule} from '../../../utils/modal/loadingModal.module'; +import {AlertModalModule} from '../../../utils/modal/alertModal.module'; +import {ClaimEntityFormatterModule} from '../entityFormatter/claimEntityFormatter.module'; +import {PagingModule } from '../../../utils/paging.module'; +// import { Claim } from '../claim'; +//helpers + + @NgModule({ + imports: [ + CommonModule, FormsModule, ClaimServiceModule, LoadingModalModule, AlertModalModule, +ClaimEntityFormatterModule, PagingModule + + ], + declarations: [ + DisplayClaimsComponent + + ], + providers: [ ], + exports: [ + DisplayClaimsComponent + ] +}) +export class DisplayClaimsModule { } diff --git a/portal-2/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.component.ts b/portal-2/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.component.ts new file mode 100644 index 00000000..f2611255 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.component.ts @@ -0,0 +1,36 @@ +import {Component, Input} from '@angular/core'; + +//Usage Example " " + +//externalUrl +@Component({ + selector: 'claim-entity', + template: ` + +
+ ({{type}}) + +
+
+ (Project) + +
+
+ (Context) +
{{entity.title}}
+
+ ` +}) + +export class ClaimEntityFormatter { + @Input() entity: string[]; + @Input() type: string; + + constructor () {} + + ngOnInit() { + + } + + +} diff --git a/portal-2/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts b/portal-2/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts new file mode 100644 index 00000000..3053559e --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/entityFormatter/claimEntityFormatter.module.ts @@ -0,0 +1,23 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {ProjectTitleFormatter} from './projectTitleFormatter.component'; +import {PublicationTitleFormatter} from './publicationTitleFormatter.component'; +import {ClaimEntityFormatter} from './claimEntityFormatter.component'; + + @NgModule({ + imports: [ + CommonModule + ], + declarations: [ + ProjectTitleFormatter, PublicationTitleFormatter, ClaimEntityFormatter + + ], + providers: [ ], + exports: [ + ProjectTitleFormatter, PublicationTitleFormatter, ClaimEntityFormatter + + ] +}) +export class ClaimEntityFormatterModule { } diff --git a/portal-2/src/app/utils/projectTitleFormatter.component.ts b/portal-2/src/app/claims/claim-utils/entityFormatter/projectTitleFormatter.component.ts similarity index 87% rename from portal-2/src/app/utils/projectTitleFormatter.component.ts rename to portal-2/src/app/claims/claim-utils/entityFormatter/projectTitleFormatter.component.ts index 54ffcb1d..77f8e38f 100644 --- a/portal-2/src/app/utils/projectTitleFormatter.component.ts +++ b/portal-2/src/app/claims/claim-utils/entityFormatter/projectTitleFormatter.component.ts @@ -1,5 +1,5 @@ import {Component, Input} from '@angular/core'; -import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; //Usage Example " " diff --git a/portal-2/src/app/utils/publicationTitleFormatter.component.ts b/portal-2/src/app/claims/claim-utils/entityFormatter/publicationTitleFormatter.component.ts similarity index 100% rename from portal-2/src/app/utils/publicationTitleFormatter.component.ts rename to portal-2/src/app/claims/claim-utils/entityFormatter/publicationTitleFormatter.component.ts diff --git a/portal-2/src/app/claims/claim-utils/service/claims.service.ts b/portal-2/src/app/claims/claim-utils/service/claims.service.ts new file mode 100644 index 00000000..defd985d --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/service/claims.service.ts @@ -0,0 +1,140 @@ +import {Injectable} from '@angular/core'; +import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +// import {Claim} from '../claim'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../../shared/cache.service'; + +@Injectable() +export class ClaimsService { + private baseUrl; + constructor(private jsonp: Jsonp, private http: Http, public _cache: CacheService) { + this.baseUrl = OpenaireProperties.getClaimsAPIURL(); + } + + private getClaimRequest(size : number, page : number, url :string):any { + console.info('ClaimsService: Claims request: '+url); + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + return this.http.get( url) + .map(request => request.json()) + .do(request => console.info("Get claims: offset = "+(size*(page-1)) + " limit ="+size )) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + } + getClaims( size : number, page : number, keyword:string, sortby: string, descending: boolean, types: string):any { + console.info('ClaimsService: getClaims ' ); + console.info('ClaimsService: Types : '+types ); + let url = this.baseUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url); + + } + getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string):any { + console.info('ClaimsService: getClaims for user : '+user); + let url = this.baseUrl +"users/"+user+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url); + + } + getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string):any { + console.info('ClaimsService: getClaims for context : '+contextId); + let url = this.baseUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url); + + } + getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string):any { + console.info('ClaimsService: getClaims for result : '+resultId); + let url = this.baseUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url); + + } + getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string):any { + console.info('ClaimsService: getClaims for project : '+projectId); + let url = this.baseUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types; + return this.getClaimRequest(size,page,url); + } + + deleteClaimById(claimId:string):any{ + console.warn('Trying to delete claim with id : '+claimId); + let url = this.baseUrl +"claims/"+claimId; + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.delete( url, options).map(request => request.json()) + // .do(request => console.info("After delete" )) + .catch(this.handleError); + + } + deleteBulk(claimIds:string[]):any{ + + console.warn('Trying to delete claims with ids : '+claimIds); + var url = ""; + + for(var claimId of claimIds){ + url=url+(url.length >0 ?"&":"")+"claimId="+claimId; + } + url= this.baseUrl +"claims/bulk?"+url; + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.delete( url, options).map(request => request.json()) + // .do(request => console.info("After delete" )) + .catch(this.handleError); + + } + insertBulkClaims(claims):any{ + console.warn('Trying toinsert claims : '+claims); + let url = this.baseUrl +"claims/bulk"; + let body = JSON.stringify( claims ); + console.warn('Json body: : '+body); + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.post(url, body, options) + .map(res => res.json()) + .do(request => console.info("Insert Response:"+request.status) ) + .catch(this.handleError); + + } + insertClaim(claim):any{ + console.warn('Trying toinsert claim : '+claim); + let url = this.baseUrl +"claims"; + let body = JSON.stringify( claim ); + let headers = new Headers({ 'Content-Type': 'application/json' }); + let options = new RequestOptions({ headers: headers }); + return this.http.post(url, body, options) + .map(res => res.json()) + .do(request => console.info("Insert Response:"+request.status) ) + .catch(this.handleError); + + } + + private handleError (error: Response) { + // in a real world app, we may send the error to some remote logging infrastructure + // instead of just logging it to the console + console.log(error); + return Observable.throw(error || 'Server error'); + } + + getClaim(id:string):any { + let url = this.baseUrl+"claims/"+id; + return new Promise((resolve, reject) => { + this.http.get(url) + .map(res => res.json()) + .subscribe( + data => { + resolve(data.data); + }, + err => { + reject(err); + } + ) + ; + }); + } + +} diff --git a/portal-2/src/app/claims/claim-utils/service/claimsService.module.ts b/portal-2/src/app/claims/claim-utils/service/claimsService.module.ts new file mode 100644 index 00000000..5272312e --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/service/claimsService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {ClaimsService} from './claims.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + ClaimsService +], + exports: [ + ] +}) +export class ClaimServiceModule { } diff --git a/portal-2/src/app/claims/claim-utils/service/contexts.service.ts b/portal-2/src/app/claims/claim-utils/service/contexts.service.ts new file mode 100644 index 00000000..a8107fd6 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/service/contexts.service.ts @@ -0,0 +1,88 @@ +import {Injectable} from '@angular/core'; +import {Jsonp, URLSearchParams,ResponseOptions} from '@angular/http'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {Claim} from '../claim'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; +import {AutoCompleteValue} from '../../../searchPages/searchUtils/searchHelperClasses.class'; +import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/share'; +import { CacheService } from '../../../shared/cache.service'; + +@Injectable() +export class ContextsService { + private baseUrl; + constructor(private http: Http, public _cache: CacheService) { + this.baseUrl = OpenaireProperties.getClaimsAPIURL(); + } + + public getCommunities():any { + let url = this.baseUrl + 'communities'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + console.info('ContextsService: request communities '+url); + return this.http.get( url) + .map(request => request.json().data) + // .do(request => console.info("Get claims: offset = ")) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + } + public getCategories(communityId :string):any { + console.info('ContextsService: request categories for community with id '+communityId); + let url= this.baseUrl + 'communities/' + communityId + '/categories'; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get( url) + .map(request => request.json().data) + // .do(request => console.info("Get claims: offset = " )) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + } + public getConcepts(categoryId :string, keyword: string):any { + console.info('ContextsService: request concept for category with id '+categoryId + ' and keyword '+ keyword); + let url= this.baseUrl + 'categories/' + categoryId+ "/concepts"; + let key = url; + if (this._cache.has(key)) { + return Observable.of(this._cache.get(key)); + } + + return this.http.get( url) + .map(request => request.json().data) + .map(res => this.parse(res.concept)) + // .do(res => console.info(res )) + .catch(this.handleError) + .do(res => { + this._cache.set(key, res); + }); + } + parse (data: any):AutoCompleteValue[] { + var array:AutoCompleteValue[] =[] + for(var i = 0; i < data.length; i++){ + var value:AutoCompleteValue = new AutoCompleteValue(); + value.id = data[i].id; + value.label = data[i].label; + array.push(value); + } + + return array; + + } + + private handleError (error: Response) { + // in a real world app, we may send the error to some remote logging infrastructure + // instead of just logging it to the console + console.log(error); + return Observable.throw(error || 'Server error'); + } +} diff --git a/portal-2/src/app/claims/claim-utils/service/contextsService.module.ts b/portal-2/src/app/claims/claim-utils/service/contextsService.module.ts new file mode 100644 index 00000000..6bd55ced --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/service/contextsService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {ContextsService} from './contexts.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + ContextsService +], + exports: [ + ] +}) +export class ContextsServiceModule { } diff --git a/portal-2/src/app/services/searchCrossref.service.ts b/portal-2/src/app/claims/claim-utils/service/searchCrossref.service.ts similarity index 95% rename from portal-2/src/app/services/searchCrossref.service.ts rename to portal-2/src/app/claims/claim-utils/service/searchCrossref.service.ts index 312048db..7b39af69 100644 --- a/portal-2/src/app/services/searchCrossref.service.ts +++ b/portal-2/src/app/claims/claim-utils/service/searchCrossref.service.ts @@ -1,11 +1,11 @@ import {Injectable} from '@angular/core'; import {Http, Response} from '@angular/http'; import {Observable} from 'rxjs/Observable'; -import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; import 'rxjs/add/observable/of'; import 'rxjs/add/operator/do'; import 'rxjs/add/operator/share'; -import { CacheService } from '../shared/cache.service'; +import { CacheService } from '../../../shared/cache.service'; @Injectable() export class SearchCrossrefService { constructor( private http: Http, public _cache: CacheService) {} diff --git a/portal-2/src/app/claims/claim-utils/service/searchCrossrefService.module.ts b/portal-2/src/app/claims/claim-utils/service/searchCrossrefService.module.ts new file mode 100644 index 00000000..798acdb3 --- /dev/null +++ b/portal-2/src/app/claims/claim-utils/service/searchCrossrefService.module.ts @@ -0,0 +1,20 @@ +import { NgModule} from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; + +import {SearchCrossrefService} from './searchCrossref.service'; + + +@NgModule({ + imports: [ + CommonModule, FormsModule + ], + declarations: [ + ], + providers:[ + SearchCrossrefService +], + exports: [ + ] +}) +export class SearchCrossrefServiceModule { } diff --git a/portal-2/src/app/services/searchDatacite.service.ts b/portal-2/src/app/claims/claim-utils/service/searchDatacite.service.ts similarity index 91% rename from portal-2/src/app/services/searchDatacite.service.ts rename to portal-2/src/app/claims/claim-utils/service/searchDatacite.service.ts index 0492c3c6..37a1a635 100644 --- a/portal-2/src/app/services/searchDatacite.service.ts +++ b/portal-2/src/app/claims/claim-utils/service/searchDatacite.service.ts @@ -1,11 +1,11 @@ import {Injectable} from '@angular/core'; import {Http, Response} from '@angular/http'; import {Observable} from 'rxjs/Observable'; -import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; import 'rxjs/add/observable/of'; import 'rxjs/add/operator/do'; import 'rxjs/add/operator/share'; -import { CacheService } from '../shared/cache.service'; +import { CacheService } from '../../../shared/cache.service'; @Injectable() export class SearchDataciteService { constructor(private http: Http, public _cache: CacheService) {} diff --git a/portal-2/src/app/services/searchOrcid.service.ts b/portal-2/src/app/claims/claim-utils/service/searchOrcid.service.ts similarity index 97% rename from portal-2/src/app/services/searchOrcid.service.ts rename to portal-2/src/app/claims/claim-utils/service/searchOrcid.service.ts index 4dd537e8..1d710a50 100644 --- a/portal-2/src/app/services/searchOrcid.service.ts +++ b/portal-2/src/app/claims/claim-utils/service/searchOrcid.service.ts @@ -3,15 +3,16 @@ import {URLSearchParams} from '@angular/http'; import {Http, Response} from '@angular/http'; import { Headers, RequestOptions } from '@angular/http'; import {Observable} from 'rxjs/Observable'; -import {OpenaireProperties} from '../utils/properties/openaireProperties'; +import {OpenaireProperties} from '../../../utils/properties/openaireProperties'; import 'rxjs/add/observable/of'; import 'rxjs/add/operator/do'; import 'rxjs/add/operator/share'; -import { CacheService } from '../shared/cache.service'; +import { CacheService } from '../../../shared/cache.service'; @Injectable() export class SearchOrcidService { constructor( private http: Http, public _cache: CacheService) {} + searchOrcidAuthor (term: string, authorIds: string[], authorGivenNames: string[], authorFamilyNames: string[]):any { console.info("In searchOrcidAuthor: "+term); diff --git a/portal-2/src/app/claims/claim.module.ts b/portal-2/src/app/claims/claim.module.ts new file mode 100644 index 00000000..113e8597 --- /dev/null +++ b/portal-2/src/app/claims/claim.module.ts @@ -0,0 +1,68 @@ +// import { NgModule} from '@angular/core'; +// import { CommonModule } from '@angular/common'; +// import { FormsModule } from '@angular/forms'; +// // +// import {UtilsModule} from '../utils/utils.module'; +// import {ServicesModule} from '../services/services.module'; +// +// import { ClaimsService} from '../services/claims.service'; +// //main +// import {ClaimComponent} from './claim/claim.component'; +// import {ClaimsAdminComponent} from './claims/claimsAdmin.component'; +// import {MyClaimsComponent} from './myClaims/myClaims.component'; +// import {LinkingHomeComponent} from './linking/linkingHome.component'; +// import {LinkingComponent} from './linking/linking.component'; +// import { BulkLinkingComponent } from './linking/bulkLinking.component'; +// +// import {BulkClaimComponent} from './linking/bulkClaim/bulkClaim.component'; +// import {ClaimsComponent} from './claim-utils/claims.component'; +// +// import {ClaimContextComponent} from './claim-utils/claimContext.component'; +// import {ClaimProjectsComponent} from './claim-utils/claimProject.component'; +// import {ClaimResultComponent} from './claim-utils/claimResult.component'; +// import {ClaimPublicationComponent} from './claim-utils/claimPublication.component'; +// import {ClaimDatasetComponent} from './claim-utils/claimDataset.component'; +// +// import {ClaimInsertComponent} from './linking/insertClaim/insertClaim.component'; +// +// import {ClaimSelectedContextsComponent} from './linking/selected/selectedContexts.component'; +// import {ClaimSelectedComponent} from './linking/selected/selected.component'; +// import {ClaimSelectedDatasetsComponent} from './linking/selected/selectedDatasets.component'; +// import {ClaimSelectedResultsComponent} from './linking/selected/selectedResults.component'; +// import {ClaimSelectedProjectsComponent} from './linking/selected/selectedProjects.component'; +// import {ClaimSelectedPublicationsComponent} from './linking/selected/selectedPublications.component'; +// +// import {LinkingGenericComponent} from './linking/linkingGeneric.component'; +// +// import {InlineClaimContextComponent} from './inlineClaims/inlineClaimContext.component'; +// import {InlineClaimProjectComponent} from './inlineClaims/inlineClaimProject.component'; +// import {InlineClaimResultComponent} from './inlineClaims/inlineClaimResult.component'; +// import {ClaimEntityFormatter} from '../utils/claimEntityFormatter.component'; +// +// import { Claim } from '../utils/entities/claim'; +// //helpers +// +// import { ClaimRoutingModule } from './claim-routing.module'; +// @NgModule({ +// imports: [ +// CommonModule, FormsModule, +// UtilsModule, +// ServicesModule, +// ClaimRoutingModule +// +// ], +// declarations: [ +// ClaimsAdminComponent, MyClaimsComponent, ClaimComponent, ClaimsComponent, +// BulkLinkingComponent, LinkingComponent, LinkingHomeComponent, LinkingGenericComponent, +// InlineClaimContextComponent, InlineClaimProjectComponent, InlineClaimResultComponent, ClaimSelectedComponent, +// ClaimContextComponent, ClaimSelectedContextsComponent, ClaimInsertComponent, ClaimProjectsComponent, ClaimSelectedProjectsComponent, +// ClaimResultComponent, ClaimSelectedPublicationsComponent, ClaimSelectedDatasetsComponent, ClaimSelectedResultsComponent, ClaimPublicationComponent, +// ClaimDatasetComponent, BulkClaimComponent, +// ClaimEntityFormatter +// ], +// providers: [ ClaimsService ], +// exports: [ +// InlineClaimContextComponent, InlineClaimProjectComponent, InlineClaimResultComponent +// ] +// }) +// export class ClaimModule { } diff --git a/portal-2/src/app/claims/claim/claim.component.html b/portal-2/src/app/claims/claim/claim.component.html new file mode 100644 index 00000000..41ecc151 --- /dev/null +++ b/portal-2/src/app/claims/claim/claim.component.html @@ -0,0 +1,10 @@ +
+

Here is the claim with id : {{id}}

+
+ {{claim.id }} || {{claim.userMail }} || + {{claim | json}} {{claim | json}} +
+
+
+

No proper id...

+
diff --git a/portal-2/src/app/claims/claim/claim.component.ts b/portal-2/src/app/claims/claim/claim.component.ts new file mode 100644 index 00000000..786270cd --- /dev/null +++ b/portal-2/src/app/claims/claim/claim.component.ts @@ -0,0 +1,43 @@ +import {Component} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ActivatedRoute, Router} from '@angular/router'; + +import {ClaimsService} from '../../services/claims.service'; +// import {Claim} from '../../utils/entities/claim'; + +@Component({ + selector: 'claim', + templateUrl: 'claim.component.html', + +}) +export class ClaimComponent { + constructor (private _claimService: ClaimsService, + private route: ActivatedRoute, private _router:Router) {} + ngOnInit() { + this.sub = this.route.queryParams.subscribe(params => { + + this.id = params['id']; + console.info("Claim id:"+this.id +" " +params['id']); + if(this.id!=null){ + this.getClaim(this.id); + } + }); + + +} +ngOnDestroy() { + this.sub.unsubscribe(); +} + sub: any; + id : string; + claim : any; + getClaim (id: string) { + this._claimService.getClaim(id) + .then(data => { + this.claim = data; + console.log(data); + }) ; + } + + +} diff --git a/portal-2/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts b/portal-2/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts new file mode 100644 index 00000000..5d2ccd80 --- /dev/null +++ b/portal-2/src/app/claims/claimsAdmin/claimsAdmin-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { ClaimsAdminComponent } from './claimsAdmin.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: ClaimsAdminComponent}, + + ]) + ] +}) +export class ClaimsAdminRoutingModule { } diff --git a/portal-2/src/app/claims/claimsAdmin/claimsAdmin.component.ts b/portal-2/src/app/claims/claimsAdmin/claimsAdmin.component.ts new file mode 100644 index 00000000..281cf824 --- /dev/null +++ b/portal-2/src/app/claims/claimsAdmin/claimsAdmin.component.ts @@ -0,0 +1,36 @@ +import {Component, ViewChild, Input} from '@angular/core'; +import {Location} from '@angular/common'; +import {Observable} from 'rxjs/Observable'; + +@Component({ + selector: 'claims-admin', + template: ` +
+ + +
+ + +
+ TODO login +
+ `, + +}) +export class ClaimsAdminComponent { + constructor ( ) { + + } +user:string="argirok@di.uoa.gr"; + ngOnInit() { + + + } + + +} diff --git a/portal-2/src/app/claims/claimsAdmin/claimsAdmin.module.ts b/portal-2/src/app/claims/claimsAdmin/claimsAdmin.module.ts new file mode 100644 index 00000000..5a1458d2 --- /dev/null +++ b/portal-2/src/app/claims/claimsAdmin/claimsAdmin.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { ClaimsAdminComponent } from './claimsAdmin.component'; +import { ClaimsAdminRoutingModule } from './claimsAdmin-routing.module'; +// import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; +import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; + +@NgModule({ + imports: [ + SharedModule, + ClaimsAdminRoutingModule, + // ClaimServiceModule, + DisplayClaimsModule + + ], + declarations: [ + ClaimsAdminComponent + ] +}) +export class ClaimsAdminModule { } diff --git a/portal-2/src/app/claims/inlineClaims/inlineClaimContext.component.ts b/portal-2/src/app/claims/inlineClaims/inlineClaimContext.component.ts new file mode 100644 index 00000000..f0f5cf93 --- /dev/null +++ b/portal-2/src/app/claims/inlineClaims/inlineClaimContext.component.ts @@ -0,0 +1,94 @@ +import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core'; +import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component'; + +@Component({ + selector: 'inline-claim-context', + template: ` + + +
+
+ + + +
+ + + + +
+` + +}) + export class InlineClaimContextComponent { + constructor ( ) { + + } + + @Input() public inlineEntity:any; + @Input() public inlineType:string; + + + contexts=[]; + publications; + datasets; + public show = 'context'; + public showComp:boolean = false; + public enableButton:boolean=true; + public keyword: string = ""; + + @Output() contextAdded = new EventEmitter(); + +@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ; + ngOnInit() { + + } + showChange($event) { + this.show=$event.value; + if(this.show == "end"){ + //TODO + this.contextAdded.emit({ + value: this.contexts + }); + this.contexts = []; + this.showComponent(); + + }else if(this.show == "error"){ + this.showComponent(); + } + } + public toggle(){ + if(!this.showComp){ + this.showComponent(); + }else{ + this.hideComponent(); + } + } + private showComponent(){ + this.showComp=true; + this.enableButton = true; + + } + private hideComponent(){ + this.showComp=false; + } + private insert(){ + this.claimInsert.publications = []; + this.claimInsert.publications.push(this.inlineEntity); + this.publications = []; + this.publications.push(this.inlineEntity); + console.info(" result: :targetId: " +this.publications[0].id + "targetType :"+ this.publications[0].type+" targetCollectedFrom:"+ this.publications[0].source+ "targetAccessRights :"+this.publications[0].accessRights+ " targetEmbargoEndDate:"+this.publications[0].embargoEndDate); + this.enableButton = false; + if (!this.claimInsert.validateInsertions()){ + this.enableButton = true; + } + + + } + private cancel(){ + this.contexts = []; + + this.hideComponent(); + } +} diff --git a/portal-2/src/app/claims/inlineClaims/inlineClaimProject.component.ts b/portal-2/src/app/claims/inlineClaims/inlineClaimProject.component.ts new file mode 100644 index 00000000..4f8cd392 --- /dev/null +++ b/portal-2/src/app/claims/inlineClaims/inlineClaimProject.component.ts @@ -0,0 +1,107 @@ +import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component'; + +@Component({ + selector: 'inline-claim-project', + template: ` + + +
+
+ + + +
+ + + +
+ + + +` + +}) + export class InlineClaimProjectComponent { + constructor () { + + } + + @Input() public inlineEntity:any; + @Input() public inlineType:string; + + + public projects=[]; + public publications; + public datasets; + public show = 'project'; + public showComp:boolean = false; + public enableButton:boolean=true; + public keyword: string = ""; + + @Output() projectAdded = new EventEmitter(); + +@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ; + ngOnInit() { + + } + + showChange($event) { + this.show=$event.value; + if(this.show == "end"){ + //TODO + this.projectAdded.emit({ + value: this.projects + }); + this.projects = []; + this.showComponent(); + }else if(this.show == "error"){ + this.showComponent(); + } + } + public toggle(){ + console.info("TOOGLE pr "); + if(!this.showComp){ + console.info("TOOGLE show "); + this.showComponent(); + }else{ + console.info("TOOGLE hide "); + this.hideComponent(); + } + } + private showComponent(){ + this.showComp=true; + this.enableButton = true; + + } + private hideComponent(){ + this.showComp=false; + } + private insert(){ + if(this.inlineType === 'dataset'){ + this.datasets = []; + this.datasets.push(this.inlineEntity); + this.claimInsert.datasets = []; + this.claimInsert.datasets.push(this.inlineEntity); + }else if(this.inlineType === 'publication'){ + this.claimInsert.publications = []; + this.claimInsert.publications.push(this.inlineEntity); + this.publications = []; + this.publications.push(this.inlineEntity); + console.info(" result: :targetId: " +this.publications[0].id + "targetType :"+ this.publications[0].type+" targetCollectedFrom:"+ this.publications[0].source+ "targetAccessRights :"+this.publications[0].accessRights+ " targetEmbargoEndDate:"+this.publications[0].embargoEndDate); + } + this.enableButton = false; + if (!this.claimInsert.validateInsertions()){ + this.enableButton = true; + } + + + } + private cancel(){ + this.projects = []; + + this.hideComponent(); + } +} diff --git a/portal-2/src/app/claims/inlineClaims/inlineClaimResult.component.ts b/portal-2/src/app/claims/inlineClaims/inlineClaimResult.component.ts new file mode 100644 index 00000000..cc14b9c7 --- /dev/null +++ b/portal-2/src/app/claims/inlineClaims/inlineClaimResult.component.ts @@ -0,0 +1,117 @@ +import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component'; +// import {ClaimResultComponent} from '../linking/claimResult/claimResult.component'; +// import {ClaimSelectedResultsComponent} from '../linking/selected/selectedResults.component'; + +@Component({ + selector: 'inline-claim-result', + template: ` + + +
+
+ + + + +
+ + + +
+ + + +` + +}) + export class InlineClaimResultComponent { + constructor () { + + } + // This is the component from the landing page + @Input() public inlineEntity:any; + @Input() public inlineType:string; + public hideType:string; + + + + public publications = []; + public datasets = []; + public show = 'project'; + public showComp:boolean = false; + public enableButton:boolean=true; + public keyword: string = ""; + +@Output() datasetAdded = new EventEmitter(); +@Output() publicationAdded = new EventEmitter(); + +@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ; + ngOnInit() { + console.info("Inline entity:"+this.inlineEntity.id); + this.hideType = this.inlineType; + if(this.inlineType == 'dataset' || this.inlineType == 'publication' ){ + this.hideType = ""; + } + } + + datasetsChange($event) { + this.datasets=$event.value; + console.log($event.value); + } + publicationsChange($event) { + this.publications=$event.value; + console.log($event.value); + } + showChange($event) { + this.show=$event.value; + if(this.show == "end"){ + this.datasetAdded.emit({ + value: this.datasets + }); + this.publicationAdded.emit({ + value: this.publications + }); + this.datasets = []; + this.publications = []; + this.showComponent(); + }else if(this.show == "error"){ + this.showComponent(); + } + } + public toggle(){ + if(!this.showComp){ + this.showComponent(); + }else{ + this.hideComponent(); + } + } + private showComponent(){ + this.showComp=true; + this.enableButton = true; + + } + private hideComponent(){ + this.showComp=false; + } + private insert(){ + if(this.inlineType === 'project'){ //TODO check if neccessary + this.claimInsert.projects = []; + this.claimInsert.projects.push(this.inlineEntity); + } + + this.enableButton = false; + if (!this.claimInsert.validateInsertions()){ + this.enableButton = true; + } + + } + private cancel(){ + this.datasets = []; + this.publications = []; + this.hideComponent(); + } +} diff --git a/portal-2/src/app/claims/linking/bulkClaim/bulkClaim.component.ts b/portal-2/src/app/claims/linking/bulkClaim/bulkClaim.component.ts new file mode 100644 index 00000000..c312e7a7 --- /dev/null +++ b/portal-2/src/app/claims/linking/bulkClaim/bulkClaim.component.ts @@ -0,0 +1,206 @@ +import {Component, Input, Output, EventEmitter,ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {SearchCrossrefService} from '../../claim-utils/service/searchCrossref.service'; +import {ModalLoading} from '../../../utils/modal/loading.component'; +import {Dates, DOI} from '../../../utils/string-utils.class'; + + +@Component({ + selector: 'bulk-claim', + template: ` +
+
+ + +
+
+ +
+
+
Upload a csv file containing DOIs. For each DOI found in file, metadata will be fetched from CrossRef. + Available results can be linked with the selected Projects and Contexts. + More information +
+ CSV format: +
    +
  • The format of CSV file should be "DOI","ACCESS_MODE","DATE".
  • +
  • Access mode column should have values: "OPEN","CLOSED" or "EMBARGO".
  • +
  • Date column valid format is YYYY-MM-DD and is required when access mode has value EMBARGO.
  • +
  • In case access mode is not available default value is "OPEN".
  • +
+
+
+ + + + ` + +}) +//[(ngModel)]="date" +export class BulkClaimComponent { + filesToUpload: Array; + navigateTo: string = "Search"; + source: string = "crossref"; + type : string = "publication"; + resultsFromSearch:number; + @Input() public select:boolean = true ; + @Input() public publications; + all:number = 0; + allIds:string[] = []; + found:number = 0; + foundIds:string[] = []; + duplicate:number = 0; + duplicateIds:string[] = []; + notFound:number = 0; + notFoundIds:string[] = []; + showReport:boolean = false; + showInfo :boolean = false; + @ViewChild (ModalLoading) loading : ModalLoading ; + errorMessage = ""; + infoMEssage = ""; + enableUpload:boolean = true; + constructor(private _searchCrossrefService: SearchCrossrefService) { + this.filesToUpload = []; + + + } + ngOnInit() {} + + upload() { + this.enableUpload = false; + this.showReport = false; + this.errorMessage = ""; + if(this.filesToUpload.length == 0){ + this.errorMessage = "There is no selected file to upload."; + return ; + } + this.makeFileRequest("http://localhost:8000/upload", [], this.filesToUpload).then((result) => { + var rows = (result as any).split('\n'); // I have used space, you can use any thing. + var i = 0; + this.all = 0; + this.duplicate = 0; + this.duplicateIds = []; + this.allIds = []; + this.found = 0; + this.foundIds = []; + this.publications.slice(0,this.publications.length); + this.notFound = 0; + this.notFoundIds = []; + + for(i=0;i-1){ + this.duplicate++; + this.duplicateIds.push(id); + }else{ + this.allIds.push(id); + this.fetchResult(id,accessMode,embargoDate); + } + } + } + + } + + }, (error) => { + this.enableUpload = true; + console.log(error); + // this.loading.close(); + this.errorMessage = "An error occured while uploading..."; + }); + } + private removeDoubleQuotes(value){ + if(value.indexOf('"')== 0){ + value = value.substring(1,value.length); + } + var index =+value.indexOf('"'); + if(index == (value.length - 1) || index == (value.length - 2) ){ + value = value.substring(0,index); + } + return value; + } + private validateAccessMode(value){ + var accessModes = ["OPEN", "CLOSED", "EMBARGO"]; + if(accessModes.indexOf(value) > -1){ + return true; + } + + return false; + } + + fileChangeEvent(fileInput: any){ + this.filesToUpload = > fileInput.target.files; + } + + makeFileRequest(url: string, params: Array, files: Array) { + return new Promise((resolve, reject) => { + var formData: any = new FormData(); + var xhr = new XMLHttpRequest(); + for(var i = 0; i < files.length; i++) { + formData.append("uploads[]", files[i], files[i].name); + } + xhr.onreadystatechange = function () { + if (xhr.readyState == 4) { + if (xhr.status == 200) { + resolve(xhr.response); + } else { + reject(xhr.response); + } + } + } + xhr.open("POST", url, true); + xhr.send(formData); + }); + } + + fetchResult(id:string,accessMode:string,date:string){ + this._searchCrossrefService.searchCrossrefByDOIs([id]).subscribe( + data => { + + var crossrefResult = data.items[0]; + if(data.items.length > 0){ + this.found++; + this.foundIds.push(id); + var result = {id: id, type :'publication', source : 'crossref', + title: crossrefResult.title,url: crossrefResult.URL, result: crossrefResult, accessRights: accessMode, embargoEndDate: date, date : crossrefResult.created['date-time']}; + this.publications.push(result); + + + }else{ + this.notFound++; + this.notFoundIds.push(id); + } + this.endOfFetching(); + }, + err => { + console.log(err); + this.notFound++; + this.notFoundIds.push(id); + this.endOfFetching(); + } + ); + } + + endOfFetching(){ + if(this.all == this.found+this.notFound+ this.duplicate ){ + this.showReport = true; + this.enableUpload = true; + } + + } +} diff --git a/portal-2/src/app/claims/linking/bulkClaim/bulkClaim.module.ts b/portal-2/src/app/claims/linking/bulkClaim/bulkClaim.module.ts new file mode 100644 index 00000000..4f460152 --- /dev/null +++ b/portal-2/src/app/claims/linking/bulkClaim/bulkClaim.module.ts @@ -0,0 +1,15 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {LoadingModalModule} from '../../../utils/modal/loadingModal.module'; +import {BulkClaimComponent} from './bulkClaim.component'; +import {SearchCrossrefServiceModule} from '../../claim-utils/service/searchCrossrefService.module'; +@NgModule({ + imports: [ + SharedModule, LoadingModalModule, SearchCrossrefServiceModule + ], + declarations: [ +BulkClaimComponent + ], exports:[ BulkClaimComponent] +}) +export class BulkClaimModule { } diff --git a/portal-2/src/app/claims/linking/bulkLinking.component.ts b/portal-2/src/app/claims/linking/bulkLinking.component.ts new file mode 100644 index 00000000..42c04446 --- /dev/null +++ b/portal-2/src/app/claims/linking/bulkLinking.component.ts @@ -0,0 +1,16 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; + +@Component({ + selector: 'bulk-linking', + //providers: [MdRadioDispatcher], + template: ` + + ` + +}) +//[(ngModel)]="date" +export class BulkLinkingComponent { + constructor () { + } +} diff --git a/portal-2/src/app/claims/linking/insertClaim/insertClaim.component.ts b/portal-2/src/app/claims/linking/insertClaim/insertClaim.component.ts new file mode 100644 index 00000000..ffe43e1a --- /dev/null +++ b/portal-2/src/app/claims/linking/insertClaim/insertClaim.component.ts @@ -0,0 +1,264 @@ +import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {Router} from '@angular/router'; +import {ClaimsService} from '../../claim-utils/service/claims.service'; +import {ModalLoading} from '../../../utils/modal/loading.component'; +import {AlertModal} from '../../../utils/modal/alert'; + + +@Component({ + selector: 'claim-insert', + template: ` + +
+ +
+
+ +
+ + + + + ` +}) +export class ClaimInsertComponent { + constructor (private claimService: ClaimsService, private _router:Router) {} + ngOnInit() { + // console.info("Inlineentity:" +(this.inlineEntity)?this.inlineEntity+(this.inlineEntity.id)?this.inlineEntity.id:"no id":"null"+ + " show "+ (!this.claiming && this.showButton) ); + } + + + @Input() public contexts; + @Input() public projects; + @Input() public publications; + @Input() public datasets; + @Input() public showButton:boolean = true; + @Input() show='claim'; + @Input() inline: boolean = false; // link from landing page? + @Input() inlineEntity; // the entity from the landing page + @Output() showChange = new EventEmitter(); + + @ViewChild (ModalLoading) loading : ModalLoading ; + @ViewChild(AlertModal) alert; + + public claiming =false; + public error = false; + public errorMessage = ""; + public warningMessage = ""; + public claimsTODO:number = 0; + public claims:number = 0; + public errorclaims:number = 0; + +public validateInsertions(){ + // console.info("Inlineentity:" +(this.inlineEntity)?this.inlineEntity+(this.inlineEntity.id)?this.inlineEntity.id:"no id":"null"+ + " show "+ (!this.claiming && this.showButton) ); + if(this.validate()){ + if(this.validateDates()){ + this.insert(); + return true; + } + } + return +} +private insert(){ + this.claiming = true; + var user="argirok@di.uoa.gr" + this.loading.open(); + var claims = []; + if(this.publications){ + console.info("publications: "+this.publications.length); + + for (var i = 0; i < this.publications.length; i++) { + + var result=this.publications[i]; + if(this.contexts){ + for (var j = 0; j < this.contexts.length; j++) { + var context = this.contexts[j]; + var claim = this.createContextClaim(result, context, user); + claims.push(claim); + } + } + if(this.projects){ + for (var k = 0; k < this.projects.length; k++) { + var project = this.projects[k]; + var projectClaim = this.createProjectClaim(result, project, user); + claims.push(projectClaim); + } + } + if(this.inline && this.inlineEntity){ + var resultClaim = this.createResultClaim(this.inlineEntity, result, user); + claims.push(resultClaim); + } + + } + } + if(this.datasets){ + for (var i = 0; i < this.datasets.length; i++) { + var result=this.datasets[i]; + if(this.contexts){ + for (var j = 0; j < this.contexts.length; j++) { + var context = this.contexts[j]; + var claim = this.createContextClaim(result, context, user); + claims.push(claim); + } + } + if(this.projects){ + for (var k = 0; k < this.projects.length; k++) { + var project = this.projects[k]; + var projectClaim = this.createProjectClaim(result, project, user); + claims.push(projectClaim); + } + } + if(this.inline && this.inlineEntity){ + var resultClaim = this.createResultClaim(this.inlineEntity, result, user); + claims.push(resultClaim); + } + + } + } + console.info("try to insert "+claims.length+" claims"); + this.claimService.insertBulkClaims(claims).subscribe( + data => { + var inserted = data.insertedIds.length; + + var inserted = data.insertedIds.length; + this.afterclaimsInsertion(data.insertedIds,data.errorInClaims); + }, + err => { + console.log(err); + this.errorsInClaimsInsertion(err.insertedIds,err.errorInClaims); + } + ); +} +private validate(){ + this.warningMessage = ""; + this.errorMessage = ""; + if(this.datasets && this.datasets.length == 0 && this.publications && this.publications.length == 0){ + this.warningMessage = "There are no publications or datasets selected."; + }else if((!this.contexts|| this.contexts.length==0 )&&(!this.projects|| this.projects.length==0 )&& ( !this.inlineEntity)){ + this.warningMessage = "There are no projects or concepts to link."; + // }else if (this.inline && !this.inlineEntity){ + // this.errorMessage = "No inline entity"; + // console.log(this.inline + " "+ this.inlineEntity); + }else{ + return true; + } + return false; +} +private validateDates(){ + if(this.projects){ + for (var k = 0; k < this.projects.length; k++) { + var project = this.projects[k]; + console.info(project.startDate+" "+project.endDate + " "+project.projectAcronym); + if(this.publications){ + for (var i = 0; i < this.publications.length; i++) { + var result = this.publications[i]; + if(result.date && result.date != null){ + console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate ); + if((project.startDate && result.date < project.startDate) || ( project.endDate && result.date > project.endDate) ){ + this.confirmOpen(); + return false; + } + } + } + } + if(this.datasets){ + for (var i = 0; i < this.datasets.length; i++) { + var result = this.datasets[i]; + if(result.date && result.date != null){ + console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate ); + if((project.startDate && result.date < project.startDate) || ( project.endDate && result.date > project.endDate) ){ + this.confirmOpen(); + return false; + } + } + } + } + + + } + } + if(this.publications){ + for (var i = 0; i < this.publications.length; i++) { + var result = this.publications[i]; + if(result.date && result.date != null){ + console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate ); + if((result.embargoEndDate && result.embargoEndDate != null) && result.date >result.embargoEndDate ){ + this.confirmOpen(); + return false; + } + } + } + } + if(this.datasets){ + for (var i = 0; i < this.datasets.length; i++) { + var result = this.datasets[i]; + if(result.date && result.date != null){ + console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate ); + if((result.embargoEndDate && result.embargoEndDate != null) && result.date >result.embargoEndDate ){ + this.confirmOpen(); + return false; + } + } + } + } + return true; +} +private afterclaimsInsertion(insertedIds, errorInClaims){ + this.loading.close(); + if(errorInClaims.length == 0){ + if(this.inline){ + this.show = "end"; + }else{ + this._router.navigate( ['/myclaims'] ); + } + this.showChange.emit({ + value: this.show + }); + }else{ + this.errorsInClaimsInsertion(insertedIds, errorInClaims); + } +} +private errorsInClaimsInsertion(insertedIds, errorInClaims){ + this.errorMessage = "An Error Occured."; + this.loading.close(); + this.error = true; + if(this.inline){ + this.show = "error"; + this.showChange.emit({ + value: this.show + }); + } + +} + + + + private createContextClaim(result:any, context:any, user:any){ + var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"no", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate: (result.embargoEndDate == null?"":result.embargoEndDate)}; + return claim; + } + private createProjectClaim(result:any, project:any, user:any){ + //project.projectId + // var dummyID = "dummyID"; + var claim = { claimedBy : user, sourceId : project.projectId, sourceType : "project", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate: (result.embargoEndDate == null?"":result.embargoEndDate)}; + return claim; + } + private createResultClaim(inlineResult:any, result:any, user:any){ + var claim = { claimedBy : user, sourceId : result.id, sourceType : result.type, sourceCollectedFrom: result.source, sourceAccessRights: result.accessRights, sourceEmbargoEndDate: result.embargoEndDate, targetId : inlineResult.id , targetType : inlineResult.type, targetCollectedFrom: inlineResult.source, targetAccessRights: inlineResult.accessRights, targetEmbargoEndDate: (inlineResult.embargoEndDate == null?"":inlineResult.embargoEndDate)}; + return claim; + } + + confirmOpen(){ + this.alert.cancelButton = true; + this.alert.okButton = true; + this.alert.alertTitle = "Invalid dates"; + this.alert.message = "There is a research result whose publication date is after project end date or before project start date. Or embargo end date of a research result is before research result's publication date."; + this.alert.okButtonText = "Procceed anyway"; + this.alert.cancelButtonText = "Cancel"; + this.alert.open(); + } + confirmClose(data){ + this.insert(); + } +} diff --git a/portal-2/src/app/claims/linking/insertClaim/insertClaim.module.ts b/portal-2/src/app/claims/linking/insertClaim/insertClaim.module.ts new file mode 100644 index 00000000..dc0067b3 --- /dev/null +++ b/portal-2/src/app/claims/linking/insertClaim/insertClaim.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {AlertModalModule} from '../../../utils/modal/alertModal.module'; +import {LoadingModalModule} from '../../../utils/modal/loadingModal.module'; +import {ClaimInsertComponent} from './insertClaim.component'; +import {ClaimServiceModule} from '../../claim-utils/service/claimsService.module'; + +@NgModule({ + imports: [ + SharedModule, AlertModalModule, LoadingModalModule, ClaimServiceModule + ], + declarations: [ +ClaimInsertComponent + ], exports:[ ClaimInsertComponent] +}) +export class InsertClaimsModule { } diff --git a/portal-2/src/app/claims/linking/linking-routing.module.ts b/portal-2/src/app/claims/linking/linking-routing.module.ts new file mode 100644 index 00000000..704227f6 --- /dev/null +++ b/portal-2/src/app/claims/linking/linking-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { LinkingComponent } from './linking.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: LinkingComponent}, + + ]) + ] +}) +export class LinkingRoutingModule { } diff --git a/portal-2/src/app/claims/linking/linking.component.ts b/portal-2/src/app/claims/linking/linking.component.ts new file mode 100644 index 00000000..99c7acc1 --- /dev/null +++ b/portal-2/src/app/claims/linking/linking.component.ts @@ -0,0 +1,16 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import {LinkingGenericComponent} from './linkingGeneric.component'; + +@Component({ + selector: 'linking', + template: ` + +` + +}) +export class LinkingComponent { + constructor () { + } + +} diff --git a/portal-2/src/app/claims/linking/linking.module.ts b/portal-2/src/app/claims/linking/linking.module.ts new file mode 100644 index 00000000..8ecf057b --- /dev/null +++ b/portal-2/src/app/claims/linking/linking.module.ts @@ -0,0 +1,19 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { LinkingComponent } from './linking.component'; +import { LinkingRoutingModule } from './linking-routing.module'; +import {LinkingGenericModule} from './linkingGeneric.module'; + +@NgModule({ + imports: [ + SharedModule, + LinkingRoutingModule, + LinkingGenericModule + + ], + declarations: [ + LinkingComponent + ], exports:[LinkingComponent] +}) +export class LinkingModule { } diff --git a/portal-2/src/app/claims/linking/linkingGeneric.component.ts b/portal-2/src/app/claims/linking/linkingGeneric.component.ts new file mode 100644 index 00000000..0b239459 --- /dev/null +++ b/portal-2/src/app/claims/linking/linkingGeneric.component.ts @@ -0,0 +1,223 @@ +import {Component, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router } from '@angular/router'; + +@Component({ + selector: 'linking-generic', + //providers: [MdRadioDispatcher], + template: ` +
+ + + +
+ + +
+ + +
+ + + +
+ +
+ +
+
+

TODO software

+
+
+ +
+ +
+
+ +
+
+ +
+ +
+ + +
+
+ + +
+ +
+
+
+ +
+ +
+
+ + +
+ + +
+ + +
+
+ + +
+ +
+ +
+
+ + +
+
+ + +` + +}) +//[(ngModel)]="date" +export class LinkingGenericComponent { + constructor ( private _router: Router) { + } + @Input() bulkMode: boolean = false; + sourceType:string; + targetType:string; + step:number = 1; + contexts=[]; + projects=[]; + publications=[]; + datasets=[]; + show = "home"; + searchType="publication"; //publication or dataset + date='8-6-2016'; + keyword: string = ""; + linkType:string ="project"; // link type (selected in home page) : project, context, software, etc + ngOnInit() { + + } + next(){ + + if((this.show == 'project' || this.show == 'context' || this.show == 'software')){ + if(!this.bulkMode){ + this.show='result'; + }else{ + this.show='claim'; + } + }else if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){ + this.show='claim'; + + } + } + prev(){ + if(this.show == 'result'){ + this.show = this.linkType; + }else if(this.show == 'context' || this.show == 'project' || this.show == 'software' ){ + this.show='home'; + } else if(this.show == 'claim'){ + // this.show='result'; + if(!this.bulkMode){ + this.show='result'; + }else{ + this.show = this.linkType; + } + } + } + goto(term: string) { + this._router.navigate( ['Search', { keyword: term }] ); + } + + search() { + if(this.searchType == 'publication' ){ + this.show="publication"; + }else{ + this.show="dataset"; + } + + } + + sourceTypeChange($event) { + this.sourceType=$event.value; + console.log($event.value); + } + targetTypeChange($event) { + this.targetType=$event.value; + console.log($event.value); + } + // contextsChange($event) { + // this.contexts=$event.value; + // console.log($event.value); + // } + publicationsChange($event) { + this.publications=$event.value; + } + datasetsChange($event) { + this.datasets=$event.value; + } + projectsChange($event) { + this.projects=$event.value; + } + typeChanged(type:string) { + this.searchType = type; + } + linkTypeChange($event) { + this.linkType =$event.value; + this.show=$event.value; + + } + showChange($event) { + this.show=$event.value; + this.showChangedType($event.value); + + + } + showChangedType(type:string) { + this.show=type; + if(this.show == 'project' || this.show == 'context' || this.show == 'software'){ + this.linkType = this.show; + } + + + } +} diff --git a/portal-2/src/app/claims/linking/linkingGeneric.module.ts b/portal-2/src/app/claims/linking/linkingGeneric.module.ts new file mode 100644 index 00000000..c923dc6e --- /dev/null +++ b/portal-2/src/app/claims/linking/linkingGeneric.module.ts @@ -0,0 +1,33 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import {SelectedProjectsModule} from './selected/selectedProjects.module'; +import {SelectedContextsModule} from './selected/selectedContexts.module'; +import {SelectedPublicationsModule} from './selected/selectedPublications.module'; +import {SelectedDatasetsModule} from './selected/selectedDatasets.module'; +// import {SelectedModule} from './selected/selectedResults.module'; + +import {ClaimProjectModule} from '../claim-utils/claimProject.module'; +import {ClaimResultModule} from '../claim-utils/claimResult.module'; +import {ClaimContextModule} from '../claim-utils/claimContext.module'; + +import {InsertClaimsModule} from './insertClaim/insertClaim.module'; +import {BulkClaimModule} from './bulkClaim/bulkClaim.module'; + +import {LinkingHomeComponent} from './linkingHome.component'; +import {LinkingGenericComponent} from './linkingGeneric.component'; + + +@NgModule({ + imports: [ + SharedModule, SelectedProjectsModule, SelectedContextsModule, + SelectedPublicationsModule, SelectedDatasetsModule, // SelectedResultsModule, + ClaimProjectModule, + ClaimResultModule, ClaimContextModule, InsertClaimsModule, BulkClaimModule + ], + declarations: [ + LinkingHomeComponent, LinkingGenericComponent + ], exports:[ + LinkingGenericComponent ] +}) +export class LinkingGenericModule { } diff --git a/portal-2/src/app/claims/linking/linkingHome.component.ts b/portal-2/src/app/claims/linking/linkingHome.component.ts new file mode 100644 index 00000000..834ccede --- /dev/null +++ b/portal-2/src/app/claims/linking/linkingHome.component.ts @@ -0,0 +1,51 @@ +import {Component, Output, EventEmitter, Input} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; + +@Component({ + selector: 'linking-home', + template: ` + +
+ +
+

Link with project

+

Link your research result with funded projects.

+ Link with project + +
+ +
+

Link with Community

+

Link your research result with research communities.

+ Link with community + +
+ +
+

Bulk mode linking

+

Link Research Results to projects,contects, etc, providing a CSV file with research results' DOIs

+ Bulk mode linking +
+
+ + ` + +}) + +export class LinkingHomeComponent { + @Output() linkTypeChange = new EventEmitter(); + @Input() bulkMode:boolean = false; + linkType:string = "project"; + select(type:string){ + this.linkType = type; + this.linkTypeChange.emit({ + value: this.linkType + }); + } + +} diff --git a/portal-2/src/app/claims/linking/selected/selected.component.ts b/portal-2/src/app/claims/linking/selected/selected.component.ts new file mode 100644 index 00000000..cb593071 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selected.component.ts @@ -0,0 +1,209 @@ +// import {Component, Input,Output, EventEmitter} from '@angular/core'; +// import {ClaimResult,ClaimProject, ClaimContext} from '../../claim-utils/claimEntities.class'; +// +// @Component({ +// selector: 'claim-selected', +// template: ` +// +//
+// +//
+// +//
+//
    +//
  • Selected Concepts ({{(contexts.length)}}) +// +//
  • +//
  • +// {{context.community }} > {{context.category}} > {{context.concept.label}} +// +// +//
  • +//
  • There are no contexts
  • +//
+//
+// +//
+//
+// +//
+//
    +//
  • Selected Projects ({{(projects.length)}}) +// +//
  • +//
  • +// +// {{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}} +// +//
  • +//
  • There are no projects
  • +//
+//
+// +//
+//
+// +// +//
+//
    +// +//
  • There are no Research Results
  • +//
  • {{publications. length }} Selected Publications: +// +//
  • +//
  • +// +// +// {{pub.title}} +// {{pub.title}}({{pub.date.substring(0,4)}}) +// +// +// +// +// +// +// +// +// +// +//
  • +//
  • {{datasets.length}} Selected Research Data: +// +//
  • +//
  • +// +// +// {{dataset.title}} +// {{dataset.title}} +// ({{dataset.date.substring(0,4)}}) +// +// +// +// +// +// +// +// +// +// +//
  • +// +//
+//
+// +//
+// +//
+// ` +// +// +// }) +// export class ClaimSelectedComponent { +// ngOnInit() { +// console.info("Show accessRights selection? :"+this.showAccessRights); +// var myDate = new Date(); +// this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; +// this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; +// //2015-05-01 +// } +// +// +// @Input() contexts: ClaimContext[]; +// @Input() projects: ClaimProject[]; +// @Input() publications: ClaimResult[]; +// @Input() datasets: ClaimResult[]; +// @Input() showAccessRights:boolean = false; +// @Input() show='home'; +// @Input() inline:boolean = false; +// @Input() hideType; +// @Input() bulkMode:boolean = false; +// @Input() linkToResults:boolean = true; +// @Output() projectsChange = new EventEmitter(); +// @Output()publicationsChange = new EventEmitter(); +// @Output() datasetsChange = new EventEmitter(); +// @Output() contextsChange = new EventEmitter(); +// +// @Output() showChange = new EventEmitter(); +// +// todayDate = ''; +// nextDate = ''; +// removeContext(item:any){ +// var index:number =this.contexts.indexOf(item); +// if (index > -1) { +// this.contexts.splice(index, 1); +// } +// this.contextsChange.emit({ +// value: this.contexts +// }); +// } +// removePublication(item:any){ +// var index:number =this.publications.indexOf(item); +// if (index > -1) { +// this.publications.splice(index, 1); +// } +// this.publicationsChange.emit({ +// value: this.publications +// }); +// } +// removeDataset(item:any){ +// var index:number =this.datasets.indexOf(item); +// if (index > -1) { +// this.datasets.splice(index, 1); +// } +// this.datasetsChange.emit({ +// value: this.datasets +// }); +// } +// removeProject(item:any){ +// var index:number =this.projects.indexOf(item); +// if (index > -1) { +// this.projects.splice(index, 1); +// } +// this.projectsChange.emit({ +// value: this.projects +// }); +// } +// showType(type){ +// if(type != this.show){ +// this.show = type; +// this.showChange.emit({ +// value: this.show +// }); +// } +// } +// accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"]; +// +// dateChanged (event:any, item:any) { +// item.embargoEndDate = event.target.value ; +// } +// publicationsChanged($event) { +// this.publications=$event.value; +// this.publicationsChange.emit({ +// value: this.publications +// }); +// } +// } +// +// +// +// // @Component({ +// // selector: 'add-more', +// // template: `` +// // }) +// // export class Addmore { +// // @Input() type = 'publication'; +// // } diff --git a/portal-2/src/app/claims/linking/selected/selectedContexts.component.ts b/portal-2/src/app/claims/linking/selected/selectedContexts.component.ts new file mode 100644 index 00000000..fbd28d61 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedContexts.component.ts @@ -0,0 +1,66 @@ +import {Component, Input,Output, EventEmitter} from '@angular/core'; +import {ClaimContext} from '../../claim-utils/claimEntities.class'; +@Component({ + selector: 'claim-selected-contexts', + template: ` +
+ + +
+

Concepts ({{(contexts.length)}}) + +

+
+
    +
  • + {{context.community }} > {{context.category}} > {{context.concept.label}} + + +
  • +
+ There are no contexts +
+
+ +
+ ` +}) +export class ClaimSelectedContextsComponent { + ngOnInit() { + var myDate = new Date(); + this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + //2015-05-01 +} + + + @Input() contexts:ClaimContext[]; + @Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects) + @Input() show='home'; + @Input() inline:boolean = false; + @Input() hideType; + @Input() bulkMode:boolean = false; + @Output() showChange = new EventEmitter(); + + todayDate = ''; + nextDate = ''; + + showType(type){ + if(type != this.show){ + this.show = type; + this.showChange.emit({ + value: this.show + }); + } + } + + + removeContext(item:any){ + var index:number =this.contexts.indexOf(item); + if (index > -1) { + this.contexts.splice(index, 1); + } + + } + +} diff --git a/portal-2/src/app/claims/linking/selected/selectedContexts.module.ts b/portal-2/src/app/claims/linking/selected/selectedContexts.module.ts new file mode 100644 index 00000000..e9833a9c --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedContexts.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {ClaimSelectedContextsComponent} from './selectedContexts.component'; + @NgModule({ + imports: [ + SharedModule, + ], + declarations: [ + ClaimSelectedContextsComponent + ], exports:[ClaimSelectedContextsComponent] +}) +export class SelectedContextsModule { } diff --git a/portal-2/src/app/claims/linking/selected/selectedDatasets.component.ts b/portal-2/src/app/claims/linking/selected/selectedDatasets.component.ts new file mode 100644 index 00000000..084fd3b3 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedDatasets.component.ts @@ -0,0 +1,133 @@ +import {Component, Input,Output, EventEmitter,ViewChild} from '@angular/core'; +import {AlertModal} from '../../../utils/modal/alert'; +import {ClaimResult} from '../../claim-utils/claimEntities.class'; +@Component({ + selector: 'claim-selected-datasets', + template: ` + +
+

Research Data ({{(datasets.length)}})

+
+ + + + There are no selected research data + +
    +
  • +
    + +
    + + {{dataset.title}} + {{dataset.title}} + ({{dataset.date.substring(0,4)}}) + +
    +
    + + + + + + + + +
    + +
    +
  • +
+ +
+
+ + + + ` +}) +export class ClaimSelectedDatasetsComponent { + ngOnInit() { + var myDate = new Date(); + this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + //2015-05-01 +} + + + + + @Input() datasets: ClaimResult[]; + @Input() showAccessRights:boolean = false; + @Input() inline:boolean = false; + @Input() hideType; + @Input() bulkMode:boolean = false; + @Input() linkToResults:boolean = true; + @Output() datasetsChange = new EventEmitter(); + + todayDate = ''; + nextDate = ''; + @ViewChild(AlertModal) alertApplyAll; + public commonAccessRights = "OPEN"; // for access rights- changes when user apply a change to every result + public commonEmbargoEndDate; // for access rights: embargoEndDate - changes when user apply a change to every result + + removeDataset(item:any){ + var index:number =this.datasets.indexOf(item); + if (index > -1) { + this.datasets.splice(index, 1); + } + this.datasetsChange.emit({ + value: this.datasets + }); + } + + accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"]; + + dateChanged (event:any, item:any) { + item.embargoEndDate = event.target.value ; + + this.confirmOpen(); + } + /* The following methods: + *typeChanged + *confirmOpen + *confirmClose + implement the functionality: change accessRights of a publication - apply to all if asked */ + accessRightsTypeChanged (type:any, item:any) { + item.accessRights = type; + if(this.datasets.length > 1 ){ + this.commonAccessRights = type; + if(this.commonAccessRights == "EMBARGO"){ + this.commonEmbargoEndDate = item.embargoEndDate; + } + this.confirmOpen(); + } + + } + confirmOpen(){ + this.alertApplyAll.cancelButton = true; + this.alertApplyAll.okButton = true; + this.alertApplyAll.alertTitle = "Change access rights"; + this.alertApplyAll.message = "Do you wish to apply the change to every dataset?"; + this.alertApplyAll.okButtonText = "Yes"; + this.alertApplyAll.cancelButtonText = "No"; + this.alertApplyAll.open(); + } + confirmClose(data){ + for (var i = 0; i < this.datasets.length; i++) { + this.datasets[i].accessRights = this.commonAccessRights; + if(this.commonAccessRights == "EMBARGO"){ + this.datasets[i].embargoEndDate = this.commonEmbargoEndDate; + } + } + } + +} diff --git a/portal-2/src/app/claims/linking/selected/selectedDatasets.module.ts b/portal-2/src/app/claims/linking/selected/selectedDatasets.module.ts new file mode 100644 index 00000000..a8a72313 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedDatasets.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {ClaimSelectedDatasetsComponent} from './selectedDatasets.component'; +import {AlertModalModule} from '../../../utils/modal/alertModal.module'; +@NgModule({ + imports: [ + SharedModule, AlertModalModule + ], + declarations: [ + ClaimSelectedDatasetsComponent + ], exports:[ClaimSelectedDatasetsComponent] +}) +export class SelectedDatasetsModule { } diff --git a/portal-2/src/app/claims/linking/selected/selectedProjects.component.ts b/portal-2/src/app/claims/linking/selected/selectedProjects.component.ts new file mode 100644 index 00000000..692a206c --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedProjects.component.ts @@ -0,0 +1,72 @@ +import {Component, Input,Output, EventEmitter} from '@angular/core'; +import {ClaimProject} from '../../claim-utils/claimEntities.class'; + +@Component({ + selector: 'claim-selected-projects', + template: ` + +
+

Projects ({{(projects.length)}}) + +

+ +
+
    +
  • + {{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}} + +
  • +
+ There are no projects +
+
+ + ` +}) +export class ClaimSelectedProjectsComponent { + + +ngOnInit() { + var myDate = new Date(); + this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + //2015-05-01 +} + + +@Input() projects: ClaimProject[]; +@Input() show='home'; +@Input() inline:boolean = false; +@Input() hideType; +@Input() bulkMode:boolean = false; +@Input() linkToResults:boolean = true; +@Output() projectsChange = new EventEmitter(); + +@Output() showChange = new EventEmitter(); + +todayDate = ''; +nextDate = ''; + +removeProject(item:any){ + var index:number =this.projects.indexOf(item); + if (index > -1) { + this.projects.splice(index, 1); + } + this.projectsChange.emit({ + value: this.projects + }); +} +showType(type){ +if(type != this.show){ + this.show = type; + this.showChange.emit({ + value: this.show + }); +} +} + +} diff --git a/portal-2/src/app/claims/linking/selected/selectedProjects.module.ts b/portal-2/src/app/claims/linking/selected/selectedProjects.module.ts new file mode 100644 index 00000000..28f84bc7 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedProjects.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {ClaimSelectedProjectsComponent} from './selectedProjects.component'; + @NgModule({ + imports: [ + SharedModule + ], + declarations: [ + ClaimSelectedProjectsComponent + ], exports:[ClaimSelectedProjectsComponent] +}) +export class SelectedProjectsModule { } diff --git a/portal-2/src/app/claims/linking/selected/selectedPublications.component.ts b/portal-2/src/app/claims/linking/selected/selectedPublications.component.ts new file mode 100644 index 00000000..2f3fdaf9 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedPublications.component.ts @@ -0,0 +1,138 @@ +import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core'; +import {AlertModal} from '../../../utils/modal/alert'; +import {ClaimResult} from '../../claim-utils/claimEntities.class'; + +@Component({ + selector: 'claim-selected-publications', + template: ` +
+
+

Publications ({{(publications.length)}})

+
+ There are no selected publications + +
    +
  • +
    +
    + + {{pub.title}} + {{pub.title}}({{pub.date.substring(0,4)}}) + +
    +
    + + + + + + +
    +
    + + + +
    +
    +
  • +
+ + +
+
+ + ` + +}) +export class ClaimSelectedPublicationsComponent { + ngOnInit() { + var myDate = new Date(); + this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; + //2015-05-01 +} + + @Input() publications: ClaimResult[]; + @Input() showAccessRights:boolean = false; + @Input() inline:boolean = false; + @Input() hideType; + @Input() bulkMode:boolean = false; + @Input() linkToResults:boolean = true; + @Output()publicationsChange = new EventEmitter(); + + @Output() showChange = new EventEmitter(); + + todayDate = ''; + nextDate = ''; + @ViewChild(AlertModal) alertApplyAll; + +public commonAccessRights = "OPEN"; // for access rights- changes when user apply a change to every result +public commonEmbargoEndDate; // for access rights: embargoEndDate - changes when user apply a change to every result + + removePublication(item:any){ + var index:number =this.publications.indexOf(item); + if (index > -1) { + this.publications.splice(index, 1); + } + this.publicationsChange.emit({ + value: this.publications + }); + } + + + accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"]; + + dateChanged (event:any, item:any) { + item.embargoEndDate = event.target.value ; + } + publicationsChanged($event) { + this.publications=$event.value; + this.publicationsChange.emit({ + value: this.publications + }); + } + /* The following methods: + *typeChanged + *confirmOpen + *confirmClose + implement the functionality: change accessRights of a publication - apply to all if asked */ + accessRightsTypeChanged (type:any, item:any) { + item.accessRights = type; + if(this.publications.length > 1 ){ + this.commonAccessRights = type; + if(this.commonAccessRights == "EMBARGO"){ + this.commonEmbargoEndDate = item.embargoEndDate; + } + this.confirmOpen(); + } + + } + confirmOpen(){ + this.alertApplyAll.cancelButton = true; + this.alertApplyAll.okButton = true; + this.alertApplyAll.alertTitle = "Change access rights"; + this.alertApplyAll.message = "Do you wish to apply the change to every publication?"; + this.alertApplyAll.okButtonText = "Yes"; + this.alertApplyAll.cancelButtonText = "No"; + this.alertApplyAll.open(); + } + confirmClose(data){ + for (var i = 0; i < this.publications.length; i++) { + this.publications[i].accessRights = this.commonAccessRights; + if(this.commonAccessRights == "EMBARGO"){ + this.publications[i].embargoEndDate = this.commonEmbargoEndDate; + } + } + } +} diff --git a/portal-2/src/app/claims/linking/selected/selectedPublications.module.ts b/portal-2/src/app/claims/linking/selected/selectedPublications.module.ts new file mode 100644 index 00000000..6f8baaf3 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedPublications.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {ClaimSelectedPublicationsComponent} from './selectedPublications.component'; +import {AlertModalModule} from '../../../utils/modal/alertModal.module'; +@NgModule({ + imports: [ + SharedModule, AlertModalModule + ], + declarations: [ + ClaimSelectedPublicationsComponent + ], exports:[ClaimSelectedPublicationsComponent] +}) +export class SelectedPublicationsModule { } diff --git a/portal-2/src/app/claims/linking/selected/selectedResults.component.ts b/portal-2/src/app/claims/linking/selected/selectedResults.component.ts new file mode 100644 index 00000000..8822b560 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedResults.component.ts @@ -0,0 +1,91 @@ +// import {Component, Input,Output, EventEmitter} from '@angular/core'; +// import {ClaimResult} from '../../claim-utils/claimEntities.class'; +// +// @Component({ +// selector: 'claim-selected-results', +// template: ` +// +// +// +//
+//
+//

Publications ({{(publications.length)}})

+//
+// +// +// +// There are no selected publications +// +// +// +//
+//
+// +//
+//

Research Data ({{(datasets.length)}})

+//
+// +// +// +// There are no selected research data +// +// +//
+//
+// +// +// ` +// +// }) +// export class ClaimSelectedResultsComponent { +// ngOnInit() { +// var myDate = new Date(); +// this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; +// this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ; +// //2015-05-01 +// } +// +// +// +// @Input() publications:ClaimResult[]; +// @Input() datasets:ClaimResult[]; +// @Input() showAccessRights:boolean = false; +// @Input() show='home'; +// @Input() inline:boolean = false; +// @Input() hideType; +// @Input() bulkMode:boolean = false; +// @Input() linkToResults:boolean = true; +// @Output() showChange = new EventEmitter(); +// +// todayDate = ''; +// nextDate = ''; +// showType(type){ +// if(type != this.show){ +// this.show = type; +// this.showChange.emit({ +// value: this.show +// }); +// } +// } +// showChanged($event) { +// this.show=$event.value; +// +// this.showChange.emit({ +// value: this.show +// }); +// +// } +// +// +// } diff --git a/portal-2/src/app/claims/linking/selected/selectedResults.module.ts b/portal-2/src/app/claims/linking/selected/selectedResults.module.ts new file mode 100644 index 00000000..ecddb7f0 --- /dev/null +++ b/portal-2/src/app/claims/linking/selected/selectedResults.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../../shared/shared.module'; +import {SelectedDatasetsModule} from './selectedDatasets.module'; +import {SelectedPublicationsModule} from './selectedPublications.module'; +// import {ClaimSelectedResultsComponent} from './selectedResults.component'; +@NgModule({ + imports: [ + SharedModule, SelectedDatasetsModule, SelectedPublicationsModule + ], + declarations: [ + // ClaimSelectedResultsComponent + ], exports:[ + // ClaimSelectedResultsComponent + ] +}) +export class SelectedResultsModule { } diff --git a/portal-2/src/app/claims/myClaims/myClaims-routing.module.ts b/portal-2/src/app/claims/myClaims/myClaims-routing.module.ts new file mode 100644 index 00000000..4c93dead --- /dev/null +++ b/portal-2/src/app/claims/myClaims/myClaims-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule } from '@angular/router'; + +import { MyClaimsComponent } from './myClaims.component'; + +@NgModule({ + imports: [ + RouterModule.forChild([ + { path: '', component: MyClaimsComponent}, + + ]) + ] +}) +export class MyClaimsRoutingModule { } diff --git a/portal-2/src/app/claims/myClaims/myClaims.component.ts b/portal-2/src/app/claims/myClaims/myClaims.component.ts new file mode 100644 index 00000000..305d70a9 --- /dev/null +++ b/portal-2/src/app/claims/myClaims/myClaims.component.ts @@ -0,0 +1,34 @@ +import {Component, Input} from '@angular/core'; +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/claims/myClaims/myClaims.module.ts b/portal-2/src/app/claims/myClaims/myClaims.module.ts new file mode 100644 index 00000000..3ec9ae0b --- /dev/null +++ b/portal-2/src/app/claims/myClaims/myClaims.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; + +import { SharedModule } from '../../shared/shared.module'; +import { MyClaimsComponent } from './myClaims.component'; +import { MyClaimsRoutingModule } from './myClaims-routing.module'; +// import{ClaimServiceModule} from '../claim-utils/service/claimsService.module'; +import {DisplayClaimsModule} from '../claim-utils/displayClaims/displayClaims.module'; + +@NgModule({ + imports: [ + SharedModule, + MyClaimsRoutingModule, + // ClaimServiceModule, + DisplayClaimsModule + + ], + declarations: [ + MyClaimsComponent + ] +}) +export class MyClaimsModule { } diff --git a/portal-2/src/app/claims/myClaimsDemo.component.ts b/portal-2/src/app/claims/myClaimsDemo.component.ts new file mode 100644 index 00000000..6490a59c --- /dev/null +++ b/portal-2/src/app/claims/myClaimsDemo.component.ts @@ -0,0 +1,51 @@ +// import {Component, Input} from '@angular/core'; +// import {Observable} from 'rxjs/Observable'; +// import { Router } from '@angular/router'; +// +// +// +// @Component({ +// selector: 'my-claims-demo', +// template: ` +//
+// +//
+// +// +// +//

Extra parameters for claims admin

+// +// +// +// +// +// +// +//
+//
+// +// +// +// ` +// //(click)="changeOrderby('target')" +// //od_______908::3a5b2885656a91307156325644e73b92 +// +// }) +// export class MyClaimsDemoComponent { +// constructor ( private _router: Router ) { +// } +// user:string="argirok@di.uoa.gr"; +// ngOnInit() { +// +// } +// goToPub(id: number){ +// this._router.navigate( ['Publication', { articleId: id}] ); +// } +// } diff --git a/portal-2/src/app/landingPages/publication/publication.component.html b/portal-2/src/app/landingPages/publication/publication.component.html index 5edd7952..039e8bf0 100644 --- a/portal-2/src/app/landingPages/publication/publication.component.html +++ b/portal-2/src/app/landingPages/publication/publication.component.html @@ -103,7 +103,7 @@ -
    +
    • diff --git a/portal-2/src/app/searchPages/search.component.ts b/portal-2/src/app/searchPages/search.component.ts deleted file mode 100644 index 909ca82f..00000000 --- a/portal-2/src/app/searchPages/search.component.ts +++ /dev/null @@ -1,75 +0,0 @@ -import {Component} from '@angular/core'; -import {Observable} from 'rxjs/Observable'; -import {ActivatedRoute, Router} from '@angular/router'; -import {SearchCrossrefService} from '../services/searchCrossref.service'; - -@Component({ - selector: 'search', - template: ` -

      Search Demo

      -

      Fetches from crossref

      -
      - - -
      -
      -
      -

      {{resultsNum }} Total Results

      - -
      -
      -

      {{item.DOI}} --{{item.publisher}}

      -
      -
      - ` -}) -export class SearchComponent { - constructor (private _searchService: SearchCrossrefService, - private route: ActivatedRoute) { - console.info('search constructor'); - } - ngOnInit() { - this.sub = this.route.queryParams.subscribe(params => { - console.info('Params'+params); - let page = (params['page']=== undefined)?1:+params['page']; - let size = (params['size']=== undefined)?10:+params['size']; - this.page = ( page <= 0 ) ? 1 : page; - this.size = ( size <= 0 ) ? 10 : size; - - this.keyword = params['keyword']; - if(this.keyword !=null){ - this.search(this.keyword,this.size,this.page); - } - - }); - -} - ngOnDestroy() { - this.sub.unsubscribe(); - } - public sub: any; - public page : number; - public size:number; - public keyword:string; - public navigateTo: string = "./search"; - - public results : String[]; - public orcidresults : String[]; - public resultsNum : number ; - search (term: string, size : number, page : number) { - this.getCrossrefResults(term,size,page); - } - - - getCrossrefResults (term: string, size : number, page : number) { - this._searchService.searchCrossrefResults(term, size, page).subscribe( - data => { - this.results = data.items; - this.page=page; - this.resultsNum = data['total-results']; - }, - err => console.log(err) - ); - } - -} diff --git a/portal-2/src/app/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts b/portal-2/src/app/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts index 40f9e378..22885425 100644 --- a/portal-2/src/app/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts +++ b/portal-2/src/app/utils/entitiesAutoComplete/entitiesAutoComplete.component.ts @@ -14,6 +14,7 @@ import {EntitiesSearchService} from './entitySearch.service'; '(document:click)': 'handleClick($event)', }, template: ` + {{truncate(showItem(item),14)}} @@ -40,7 +41,6 @@ import {EntitiesSearchService} from './entitySearch.service'; - ` }) export class EntitiesAutocompleteComponent { @@ -168,6 +168,7 @@ export class EntitiesAutocompleteComponent { if (index > -1 && !this.allowDuplicates) { // this.keyword = ""; // this.filtered.splice(0, this.filtered.length); + this.focus=false; return; } else{ @@ -177,6 +178,7 @@ export class EntitiesAutocompleteComponent { this.addItem.emit({ value: item }); + this.focus=false; } }else{ this.selected.splice(0, this.selected.length); @@ -188,6 +190,7 @@ export class EntitiesAutocompleteComponent { this.selectedValueChanged.emit({ value: this.selectedValue }); + this.focus=false; } diff --git a/portal-2/src/app/utils/modal/alert.ts b/portal-2/src/app/utils/modal/alert.ts index 98c0cc28..a86cdfe4 100644 --- a/portal-2/src/app/utils/modal/alert.ts +++ b/portal-2/src/app/utils/modal/alert.ts @@ -6,27 +6,26 @@ import {Open} from './open.component'; @Component({ selector: 'modal-alert', template: ` -