reintroduce numbersComponent in homepage, update submodules

This commit is contained in:
Alex Martzios 2022-11-08 14:10:18 +02:00
parent 734d7897ee
commit 9f67013ad0
5 changed files with 35 additions and 150 deletions

View File

@ -6,24 +6,7 @@
<h1 class="uk-h2 uk-width-1-2@m" uk-scrollspy-class>
Discover open linked research<span class="uk-text-primary">.</span>
</h1>
<div *ngIf="showContentWithNumbers" class="uk-margin-top" style="max-width: 600px;" uk-scrollspy-class>
<div>
A comprehensive and open dataset of research information covering
<span *ngIf="hasPublications" class="uk-text-bold">{{numbers.publicationsSize.number|number}}<span class="uk-text-lowercase">{{numbers.publicationsSize.size}}</span> {{openaireEntities.PUBLICATIONS.toLowerCase()}}</span>
<ng-container *ngIf="(hasPublications && (hasDatasets || hasSoftware || (hasDatasources || hasProjects || hasOrganizations)))">, </ng-container>
<span *ngIf="hasDatasets" class="uk-text-bold">{{numbers.datasetsSize.number|number}}<span class="uk-text-lowercase">{{numbers.datasetsSize.size}}</span> {{openaireEntities.DATASETS.toLowerCase()}}</span>
<ng-container *ngIf="(hasDatasets && (hasSoftware || (hasDatasources || hasProjects || hasOrganizations)))">, </ng-container>
<span *ngIf="hasSoftware" class="uk-text-bold">{{numbers.softwareSize.number|number}}<span class="uk-text-lowercase">{{numbers.softwareSize.size}}</span> {{openaireEntities.SOFTWARE.toLowerCase()}} items</span>
<ng-container *ngIf="(hasSoftware && (hasDatasources || hasProjects || hasOrganizations))">, </ng-container>
<ng-container *ngIf="((hasPublications || hasDatasets || hasSoftware) && (hasDatasources))"> from </ng-container>
<span *ngIf="hasDatasources" class="uk-text-bold">{{numbers.datasourcesSize.number|number}}<span class="uk-text-lowercase">{{numbers.datasourcesSize.size}}</span> {{openaireEntities.DATASOURCES.toLowerCase()}}</span>
<ng-container *ngIf="(hasDatasources) && ((hasProjects) || hasOrganizations)">, linked to </ng-container>
<span *ngIf="hasProjects" class="uk-text-bold">{{numbers.projectsSize.number|number}}<span class="uk-text-lowercase">{{numbers.projectsSize.size}}</span> grants</span>
<ng-container *ngIf="hasProjects && hasOrganizations"> and </ng-container>
<span *ngIf="hasOrganizations" class="uk-text-bold">{{numbers.organizationsSize.number|number}}<span class="uk-text-lowercase">{{numbers.organizationsSize.size}}</span> {{openaireEntities.ORGANIZATIONS.toLowerCase()}}</span>.
</div>
<div class="uk-text-primary">All linked together through citations and semantics.</div>
</div>
<numbers #numbersComponent [defaultInit]="false"></numbers>
<div [class.uk-invisible]="disableSelect" class="uk-margin-medium-top uk-width-3-4@xl">
<advanced-search-input #advanced (searchEmitter)="goTo(true)">
<entities-selection [simpleView]="true" currentEntity="all" [selectedEntity]="selectedEntity"

View File

@ -1,21 +1,15 @@
import {ChangeDetectorRef, Component, ViewChild} from '@angular/core';
import {of, Subscription, zip} from 'rxjs';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Subscription, zip} from 'rxjs';
import {Router} from '@angular/router';
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 {OpenaireEntities, 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 {PiwikService} from '../openaireLibrary/utils/piwik/piwik.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";
import {AggregatorInfo, PortalAggregators} from "../utils/aggregators";
@ -25,7 +19,6 @@ import {portalProperties} from "../../environments/environment-aggregator";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
import {ConnectHelper} from "../openaireLibrary/connect/connectHelper";
import {Numbers, NumbersComponent} from "../openaireLibrary/sharedComponents/numbers/numbers.component";
import {NumberUtils} from '../openaireLibrary/utils/number-utils.class';
@Component({
selector: 'home',
@ -34,27 +27,15 @@ import {NumberUtils} from '../openaireLibrary/utils/number-utils.class';
})
export class HomeComponent {
public keyword:string = "";
public searchFields:SearchFields = new SearchFields();
public errorCodes:ErrorCodes = new ErrorCodes();
public routerHelper:RouterHelper = new RouterHelper();
public numbers: Numbers = {};
showPublications: boolean = portalProperties.entities.publication.isEnabled;
showDatasets: boolean = portalProperties.entities.dataset.isEnabled;
showSoftware: boolean = portalProperties.entities.software.isEnabled;
showOrp: boolean = portalProperties.entities.other.isEnabled;
showOrganizations: boolean = portalProperties.entities.organization.isEnabled;
showProjects: boolean = portalProperties.entities.project.isEnabled;
showDataProviders: boolean = portalProperties.entities.datasource.isEnabled;
properties: EnvProperties = properties;
public openaireEntities = OpenaireEntities;
public readMore: boolean = false;
private noOfFunders = 3;
public funders = [];
subs: Subscription[] = [];
resultsQuickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = {
filter: null,
selected: true,
@ -70,19 +51,12 @@ export class HomeComponent {
customFilter:SearchCustomFilter= null;
aggregatorId;
aggregator:AggregatorInfo;
// @ViewChild('numbersComponent', { static: true }) numbersComponent: NumbersComponent;
numbersLimit: number = 100;
@ViewChild('numbersComponent', { static: true }) numbersComponent: NumbersComponent;
constructor (
private route: ActivatedRoute,
private _router: Router,
private _searchResearchResultsService: SearchResearchResultsService,
private _searchDataprovidersService: SearchDataprovidersService,
private _searchProjectsService: SearchProjectsService,
private _searchOrganizationsService: SearchOrganizationsService,
private _refineFieldResultsService:RefineFieldResultsService,
private location: Location, private _piwikService:PiwikService,
private _piwikService:PiwikService,
private config: ConfigurationService, private _meta: Meta, private _title: Title, private seoService: SEOService,
private helper: HelperService,
private cdr: ChangeDetectorRef
@ -92,13 +66,10 @@ export class HomeComponent {
this.customFilter = PortalAggregators.getSearchCustomFilterByAggregator(this.aggregator);
let description = "OpenAIRE Explore: Over 100M of research deduplicated, 170K research software, 11M research data. One of the largest open scholarly records collection worldwide.";
let title = "OpenAIRE - Explore | " +this.aggregator.title;
this._title.setTitle(title);
this._meta.updateTag({content:description},"name='description'");
this._meta.updateTag({content:description},"property='og:description'");
this._meta.updateTag({content:title},"property='og:title'");
}
private getPageContents() {
@ -120,36 +91,46 @@ export class HomeComponent {
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.subs.push(this._piwikService.trackView(this.properties, "OpenAIRE").subscribe());
}
//this.config.getCommunityInformation(this.properties, this.properties.adminToolsCommunity ).subscribe(data => {
if(this.numbersComponent) {
this.numbersComponent.showPublications = portalProperties.entities.publication.isEnabled;
this.numbersComponent.showDatasets = portalProperties.entities.dataset.isEnabled;
this.numbersComponent.showSoftware = portalProperties.entities.software.isEnabled;
this.numbersComponent.showOrp = portalProperties.entities.other.isEnabled;
this.numbersComponent.showOrganizations = portalProperties.entities.organization.isEnabled;
this.numbersComponent.showProjects = portalProperties.entities.project.isEnabled;
this.numbersComponent.showDataProviders = portalProperties.entities.datasource.isEnabled;
}
this.subs.push(this.config.communityInformationState.subscribe(data => {
if(data) {
var showEntity = {};
for (var i = 0; i < data['entities'].length; i++) {
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"];
if(this.showPublications){
if(this.numbersComponent) {
this.numbersComponent.showPublications = !!showEntity["publication"];
this.numbersComponent.showDatasets = !!showEntity["dataset"];
this.numbersComponent.showSoftware = !!showEntity["software"];
this.numbersComponent.showOrp = !!showEntity["orp"];
this.numbersComponent.showProjects = !!showEntity["project"];
this.numbersComponent.showDataProviders = !!showEntity["datasource"];
this.numbersComponent.showOrganizations = !!showEntity["organization"];
}
if(this.numbersComponent && this.numbersComponent.showPublications){
this.resultTypes.values.push({name: this.openaireEntities.PUBLICATIONS , id:"publications",selected:false, number:0});
}
if(this.showDatasets){
if(this.numbersComponent && this.numbersComponent.showDatasets){
this.resultTypes.values.push({name: this.openaireEntities.DATASETS , id:"datasets",selected:false, number:0});
}
if(this.showSoftware){
if(this.numbersComponent && this.numbersComponent.showSoftware){
this.resultTypes.values.push({name: this.openaireEntities.SOFTWARE , id:"software",selected:false, number:0});
}
if(this.showOrp){
if(this.numbersComponent && this.numbersComponent.showOrp){
this.resultTypes.values.push({name: this.openaireEntities.OTHER , id:"other",selected:false, number:0});
}
this.init(false, false, this.showPublications, this.showDatasets, this.showSoftware, this.showOrp, this.showProjects, this.showDataProviders, this.showOrganizations,
this.customFilter ? StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId))) : '');
if(this.numbersComponent) {
this.numbersComponent.init(false, false, this.numbersComponent.showPublications, this.numbersComponent.showDatasets, this.numbersComponent.showSoftware, this.numbersComponent.showOrp, this.numbersComponent.showProjects, this.numbersComponent.showDataProviders, this.numbersComponent.showOrganizations,
this.customFilter ? StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId))) : '');
}
this.getFunders();
}
},
@ -227,7 +208,7 @@ export class HomeComponent {
params["f0"] = "q";
}
if(this.customFilter){
params = this.customFilter.getParameters(params);
params = this.customFilter.getParameters(params);
}
return params;
}
@ -297,87 +278,8 @@ export class HomeComponent {
return false;
}
init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
getSoftware = true, getOther = true, getProjects = true, getDataProviders = true, getOrganizations = true, refineValue: string = null) {
let refineParams = (refineValue) ? ('&fq=' + refineValue) : null;
this.subs.push(zip(
(getPublications) ? this._searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : of(0),
(getDatasets) ? this._searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, refineParams) : of(0),
(getDatasetsLinked) ? this._searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties) : of(0),
(getSoftware) ? this._searchResearchResultsService.numOfSearchResults('software', '', this.properties, refineParams) : of(0),
(getSoftwareLinked) ? this._searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties) : of(0),
(getOther) ? this._searchResearchResultsService.numOfSearchResults('other', '', this.properties, refineParams) : of(0),
(getProjects) ? this._refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, refineParams) : of(0),
(getDataProviders) ? this._searchDataprovidersService.numOfSearchDataproviders('', this.properties, refineParams) : of(0),
(getOrganizations) ? this._searchOrganizationsService.numOfSearchOrganizations2('', this.properties, refineParams) : of(0)
).subscribe((data: any[]) => {
if (data[0] && data[0] > 0) {
this.numbers.publicationsSize = NumberUtils.roundNumber(data[0]);
}
if (data[1] && data[1] > 0) {
this.numbers.datasetsSize = NumberUtils.roundNumber(data[1]);
}
if (data[2] && data[2] > 0) {
this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data[2]);
}
if (data[3] && data[3] > 0) {
this.numbers.softwareSize = NumberUtils.roundNumber(data[3]);
}
if (data[4] && data[4] > 0) {
this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data[4]);
}
if (data[5] && data[5] > 0) {
this.numbers.otherSize = NumberUtils.roundNumber(data[5]);
}
if (data[6][0] && data[6][0] > 0) {
this.numbers.projectsSize = NumberUtils.roundNumber(data[6][0]);
}
if (data[6][1] && data[6][1].length > 0 && data[6][1][0].filterId == 'funder' && data[6][1][0].values) {
this.numbers.fundersSize = NumberUtils.roundNumber(data[6][1][0].values.length);
}
if (data[7] && data[7] > 0) {
this.numbers.datasourcesSize = NumberUtils.roundNumber(data[7]);
}
if (data[8] && data[8] > 0) {
this.numbers.organizationsSize = NumberUtils.roundNumber(data[8]);
}
}, err => {
this.handleError('Error getting numbers', err);
}));
}
disableSelectChange(event: boolean) {
this.disableSelect = event;
this.cdr.detectChanges();
}
public get showContentWithNumbers() {
if (this.numbers && (this.hasPublications || this.hasDatasets || this.hasSoftware || this.hasDatasources || this.hasProjects || this.hasOrganizations)) {
return true;
}
}
public get hasPublications() {
return this.showPublications && this.numbers.publicationsSize && this.numbers.publicationsSize.count >= this.numbersLimit;
}
public get hasDatasets() {
return this.showDatasets && this.numbers.datasetsSize && this.numbers.datasetsSize.count >= this.numbersLimit;
}
public get hasSoftware() {
return this.showSoftware && this.numbers.softwareSize && this.numbers.softwareSize.count >= this.numbersLimit;
}
public get hasDatasources() {
return this.showDataProviders && this.numbers.datasourcesSize && this.numbers.datasourcesSize.count >= this.numbersLimit;
}
public get hasProjects() {
return this.showProjects && this.numbers.projectsSize && this.numbers.projectsSize.count >= this.numbersLimit;
}
public get hasOrganizations() {
return this.showOrganizations && this.numbers.organizationsSize && this.numbers.organizationsSize.count >= this.numbersLimit;
}
}

@ -1 +1 @@
Subproject commit 17212458ebd439e3195808e61dc2a6169d76d9c7
Subproject commit a2fea9e32331de06ab2192e3e638662531b9f42f

@ -1 +1 @@
Subproject commit 3ec9d00bc4b794ae782b163a1a17886bd83534f4
Subproject commit 06e1889730e456e86f728a31410bf550d16ac7d6

@ -1 +1 @@
Subproject commit 67483e8b95c23aa8dcb2d1203e1fe89a4d7f033f
Subproject commit e3e2a6ec11055f4d4352d0749bb1b484ddd711ae