From d0df3d127a52ac37c55bf928c9044bb9c6ae5c0d Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 17 Jul 2017 09:53:19 +0000 Subject: [PATCH] Landing pages: Paging (no-load) added in every tab with no extra queries | Publication & Dataset landing pages: 'handle' identifier is parsed and displayed like 'doi' and 'pmc git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@48573 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../depositBySubjectResult.component.ts | 8 +- .../organizationsTab.component.ts | 23 +++- .../landing-utils/parsingFunctions.class.ts | 4 +- .../src/app/landingPages/landing.module.ts | 2 +- .../organization/organization.component.ts | 1 + .../publication/publication.component.html | 65 +++++++---- .../publication/publication.component.ts | 110 +++++++++++++++++- .../publication/publication.module.ts | 4 +- .../publication/publication.service.ts | 1 + .../app/landingPages/resultLanding.module.ts | 3 +- .../landingPages/showIdentifiers.component.ts | 52 ++++++--- .../app/landingPages/tabTable.component.ts | 23 +++- .../searchUtils/searchFilter.component.ts | 4 +- .../utils/properties/openaireProperties.ts | 4 + 14 files changed, 249 insertions(+), 55 deletions(-) diff --git a/portal-2/src/app/deposit/datasets/depositBySubjectResult.component.ts b/portal-2/src/app/deposit/datasets/depositBySubjectResult.component.ts index fc954afe..3de1bee9 100644 --- a/portal-2/src/app/deposit/datasets/depositBySubjectResult.component.ts +++ b/portal-2/src/app/deposit/datasets/depositBySubjectResult.component.ts @@ -25,7 +25,7 @@ import {RouterHelper} from '../../utils/routerHelper.class';
- +
-
+
+ {{organizations.length}} organizations, page {{organizationsPage}} of {{totalPages(organizations.length)}} + +
+ +

@@ -25,11 +30,25 @@ import {Component, Input} from '@angular/core'; export class OrganizationsTabComponent { - @Input() organizations: {"name": string, "id": string}[] ; + @Input() organizations: {"name": string, "id": string}[]; + public organizationsPage: number = 1; + public pageSize: number = 10; constructor () {} ngOnInit() {} ngOnDestroy() {} + + totalPages(totalResults: number): number { + let totalPages:any = totalResults/this.pageSize; + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, this.pageSize) + 1); + } + return totalPages; + } + + updateOrganizationsPage($event) { + this.organizationsPage = $event.value; + } } diff --git a/portal-2/src/app/landingPages/landing-utils/parsingFunctions.class.ts b/portal-2/src/app/landingPages/landing-utils/parsingFunctions.class.ts index e518799b..59073d9a 100644 --- a/portal-2/src/app/landingPages/landing-utils/parsingFunctions.class.ts +++ b/portal-2/src/app/landingPages/landing-utils/parsingFunctions.class.ts @@ -329,7 +329,7 @@ export class ParsingFunctions { let identifiers = new Map(); if(pid.hasOwnProperty("classname") && pid['classname'] != "") { - if(pid.classname == "doi" || pid.classname == "pmc") { + if(pid.classname == "doi" || pid.classname == "pmc" || pid.classname == "handle") { if(!identifiers.has(pid.classname)) { identifiers.set(pid.classname, new Array()); } @@ -338,7 +338,7 @@ export class ParsingFunctions { } } else { for(let i=0; i()); } diff --git a/portal-2/src/app/landingPages/landing.module.ts b/portal-2/src/app/landingPages/landing.module.ts index 98402228..56632800 100644 --- a/portal-2/src/app/landingPages/landing.module.ts +++ b/portal-2/src/app/landingPages/landing.module.ts @@ -7,9 +7,9 @@ import { FormsModule } from '@angular/forms'; import {TabPagingComponent} from './tabPaging.component'; import {ShowTitleComponent} from './showTitle.component'; import {AddThisComponent} from './addThis.component'; + @NgModule({ imports: [ - CommonModule, FormsModule ], declarations: [ diff --git a/portal-2/src/app/landingPages/organization/organization.component.ts b/portal-2/src/app/landingPages/organization/organization.component.ts index 9e28732d..66c8d444 100644 --- a/portal-2/src/app/landingPages/organization/organization.component.ts +++ b/portal-2/src/app/landingPages/organization/organization.component.ts @@ -127,6 +127,7 @@ export class OrganizationComponent { this._organizationService.getOrganizationInfo(this.organizationId).subscribe( data => { if(data == null) { + this.showLoading = false; this.errorMessage = 'No organization found'; } else { this.organizationInfo = data; diff --git a/portal-2/src/app/landingPages/publication/publication.component.html b/portal-2/src/app/landingPages/publication/publication.component.html index c90cad4c..f7089ff4 100644 --- a/portal-2/src/app/landingPages/publication/publication.component.html +++ b/portal-2/src/app/landingPages/publication/publication.component.html @@ -200,9 +200,13 @@

- + +
+ {{publicationInfo.references.length}} references, page {{referencesPage}} of {{totalPages(publicationInfo.references.length)}} + +
-
-
{{provenanceaction}}
+
{{provenanceaction}}
@@ -262,6 +266,10 @@ There are no related organizations
+
+ {{publicationInfo.organizations.length}} organizations, page {{organizationsPage}} of {{totalPages(publicationInfo.organizations.length)}} + +
@@ -271,7 +279,7 @@ - +
@@ -309,6 +317,11 @@
  • +
    + {{bioentitiesNum}} bioentities, page {{bioentitiesPage}} of {{totalPages(bioentitiesNum)}} + +
    + @@ -316,24 +329,32 @@ - - - - - + + + + + + + + +
    Site Name
    - - - {{keyIn}} - - - - {{key}} -
    + + + {{keyIn}} + + + + {{key}} +
  • +
    + {{publicationInfo.software.length}} software results, page {{softwarePage}} of {{totalPages(publicationInfo.software.length)}} + +
    @@ -342,7 +363,7 @@ - +
    diff --git a/portal-2/src/app/landingPages/publication/publication.component.ts b/portal-2/src/app/landingPages/publication/publication.component.ts index b4c8bfa5..654cb02f 100644 --- a/portal-2/src/app/landingPages/publication/publication.component.ts +++ b/portal-2/src/app/landingPages/publication/publication.component.ts @@ -32,10 +32,14 @@ export class PublicationComponent { private totalDownloads: number; private pageViews: number; - public showAllReferences: boolean = false; + //public showAllReferences: boolean = false; + public referencesPage: number = 1; + public organizationsPage: number = 1; + public softwarePage: number = 1; + public bioentitiesPage: number = 1; + public showAllRelResData: boolean = false; public showAllSimilPubl: boolean = false; - public showAllBioentities: boolean = false; public showFundingDetails: boolean = false; public bioentitiesNum: number = 0; @@ -53,6 +57,11 @@ export class PublicationComponent { public activeTab: string = "References"; + public startt: number = 0; + public stopp: number = 0; + + public pageSize: number = 10; + constructor ( private element: ElementRef, private _publicationService: PublicationService, private route: ActivatedRoute, private _meta: Meta, @@ -167,9 +176,9 @@ export class PublicationComponent { ); } - showChange($event) { + /*showChange($event) { this.showAllReferences=$event.value; - } + }*/ public downloadClicked($event) { this.totalViews = $event.totalViews; @@ -253,4 +262,97 @@ export class PublicationComponent { this._meta.updateProperty("og:url", url); } + totalPages(totalResults: number): number { + let totalPages:any = totalResults/this.pageSize; + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, this.pageSize) + 1); + } + return totalPages; + } + + updateReferencesPage($event) { + this.referencesPage = $event.value; + } + + updateOrganizationsPage($event) { + this.organizationsPage = $event.value; + } + + updateSoftwarePage($event) { + this.softwarePage = $event.value; + } + + updateBioentitiesPage($event) { + this.bioentitiesPage = $event.value; + } + + start(i: number, bioentitiesPage: number) { + let sum = 0; + let index=0; + let retValue = 0; + let valuesToPage = this.pageSize*bioentitiesPage; + let valuesToPreviousPage = valuesToPage - this.pageSize; + + if(bioentitiesPage == 1) { + return 0; + } + + this.publicationInfo.bioentities.forEach(function (value, key, map) { + sum += map.get(key).size; + + if(index == i) { + if(sum <= valuesToPreviousPage) { + retValue = 0; + } else if((sum-map.get(key).size) >= valuesToPage){ + retValue = 0; + } else { + if(map.get(key).size < (sum - valuesToPreviousPage)) { + retValue = 0; + } else { + retValue = map.get(key).size - (sum - valuesToPreviousPage); + } + } + } + index++; + }); + this.startt = retValue; + return retValue; + } + + stop(i: number, bioentitiesPage: number) { + let sum = 0; + let index=0; + let retValue = 0; + let valuesToPage = this.pageSize*bioentitiesPage; + let valuesToPreviousPage = valuesToPage - this.pageSize; + + this.publicationInfo.bioentities.forEach(function (value, key, map) { + sum += map.get(key).size; + if(index == i) { + if(sum <= valuesToPreviousPage) { + retValue = 0; + } else if((sum - map.get(key).size) >= valuesToPage){ + retValue = 0; + } else { + if(sum < valuesToPage) { + retValue = map.get(key).size; + } else { + retValue = map.get(key).size - (sum - valuesToPage); + } + } + } + index++; + }); + this.stopp = retValue; + return retValue; + } + + keysToArray(bioentities: Map) : string[] { + let keys: string[] = []; + bioentities.forEach(function (value, key, map) { + keys.push(key); + }); + return keys; + } + } diff --git a/portal-2/src/app/landingPages/publication/publication.module.ts b/portal-2/src/app/landingPages/publication/publication.module.ts index 1c4dd98a..ed6d05c9 100644 --- a/portal-2/src/app/landingPages/publication/publication.module.ts +++ b/portal-2/src/app/landingPages/publication/publication.module.ts @@ -12,7 +12,7 @@ import {MetricsModule} from '../metrics.module'; import {IFrameModule} from '../../utils/iframe.module'; import {AltMetricsModule} from '../../utils/altmetrics.module'; import {CiteThisModule} from '../landing-utils/citeThis/citeThis.module'; - +import {PagingModule} from '../../utils/paging.module'; import { ResultLandingModule } from '../resultLanding.module'; import { LandingModule } from '../landing.module'; @@ -20,7 +20,7 @@ import {FreeGuard} from'../../login/freeGuard.guard'; @NgModule({ imports: [ - CommonModule, FormsModule, LandingModule,SharedModule, RouterModule, CiteThisModule, + CommonModule, FormsModule, LandingModule,SharedModule, RouterModule, CiteThisModule, PagingModule, ResultLandingModule, PublicationRoutingModule, IFrameModule, MetricsModule, AltMetricsModule ], declarations: [ diff --git a/portal-2/src/app/landingPages/publication/publication.service.ts b/portal-2/src/app/landingPages/publication/publication.service.ts index b63e5f6d..587a0f06 100644 --- a/portal-2/src/app/landingPages/publication/publication.service.ts +++ b/portal-2/src/app/landingPages/publication/publication.service.ts @@ -311,6 +311,7 @@ export class PublicationService { } } } + return [bioentities, software]; } diff --git a/portal-2/src/app/landingPages/resultLanding.module.ts b/portal-2/src/app/landingPages/resultLanding.module.ts index d615a83a..6529c62d 100644 --- a/portal-2/src/app/landingPages/resultLanding.module.ts +++ b/portal-2/src/app/landingPages/resultLanding.module.ts @@ -3,6 +3,7 @@ import { NgModule} from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; +import {PagingModule} from '../utils/paging.module'; import {ShowAuthorsComponent} from './showAuthors.component'; import {ShowIdentifiersComponent} from './showIdentifiers.component'; @@ -11,7 +12,7 @@ import {TabTableComponent} from './tabTable.component'; @NgModule({ imports: [ - CommonModule, FormsModule, RouterModule + CommonModule, FormsModule, RouterModule, PagingModule ], declarations: [ ShowAuthorsComponent,ShowIdentifiersComponent,ShowSubjectsComponent, TabTableComponent diff --git a/portal-2/src/app/landingPages/showIdentifiers.component.ts b/portal-2/src/app/landingPages/showIdentifiers.component.ts index e5e46281..54247998 100644 --- a/portal-2/src/app/landingPages/showIdentifiers.component.ts +++ b/portal-2/src/app/landingPages/showIdentifiers.component.ts @@ -5,27 +5,30 @@ import {OpenaireProperties} from '../utils/properties/openaireProperties'; selector: 'showIdentifiers', template: ` - + View less identifiers + - + {{key}}: {{item}}{{key}}: {{item}}{{key}}: {{item}}{{key}}: {{item}}{{", "}} - ... + *ngIf="((sizeOfPreviousIdentifiers + j) < pageSize || showAll) && ((sizeOfPreviousIdentifiers + j) < countIdentifiers()-1)">{{", "}} + ... + - + view all {{countIdentifiers()}} identifiers - + View less identifiers @@ -35,29 +38,48 @@ import {OpenaireProperties} from '../utils/properties/openaireProperties'; export class ShowIdentifiersComponent { @Input() identifiers: Map; - doiURL: string; - pmcURL: string; + public doiURL: string; + public pmcURL: string; + public handleURL: string; public showAll: boolean = false; - public num: number = -1; + public sizeOfIdentifiers: number = -1; + public sizeOfPreviousIdentifiers: number = -1; + public pageSize: number = 10; constructor (private element: ElementRef) { this.doiURL = OpenaireProperties.getDoiURL(); this.pmcURL = OpenaireProperties.getPmcURL(); + this.handleURL = OpenaireProperties.getHandleURL(); } ngOnInit() {} - public countIdentifiers() { - if(this.num < 0) { - let num = 0; + public countIdentifiers(): number { + if(this.sizeOfIdentifiers < 0) { + let num: number = 0; if(this.identifiers != undefined) { this.identifiers.forEach(function (value, key, map) { num += value.length; }); } - this.num = num; + this.sizeOfIdentifiers = num; } - return this.num; + return this.sizeOfIdentifiers; + } + + public countSizeOfPreviousIdentifiers(index: number): number { + let num: number = 0; + let i: number = 0; + if(this.identifiers != undefined) { + this.identifiers.forEach(function (value, key, map) { + if(i < index) { + num += value.length; + } + i++; + }); + } + this.sizeOfPreviousIdentifiers= num; + return num; } public scroll() { diff --git a/portal-2/src/app/landingPages/tabTable.component.ts b/portal-2/src/app/landingPages/tabTable.component.ts index 5758010a..ebb0e6fa 100644 --- a/portal-2/src/app/landingPages/tabTable.component.ts +++ b/portal-2/src/app/landingPages/tabTable.component.ts @@ -1,10 +1,16 @@ import {Component, Input} from '@angular/core'; import {RouterHelper} from '../utils/routerHelper.class'; import {OpenaireProperties} from '../utils/properties/openaireProperties'; +//import {PagingModule} from '../utils/paging.module'; @Component({ selector: 'tabTable', template: ` +
    + {{info.length}} research results, page {{page}} of {{totalPages(info.length)}} + +
    + @@ -13,7 +19,7 @@ import {OpenaireProperties} from '../utils/properties/openaireProperties'; - +
    (Publication) @@ -62,6 +68,9 @@ export class TabTableComponent { public searchLinkToPublication: string; public searchLinkToDataset: string; + public page: number = 1; + public pageSize: number = 10; + constructor () { } @@ -69,4 +78,16 @@ export class TabTableComponent { this.searchLinkToPublication = OpenaireProperties.getsearchLinkToPublication(); this.searchLinkToDataset = OpenaireProperties.getsearchLinkToDataset(); } + + totalPages(totalResults: number): number { + let totalPages:any = totalResults/this.pageSize; + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, this.pageSize) + 1); + } + return totalPages; + } + + updatePage($event) { + this.page = $event.value; + } } diff --git a/portal-2/src/app/searchPages/searchUtils/searchFilter.component.ts b/portal-2/src/app/searchPages/searchUtils/searchFilter.component.ts index 5148f2a4..0a2afe2b 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchFilter.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchFilter.component.ts @@ -45,9 +45,9 @@ import {Open} from '../../utils/modal/open.component';
    -

    +

    {{filter.title}} -
    +
    diff --git a/portal-2/src/app/utils/properties/openaireProperties.ts b/portal-2/src/app/utils/properties/openaireProperties.ts index dcc810ee..35065aa4 100644 --- a/portal-2/src/app/utils/properties/openaireProperties.ts +++ b/portal-2/src/app/utils/properties/openaireProperties.ts @@ -68,6 +68,7 @@ export class OpenaireProperties { private static doiURL = "https://dx.doi.org/"; private static cordisURL = "http://cordis.europa.eu/projects/"; private static pmcURL = "http://europepmc.org/articles/"; + private static handleURL = "http://hdl.handle.net/"; // Zenodo's url private static zenodo = "https://zenodo.org/"; @@ -271,6 +272,9 @@ export class OpenaireProperties { public static getPmcURL():string{ return this.pmcURL; } + public static getHandleURL():string{ + return this.handleURL; + } // Zenodo's getter public static getZenodoURL():string{