From 79940e6fb529f1863c85a835d736f974faeff956 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 2 Dec 2016 17:09:13 +0000 Subject: [PATCH] Tabs for every type in Dataprovider landing page ready (organizations tab added) git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44796 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../dataProvider/dataProvider.component.html | 3 +- .../dataProvider/datasourcesTab.component.ts | 19 +- .../organizationsTab.component.ts | 39 ++++ .../dataProvider/projectsTab.component.ts | 20 ++- .../dataProvider/tabs.component.ts | 166 +++++++++++++----- .../src/app/landingPages/landing.module.ts | 3 +- .../searchUtils/searchResult.component.ts | 4 +- .../simple/searchDataproviders.component.ts | 26 +++ .../simple/searchProjects.component.ts | 26 +++ .../src/app/services/dataProvider.service.ts | 44 +++-- portal-2/src/app/services/dataset.service.ts | 8 +- .../services/searchPublications.service.ts | 6 +- .../app/utils/entities/dataProviderInfo.ts | 11 +- 13 files changed, 292 insertions(+), 83 deletions(-) create mode 100644 portal-2/src/app/landingPages/dataProvider/organizationsTab.component.ts diff --git a/portal-2/src/app/landingPages/dataProvider/dataProvider.component.html b/portal-2/src/app/landingPages/dataProvider/dataProvider.component.html index 0f7246b5..5aa719a6 100644 --- a/portal-2/src/app/landingPages/dataProvider/dataProvider.component.html +++ b/portal-2/src/app/landingPages/dataProvider/dataProvider.component.html @@ -38,8 +38,7 @@ [resultsBy] = "dataProviderInfo.resultsBy" [tabs]="dataProviderInfo.tabs" [statistics]="dataProviderInfo.statistics" - [projects]="dataProviderInfo.projects" - [datasources]="dataProviderInfo.datasources"> + [organizations]="dataProviderInfo.organizations"> diff --git a/portal-2/src/app/landingPages/dataProvider/datasourcesTab.component.ts b/portal-2/src/app/landingPages/dataProvider/datasourcesTab.component.ts index f10579f0..ce1bf7cb 100644 --- a/portal-2/src/app/landingPages/dataProvider/datasourcesTab.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/datasourcesTab.component.ts @@ -1,28 +1,39 @@ import {Component, Input} from '@angular/core'; +import { SearchDataprovidersComponent } from '../../searchPages/simple/searchDataproviders.component'; +import {SearchResultComponent} from '../../searchPages/searchUtils/searchResult.component'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; @Component({ selector: 'datasourcesTab', template: ` -
+
There are no datasources
-
+

The results below are discovered through our pilot algorithms. Let us know how we are doing!

+ + +
` }) export class DatasourcesTabComponent { - @Input() datasources; + @Input() paramsForSearchLink: string = ""; + @Input() searchDataprovidersComponent : SearchDataprovidersComponent; + private linkToSearchDataproviders = ""; constructor () {} - ngOnInit() {} + ngOnInit() { + this.linkToSearchDataproviders = OpenaireProperties.getLinkToSearchDataProviders()+this.paramsForSearchLink; + } ngOnDestroy() {} } diff --git a/portal-2/src/app/landingPages/dataProvider/organizationsTab.component.ts b/portal-2/src/app/landingPages/dataProvider/organizationsTab.component.ts new file mode 100644 index 00000000..47bed31f --- /dev/null +++ b/portal-2/src/app/landingPages/dataProvider/organizationsTab.component.ts @@ -0,0 +1,39 @@ +import {Component, Input} from '@angular/core'; + +@Component({ + selector: 'organizationsTab', + template: ` +
+ There are no organizations +
+ +
+

+ The results below are discovered through our pilot algorithms. + Let us know how we are doing! +

+ +
+

+ + {{item['name']}} + +

+

+ {{item['name']}} +

+
+
+ ` +}) + +export class OrganizationsTabComponent { + + @Input() organizations: {"name": string, "url": string}[]; + + constructor () {} + + ngOnInit() {} + + ngOnDestroy() {} +} diff --git a/portal-2/src/app/landingPages/dataProvider/projectsTab.component.ts b/portal-2/src/app/landingPages/dataProvider/projectsTab.component.ts index de5c0948..c161676b 100644 --- a/portal-2/src/app/landingPages/dataProvider/projectsTab.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/projectsTab.component.ts @@ -1,28 +1,40 @@ import {Component, Input} from '@angular/core'; +import { SearchProjectsComponent } from '../../searchPages/simple/searchProjects.component'; +import {SearchResultComponent} from '../../searchPages/searchUtils/searchResult.component'; + +import {OpenaireProperties} from '../../utils/properties/openaireProperties'; + @Component({ selector: 'projectsTab', template: ` -
+
There are no projects
-
+

The results below are discovered through our pilot algorithms. Let us know how we are doing!

+ + +
` }) export class ProjectsTabComponent { - @Input() projects; + @Input() paramsForSearchLink: string = ""; + @Input() searchProjectsComponent : SearchProjectsComponent; + private linkToSearchProjects = ""; constructor () {} - ngOnInit() {} + ngOnInit() { + this.linkToSearchProjects = OpenaireProperties.getLinkToSearchProjects()+this.paramsForSearchLink; + } ngOnDestroy() {} } diff --git a/portal-2/src/app/landingPages/dataProvider/tabs.component.ts b/portal-2/src/app/landingPages/dataProvider/tabs.component.ts index 3fb91203..e7870ea2 100644 --- a/portal-2/src/app/landingPages/dataProvider/tabs.component.ts +++ b/portal-2/src/app/landingPages/dataProvider/tabs.component.ts @@ -5,14 +5,17 @@ import { SearchPublicationsComponent } from '../../searchPages/simple/searchPubl import { SearchPublicationsService } from '../../services/searchPublications.service'; import { SearchDatasetsComponent } from '../../searchPages/simple/searchDatasets.component'; import { SearchDatasetsService } from '../../services/searchDatasets.service'; +import { SearchProjectsComponent } from '../../searchPages/simple/searchProjects.component'; +import { SearchProjectsService } from '../../services/searchProjects.service'; +import { SearchDataprovidersComponent } from '../../searchPages/simple/searchDataproviders.component'; +import { SearchDataprovidersService } from '../../services/searchDataproviders.service'; @Component({ selector: 'tabs', template: `
-
- @@ -50,20 +69,22 @@ import { SearchDatasetsService } from '../../services/searchDatasets.service'; [searchDatasetsComponent]="searchDatasetsComponent"> + [statistics]="statistics"> + [paramsForSearchLink]="paramsForSearchLink" + [searchProjectsComponent]="searchProjectsComponent"> + [paramsForSearchLink]="paramsForSearchLink" + [searchDataprovidersComponent]="searchDataprovidersComponent"> + + [organizations]="organizations" +
-
-
- @@ -73,9 +94,17 @@ import { SearchDatasetsService } from '../../services/searchDatasets.service'; [searchDatasetsComponent]="searchDatasetsComponent"> - - -
+ + + + + +
` @@ -89,30 +118,37 @@ export class TabsComponent { //@Input() publications; //@Input() datasets; @Input() statistics; - @Input() projects; - @Input() datasources; + //@Input() projects; + //@Input() datasources; + @Input() organizations: {"name": string, "url": string}[]; private paramsForSearchLink: string = ""; private reloadPublications: boolean = true; private reloadDatasets: boolean = true; - - subPublications: any; - subDatasets: any; + private reloadProjects: boolean = true; + private reloadDataproviders: boolean = true; private searchPublicationsComponent : SearchPublicationsComponent; private searchDatasetsComponent: SearchDatasetsComponent; + private searchProjectsComponent: SearchProjectsComponent; + private searchDataprovidersComponent: SearchDataprovidersComponent; constructor (private route: ActivatedRoute, private _searchPublicationsService: SearchPublicationsService, - private _searchDatasetsService: SearchDatasetsService) { + private _searchDatasetsService: SearchDatasetsService, + private _searchProjectsService: SearchProjectsService, + private _searchDataprovidersService: SearchDataprovidersService) { this.searchPublicationsComponent = new SearchPublicationsComponent(this.route, this._searchPublicationsService); this.searchDatasetsComponent = new SearchDatasetsComponent(this.route, this._searchDatasetsService); + this.searchProjectsComponent = new SearchProjectsComponent(this.route, this._searchProjectsService); + this.searchDataprovidersComponent = new SearchDataprovidersComponent(this.route, this._searchDataprovidersService); } ngOnInit() { if(this.tabs != undefined && this.tabs.length > 0) { - this.search(this.tabs[0].content); + this.search(this.tabs[0].content, 1, 10); + this.count(1, 0); } if(this.resultsBy == "collectedFrom") { @@ -122,38 +158,76 @@ export class TabsComponent { } } - ngOnDestroy() { - if(this.subPublications != undefined) { - this.subPublications.unsubscribe(); - } - if(this.subDatasets != undefined) { - this.subDatasets.unsubscribe(); + private count(page: number, size: number) { + console.info("number of tabs: "+this.tabs.length); + + for(let i=1; i { - this.searchPublications(); - }); + this.searchPublications(page, size); } else if(content=='datasetsTab') { - this.subDatasets = this.route.queryParams.subscribe(params => { - this.searchDatasets(); - }); + this.searchDatasets(page, size); + } else if(content=='projectsTab') { + this.searchProjects(page, size); + } else if(content=='datasourcesTab') { + this.searchDataproviders(page, size); } } - private searchPublications() { + private searchPublications(page: number, size: number) { if(this.reloadPublications) { - this.searchPublicationsComponent.getResultsForDataproviders(this.id, this.resultsBy, 1, 10); + this.searchPublicationsComponent.getResultsForDataproviders(this.id, this.resultsBy, page, size); } this.reloadPublications = false; } - private searchDatasets() { + private countPublications(page: number, size: number) { + this.searchPublicationsComponent.getResultsForDataproviders(this.id, this.resultsBy, page, size); + } + + private searchDatasets(page: number, size: number) { if(this.reloadDatasets) { - this.searchDatasetsComponent.getResultsForDataproviders(this.id, this.resultsBy, 1, 10); + this.searchDatasetsComponent.getResultsForDataproviders(this.id, this.resultsBy, page, size); } this.reloadDatasets = false; } + + private countDatasets(page: number, size: number) { + this.searchDatasetsComponent.getResultsForDataproviders(this.id, this.resultsBy, page, size); + } + + private searchProjects(page: number, size: number) { + if(this.reloadProjects) { + this.searchProjectsComponent.getResultsForDataproviders(this.id, page, size); + } + this.reloadProjects = false; + } + + private countProjects(page: number, size: number) { + this.searchProjectsComponent.getResultsForDataproviders(this.id, page, size); + } + + private searchDataproviders(page: number, size: number) { + if(this.reloadDataproviders) { + this.searchDataprovidersComponent.getResultsForDataproviders(this.id, page, size); + } + this.reloadDataproviders = false; + } + + private countDataproviders(page: number, size: number) { + this.searchDataprovidersComponent.getResultsForDataproviders(this.id, page, size); + } } diff --git a/portal-2/src/app/landingPages/landing.module.ts b/portal-2/src/app/landingPages/landing.module.ts index cecfffaa..e01d322e 100644 --- a/portal-2/src/app/landingPages/landing.module.ts +++ b/portal-2/src/app/landingPages/landing.module.ts @@ -21,6 +21,7 @@ import {DatasetsTabComponent} from './dataProvider/datasetsTab.component'; import {StatisticsTabComponent} from './dataProvider/statisticsTab.component'; import {ProjectsTabComponent} from './dataProvider/projectsTab.component'; import {DatasourcesTabComponent} from './dataProvider/datasourcesTab.component'; +import {OrganizationsTabComponent} from './dataProvider/organizationsTab.component'; import {TabsComponent} from './dataProvider/tabs.component'; @@ -45,7 +46,7 @@ import { LandingRoutingModule } from './landing-routing.module'; ], declarations: [ TabPagingComponent, TabTableComponent, ShowTitleComponent, ShowAuthorsComponent, ShowAuthorsComponent, ShowIdentifiersComponent, ShowIdentifiersComponent,ShowSubjectsComponent, - PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, TabsComponent, + PublicationsTabComponent, DatasetsTabComponent, StatisticsTabComponent, ProjectsTabComponent, DatasourcesTabComponent, OrganizationsTabComponent, TabsComponent, DataProviderComponent, PersonComponent, ProjectComponent, PublicationComponent, OrganizationComponent, DatasetComponent, ], providers:[ diff --git a/portal-2/src/app/searchPages/searchUtils/searchResult.component.ts b/portal-2/src/app/searchPages/searchUtils/searchResult.component.ts index 9d7ad5f0..52ac4957 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchResult.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchResult.component.ts @@ -14,8 +14,8 @@ import { ErrorCodes} from '../../utils/properties/openaireProperties';
  • -

    - {{result['title'].name}} +

    {{result['title'].url}} diff --git a/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts b/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts index d92ae4cd..a6b4d38b 100644 --- a/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts +++ b/portal-2/src/app/searchPages/simple/searchDataproviders.component.ts @@ -181,6 +181,32 @@ public getResultsForDeposit(id:string, type:string, page: number, size: number) } } + public getResultsForDataproviders(id:string, page: number, size: number){ + + this._searchDataprovidersService.getDataProvidersforEntityRegistry(id, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Dataproviders for Entity Registry: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + public getResults(keyword:string,refine:boolean, page: number, size: number){ var parameters = ""; if(keyword.length > 0){ diff --git a/portal-2/src/app/searchPages/simple/searchProjects.component.ts b/portal-2/src/app/searchPages/simple/searchProjects.component.ts index 4df9b4a0..87e86d7e 100644 --- a/portal-2/src/app/searchPages/simple/searchProjects.component.ts +++ b/portal-2/src/app/searchPages/simple/searchProjects.component.ts @@ -114,6 +114,32 @@ export class SearchProjectsComponent { ); } + public getResultsForDataproviders(id:string, page: number, size: number){ + + this._searchProjectsService.getProjectsforDataProvider(id, page, size).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + console.info("search Projects for Dataproviders: [Id:"+id+" ] [total results:"+this.searchUtils.totalResults+"]"); + this.results = data[1]; + + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = errorCodes.NONE; + } + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.searchUtils.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.searchUtils.status = errorCodes.ERROR; + } + ); + } + private queryChanged($event) { this.urlParams = undefined; diff --git a/portal-2/src/app/services/dataProvider.service.ts b/portal-2/src/app/services/dataProvider.service.ts index 7fd4a929..4ae9ae53 100644 --- a/portal-2/src/app/services/dataProvider.service.ts +++ b/portal-2/src/app/services/dataProvider.service.ts @@ -56,10 +56,18 @@ export class DataProviderService { if(data[1] != null) { this.dataProviderInfo.type = data[1].classname; + if(data[1].classid == "entityregistry" || data[1].classid == "entityregistry::projects" || data[1].classid == "entityregistry::repositories") { + this.dataProviderInfo.registry = true; + console.info("true"); + } else { + this.dataProviderInfo.registry = false; + console.info("false"); + } + console.info(this.dataProviderInfo.type); + if(this.dataProviderInfo.tabs == undefined) { this.dataProviderInfo.tabs = new Array<{"name": string, "content": string}>(); } - if(this.dataProviderInfo.tabsInTypes.publicationsTab.has(data[1].classid)) { this.dataProviderInfo.tabs.push({"name": "Publications", "content": "publicationsTab"}); } @@ -75,6 +83,7 @@ export class DataProviderService { if(this.dataProviderInfo.tabsInTypes.datasourcesTab.has(data[1].classid)) { this.dataProviderInfo.tabs.push({"name": "Datasources", "content": "datasourcesTab"}); } + this.dataProviderInfo.tabs.push({"name": "Organizations", "content": "organizationsTab"}); if(this.dataProviderInfo.resultTypes.collectedFrom.has(data[1].classid)) { this.dataProviderInfo.resultsBy = "collectedFrom"; @@ -83,21 +92,23 @@ export class DataProviderService { } } - if(data[2] != null) { - this.dataProviderInfo.compatibility = data[2].classname; - } - - if(data[3] != null) { - let oaiPmhURL: string; - if(Array.isArray(data[3])) { - oaiPmhURL = data[3][0]; - } - else { - oaiPmhURL = data[3]; + if(!this.dataProviderInfo.registry) { + if(data[2] != null) { + this.dataProviderInfo.compatibility = data[2].classname; } - if(oaiPmhURL != '' && oaiPmhURL != 'unknown') { - this.dataProviderInfo.oaiPmhURL = oaiPmhURL; + if(data[3] != null) { + let oaiPmhURL: string; + if(Array.isArray(data[3])) { + oaiPmhURL = data[3][0]; + } + else { + oaiPmhURL = data[3]; + } + + if(oaiPmhURL != '' && oaiPmhURL != 'unknown') { + this.dataProviderInfo.oaiPmhURL = oaiPmhURL; + } } } @@ -111,8 +122,9 @@ export class DataProviderService { mydata = length > 1 ? data[4][i] : data[4]; if(mydata.hasOwnProperty("to")) { if(mydata['to'].class == "provides" && mydata['to'].type == "organization") { - if(this.dataProviderInfo.organizations == undefined) { - this.dataProviderInfo.organizations = new Array<{"name": string, "url": string}>(); + //if(this.dataProviderInfo.organizations == undefined) { + if(this.dataProviderInfo.organizations.length == 0) { + //this.dataProviderInfo.organizations = new Array<{"name": string, "url": string}>(); this.dataProviderInfo.countries = new Array(); countriesSet = new Set(); } diff --git a/portal-2/src/app/services/dataset.service.ts b/portal-2/src/app/services/dataset.service.ts index c80130e1..4f8e68ec 100644 --- a/portal-2/src/app/services/dataset.service.ts +++ b/portal-2/src/app/services/dataset.service.ts @@ -201,9 +201,11 @@ export class DatasetService { } } - this.datasetInfo.authors = this.datasetInfo.authors.filter(function (item) { - return (item != undefined); - }); + if(this.datasetInfo.authors != undefined) { + this.datasetInfo.authors = this.datasetInfo.authors.filter(function (item) { + return (item != undefined); + }); + } } if(data[3] != null) { diff --git a/portal-2/src/app/services/searchPublications.service.ts b/portal-2/src/app/services/searchPublications.service.ts index 74745914..397287ba 100644 --- a/portal-2/src/app/services/searchPublications.service.ts +++ b/portal-2/src/app/services/searchPublications.service.ts @@ -86,7 +86,7 @@ export class SearchPublicationsService { searchPublicationsForDataproviders(params: string, page: number, size: number):any { let link = OpenaireProperties.getSearchAPIURLLast(); - let url = link+params+ "&format=json"; + let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json"; let key = url; if (this._cache.has(key)) { return Observable.of(this._cache.get(key)); @@ -217,10 +217,12 @@ export class SearchPublicationsService { } else { result.description = resData.description[0]; } + if(result.description.length > this.sizeOfDescription) { - result.description = result.description.substring(0, this.sizeOfDescription)+"..."; + result.description = result.description.substring(0, this.sizeOfDescription) + "..."; } + result.embargoEndDate = resData.embargoenddate; results.push(result); diff --git a/portal-2/src/app/utils/entities/dataProviderInfo.ts b/portal-2/src/app/utils/entities/dataProviderInfo.ts index abebae8f..095674c0 100644 --- a/portal-2/src/app/utils/entities/dataProviderInfo.ts +++ b/portal-2/src/app/utils/entities/dataProviderInfo.ts @@ -1,6 +1,7 @@ export class DataProviderInfo { title: { "name": string, "url": string }; type: string; + registry: boolean; compatibility: string; oaiPmhURL: string; countries: string[]; @@ -37,6 +38,10 @@ export class DataProviderInfo { "pubsrepository::thematic", "pubscatalogue::unknown" ]), + // "organizationsTab": new Set( + // [ "entityregistry::projects", + // "entityregistry::repositories" + // ]), "projectsTab": new Set(["entityregistry::projects"]), "datasourcesTab": new Set(["entityregistry::repositories"]) }; @@ -63,10 +68,10 @@ export class DataProviderInfo { ]) }; - organizations: {"name": string, "url": string}[]; + organizations: {"name": string, "url": string}[] = []; //publications: any; - datasets: any; + //datasets: any; statistics: any; - projects: any; + //projects: any; datasources: any; }