Rename stakeholders and organizations(UI only) and add explore links to homepage's numbers

This commit is contained in:
Alex Martzios 2021-10-19 16:22:35 +03:00
parent e83f5febf9
commit 7ab16878b0
2 changed files with 692 additions and 675 deletions

View File

@ -1,242 +1,259 @@
<div class="image-front-topbar"
style="background: transparent linear-gradient(180deg, #F4F4F4 0%, #F5F5F5 83%, #FAFAFA 100%) no-repeat;">
<div
class="uk-section uk-container uk-container-large uk-text-center uk-section uk-section-small uk-margin-large-bottom"
uk-parallax="media: @l; y: -200; easing: 0.5">
<div class="uk-padding-small">
<h1 class="uk-margin-top">A new era of monitoring research.</h1>
<div class="girl-background">
<h4 class="uk-margin-remove-top">Open data. Open methodologies.</h4>
<div class="uk-margin-medium-top uk-text-muted">
Work together with us to view, understand and visualize<br>research statistics and indicators.
</div>
</div>
</div>
</div>
style="background: transparent linear-gradient(180deg, #F4F4F4 0%, #F5F5F5 83%, #FAFAFA 100%) no-repeat;">
<div
class="uk-section uk-container uk-container-large uk-text-center uk-section uk-section-small uk-margin-large-bottom"
uk-parallax="media: @l; y: -200; easing: 0.5">
<div class="uk-padding-small">
<h1 class="uk-margin-top">A new era of monitoring research.</h1>
<div class="girl-background">
<h4 class="uk-margin-remove-top">Open data. Open methodologies.</h4>
<div class="uk-margin-medium-top uk-text-muted">
Work together with us to view, understand and visualize<br>research statistics and indicators.
</div>
</div>
</div>
</div>
</div>
<div class="uk-section uk-container uk-container-large dashboard-section">
<div class="uk-padding-small">
<div class="dashboard uk-flex uk-flex-center">
<img class="uk-width-1-2@l" src="/assets/monitor-assets/home/dashboard.png">
</div>
<div class="uk-margin-large-top">
<div class="uk-margin-medium-left uk-margin-medium-right uk-margin-large-bottom">
<div class="uk-child-width-1-3@m uk-grid info" uk-grid>
<div [@1]="state.toString()" class="clickable" [class.uk-active]="state === 1" (click)="startAnimation()">
<h5>
Get a complete picture
</h5>
<div class="uk-text-muted">
Track and discover your organizations research output. Use the OpenAIRE Research Graph to get a 360<span>&#176;</span>
view of your publications-data-code.
</div>
</div>
<div [@2]="state.toString()" class="clickable" [class.uk-active]="state === 2" (click)="startAnimation(2)">
<h5>
Monitor open science compliance
</h5>
<div class="uk-text-muted">
Work with the open science expert community for open and transparent metrics. Discover open science trends
for your organization and see how you fare in EOSC.
</div>
</div>
<div [@3]="state.toString()" class="clickable" [class.uk-active]="state === 3" (click)="startAnimation(3)">
<h5>
Turn research results to insights
</h5>
<div class="uk-text-muted">
Understand your community. Measure impact, discover trends, connections and collaborations to improve
and optimize your future actions.
</div>
</div>
</div>
</div>
</div>
</div>
<div class="uk-padding-small">
<div class="dashboard uk-flex uk-flex-center">
<img class="uk-width-1-2@l" src="/assets/monitor-assets/home/dashboard.png">
</div>
<div class="uk-margin-large-top">
<div class="uk-margin-medium-left uk-margin-medium-right uk-margin-large-bottom">
<div class="uk-child-width-1-3@m uk-grid info" uk-grid>
<div [@1]="state.toString()" class="clickable" [class.uk-active]="state === 1" (click)="startAnimation()">
<h5>
Get a complete picture
</h5>
<div class="uk-text-muted">
Track and discover your organizations research output. Use the OpenAIRE Research Graph to get a
360<span>&#176;</span>
view of your publications-data-code.
</div>
</div>
<div [@2]="state.toString()" class="clickable" [class.uk-active]="state === 2" (click)="startAnimation(2)">
<h5>
Monitor open science compliance
</h5>
<div class="uk-text-muted">
Work with the open science expert community for open and transparent metrics. Discover open science trends
for your organization and see how you fare in EOSC.
</div>
</div>
<div [@3]="state.toString()" class="clickable" [class.uk-active]="state === 3" (click)="startAnimation(3)">
<h5>
Turn research results to insights
</h5>
<div class="uk-text-muted">
Understand your community. Measure impact, discover trends, connections and collaborations to improve
and optimize your future actions.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="uk-section uk-container uk-container-large">
<div class="uk-padding-small hologram uk-position-relative">
<div class="uk-grid uk-grid-match uk-child-width-1-2 uk-visible@m" uk-grid>
<div uk-parallax="y: 40, -60; easing: 0.5">
<div class="uk-margin-large-left uk-margin-large-bottom uk-width-3-4 part">
<h5 class="uk-text-secondary">Global outlook</h5>
<div>
Monitor is built on the OpenAIRE Research Graph. An interconnected scholarly communication shared data
resource from open initiatives around the world, of global interest.
</div>
</div>
</div>
<div uk-parallax="y: 40, -60; easing: 0.5" class="uk-flex uk-flex-right">
<div class="part uk-width-3-4 uk-margin-medium-right">
<h5 class="uk-text-secondary">Transparent methodology</h5>
<div>
We base our service on open science principles. We rely on open data sources, and document our algorithms
for every metric and indicator we publish.
</div>
</div>
</div>
<div uk-parallax="y: -100; easing: 0.5">
<div class="part uk-width-3-4 uk-margin-medium-left">
<h5 class="uk-text-secondary">Customised to your needs</h5>
<div>
Choose from a variety of pre-defined metrics. Select how to visualize them, and who to share with. Use our
advanced tools and expertise add add your own metrics.
</div>
</div>
</div>
<div uk-parallax="y: -100; easing: 2" class="uk-flex uk-flex-center">
<div class="part uk-width-3-4 uk-margin-large-left">
<h5 class="uk-text-secondary">Minimum effort to join</h5>
<div>
You only share some information with us to include in out backend aggregating and data mining, and we
deliver a view of your world. As you see fit.
</div>
</div>
</div>
</div>
<div class="uk-hidden@m uk-grid uk-child-width-1-1" uk-grid>
<div>
<h5 class="uk-text-secondary">Global outlook</h5>
<div>
Monitor is built on the OpenAIRE Research Graph. An interconnected scholarly communication shared data
resource from open initiatives around the world, of global interest.
</div>
</div>
<div>
<h5 class="uk-text-secondary">Transparent methodology</h5>
<div>
We base our service on open science principles. We rely on open data sources, and document our algorithms for
every metric and indicator we publish.
</div>
</div>
<div>
<h5 class="uk-text-secondary">Customised to your needs</h5>
<div>
Choose from a variety of pre-defined metrics. Select how to visualize them, and who to share with. Use our
advanced tools and expertise add add your own metrics.
</div>
</div>
<div>
<h5 class="uk-text-secondary">Minimum effort to join</h5>
<div>
You only share some information with us to include in out backend aggregating and data mining, and we deliver
a view of your world. As you see fit.
</div>
</div>
</div>
</div>
<div class="uk-text-center uk-margin-large">
<a class="uk-button portal-button" routerLink="/about">Learn More</a>
</div>
<div class="uk-padding-small hologram uk-position-relative">
<div class="uk-grid uk-grid-match uk-child-width-1-2 uk-visible@m" uk-grid>
<div uk-parallax="y: 40, -60; easing: 0.5">
<div class="uk-margin-large-left uk-margin-large-bottom uk-width-3-4 part">
<h5 class="uk-text-secondary">Global outlook</h5>
<div>
Monitor is built on the OpenAIRE Research Graph. An interconnected scholarly communication shared data
resource from open initiatives around the world, of global interest.
</div>
</div>
</div>
<div uk-parallax="y: 40, -60; easing: 0.5" class="uk-flex uk-flex-right">
<div class="part uk-width-3-4 uk-margin-medium-right">
<h5 class="uk-text-secondary">Transparent methodology</h5>
<div>
We base our service on open science principles. We rely on open data sources, and document our algorithms
for every metric and indicator we publish.
</div>
</div>
</div>
<div uk-parallax="y: -100; easing: 0.5">
<div class="part uk-width-3-4 uk-margin-medium-left">
<h5 class="uk-text-secondary">Customised to your needs</h5>
<div>
Choose from a variety of pre-defined metrics. Select how to visualize them, and who to share with. Use our
advanced tools and expertise add add your own metrics.
</div>
</div>
</div>
<div uk-parallax="y: -100; easing: 2" class="uk-flex uk-flex-center">
<div class="part uk-width-3-4 uk-margin-large-left">
<h5 class="uk-text-secondary">Minimum effort to join</h5>
<div>
You only share some information with us to include in out backend aggregating and data mining, and we
deliver a view of your world. As you see fit.
</div>
</div>
</div>
</div>
<div class="uk-hidden@m uk-grid uk-child-width-1-1" uk-grid>
<div>
<h5 class="uk-text-secondary">Global outlook</h5>
<div>
Monitor is built on the OpenAIRE Research Graph. An interconnected scholarly communication shared data
resource from open initiatives around the world, of global interest.
</div>
</div>
<div>
<h5 class="uk-text-secondary">Transparent methodology</h5>
<div>
We base our service on open science principles. We rely on open data sources, and document our algorithms for
every metric and indicator we publish.
</div>
</div>
<div>
<h5 class="uk-text-secondary">Customised to your needs</h5>
<div>
Choose from a variety of pre-defined metrics. Select how to visualize them, and who to share with. Use our
advanced tools and expertise add add your own metrics.
</div>
</div>
<div>
<h5 class="uk-text-secondary">Minimum effort to join</h5>
<div>
You only share some information with us to include in out backend aggregating and data mining, and we deliver
a view of your world. As you see fit.
</div>
</div>
</div>
</div>
<div class="uk-text-center uk-margin-large">
<a class="uk-button portal-button" routerLink="/about">Learn More</a>
</div>
</div>
<div class="graph-section">
<div class="uk-section uk-container uk-margin-large">
<div class="uk-text-center uk-padding-small">
<h2>Tap into the OpenAIRE Research Graph</h2>
<div class="uk-flex uk-flex-center">
<div class="uk-width-3-4@m uk-margin-large-top uk-grid uk-child-width-1-5@m uk-child-width-1-2">
<div *ngIf="publicationsSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<span class="uk-text-bold number">{{publicationsSize.number|number}}</span>{{publicationsSize.size}}
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">publications</div>
</div>
<div *ngIf="datasetsSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<span class="uk-text-bold number">{{datasetsSize.number|number}}</span>{{datasetsSize.size}}
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">datasets</div>
</div>
<div *ngIf="softwareSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<span class="uk-text-bold number">{{softwareSize.number|number}}</span>{{softwareSize.size}}
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">software</div>
</div>
<div *ngIf="otherSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<span class="uk-text-bold number">{{otherSize.number|number}}</span>{{otherSize.size}}
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">other</div>
</div>
<div *ngIf="fundersSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<span class="uk-text-bold number">{{fundersSize.number|number}}</span>{{fundersSize.size}}
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">Funders</div>
</div>
</div>
</div>
</div>
</div>
<div class="uk-section uk-container uk-margin-large">
<div class="uk-text-center uk-padding-small">
<h2>Tap into the OpenAIRE Research Graph</h2>
<div class="uk-flex uk-flex-center">
<div class="uk-width-3-4@m uk-margin-large-top uk-grid uk-child-width-1-5@m uk-child-width-1-2">
<div *ngIf="publicationsSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<a class="uk-link-reset"
href="https://explore.openaire.eu/search/find/research-outcomes?type=publications" target=_blank>
<span class="uk-text-bold number">{{publicationsSize.number|number}}</span>{{publicationsSize.size}}
</a>
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">publications</div>
</div>
<div *ngIf="datasetsSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<a class="uk-link-reset" href="https://explore.openaire.eu/search/find/research-outcomes?type=datasets"
target=_blank>
<span class="uk-text-bold number">{{datasetsSize.number|number}}</span>{{datasetsSize.size}}
</a>
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">datasets</div>
</div>
<div *ngIf="softwareSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<a class="uk-link-reset" href="https://explore.openaire.eu/search/find/research-outcomes?type=software"
target="_blank">
<span class="uk-text-bold number">{{softwareSize.number|number}}</span>{{softwareSize.size}}
</a>
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">software</div>
</div>
<div *ngIf="otherSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<a class="uk-link-reset" href="https://explore.openaire.eu/search/find/research-outcomes?type=other"
target="_blank">
<span class="uk-text-bold number">{{otherSize.number|number}}</span>{{otherSize.size}}
</a>
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">other</div>
</div>
<div *ngIf="fundersSize" class="uk-margin-medium-bottom uk-text-center">
<h3 class="uk-margin-remove portal-color">
<a class="uk-link-reset" href="https://explore.openaire.eu/search/find/projects" target="_blank">
<span class="uk-text-bold number">{{fundersSize.number|number}}</span>{{fundersSize.size}}
</a>
</h3>
<div class="uk-margin-small uk-text-large uk-text-uppercase">Funders</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div *ngIf="loading && stakeholders.length === 0" class="uk-container uk-container-large uk-margin-large-bottom">
<errorMessages [status]="[status]" [type]="'stakeholders'"></errorMessages>
<errorMessages [status]="[status]" [type]="'stakeholders'"></errorMessages>
</div>
<div *ngIf="!loading && stakeholders && stakeholders.length > 0"
class="uk-section uk-section-large uk-margin-right uk-margin-left uk-margin-large-top stakeholder-section">
<div class="uk-container" uk-filter="target: .stakeholders">
<ul class="uk-subnav uk-subnav-pill">
<li class="uk-active" uk-filter-control><a (click)="type = null">All</a></li>
<li uk-filter-control="[data-type='funder']"><a (click)="type = 'funder'">Funders</a></li>
<li uk-filter-control="[data-type='ri']"><a (click)="type = 'ri'">Research Initiatives</a></li>
<!--<li uk-filter-control="[data-type='project']"><a (click)="type = 'project'">Projects</a></li>-->
<li uk-filter-control="[data-type='organization']"><a (click)="type = 'organization'">Organizations</a></li>
</ul>
<div class="stakeholders uk-margin-large-top uk-child-width-1-1 uk-child-width-1-2@s uk-child-width-1-3@m uk-grid uk-flex-top uk-flex-wrap-top"
uk-grid="masonry: true" uk-height-match="target: .uk-card; row: false;">
<div *ngFor="let stakeholder of stakeholders" [attr.data-type]="stakeholder.type">
<a *ngIf="directLink && hasPermission(stakeholder)" [href]="getStakeholderPageUrl(stakeholder)" target="_blank">
<div class="uk-card uk-card-default uk-text-center uk-position-relative">
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
</div>
</a>
<a *ngIf="!directLink && hasPermission(stakeholder)" (click)="confirmModalOpen(stakeholder)">
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
</a>
<ng-container *ngIf="!hasPermission(stakeholder)">
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
</ng-container>
</div>
<div *ngIf="stakeholdersNumber === 0" [attr.data-type]="type"
class="uk-text-center uk-text-large uk-width-1-1 uk-margin-large-top uk-padding-large">
Nothing here yet.
</div>
</div>
</div>
class="uk-section uk-section-large uk-margin-right uk-margin-left uk-margin-large-top stakeholder-section">
<div class="uk-container" uk-filter="target: .stakeholders">
<ul class="uk-subnav uk-subnav-pill">
<li class="uk-active" uk-filter-control><a (click)="type = null">All</a></li>
<li uk-filter-control="[data-type='funder']"><a (click)="type = 'funder'">Funders</a></li>
<li uk-filter-control="[data-type='ri']"><a (click)="type = 'ri'">Research Initiatives</a></li>
<!--<li uk-filter-control="[data-type='project']"><a (click)="type = 'project'">Projects</a></li>-->
<li uk-filter-control="[data-type='organization']"><a (click)="type = 'organization'">Institutions</a></li>
</ul>
<div
class="stakeholders uk-margin-large-top uk-child-width-1-1 uk-child-width-1-2@s uk-child-width-1-3@m uk-grid uk-flex-top uk-flex-wrap-top"
uk-grid="masonry: true" uk-height-match="target: .uk-card; row: false;">
<div *ngFor="let stakeholder of stakeholders" [attr.data-type]="stakeholder.type">
<a *ngIf="directLink && hasPermission(stakeholder)" [href]="getStakeholderPageUrl(stakeholder)" target="_blank">
<div class="uk-card uk-card-default uk-text-center uk-position-relative">
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
</div>
</a>
<a *ngIf="!directLink && hasPermission(stakeholder)" (click)="confirmModalOpen(stakeholder)">
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
</a>
<ng-container *ngIf="!hasPermission(stakeholder)">
<ng-container *ngTemplateOutlet="stakeholderCard; context: {stakeholder: stakeholder}"></ng-container>
</ng-container>
</div>
<div *ngIf="stakeholdersNumber === 0" [attr.data-type]="type"
class="uk-text-center uk-text-large uk-width-1-1 uk-margin-large-top uk-padding-large">
Nothing here yet.
</div>
</div>
</div>
</div>
<div style="background: linear-gradient(0deg, #FFFFFF 0%, #EFF3F8 0%, #FAFAFA 100%);">
<div class="uk-section uk-container uk-text-center uk-margin-large-bottom">
<div class="uk-padding-small">
<h3>Contact us to help you.</h3>
<div class="uk-text-muted uk-margin-medium">
Are you looking for more? Get in touch with our team and let us help you.
</div>
<a class="uk-button portal-button" routerLink="/contact-us">CONTACT US</a>
</div>
</div>
<div class="uk-section uk-container uk-text-center uk-margin-large-bottom">
<div class="uk-padding-small">
<h3>Contact us to help you.</h3>
<div class="uk-text-muted uk-margin-medium">
Are you looking for more? Get in touch with our team and let us help you.
</div>
<a class="uk-button portal-button" routerLink="/contact-us">CONTACT US</a>
</div>
</div>
</div>
<div class="uk-section-muted"
uk-scrollspy="{&quot;target&quot;:&quot;[uk-scrollspy-class]&quot;,&quot;cls&quot;:&quot;uk-animation-fade&quot;,&quot;delay&quot;:false}">
<div class="uk-container uk-container-large">
<other-portals [properties]="properties" portal="monitor"></other-portals>
</div>
uk-scrollspy="{&quot;target&quot;:&quot;[uk-scrollspy-class]&quot;,&quot;cls&quot;:&quot;uk-animation-fade&quot;,&quot;delay&quot;:false}">
<div class="uk-container uk-container-large">
<other-portals [properties]="properties" portal="monitor"></other-portals>
</div>
</div>
<modal-alert #AlertModal (alertOutput)="goToPage($event)">
<div class="uk-text-left">
You will be navigated to a new tab. Are you sure that you want to proceed?
</div>
<div class="uk-text-left">
You will be navigated to a new tab. Are you sure that you want to proceed?
</div>
</modal-alert>
<ng-template #stakeholderCard let-stakeholder="stakeholder">
<div class="uk-card uk-card-default uk-text-center" [class.disabled]="!hasPermission(stakeholder)">
<div *ngIf="stakeholder.visibility && stakeholder.visibility !== 'PUBLIC'"
class="uk-position-top-right uk-margin-top uk-margin-right uk-flex uk-flex-middle">
<icon [name]="visibilityIcon.get(stakeholder.visibility)"></icon>
<span class="space uk-text-small uk-text-capitalize">{{stakeholder.visibility.toLowerCase()}}</span>
</div>
<img *ngIf="stakeholder.logoUrl && stakeholder.isUpload" class="uk-margin-auto"
[src]="properties.utilsService + '/download/' + stakeholder.logoUrl">
<img *ngIf="stakeholder.logoUrl && !stakeholder.isUpload" class="uk-margin-auto" [src]="stakeholder.logoUrl | urlPrefix">
<div class="uk-text-light uk-margin-medium-top">{{stakeholder.name}}</div>
</div>
</ng-template>
<div class="uk-card uk-card-default uk-text-center" [class.disabled]="!hasPermission(stakeholder)">
<div *ngIf="stakeholder.visibility && stakeholder.visibility !== 'PUBLIC'"
class="uk-position-top-right uk-margin-top uk-margin-right uk-flex uk-flex-middle">
<icon [name]="visibilityIcon.get(stakeholder.visibility)"></icon>
<span class="space uk-text-small uk-text-capitalize">{{stakeholder.visibility.toLowerCase()}}</span>
</div>
<img *ngIf="stakeholder.logoUrl && stakeholder.isUpload" class="uk-margin-auto"
[src]="properties.utilsService + '/download/' + stakeholder.logoUrl">
<img *ngIf="stakeholder.logoUrl && !stakeholder.isUpload" class="uk-margin-auto"
[src]="stakeholder.logoUrl | urlPrefix">
<div class="uk-text-light uk-margin-medium-top">{{stakeholder.name}}</div>
</div>
</ng-template>

View File

@ -1,27 +1,27 @@
import {Component, ViewChild} from "@angular/core";
import {SearchUtilsClass} from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ErrorMessagesComponent} from "../openaireLibrary/utils/errorMessages.component";
import {ErrorCodes} from "../openaireLibrary/utils/properties/errorCodes";
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
import {ActivatedRoute} from "@angular/router";
import {AdvancedField, Filter, Value} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
import {SearchFields} from "../openaireLibrary/utils/properties/searchFields";
import {Session, User} from "../openaireLibrary/login/utils/helper.class";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {NewSearchPageComponent} from "../openaireLibrary/searchPages/searchUtils/newSearchPage.component";
import {StakeholderInfo} from "../openaireLibrary/monitor/entities/stakeholder";
import {properties} from "../../environments/environment";
import {Subscriber} from "rxjs";
import { Component, ViewChild } from "@angular/core";
import { SearchUtilsClass } from "../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import { ErrorMessagesComponent } from "../openaireLibrary/utils/errorMessages.component";
import { ErrorCodes } from "../openaireLibrary/utils/properties/errorCodes";
import { EnvProperties } from "../openaireLibrary/utils/properties/env-properties";
import { ActivatedRoute } from "@angular/router";
import { AdvancedField, Filter, Value } from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
import { SearchFields } from "../openaireLibrary/utils/properties/searchFields";
import { Session, User } from "../openaireLibrary/login/utils/helper.class";
import { StringUtils } from "../openaireLibrary/utils/string-utils.class";
import { UserManagementService } from "../openaireLibrary/services/user-management.service";
import { StakeholderService } from "../openaireLibrary/monitor/services/stakeholder.service";
import { NewSearchPageComponent } from "../openaireLibrary/searchPages/searchUtils/newSearchPage.component";
import { StakeholderInfo } from "../openaireLibrary/monitor/entities/stakeholder";
import { properties } from "../../environments/environment";
import { Subscriber } from "rxjs";
@Component({
selector: 'search-stakeholders',
template: `
selector: 'search-stakeholders',
template: `
<new-search-page pageTitle="OpenAIRE-Monitor | Browse"
[hasPrefix]=false [piwikSiteId]="piwikSiteId"
[formPlaceholderText]="'Search profiles'"
type="stakeholders" entityType="stakeholder"
type="organizations" entityType="stakeholder"
[results]="results" [searchUtils]="searchUtils"
[showResultCount]=true
[disableForms]="disableForms"
@ -33,442 +33,442 @@ import {Subscriber} from "rxjs";
`
})
export class SearchStakeholdersComponent {
public piwikSiteId = null;
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
public results: StakeholderInfo[] = [];
public totalResults: StakeholderInfo[] = [];
public subscriptions = [];
public filters = [];
public searchFields: SearchFields = new SearchFields();
public searchUtils: SearchUtilsClass = new SearchUtilsClass();
public selectedFields: AdvancedField[] = [];
public disableForms: boolean = false;
public baseUrl: string = null;
public fieldIds: string[] = ["q"];
public refineFields: string[] = this.searchFields.STAKEHOLDER_SEARCH_FIELDS;
public fieldIdsMap = {
["q"]: {
name: "All fields",
type: "keyword",
param: "q",
operator: "op",
equalityOperator: "=",
filterType: null
}
};
public keyword = "";
public searchLink;
properties: EnvProperties = properties;
@ViewChild(NewSearchPageComponent, {static: true}) searchPage: NewSearchPageComponent;
private user: User;
constructor(private route: ActivatedRoute,
private _stakeholderService: StakeholderService,
private userManagementService: UserManagementService) {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
this.searchUtils.status = this.errorCodes.LOADING;
}
public ngOnInit() {
this.piwikSiteId = this.properties.piwikSiteId;
this.baseUrl = this.properties.searchLinkToStakeholders;
this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.searchPage.resultsPerPage = 10;
this.keyword = (params['fv0'] ? params['fv0'] : '');
this.keyword = StringUtils.URIDecode(this.keyword);
this.searchUtils.page = (params['page'] === undefined) ? 1 : +params['page'];
this.searchUtils.sortBy = (params['sortBy'] === undefined) ? '' : params['sortBy'];
this.searchUtils.validateSize(params['size']);
this.searchUtils.baseUrl = this.baseUrl;
this.searchPage.searchUtils = this.searchUtils;
if (this.searchUtils.sortBy && this.searchUtils.sortBy != "creationdate,descending" && this.searchUtils.sortBy != "creationdate,ascending") {
this.searchUtils.sortBy = "";
}
this.searchPage.refineFields = this.refineFields;
this.searchLink = this.properties.searchLinkToStakeholders;
this.selectedFields = [];
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap, null, params, "stakeholder", null);
let queryParams = params;
if (typeof document !== 'undefined') {
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
this.initFunders(queryParams);
}));
} else {
this.initFunders(queryParams);
}
}));
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
/**
* Initialize stakeholders from Communities APIs
*
* @param params
*/
private initFunders(params) {
this.subscriptions.push(this._stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL).subscribe(
data => {
if (!data) {
return;
}
for (let i = 0; i < data.length; i++) {
this.totalResults[i] = data[i];
this.totalResults[i].isManager = this.isManager(data[i]);
this.totalResults[i].isMember = this.isMember(data[i]);
}
this._getResults(params);
},
err => {
this.handleError('Error getting stakeholders', err);
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
this.disableForms = false;
}
));
}
/**
* Get all stakeholders from mock API and apply permission access validator,
* keyword searching, filter, paging and sorting.
*
* @param params, status
* @private
*/
private _getResults(params) {
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
this.results = this.totalResults;
this.filters = this.createFilters();
this.searchUtils.totalResults = 0;
this.applyParams(params);
}
/**
* Apply permission access validator,
* keyword searching, filter, paging and sorting.
*
* @param params
* @param status
*/
public applyParams(params) {
if (this.keyword && this.keyword != '') {
this.searchForKeywords();
}
this.checkFilters(params);
this.sort();
this.searchUtils.totalResults = this.results.length;
this.filters = this.searchPage.prepareFiltersToShow(this.filters, this.searchUtils.totalResults);
this.results = this.results.slice((this.searchUtils.page - 1) * this.searchUtils.size, (this.searchUtils.page * this.searchUtils.size));
this.searchUtils.status = this.errorCodes.DONE;
if (this.searchUtils.totalResults == 0) {
this.searchUtils.status = this.errorCodes.NONE;
}
this.disableForms = false;
if (this.searchUtils.status == this.errorCodes.DONE) {
// Page out of limit!!!
let totalPages: any = this.searchUtils.totalResults / (this.searchUtils.size);
if (!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1);
}
if (totalPages < this.searchUtils.page) {
this.searchUtils.totalResults = 0;
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
}
}
}
/**
* Parse the given keywords into array and check if any of the requirements field of a funder includes
* one of the given words.
*/
private searchForKeywords() {
let ret = [];
let keywords: string[] = this.keyword.split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
for (let i = 0; i < this.results.length; i++) {
for (let keyword of keywords) {
keyword = keyword.toLowerCase();
if (keyword != '' && (StringUtils.containsWord(this.results[i].name, keyword) || StringUtils.containsWord(this.results[i].index_shortName, keyword) ||
StringUtils.containsWord(this.results[i].alias, keyword) || StringUtils.containsWord(this.results[i].description, keyword))) {
ret.push(this.results[i]);
break;
}
}
}
this.results = ret;
}
/**
* Check the current results if they satisfy the values of each filter category and
* update the number of possible results in each value.
*
* @param params
*/
private checkFilters(params) {
let typeResults: StakeholderInfo[] = this.applyFilter('type', params);
let accessResults: StakeholderInfo[] = this.results;
let roleResults: StakeholderInfo[] = this.results;
accessResults = this.applyFilter('access', params);
roleResults = this.applyFilter('role', params);
this.resetFilterNumbers('access');
this.updateFilterNumbers(typeResults.filter(value => {
return roleResults.includes(value);
}), 'access');
if (this.user) {
this.resetFilterNumbers('role');
this.updateFilterNumbers(accessResults.filter(value => {
return typeResults.includes(value);
}), 'role');
}
this.resetFilterNumbers('type');
this.updateFilterNumbers(accessResults.filter(value => {
return roleResults.includes(value);
}), 'type');
this.results = accessResults.filter(value => {
return typeResults.includes(value);
})
this.results = this.results.filter(value => {
return roleResults.includes(value);
});
}
/**
* Apply filter with filterId and return the results
*
* @param filterId
* @param params
*/
private applyFilter(filterId: string, params): StakeholderInfo[] {
let results = [];
let values: string[] = [];
if (params[filterId]) {
values = (StringUtils.URIDecode(params[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
}
if (filterId == 'type') {
for (let i = 0; i < this.results.length; i++) {
if (values.length == 0) {
results.push(this.results[i]);
} else {
for (let value of values) {
if (this.results[i].type == value.replace(/["']/g, "")) {
results.push(this.results[i]);
break;
}
}
}
}
} else if (filterId == 'access') {
for (let i = 0; i < this.results.length; i++) {
if (values.length == 0) {
results.push(this.results[i]);
} else {
for (let value of values) {
if (value.replace(/["']/g, "") == 'public') {
if (this.results[i].visibility === 'PUBLIC') {
results.push(this.results[i]);
break;
}
} else if (value.replace(/["']/g, "") == 'restricted') {
if (this.results[i].visibility === 'RESTRICTED') {
results.push(this.results[i]);
break;
}
} /*else if (value.replace(/["']/g, "") == 'private') {
public piwikSiteId = null;
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
public results: StakeholderInfo[] = [];
public totalResults: StakeholderInfo[] = [];
public subscriptions = [];
public filters = [];
public searchFields: SearchFields = new SearchFields();
public searchUtils: SearchUtilsClass = new SearchUtilsClass();
public selectedFields: AdvancedField[] = [];
public disableForms: boolean = false;
public baseUrl: string = null;
public fieldIds: string[] = ["q"];
public refineFields: string[] = this.searchFields.STAKEHOLDER_SEARCH_FIELDS;
public fieldIdsMap = {
["q"]: {
name: "All fields",
type: "keyword",
param: "q",
operator: "op",
equalityOperator: "=",
filterType: null
}
};
public keyword = "";
public searchLink;
properties: EnvProperties = properties;
@ViewChild(NewSearchPageComponent, { static: true }) searchPage: NewSearchPageComponent;
private user: User;
constructor(private route: ActivatedRoute,
private _stakeholderService: StakeholderService,
private userManagementService: UserManagementService) {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
this.searchUtils.status = this.errorCodes.LOADING;
}
public ngOnInit() {
this.piwikSiteId = this.properties.piwikSiteId;
this.baseUrl = this.properties.searchLinkToStakeholders;
this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.searchPage.resultsPerPage = 10;
this.keyword = (params['fv0'] ? params['fv0'] : '');
this.keyword = StringUtils.URIDecode(this.keyword);
this.searchUtils.page = (params['page'] === undefined) ? 1 : +params['page'];
this.searchUtils.sortBy = (params['sortBy'] === undefined) ? '' : params['sortBy'];
this.searchUtils.validateSize(params['size']);
this.searchUtils.baseUrl = this.baseUrl;
this.searchPage.searchUtils = this.searchUtils;
if (this.searchUtils.sortBy && this.searchUtils.sortBy != "creationdate,descending" && this.searchUtils.sortBy != "creationdate,ascending") {
this.searchUtils.sortBy = "";
}
this.searchPage.refineFields = this.refineFields;
this.searchLink = this.properties.searchLinkToStakeholders;
this.selectedFields = [];
this.searchPage.prepareSearchPage(this.fieldIds, this.selectedFields, this.refineFields, [], this.fieldIdsMap, null, params, "stakeholder", null);
let queryParams = params;
if (typeof document !== 'undefined') {
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
this.initFunders(queryParams);
}));
} else {
this.initFunders(queryParams);
}
}));
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
/**
* Initialize stakeholders from Communities APIs
*
* @param params
*/
private initFunders(params) {
this.subscriptions.push(this._stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL).subscribe(
data => {
if (!data) {
return;
}
for (let i = 0; i < data.length; i++) {
this.totalResults[i] = data[i];
this.totalResults[i].isManager = this.isManager(data[i]);
this.totalResults[i].isMember = this.isMember(data[i]);
}
this._getResults(params);
},
err => {
this.handleError('Error getting stakeholders', err);
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
this.disableForms = false;
}
));
}
/**
* Get all stakeholders from mock API and apply permission access validator,
* keyword searching, filter, paging and sorting.
*
* @param params, status
* @private
*/
private _getResults(params) {
this.searchUtils.status = this.errorCodes.LOADING;
this.disableForms = true;
this.results = this.totalResults;
this.filters = this.createFilters();
this.searchUtils.totalResults = 0;
this.applyParams(params);
}
/**
* Apply permission access validator,
* keyword searching, filter, paging and sorting.
*
* @param params
* @param status
*/
public applyParams(params) {
if (this.keyword && this.keyword != '') {
this.searchForKeywords();
}
this.checkFilters(params);
this.sort();
this.searchUtils.totalResults = this.results.length;
this.filters = this.searchPage.prepareFiltersToShow(this.filters, this.searchUtils.totalResults);
this.results = this.results.slice((this.searchUtils.page - 1) * this.searchUtils.size, (this.searchUtils.page * this.searchUtils.size));
this.searchUtils.status = this.errorCodes.DONE;
if (this.searchUtils.totalResults == 0) {
this.searchUtils.status = this.errorCodes.NONE;
}
this.disableForms = false;
if (this.searchUtils.status == this.errorCodes.DONE) {
// Page out of limit!!!
let totalPages: any = this.searchUtils.totalResults / (this.searchUtils.size);
if (!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1);
}
if (totalPages < this.searchUtils.page) {
this.searchUtils.totalResults = 0;
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
}
}
}
/**
* Parse the given keywords into array and check if any of the requirements field of a funder includes
* one of the given words.
*/
private searchForKeywords() {
let ret = [];
let keywords: string[] = this.keyword.split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
for (let i = 0; i < this.results.length; i++) {
for (let keyword of keywords) {
keyword = keyword.toLowerCase();
if (keyword != '' && (StringUtils.containsWord(this.results[i].name, keyword) || StringUtils.containsWord(this.results[i].index_shortName, keyword) ||
StringUtils.containsWord(this.results[i].alias, keyword) || StringUtils.containsWord(this.results[i].description, keyword))) {
ret.push(this.results[i]);
break;
}
}
}
this.results = ret;
}
/**
* Check the current results if they satisfy the values of each filter category and
* update the number of possible results in each value.
*
* @param params
*/
private checkFilters(params) {
let typeResults: StakeholderInfo[] = this.applyFilter('type', params);
let accessResults: StakeholderInfo[] = this.results;
let roleResults: StakeholderInfo[] = this.results;
accessResults = this.applyFilter('access', params);
roleResults = this.applyFilter('role', params);
this.resetFilterNumbers('access');
this.updateFilterNumbers(typeResults.filter(value => {
return roleResults.includes(value);
}), 'access');
if (this.user) {
this.resetFilterNumbers('role');
this.updateFilterNumbers(accessResults.filter(value => {
return typeResults.includes(value);
}), 'role');
}
this.resetFilterNumbers('type');
this.updateFilterNumbers(accessResults.filter(value => {
return roleResults.includes(value);
}), 'type');
this.results = accessResults.filter(value => {
return typeResults.includes(value);
})
this.results = this.results.filter(value => {
return roleResults.includes(value);
});
}
/**
* Apply filter with filterId and return the results
*
* @param filterId
* @param params
*/
private applyFilter(filterId: string, params): StakeholderInfo[] {
let results = [];
let values: string[] = [];
if (params[filterId]) {
values = (StringUtils.URIDecode(params[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/, -1);
}
if (filterId == 'type') {
for (let i = 0; i < this.results.length; i++) {
if (values.length == 0) {
results.push(this.results[i]);
} else {
for (let value of values) {
if (this.results[i].type == value.replace(/["']/g, "")) {
results.push(this.results[i]);
break;
}
}
}
}
} else if (filterId == 'access') {
for (let i = 0; i < this.results.length; i++) {
if (values.length == 0) {
results.push(this.results[i]);
} else {
for (let value of values) {
if (value.replace(/["']/g, "") == 'public') {
if (this.results[i].visibility === 'PUBLIC') {
results.push(this.results[i]);
break;
}
} else if (value.replace(/["']/g, "") == 'restricted') {
if (this.results[i].visibility === 'RESTRICTED') {
results.push(this.results[i]);
break;
}
} /*else if (value.replace(/["']/g, "") == 'private') {
if (this.results[i].visibility === 'PRIVATE') {
results.push(this.results[i]);
break;
}
}*/
}
}
}
} else if (filterId == 'role') {
for (let i = 0; i < this.results.length; i++) {
if (values.length == 0) {
results.push(this.results[i]);
} else {
for (let value of values) {
if (value.replace(/["']/g, "") == 'manager') {
if (this.results[i].isManager) {
results.push(this.results[i]);
break;
}
}
if (value.replace(/["']/g, "") == 'member') {
if (this.results[i].isMember) {
results.push(this.results[i]);
break;
}
}
}
}
}
}
return results;
}
/**
* Reset the values of filter with id filterId with zero.
*
* @param filterId
*/
private resetFilterNumbers(filterId: string) {
for (let i = 0; i < this.filters.length; i++) {
if (this.filters[i].filterId == filterId) {
for (let j = 0; j < this.filters[i].values.length; j++) {
this.filters[i].values[j].number = 0;
}
break;
}
}
}
/**
* Update the values of filter with id filterId based on
* results.
*
* @param results
* @param filterId
*/
private updateFilterNumbers(results: StakeholderInfo[], filterId: string) {
for (let k = 0; k < results.length; k++) {
for (let i = 0; i < this.filters.length; i++) {
if (this.filters[i].filterId == filterId) {
if (this.filters[i].filterId == 'type') {
for (let j = 0; j < this.filters[i].values.length; j++) {
if (results[k].type == this.filters[i].values[j].id) {
this.filters[i].values[j].number++;
}
}
} else if (this.filters[i].filterId == 'access') {
if (results[k].visibility === 'PUBLIC') {
this.filters[i].values[0].number++;
} else if (results[k].visibility === 'RESTRICTED') {
this.filters[i].values[1].number++;
} else {
this.filters[i].values[2].number++;
}
} else if (this.filters[i].filterId == 'role') {
if (results[k].isManager) {
this.filters[i].values[0].number++;
}
if (results[k].isMember) {
this.filters[i].values[1].number++;
}
}
break;
}
}
}
}
/**
* Sorting results based on sortBy.
*/
private sort() {
if (this.searchUtils.sortBy == '') {
this.results.sort((left, right): number => {
if (left.name > right.name) {
return 1;
} else if (left.name < right.name) {
return -1;
} else {
return 0;
}
})
} else if (this.searchUtils.sortBy == 'creationdate,descending') {
this.results.sort((left, right): number => {
if (!right.creationDate || left.creationDate > right.creationDate) {
return -1;
} else if (!left.creationDate || left.creationDate < right.creationDate) {
return 1;
} else {
return 0;
}
})
} else if (this.searchUtils.sortBy == 'creationdate,ascending') {
this.results.sort((left, right): number => {
if (!right.creationDate || left.creationDate > right.creationDate) {
return 1;
} else if (!left.creationDate || left.creationDate < right.creationDate) {
return -1;
} else {
return 0;
}
})
}
}
private isManager(stakeholder) {
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user)
|| Session.isCommunityCurator(this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user);
}
private isMember(stakeholder) {
return this.isManager(stakeholder) || Session.isSubscribedTo(stakeholder.type, stakeholder.alias, this.user);
}
/**
* Create Search Stakeholder filters.
*
*/
private createFilters(): Filter[] {
let filter_names = [];
let filter_ids = [];
let value_names = [];
let value_original_ids = [];
filter_names.push("Type");
filter_ids.push("type");
value_names.push(["Funders", "Research Initiatives", "Organizations"]);
value_original_ids.push(["funder", "ri", "organization"]);
filter_names.push("Accessibility");
filter_ids.push("access");
if(!this.user) {
value_names.push(["Public", "Restricted"]);
value_original_ids.push(["public", "restricted"]);
} else {
value_names.push(["Public", "Restricted", "Private"]);
value_original_ids.push(["public", "restricted", "private"]);
filter_names.push("Role");
filter_ids.push("role");
value_names.push(["Manager", "Member"]);
value_original_ids.push(["manager", "member"]);
}
let filters: Filter[] = [];
for (let i = 0; i < filter_names.length; i++) {
let values: Value[] = [];
for (let j = 0; j < value_names[i].length; j++) {
let value: Value = {name: value_names[i][j], id: value_original_ids[i][j], number: 0, selected: false};
values.push(value);
}
let filter: Filter = {
title: filter_names[i],
filterId: filter_ids[i],
originalFilterId: this.refineFields[i],
values: values,
countSelectedValues: 0,
"filterOperator": 'or',
valueIsExact: true,
filterType: "checkbox"
};
filters.push(filter);
}
return filters;
}
private handleError(message: string, error) {
console.error('Communities Search Page: ' + message, error);
}
}
}
}
} else if (filterId == 'role') {
for (let i = 0; i < this.results.length; i++) {
if (values.length == 0) {
results.push(this.results[i]);
} else {
for (let value of values) {
if (value.replace(/["']/g, "") == 'manager') {
if (this.results[i].isManager) {
results.push(this.results[i]);
break;
}
}
if (value.replace(/["']/g, "") == 'member') {
if (this.results[i].isMember) {
results.push(this.results[i]);
break;
}
}
}
}
}
}
return results;
}
/**
* Reset the values of filter with id filterId with zero.
*
* @param filterId
*/
private resetFilterNumbers(filterId: string) {
for (let i = 0; i < this.filters.length; i++) {
if (this.filters[i].filterId == filterId) {
for (let j = 0; j < this.filters[i].values.length; j++) {
this.filters[i].values[j].number = 0;
}
break;
}
}
}
/**
* Update the values of filter with id filterId based on
* results.
*
* @param results
* @param filterId
*/
private updateFilterNumbers(results: StakeholderInfo[], filterId: string) {
for (let k = 0; k < results.length; k++) {
for (let i = 0; i < this.filters.length; i++) {
if (this.filters[i].filterId == filterId) {
if (this.filters[i].filterId == 'type') {
for (let j = 0; j < this.filters[i].values.length; j++) {
if (results[k].type == this.filters[i].values[j].id) {
this.filters[i].values[j].number++;
}
}
} else if (this.filters[i].filterId == 'access') {
if (results[k].visibility === 'PUBLIC') {
this.filters[i].values[0].number++;
} else if (results[k].visibility === 'RESTRICTED') {
this.filters[i].values[1].number++;
} else {
this.filters[i].values[2].number++;
}
} else if (this.filters[i].filterId == 'role') {
if (results[k].isManager) {
this.filters[i].values[0].number++;
}
if (results[k].isMember) {
this.filters[i].values[1].number++;
}
}
break;
}
}
}
}
/**
* Sorting results based on sortBy.
*/
private sort() {
if (this.searchUtils.sortBy == '') {
this.results.sort((left, right): number => {
if (left.name > right.name) {
return 1;
} else if (left.name < right.name) {
return -1;
} else {
return 0;
}
})
} else if (this.searchUtils.sortBy == 'creationdate,descending') {
this.results.sort((left, right): number => {
if (!right.creationDate || left.creationDate > right.creationDate) {
return -1;
} else if (!left.creationDate || left.creationDate < right.creationDate) {
return 1;
} else {
return 0;
}
})
} else if (this.searchUtils.sortBy == 'creationdate,ascending') {
this.results.sort((left, right): number => {
if (!right.creationDate || left.creationDate > right.creationDate) {
return 1;
} else if (!left.creationDate || left.creationDate < right.creationDate) {
return -1;
} else {
return 0;
}
})
}
}
private isManager(stakeholder) {
return Session.isPortalAdministrator(this.user) || Session.isMonitorCurator(this.user)
|| Session.isCommunityCurator(this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user);
}
private isMember(stakeholder) {
return this.isManager(stakeholder) || Session.isSubscribedTo(stakeholder.type, stakeholder.alias, this.user);
}
/**
* Create Search Stakeholder filters.
*
*/
private createFilters(): Filter[] {
let filter_names = [];
let filter_ids = [];
let value_names = [];
let value_original_ids = [];
filter_names.push("Type");
filter_ids.push("type");
value_names.push(["Funders", "Research Initiatives", "Institutions"]);
value_original_ids.push(["funder", "ri", "organization"]);
filter_names.push("Accessibility");
filter_ids.push("access");
if (!this.user) {
value_names.push(["Public", "Restricted"]);
value_original_ids.push(["public", "restricted"]);
} else {
value_names.push(["Public", "Restricted", "Private"]);
value_original_ids.push(["public", "restricted", "private"]);
filter_names.push("Role");
filter_ids.push("role");
value_names.push(["Manager", "Member"]);
value_original_ids.push(["manager", "member"]);
}
let filters: Filter[] = [];
for (let i = 0; i < filter_names.length; i++) {
let values: Value[] = [];
for (let j = 0; j < value_names[i].length; j++) {
let value: Value = { name: value_names[i][j], id: value_original_ids[i][j], number: 0, selected: false };
values.push(value);
}
let filter: Filter = {
title: filter_names[i],
filterId: filter_ids[i],
originalFilterId: this.refineFields[i],
values: values,
countSelectedValues: 0,
"filterOperator": 'or',
valueIsExact: true,
filterType: "checkbox"
};
filters.push(filter);
}
return filters;
}
private handleError(message: string, error) {
console.error('Communities Search Page: ' + message, error);
}
}