[Aggragator | Trunk]: Add numbers on home page

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-aggregator-portal/trunk@60908 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2021-04-18 12:03:23 +00:00
parent d9b4e45c31
commit 0658c30096
4 changed files with 30 additions and 244 deletions

View File

@ -148,96 +148,8 @@
</div>
</div>
<div class="uk-section uk-padding-remove-bottom">
<div class="uk-container uk-text-center uk-margin-medium-bottom">
<div class="uk-margin-medium uk-flex-center">
<div class="uk-first-column">
<div class="uk-panel">
<h3 class="uk-margin uk-text-center">
Our growing <span class="uk-text-bold">Community</span>
</h3>
<div class="uk-margin-large-top uk-container uk-margin-bottom uk-text-center">
<div class="uk-grid uk-flex uk-flex-center">
<div *ngIf="fundersSize" class="uk-width-1-3@m">
<h3>
<a [routerLink]="properties.searchLinkToProjects" class="uk-text-bold number">
{{fundersSize.number|number}}<span class="number-size">{{fundersSize.size}}</span>
</a>
</h3>
<div class="uk-text-uppercase uk-text-large">Funders</div>
</div>
<div *ngIf="datasourcesSize" class="uk-width-1-3@m">
<h3>
<a [routerLink]="properties.searchLinkToDataProviders" class="uk-text-bold number">
{{datasourcesSize.number|number}}<span class="number-size">{{datasourcesSize.size}}</span>
</a>
</h3>
<div class="uk-text-uppercase uk-text-large">Content providers</div>
</div>
<div *ngIf="projectsSize" class="uk-width-1-3@m">
<h3>
<a [routerLink]="properties.searchLinkToProjects" class="uk-text-bold number">
{{projectsSize.number|number}}<span class="number-size">{{projectsSize.size}}</span>
</a>
</h3>
<div class="uk-text-uppercase uk-text-large">Projects</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="numbers-background uk-section">
<div class="uk-container">
<div class="uk-grid uk-margin-auto-left uk-margin-auto-right uk-grid-large uk-flex uk-flex-center" uk-grid>
<div *ngIf="publicationsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width">
<a class="number uk-text-bold uk-margin-bottom" [routerLink]="properties.searchLinkToResults"
[queryParams]="{type: 'publications', qf: false}">
{{publicationsSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="book" ratio="1.5" [flex]="true" class="uk-margin-right" customClass="portal-color"></icon>
<span>publications</span>
</div>
</div>
</div>
<div *ngIf="datasetsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width">
<a class="number uk-text-bold uk-margin-bottom"
[routerLink]="properties.searchLinkToResults"
[queryParams]="{type: 'datasets', qf: false}">{{datasetsSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right"
customClass="portal-color"></icon>
<span>research data</span>
</div>
</div>
</div>
<div *ngIf="softwareSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width">
<a class="number uk-text-bold uk-margin-bottom" [routerLink]="properties.searchLinkToResults"
[queryParams]="{type: 'software', qf: false}">
{{softwareSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="cog" ratio="1.5" [flex]="true" class="uk-margin-right" customClass="portal-color"></icon>
<span>software</span>
</div>
</div>
</div>
<div *ngIf="otherSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width">
<a class="number uk-text-bold uk-margin-bottom" [routerLink]="properties.searchLinkToResults"
[queryParams]="{type: 'other', qf: false}">{{otherSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right" customClass="portal-color"></icon>
<span>other research products</span>
</div>
</div>
</div>
</div>
</div>
</div>
<h3 class="uk-text-center uk-margin-medium-bottom">Our growing <span class="uk-text-bold">Community</span></h3>
<numbers #numbersComponent [defaultInit]="false" backgroundClass="numbers-background"></numbers>
</div>
<!--<helper *ngIf="pageContents && pageContents['left'] && pageContents['left'].length > 0"-->
<!-- [texts]="pageContents['left']"></helper>-->

View File

@ -1,22 +1,21 @@
import {Component} from '@angular/core';
import {Component, ViewChild} from '@angular/core';
import {Subscription} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import "rxjs/add/observable/zip";
import {Title, Meta} from '@angular/platform-browser';
import {Meta, Title} from '@angular/platform-browser';
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
import { SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
import { SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
import { SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service';
import { RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service';
import { SearchFields} from '../openaireLibrary/utils/properties/searchFields';
import { NumberUtils} from '../openaireLibrary/utils/number-utils.class';
import {SearchDataprovidersService} from '../openaireLibrary/services/searchDataproviders.service';
import {SearchProjectsService} from '../openaireLibrary/services/searchProjects.service';
import {SearchOrganizationsService} from '../openaireLibrary/services/searchOrganizations.service';
import {RefineFieldResultsService} from '../openaireLibrary/services/refineFieldResults.service';
import {SearchFields} from '../openaireLibrary/utils/properties/searchFields';
import { RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
import { EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import { ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {RouterHelper} from '../openaireLibrary/utils/routerHelper.class';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import { SEOService } from '../openaireLibrary/sharedComponents/SEO/SEO.service';
import {SEOService} from '../openaireLibrary/sharedComponents/SEO/SEO.service';
import {SearchResearchResultsService} from "../openaireLibrary/services/searchResearchResults.service";
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
@ -26,6 +25,7 @@ import {properties} from "../../environments/environment";
import {portalProperties} from "../../environments/environment-aggregator";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
import {NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
@Component({
selector: 'home',
@ -58,7 +58,7 @@ export class HomeComponent {
showOrganizations: boolean = portalProperties.entities.organization.isEnabled;
showProjects: boolean = portalProperties.entities.project.isEnabled;
showDataProviders: boolean = portalProperties.entities.datasource.isEnabled;
properties: EnvProperties;
properties: EnvProperties = properties;
public readMore: boolean = false;
subs: Subscription[] = [];
@ -77,6 +77,8 @@ export class HomeComponent {
customFilter:SearchCustomFilter= null;
aggregatorId;
aggregator:AggregatorInfo;
@ViewChild('numbersComponent') numbersComponent: NumbersComponent;
constructor (
private route: ActivatedRoute,
private _router: Router,
@ -109,27 +111,13 @@ export class HomeComponent {
}));
}
public getKeys(obj: {}) {
return Object.keys(obj);
}
createRange(number){
var items: number[] = [];
for(var i = 1; i <= number; i++){
items.push(i);
}
return items;
}
public ceil(num: number) {
return Math.ceil(num);
}
public ngOnInit() {
this.properties = properties;
this.seoService.createLinkForCanonicalURL(this.properties.domain + this.properties.baseLink+this._router.url, false);
this.getPageContents();
if(this.properties!=null){
var url = this.properties.domain + this.properties.baseLink+this._router.url;
this._meta.updateTag({content:url},"property='og:url'");
@ -145,13 +133,13 @@ export class HomeComponent {
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
}
this.showPublications = showEntity["publication"];
this.showDatasets = showEntity["dataset"];
this.showSoftware = showEntity["software"];
this.showOrp = showEntity["orp"];
this.showProjects = showEntity["project"];
this.showDataProviders = showEntity["datasource"];
this.showOrganizations = showEntity["organization"];
this.showPublications = !!showEntity["publication"];
this.showDatasets = !!showEntity["dataset"];
this.showSoftware = !!showEntity["software"];
this.showOrp = !!showEntity["orp"];
this.showProjects = !!showEntity["project"];
this.showDataProviders = !!showEntity["datasource"];
this.showOrganizations = !!showEntity["organization"];
if(this.showPublications){
this.resultTypes.values.push({name: "Publications" , id:"publications",selected:true, number:0});
}
@ -164,7 +152,9 @@ export class HomeComponent {
if(this.showOrp){
this.resultTypes.values.push({name: "Other research products" , id:"other",selected:true, number:0});
}
this.getNumbers();
this.numbersComponent.init(false, false, this.showPublications, this.showDatasets,
this.showSoftware, this.showOrp, this.showProjects, this.showDataProviders,
StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId ))));
}
},
error => {
@ -180,123 +170,6 @@ export class HomeComponent {
}
}
private getNumbers() {
let refineQuery = null
if(this.customFilter){
refineQuery= "&fq="+StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId )));
}
if(this.showPublications){
this.subs.push(this._searchResearchResultsService.numOfSearchResults("publication", "", this.properties, refineQuery).subscribe(
data => {
if(data && data != null && data > 0 ){
this.publicationsSize = NumberUtils.roundNumber(data);
}
},
err => {
//console.log(err);
this.handleError("Error getting number of publications", err);
}
));
}
if(this.showDatasets){
this.subs.push(this._searchResearchResultsService.numOfSearchResults("dataset", "", this.properties, refineQuery).subscribe(
data => {
if(data && data != null && data > 0 ){
this.datasetsSize = NumberUtils.roundNumber(data);
}
},
err => {
//console.log(err);
this.handleError("Error getting number of research data", err);
}
));
/*this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties, refineQuery).subscribe(
data => {
if(data && data != null && data > 0 ){
this.datasetsLinkedSize = NumberUtils.roundNumber(data);
}
},
err => {
//console.log(err);
this.handleError("Error getting number of linkedresearch data", err);
}
));*/
}
if (this.showSoftware) {
this.subs.push(this._searchResearchResultsService.numOfSearchResults("software", "", this.properties, refineQuery).subscribe(
data => {
if (data && data > 0) {
this.softwareSize = NumberUtils.roundNumber(data);
}else{
this.showSoftware = false;
}
},
err => {
this.handleError("Error getting number of software data", err);
}
));
/* this.subs.push(this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties, refineQuery).subscribe(
data => {
if(data && data != null && data > 0 ){
this.softwareLinkedSize = NumberUtils.roundNumber(data);
}
},
err => {
//console.log(err);
this.handleError("Error getting number of linked software", err);
}
));*/
}
if (this.showOrp) {
this.subs.push(this._searchResearchResultsService.numOfSearchResults("other", "", this.properties, refineQuery).subscribe(
data => {
if (data && data > 0) {
this.otherSize = NumberUtils.roundNumber(data);
}else{
this.showOrp = false;
}
},
err => {
this.handleError("Error getting number of software data", err);
}
));
}
if(this.showProjects){
this.subs.push(this._refineFieldResultsService.getRefineFieldsResultsByEntityName(["funder"],"project", this.properties, refineQuery).subscribe(
data => {
if(data[0] && data[0] > 0 ){
this.projectsSize = NumberUtils.roundNumber(data[0]);
}
if(data[1].length > 0 && data[1][0].filterId == "funder" && data[1][0].values ){
this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length);
}
},
err => {
//console.log(err);
this.handleError("Error getting 'funder' field results of projects", err);
}));
}
if(this.showDataProviders){
this.subs.push(this._searchDataprovidersService.numOfSearchDataproviders("", this.properties, refineQuery).subscribe(
data => {
if(data && data != null && data > 0 ){
this.datasourcesSize = NumberUtils.roundNumber(data);
}
},
err => {
//console.log(err);
this.handleError("Error getting number of content providers", err);
}
));
}
}
private handleError(message: string, error) {
console.error("Home Page: "+message, error);
}

View File

@ -25,6 +25,7 @@ import {QuickSelectionsModule} from "../openaireLibrary/searchPages/searchUtils/
import {IconsModule} from "../openaireLibrary/utils/icons/icons.module";
import {IconsService} from "../openaireLibrary/utils/icons/icons.service";
import {arrow_right, book, cog, database, earth} from "../openaireLibrary/utils/icons/icons";
import {NumbersModule} from "../openaireLibrary/sharedComponents/numbers/numbers.module";
@NgModule({
imports: [
@ -37,7 +38,7 @@ import {arrow_right, book, cog, database, earth} from "../openaireLibrary/utils/
HomeRoutingModule,
HelperModule,
ErrorMessagesModule,
SEOServiceModule, EntitiesSelectionModule, QuickSelectionsModule, IconsModule
SEOServiceModule, EntitiesSelectionModule, QuickSelectionsModule, IconsModule, NumbersModule
],
declarations: [
HomeComponent

View File

@ -46,7 +46,7 @@
}
.numbers-background {
background: transparent url('numbers_background_pattern.svg') 0 0 repeat-x padding-box;
background: transparent url('numbers_background_pattern.svg') repeat-x center bottom;
}
.number {
color: #1d1d1d;