[Library | Trunk]: Numbers add external link choice for links
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60902 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
be73ba0510
commit
6e4b4d5d3b
|
@ -6,6 +6,7 @@ import {EnvProperties} from '../../utils/properties/env-properties';
|
|||
import {properties} from '../../../../environments/environment';
|
||||
import {NumberSize, NumberUtils} from '../../utils/number-utils.class';
|
||||
import {BehaviorSubject, Observable, Subscription, zip} from 'rxjs';
|
||||
import {RouterHelper} from "../../utils/routerHelper.class";
|
||||
|
||||
export interface Numbers {
|
||||
publicationsSize?: NumberSize;
|
||||
|
@ -19,6 +20,13 @@ export interface Numbers {
|
|||
datasourcesSize?: NumberSize;
|
||||
}
|
||||
|
||||
type Entity = 'publication' | 'dataset' | 'software' | 'other' | 'project' | 'datasource';
|
||||
|
||||
interface Link {
|
||||
link: string,
|
||||
params?: any
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'numbers',
|
||||
template: `
|
||||
|
@ -26,8 +34,11 @@ export interface Numbers {
|
|||
<div class="uk-container uk-section uk-padding-remove-bottom uk-text-center">
|
||||
<div class="uk-grid uk-grid-large uk-child-width-1-3@m" uk-grid>
|
||||
<div *ngIf="numbers.fundersSize">
|
||||
<h3>
|
||||
<a href="https://explore.openaire.eu/search/find/projects" target="_blank" class="uk-text-bold number">
|
||||
<h3 *ngIf="links.get('project')">
|
||||
<a *ngIf="externalLink" [href]="links.get('project').link" target="_blank" class="uk-text-bold number">
|
||||
{{numbers.fundersSize.number|number}}<span class="number-size">{{numbers.fundersSize.size}}</span>
|
||||
</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('project').link" [queryParams]="links.get('project').params" class="uk-text-bold number">
|
||||
{{numbers.fundersSize.number|number}}<span class="number-size">{{numbers.fundersSize.size}}</span>
|
||||
</a>
|
||||
</h3>
|
||||
|
@ -35,8 +46,10 @@ export interface Numbers {
|
|||
</div>
|
||||
<div *ngIf="numbers.datasourcesSize">
|
||||
<h3>
|
||||
<a href="https://explore.openaire.eu/search/find/dataproviders" target="_blank"
|
||||
class="uk-text-bold number">
|
||||
<a *ngIf="externalLink" [href]="links.get('datasource').link" target="_blank" class="uk-text-bold number">
|
||||
{{numbers.datasourcesSize.number|number}}<span class="number-size">{{numbers.datasourcesSize.size}}</span>
|
||||
</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('datasource').link" [queryParams]="links.get('datasource').params" class="uk-text-bold number">
|
||||
{{numbers.datasourcesSize.number|number}}<span class="number-size">{{numbers.datasourcesSize.size}}</span>
|
||||
</a>
|
||||
</h3>
|
||||
|
@ -44,7 +57,10 @@ export interface Numbers {
|
|||
</div>
|
||||
<div *ngIf="numbers.projectsSize">
|
||||
<h3>
|
||||
<a href="https://explore.openaire.eu/search/find/projects" target="_blank" class="uk-text-bold number">
|
||||
<a *ngIf="externalLink" [href]="links.get('project').link" target="_blank" class="uk-text-bold number">
|
||||
{{numbers.projectsSize.number|number}}<span class="number-size">{{numbers.projectsSize.size}}</span>
|
||||
</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('project').link" [queryParams]="links.get('project').params" class="uk-text-bold number">
|
||||
{{numbers.projectsSize.number|number}}<span class="number-size">{{numbers.projectsSize.size}}</span>
|
||||
</a>
|
||||
</h3>
|
||||
|
@ -57,8 +73,10 @@ export interface Numbers {
|
|||
<div class="uk-grid uk-flex-center uk-margin-auto-left@m uk-margin-auto-right@m uk-grid-large" uk-grid>
|
||||
<div *ngIf="numbers.publicationsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
||||
<div class="number-width uk-flex uk-flex-column">
|
||||
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=publications&qf=false"
|
||||
target="_blank" class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.publicationsSize.count|number}} </a>
|
||||
<a *ngIf="externalLink" [href]="links.get('publication').link" target="_blank"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.publicationsSize.count|number}}</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('publication').link" [queryParams]="links.get('publication').params"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.publicationsSize.count|number}}</a>
|
||||
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
||||
<icon name="book" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
||||
<span>publications</span>
|
||||
|
@ -67,8 +85,10 @@ export interface Numbers {
|
|||
</div>
|
||||
<div *ngIf="numbers.datasetsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
||||
<div class="number-width uk-flex uk-flex-column">
|
||||
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=datasets&qf=false"
|
||||
target="_blank" class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.datasetsSize.count|number}} </a>
|
||||
<a *ngIf="externalLink" [href]="links.get('dataset').link" target="_blank"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.datasetsSize.count|number}}</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('datasource').link" [queryParams]="links.get('dataset').params"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.datasetsSize.count|number}}</a>
|
||||
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
||||
<icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
||||
<span>research data</span>
|
||||
|
@ -77,8 +97,10 @@ export interface Numbers {
|
|||
</div>
|
||||
<div *ngIf="numbers.softwareSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
||||
<div class="number-width uk-flex uk-flex-column">
|
||||
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=software&qf=false"
|
||||
target="_blank" class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.softwareSize.count|number}} </a>
|
||||
<a *ngIf="externalLink" [href]="links.get('software').link" target="_blank"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.softwareSize.count|number}}</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('software').link" [queryParams]="links.get('software').params"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.softwareSize.count|number}}</a>
|
||||
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
||||
<icon name="cog" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
||||
<span>software</span>
|
||||
|
@ -87,8 +109,10 @@ export interface Numbers {
|
|||
</div>
|
||||
<div *ngIf="numbers.otherSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
||||
<div class="number-width uk-flex uk-flex-column">
|
||||
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=other&qf=false"
|
||||
target="_blank" class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.otherSize.count|number}} </a>
|
||||
<a *ngIf="externalLink" [href]="links.get('other').link" target="_blank"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.otherSize.count|number}}</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('other').link" [queryParams]="links.get('other').params"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.otherSize.count|number}}</a>
|
||||
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
||||
<icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
||||
<span>other research products</span>
|
||||
|
@ -107,13 +131,22 @@ export interface Numbers {
|
|||
export class NumbersComponent implements OnInit, OnDestroy {
|
||||
@Input() colorClass = 'portal-color';
|
||||
@Input() backgroundClass = null;
|
||||
@Input() refineQuery = null;
|
||||
/** Add a value if you want to apply refine query*/
|
||||
@Input() refineValue = null;
|
||||
/** True: Default initialization
|
||||
* False: Call init method to initialize numbers */
|
||||
@Input() defaultInit = true;
|
||||
/** Add an external link for numbers link */
|
||||
@Input() externalLink;
|
||||
/** When numbers have been initialized this emitter will emitted */
|
||||
@Output() results: EventEmitter<Numbers> = new EventEmitter<Numbers>();
|
||||
private emptySubject: BehaviorSubject<number> = new BehaviorSubject<number>(0);
|
||||
public properties: EnvProperties = properties;
|
||||
public routerHelper: RouterHelper = new RouterHelper();
|
||||
public numbers: Numbers = {};
|
||||
public loading: boolean = true;
|
||||
public links: Map<Entity, Link> = new Map<Entity, Link>();
|
||||
private params: Map<Entity, {}> = new Map<Entity, {}>();
|
||||
private emptySubject: BehaviorSubject<number> = new BehaviorSubject<number>(0);
|
||||
private subs: any[] = [];
|
||||
|
||||
constructor(private searchResearchResultsService: SearchResearchResultsService,
|
||||
|
@ -125,20 +158,79 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
if(this.defaultInit) {
|
||||
this.init();
|
||||
}
|
||||
this.setLinks();
|
||||
}
|
||||
|
||||
setParams() {
|
||||
this.params.set('publication', {type: 'publications', qf: 'false'});
|
||||
this.params.set('dataset', {type: 'datasets', qf: 'false'});
|
||||
this.params.set('software', {type: 'software', qf: 'false'});
|
||||
this.params.set('other', {type: 'other', qf: 'false'});
|
||||
this.params.set('project', {});
|
||||
this.params.set('datasource', {});
|
||||
if(this.refineValue) {
|
||||
this.params.forEach((value) => {
|
||||
value['fq'] = this.refineValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setLinks() {
|
||||
this.setParams();
|
||||
if(this.externalLink) {
|
||||
this.links.set('publication', {link: this.externalLink + properties.searchLinkToResults +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('publication')), Object.values(this.params.get('publication')))});
|
||||
this.links.set('dataset', {link: this.externalLink + properties.searchLinkToResults +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('dataset')), Object.values(this.params.get('dataset')))});
|
||||
this.links.set('software', {link: this.externalLink + properties.searchLinkToResults +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('software')), Object.values(this.params.get('software')))});
|
||||
this.links.set('other', {link: this.externalLink + properties.searchLinkToResults +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('other')), Object.values(this.params.get('other')))});
|
||||
this.links.set('project', {link: this.externalLink + properties.searchLinkToProjects +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('project')), Object.values(this.params.get('project')))});
|
||||
this.links.set('datasource', {link: this.externalLink + properties.searchLinkToDataProviders +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('datasource')), Object.values(this.params.get('datasource')))});
|
||||
} else {
|
||||
this.links.set('publication', {
|
||||
link: properties.searchLinkToResults,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('publication')), Object.values(this.params.get('publication')))
|
||||
});
|
||||
this.links.set('dataset', {
|
||||
link: properties.searchLinkToResults,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('dataset')), Object.values(this.params.get('dataset')))
|
||||
});
|
||||
this.links.set('software', {
|
||||
link: properties.searchLinkToResults,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('software')), Object.values(this.params.get('software')))
|
||||
});
|
||||
this.links.set('other', {
|
||||
link: properties.searchLinkToResults,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('other')), Object.values(this.params.get('other')))
|
||||
});
|
||||
this.links.set('project', {
|
||||
link: properties.searchLinkToProjects,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('project')), Object.values(this.params.get('project')))
|
||||
});
|
||||
this.links.set('datasource', {
|
||||
link: properties.searchLinkToDataProviders,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('datasource')), Object.values(this.params.get('datasource')))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
|
||||
getSoftware = true, getOther = true, getProjects = true, getDataProviders = true) {
|
||||
this.loading = true;
|
||||
let refineParams = (this.refineValue)?('&fq=' + this.refineValue):null;
|
||||
this.subs.push(zip(
|
||||
(getPublications)?this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, this.refineQuery):this.empty,
|
||||
(getDatasets)?this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, this.refineQuery):this.empty,
|
||||
(getPublications)?this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams):this.empty,
|
||||
(getDatasets)?this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, refineParams):this.empty,
|
||||
(getDatasetsLinked)?this.searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties):this.empty,
|
||||
(getSoftware)?this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, this.refineQuery):this.empty,
|
||||
(getSoftware)?this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, refineParams):this.empty,
|
||||
(getSoftwareLinked)?this.searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties):this.empty,
|
||||
(getOther)?this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, this.refineQuery):this.empty,
|
||||
(getProjects)?this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, this.refineQuery):this.empty,
|
||||
(getDataProviders)?this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, this.refineQuery):this.empty
|
||||
(getOther)?this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, refineParams):this.empty,
|
||||
(getProjects)?this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, refineParams):this.empty,
|
||||
(getDataProviders)?this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, refineParams):this.empty
|
||||
).subscribe((data: any[]) => {
|
||||
if (data[0] && data[0] > 0) {
|
||||
this.numbers.publicationsSize = NumberUtils.roundNumber(data[0]);
|
||||
|
|
|
@ -8,9 +8,10 @@ import {SearchResearchResultsService} from '../../services/searchResearchResults
|
|||
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
||||
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
|
||||
import {LoadingModule} from '../../utils/loading/loading.module';
|
||||
import {RouterModule} from "@angular/router";
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, IconsModule, LoadingModule],
|
||||
imports: [CommonModule, IconsModule, LoadingModule, RouterModule],
|
||||
declarations: [NumbersComponent],
|
||||
exports: [NumbersComponent],
|
||||
providers: [SearchResearchResultsService, SearchDataprovidersService, RefineFieldResultsService]
|
||||
|
|
Loading…
Reference in New Issue