Merge irish-monitor to develop #11

Merged
k.triantafyllou merged 6 commits from irish-monitor into develop 2024-02-13 10:03:22 +01:00
6 changed files with 72 additions and 558 deletions

View File

@ -18,7 +18,7 @@ import {LinksResolver} from "./search/links-resolver";
import {Header} from "./openaireLibrary/sharedComponents/navigationBar.component";
import {properties} from "../environments/environment";
import {ConfigurationService} from "./openaireLibrary/utils/configuration/configuration.service";
import {StakeholderUtils} from "./openaireLibrary/monitor-admin/utils/indicator-utils";
import {StakeholderConfiguration, StakeholderUtils} from "./openaireLibrary/monitor-admin/utils/indicator-utils";
import {SmoothScroll} from "./openaireLibrary/utils/smooth-scroll";
import {ConnectHelper} from "./openaireLibrary/connect/connectHelper";
import {ResourcesService} from "./openaireLibrary/monitor/services/resources.service";
@ -26,6 +26,8 @@ import {StringUtils} from "./openaireLibrary/utils/string-utils.class";
import {
NotificationConfiguration
} from "./openaireLibrary/notifications/notifications-sidebar/notifications-sidebar.component";
import {StakeholderBaseComponent} from "./openaireLibrary/monitor-admin/utils/stakeholder-base.component";
import {SidebarBaseComponent} from "./openaireLibrary/dashboard/sharedComponents/sidebar/sidebar-base.component";
@Component({
@ -33,12 +35,9 @@ import {
templateUrl: './app.component.html',
styleUrls: ['app.component.less']
})
export class AppComponent implements OnInit, OnDestroy {
properties: EnvProperties = properties;
export class AppComponent extends SidebarBaseComponent implements OnInit {
user: User;
updateStakeholder: boolean = true;
params: BehaviorSubject<Params> = new BehaviorSubject<Params>(null);
data: BehaviorSubject<Data> = new BehaviorSubject<Data>(null);
hasSidebar: boolean = false;
hasHeader: boolean = false;
hasAdminMenu: boolean = false;
@ -46,13 +45,10 @@ export class AppComponent implements OnInit, OnDestroy {
isFrontPage: boolean = false;
isMobile: boolean = false;
view: Visibility;
sideBarItems: MenuItem[] = [];
backItem: MenuItem = null;
menuItems: MenuItem[] = [];
notificationGroupsInitialized: boolean = false;
notificationConfiguration: NotificationConfiguration = new NotificationConfiguration();
stakeholderUtils: StakeholderUtils = new StakeholderUtils();
public stakeholderEntities = StakeholderEntities;
menuHeader: Header = {
route: "/",
url: null,
@ -73,38 +69,25 @@ export class AppComponent implements OnInit, OnDestroy {
innerWidth;
projectUpdate: 'danger' | 'warning';
paramsSubscription: Subscription;
private subscriptions: any[] = [];
constructor(private route: ActivatedRoute,
private router: Router,
constructor(protected _route: ActivatedRoute,
protected _router: Router,
protected layoutService: LayoutService,
protected cdr: ChangeDetectorRef,
private userManagementService: UserManagementService,
private layoutService: LayoutService,
private smoothScroll: SmoothScroll,
private stakeholderService: StakeholderService,
private cdr: ChangeDetectorRef,
private configurationService: ConfigurationService,
private resourcesService: ResourcesService) {
this.subscriptions.push(this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
let r = this.route;
while (r.firstChild) {
r = r.firstChild;
}
this.paramsResolved = true;
this.params.next(r.snapshot.params);
this.data.next(r.snapshot.data);
}
}));
super();
this.initRouterParams(_route);
}
ngOnInit() {
super.ngOnInit();
if (typeof document !== 'undefined' && window) {
this.innerWidth = window.innerWidth;
}
this.subscriptions.push(this.layoutService.hasSidebar.subscribe(hasSidebar => {
this.hasSidebar = hasSidebar;
this.cdr.detectChanges();
}));
this.subscriptions.push(this.layoutService.hasHeader.subscribe(hasHeader => {
this.hasHeader = hasHeader;
this.cdr.detectChanges();
@ -113,10 +96,6 @@ export class AppComponent implements OnInit, OnDestroy {
this.hasAdminMenu = hasAdminMenu;
this.cdr.detectChanges();
}));
this.subscriptions.push(this.layoutService.hasInternalSidebar.subscribe(hasInternalSidebar => {
this.hasInternalSidebar = hasInternalSidebar;
this.cdr.detectChanges();
}));
this.subscriptions.push(this.layoutService.isFrontPage.subscribe(isFrontPage => {
this.isFrontPage = isFrontPage;
this.cdr.detectChanges();
@ -125,13 +104,12 @@ export class AppComponent implements OnInit, OnDestroy {
this.isMobile = isMobile;
this.cdr.detectChanges();
}));
this.route.queryParams.subscribe(params => {
this._route.queryParams.subscribe(params => {
this.view = params['view'];
if(this.stakeholder) {
this.setSideBar();
}
});
this.layoutService.setOpen(true);
this.subscriptions.push(this.data.subscribe(data => {
if (data && data.portal) {
this.setProperties(data.portal);
@ -139,7 +117,7 @@ export class AppComponent implements OnInit, OnDestroy {
}
}));
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.updateStakeholder = !this.router.url.includes('user-info');
this.updateStakeholder = !this._router.url.includes('user-info');
if (user) {
this.user = user;
if (!this.notificationGroupsInitialized) {
@ -258,14 +236,10 @@ export class AppComponent implements OnInit, OnDestroy {
}
public ngOnDestroy() {
super.ngOnDestroy();
if(this.paramsSubscription) {
this.paramsSubscription.unsubscribe();
}
this.subscriptions.forEach(value => {
if (value instanceof Subscriber) {
value.unsubscribe();
}
});
this.userManagementService.clearSubscriptions();
this.layoutService.clearSubscriptions();
this.stakeholderService.clearSubscriptions();
@ -274,25 +248,17 @@ export class AppComponent implements OnInit, OnDestroy {
}
private navigateToError() {
this.router.navigate([this.properties.errorLink], {queryParams: {'page': this.properties.baseLink + this.router.url}});
this._router.navigate([this.properties.errorLink], {queryParams: {'page': this.properties.baseLink + this._router.url}});
}
public removeView() {
this.router.navigate([], {relativeTo: this.route});
this._router.navigate([], {relativeTo: this._route});
}
public login() {
this.userManagementService.login();
}
public get open() {
return this.layoutService.open;
}
public get hover() {
return this.layoutService.hover;
}
get isHidden() {
return this.stakeholder && !this.hasPermission(this.view?this.view:this.stakeholder.visibility);
}
@ -419,7 +385,7 @@ export class AppComponent implements OnInit, OnDestroy {
menuPosition: "center"
};
this.menuItems.push(
new MenuItem("stakeholders", "Browse " + this.stakeholderEntities.STAKEHOLDERS,
new MenuItem("stakeholders", "Browse " + this.stakeholderUtils.entities.stakeholders,
this.monitorLink + '/browse', "", false, [], null, {}, null, null, null, null, "_self")
);
this.resourcesService.setResources(this.menuItems, '', this.monitorLink);

View File

@ -47,7 +47,7 @@
<sidebar-mobile-toggle *ngIf="isMobile" [class.uk-margin-bottom]="!activeCategory || countSubCategoriesToShow(activeCategory) <= 1" class="uk-margin-top uk-display-block"></sidebar-mobile-toggle>
<div *ngIf="activeCategory && countSubCategoriesToShow(activeCategory) > 1"
[class.uk-margin-bottom]="isMobile" class="uk-margin-medium-top">
<slider-tabs *ngIf="stakeholder && status === errorCodes.DONE && activeTopic" [border]="!isMobile"
<slider-tabs *ngIf="stakeholder && !loading && activeTopic" [border]="!isMobile"
[tabsClass]="isMobile?'uk-subnav uk-subnav-pill-alt uk-text-small':'uk-tab'" [type]="'dynamic'">
<ng-template ngFor [ngForOf]="activeCategory.subCategories" let-subCategory>
<slider-tab *ngIf="hasPermission(subCategory.visibility)" [tabTitle]="subCategory.name"
@ -103,7 +103,7 @@
<div *ngIf="hasPermission(indicator.visibility)" [ngClass]="getNumberClassBySize(indicator.width)">
<div class="uk-card uk-card-default uk-padding-small number-card uk-position-relative"
[class.semiFiltered]="indicator.indicatorPaths[0].filtersApplied < countSelectedFilters()">
<div *ngIf="!indicator.descriptionOverlay">
<div *ngIf="!indicator.overlay">
<div
class="uk-text-small uk-text-truncate uk-margin-xsmall-bottom uk-margin-right">{{indicator.name}}</div>
<div class="number uk-text-small uk-text-bold">
@ -114,7 +114,7 @@
<div *ngIf="indicator.description || indicator.additionalDescription"
class="uk-position-top-right uk-text-center uk-margin-small-top uk-margin-small-right uk-visible@m">
<a class="uk-display-inline-block uk-button uk-button-link" uk-tooltip="Note"
(click)="toggleDescriptionOverlay($event, indicator)">
(click)="changeOverlay($event, indicator, 'description')">
<span class="uk-flex uk-flex-middle">
<icon name="analytics" type="outlined" [flex]="true"></icon>
</span>
@ -122,12 +122,12 @@
</div>
</div>
<div
*ngIf="indicator.descriptionOverlay && (indicator.description || indicator.additionalDescription)"
*ngIf="indicator.overlay && (indicator.description || indicator.additionalDescription)"
click-outside-or-esc class="uk-overflow-auto"
(clickOutside)="closeDescriptionOverlay($event, indicator)">
(clickOutside)="closeOverlay($event, indicator)">
<div class="uk-position-top-right uk-text-center uk-margin-small-top uk-margin-small-right">
<a class="uk-display-inline-block uk-button uk-button-link"
(click)="toggleDescriptionOverlay($event, indicator)">
(click)="changeOverlay($event, indicator, false)">
<span class="uk-flex uk-flex-middle">
<icon name="close" type="outlined" [flex]="true"></icon>
</span>
@ -154,7 +154,7 @@
<ng-template ngFor [ngForOf]="number.indicators" let-indicator let-j="index">
<div *ngIf="hasPermission(indicator.visibility)" [ngClass]="getNumberClassBySize(indicator.width)">
<div [class.semiFiltered]="indicator.indicatorPaths[0].filtersApplied < countSelectedFilters()">
<div *ngIf="!indicator.descriptionOverlay">
<div *ngIf="!indicator.overlay">
<div
class="uk-text-xsmall uk-text-truncate uk-margin-xsmall-bottom uk-margin-right">{{indicator.name}}</div>
<div class="number uk-text-small uk-text-bold">
@ -183,8 +183,8 @@
<div class="uk-card uk-card-default uk-position-relative"
[class.semiFiltered]="chartsActiveType.get(i + '-' + j).filtersApplied < countSelectedFilters()">
<div class="uk-card-body uk-text-center uk-margin-small-bottom">
<h6 class="uk-margin-bottom chartTitle uk-flex uk-flex-bottom ">
<div>{{indicator.name + " "}}</div>
<h6 class="uk-margin-bottom chartTitle uk-flex uk-flex-bottom">
{{indicator.name + " "}}
</h6>
<div *ngIf="indicator.indicatorPaths.length > 1" class="uk-button-group">
<button *ngFor="let indicatorPath of indicator.indicatorPaths;"
@ -212,23 +212,22 @@
class="uk-width-1-1 uk-blend-multiply"
[ngClass]="'uk-height-' + (indicator.height?indicator.height.toLowerCase():'medium')">
</div>
<div *ngIf="indicator.description || indicator.additionalDescription"
class="uk-position-bottom-left uk-margin-left uk-margin-small-bottom uk-visible@m">
<a class="uk-display-inline-block uk-button uk-button-text"
(click)="toggleDescriptionOverlay($event, indicator)">
<div class="uk-position-bottom-left uk-margin-left uk-margin-small-bottom uk-visible@m">
<a *ngIf="indicator.description || indicator.additionalDescription"
class="uk-display-inline-block uk-button uk-button-text"
(click)="changeOverlay($event, indicator, 'description')">
<span class="uk-flex uk-flex-middle">
<icon name="analytics" type="outlined" [flex]="true"></icon>
<span class="uk-margin-small-left">Note</span>
</span>
</a>
</div>
<div *ngIf="indicator.descriptionOverlay && (indicator.description || indicator.additionalDescription)"
class="indicator-overlay uk-card uk-card-default uk-flex uk-flex-middle uk-flex-center">
<div class="inner" click-outside-or-esc
(clickOutside)="closeDescriptionOverlay($event, indicator)">
<div *ngIf="indicator.overlay" class="indicator-overlay uk-card uk-card-default uk-flex uk-flex-middle uk-flex-center">
<div *ngIf="indicator.overlay == 'description'" class="inner" click-outside-or-esc
(clickOutside)="closeOverlay($event, indicator)">
<div class="uk-padding-small">
<div class="uk-flex uk-flex-right">
<button class="uk-close uk-icon" (click)="toggleDescriptionOverlay($event, indicator)">
<button class="uk-close uk-icon" (click)="changeOverlay($event, indicator, false)">
<icon name="close" ratio="1"></icon>
</button>
</div>
@ -320,7 +319,7 @@
</div>
</div>
<!-- <div *ngIf="stakeholder && status === errorCodes.DONE && activeTopic" id="print_toggle"
<!-- <div *ngIf="stakeholder && !loading && activeTopic" id="print_toggle"
class="uk-offcanvas-switcher uk-flex uk-flex-center uk-flex-middle" (click)="printReport()">
<icon name="print" ratio="1.5" customClass="uk-text-background" visuallyHidden="Print"></icon>
</div> -->

View File

@ -1,115 +1,47 @@
import {ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit, ViewChild, ViewRef} from '@angular/core';
import {ActivatedRoute, Params, Router} from '@angular/router';
import {ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {DomSanitizer, Meta, Title} from '@angular/platform-browser';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {Dates, StringUtils} from '../openaireLibrary/utils/string-utils.class';
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../openaireLibrary/utils/errorMessages.component';
import {HelperService} from "../openaireLibrary/utils/helper/helper.service";
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
import {SEOService} from "../openaireLibrary/sharedComponents/SEO/SEO.service";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {
Category,
Indicator,
IndicatorPath,
IndicatorSize,
Section,
Stakeholder,
SubCategory,
Topic,
Visibility
} from "../openaireLibrary/monitor/entities/stakeholder";
import {IndicatorPath} from "../openaireLibrary/monitor/entities/stakeholder";
import {StatisticsService} from "../openaireLibrary/monitor-admin/utils/services/statistics.service";
import {IndicatorUtils} from "../openaireLibrary/monitor-admin/utils/indicator-utils";
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {UntypedFormBuilder, UntypedFormControl} from "@angular/forms";
import {Subscriber, Subscription} from "rxjs";
import {Session, User} from "../openaireLibrary/login/utils/helper.class";
import {Subscription} from "rxjs";
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {RangeFilter} from "../openaireLibrary/utils/rangeFilter/rangeFilterHelperClasses.class";
import {Filter, Value} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
import {RouterHelper} from "../openaireLibrary/utils/routerHelper.class";
import {properties} from "../../environments/environment";
import {IndexInfoService} from "../openaireLibrary/utils/indexInfo.service";
import {ConfigurationService} from "../openaireLibrary/utils/configuration/configuration.service";
import {ClickEvent} from '../openaireLibrary/utils/click/click-outside-or-esc.directive';
import {RangeFilterComponent} from "../openaireLibrary/utils/rangeFilter/rangeFilter.component";
import {
MonitorIndicatorStakeholderBaseComponent
} from "../openaireLibrary/monitor/monitor-indicator-stakeholder-base.component";
@Component({
selector: 'monitor',
templateUrl: 'monitor.component.html',
styleUrls: ['monitor.component.less']
})
export class MonitorComponent implements OnInit, OnDestroy {
public user: User;
public subscriptions: any[] = [];
title;
description;
public pageContents = null;
public divContents = null;
public status: number;
public loading: boolean = true;
public view: Visibility;
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
public activeTopic: Topic = null;
public activeCategory: Category = null;
public activeSubCategory: SubCategory = null;
public errorCodes: ErrorCodes;
public stakeholder: Stakeholder;
public numberResults: Map<string, number> = new Map<string, number>();
public chartsActiveType: Map<string, IndicatorPath> = new Map<string, IndicatorPath>();
private errorMessages: ErrorMessagesComponent;
properties: EnvProperties = properties;
public routerHelper: RouterHelper = new RouterHelper();
filters: Filter[] = [];
queryParams = {};
public currentYear = new Date().getFullYear();
periodFilter: RangeFilter = {
title: "Time range",
filterId: "year",
originalFilterIdFrom: null,
originalFilterIdTo: null,
selectedFromValue: null,
selectedToValue: null,
selectedFromAndToValues: ""
};
export class MonitorComponent extends MonitorIndicatorStakeholderBaseComponent implements OnInit {
@ViewChild('rangeFilter') rangeFilter: RangeFilterComponent;
privateStakeholder = false;
public keyword: UntypedFormControl;
public statsUpdateDate: Date;
public isFullscreen: boolean = false;
public isMobile: boolean = false;
@HostListener('fullscreenchange', ['$event'])
@HostListener('webkitfullscreenchange', ['$event'])
@HostListener('mozfullscreenchange', ['$event'])
@HostListener('MSFullscreenChange', ['$event'])
screenChange(event) {
this.isFullscreen = !this.isFullscreen;
}
constructor(
private route: ActivatedRoute,
private _router: Router,
private _meta: Meta,
private _title: Title,
private _piwikService: PiwikService,
private helper: HelperService,
protected _route: ActivatedRoute,
protected _router: Router,
protected _meta: Meta,
protected _title: Title,
protected _piwikService: PiwikService,
protected seoService: SEOService,
protected sanitizer: DomSanitizer,
protected cdr: ChangeDetectorRef,
protected layoutService: LayoutService,
protected statisticsService: StatisticsService,
private stakeholderService: StakeholderService,
private userManagementService: UserManagementService,
private statisticsService: StatisticsService,
private layoutService: LayoutService,
private seoService: SEOService,
private cdr: ChangeDetectorRef,
private indexInfoService: IndexInfoService,
private sanitizer: DomSanitizer, private _fb: UntypedFormBuilder, private router: Router,
private configurationService: ConfigurationService) {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
this.status = this.errorCodes.LOADING;
private indexInfoService: IndexInfoService) {
super();
}
public ngOnInit() {
@ -120,15 +52,11 @@ export class MonitorComponent implements OnInit, OnDestroy {
}
}));
}
this.keyword = this._fb.control('');
let subscription: Subscription;
this.layoutService.isMobile.subscribe(isMobile => {
this.isMobile = isMobile;
this.cdr.detectChanges();
});
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
this.subscriptions.push(this.route.params.subscribe(params => {
this.subscriptions.push(this._route.params.subscribe(params => {
this.loading = true;
this.activeTopic = null;
this.activeCategory = null;
@ -136,9 +64,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
if (subscription) {
subscription.unsubscribe();
}
var url = properties.domain + properties.baseLink + this._router.url;
if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) {
this.status = this.errorCodes.LOADING;
this.numberResults = new Map<string, number>();
this.chartsActiveType = new Map<string, IndicatorPath>();
subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
@ -174,25 +100,15 @@ export class MonitorComponent implements OnInit, OnDestroy {
, filterOperator: "or", valueIsExact: true, filterType: "checkbox", radioValue: ""
});
}
this.subscriptions.push(this.route.queryParams.subscribe( queryParams => {
this.subscriptions.push(this._route.queryParams.subscribe(queryParams => {
this.handleQueryParams(queryParams, params);
this.seoService.createLinkForCanonicalURL(url, false);
this._meta.updateTag({content: url}, "property='og:url'");
this.description = "Monitor Dashboard | " + this.stakeholder.name;
this.title = "Monitor Dashboard | " + this.stakeholder.name;
this._meta.updateTag({content: this.description}, "name='description'");
this._meta.updateTag({content: this.description}, "property='og:description'");
this._meta.updateTag({content: this.title}, "property='og:title'");
this._title.setTitle(this.title);
this.subscriptions.push(this._piwikService.trackView(this.properties, this.title).subscribe());
this.description = "Monitor Dashboard | " + this.stakeholder.name;
this.setMetadata();
if (this.hasPermission((this.view && this.isManager(this.stakeholder))?this.view:this.stakeholder.visibility)) {
//this.getDivContents();
// this.getPageContents();
this.status = this.errorCodes.DONE;
this.setView(params);
} else {
this.privateStakeholder = true;
// this.navigateToError();
if (subscription) {
subscription.unsubscribe();
}
@ -207,8 +123,8 @@ export class MonitorComponent implements OnInit, OnDestroy {
});
this.subscriptions.push(subscription);
} else {
this.subscriptions.push(this._piwikService.trackView(this.properties, this.title).subscribe());
this.subscriptions.push(this.route.queryParams.subscribe( queryParams => {
this.trackView();
this.subscriptions.push(this._route.queryParams.subscribe(queryParams => {
this.handleQueryParams(queryParams, params);
}));
}
@ -216,207 +132,6 @@ export class MonitorComponent implements OnInit, OnDestroy {
}));
}
get monitorLink() {
return "https://" + (this.properties.environment == 'beta' ? 'beta.' : '') + 'monitor.openaire.eu';
}
private handleQueryParams(queryParams, params) {
this.queryParams = Object.assign({}, queryParams);
this.initializeFilters();
this.setView(params);
if(!this.user && (this.filters.filter(filter => this.queryParams[filter.filterId]).length > 0 || this.queryParams['year'])) {
if(queryParams['view']) {
this.router.navigate([], {queryParams: {view: queryParams['view']}});
} else {
this.router.navigate([], {queryParams: {}});
}
}
this.view = queryParams['view'];
}
private initializeFilters() {
this.periodFilter.selectedFromValue = (this.queryParams['year'] && this.queryParams['year'].indexOf("range") == 0) ? this.queryParams['year'].split("range")[1].split(":")[0] : "";
this.periodFilter.selectedToValue = (this.queryParams['year'] && this.queryParams['year'].indexOf("range") == 0) ? this.queryParams['year'].split("range")[1].split(":")[1] : "";
this.validateYearRange(false);
for (let filter of this.filters) {
if (this.queryParams[filter.filterId]) {
for (let value of filter.values) {
if (value.id == StringUtils.URIDecode(StringUtils.unquote(this.queryParams[filter.filterId]))) {
value.selected = true;
filter.countSelectedValues = 1;
break;
}
}
} else {
this.clearFilter(filter);
}
}
}
private validateYearRange(navigateTo: boolean = false) {
let validYears = true;
if (this.periodFilter.selectedToValue && (this.periodFilter.selectedToValue.length == 0 || !Dates.isValidYear(this.periodFilter.selectedToValue, Dates.currentYear - 20, Dates.currentYear))) {
this.periodFilter.selectedToValue = Dates.currentYear + "";
validYears = false;
}
if (this.periodFilter.selectedFromValue && (this.periodFilter.selectedFromValue.length == 0 || !Dates.isValidYear(this.periodFilter.selectedFromValue, Dates.currentYear - 20, Dates.currentYear))) {
this.periodFilter.selectedFromValue = Dates.currentYear - 20 + "";
validYears = false;
}
if (this.periodFilter.selectedFromValue && this.periodFilter.selectedFromValue.length && this.periodFilter.selectedToValue && this.periodFilter.selectedToValue.length > 0 && parseInt(this.periodFilter.selectedFromValue, 10) > parseInt(this.periodFilter.selectedToValue, 10)) {
this.periodFilter.selectedFromValue = this.periodFilter.selectedToValue;
validYears = false;
}
if (!validYears || navigateTo) {
if (this.periodFilter.selectedFromValue || this.periodFilter.selectedToValue) {
this.queryParams["year"] = 'range' + (this.periodFilter.selectedFromValue ? this.periodFilter.selectedFromValue : '') + ":" + (this.periodFilter.selectedToValue ? this.periodFilter.selectedToValue : "");
} else {
delete this.queryParams["year"];
}
// this.location.go(location.pathname, this.routerHelper.createQueryParamsString( Object.keys(this.queryParams), Object.values(this.queryParams)));
this.router.navigate([], {queryParams: this.queryParams});
this.setIndicators();
}
}
clearAll() {
for (let filter of this.filters) {
this.clearFilter(filter);
}
this.periodFilter.selectedFromValue = "";
this.periodFilter.selectedToValue = "";
this.validateYearRange(true)
}
clearFilter(filter: Filter) {
filter.countSelectedValues = 0;
filter.radioValue = "";
for (let value of filter.values) {
if (value.selected) {
value.selected = false;
}
}
if (this.queryParams[filter.filterId]) {
delete this.queryParams[filter.filterId];
}
}
countSelectedFilters(): number {
let count = 0;
if (this.periodFilter.selectedFromAndToValues.length > 0) {
count += 1;
}
for (let filter of this.filters) {
count += filter.countSelectedValues;
}
return count;
}
public get open() {
return this.layoutService.open;
}
private getPageContents() {
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.properties.adminToolsCommunity, this._router.url).subscribe(contents => {
this.pageContents = contents;
}));
}
private getDivContents() {
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.properties.adminToolsCommunity, this._router.url).subscribe(contents => {
this.divContents = contents;
}));
}
private setView(params: Params) {
this.loading = false;
if (params['topic']) {
this.activeTopic = this.stakeholder.topics.find(topic => topic.alias === decodeURIComponent(params['topic']) && this.hasPermission(topic.visibility));
if (this.activeTopic) {
if (params['category']) {
this.activeCategory = this.activeTopic.categories.find(category =>
(category.alias === params['category']) && this.hasPermission(category.visibility));
if (!this.activeCategory) {
this.navigateToError();
return;
}
} else {
this.activeCategory = this.activeTopic.categories.find(category => this.hasPermission(category.visibility));
if (this.activeCategory) {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
this.hasPermission(subCategory.visibility));
if (this.activeSubCategory) {
this.setIndicators();
}
}
return;
}
if (this.activeCategory) {
if (params['subCategory']) {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
(subCategory.alias === params['subCategory'] && this.hasPermission(subCategory.visibility)));
if (!this.activeSubCategory) {
this.navigateToError();
return;
}
} else {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory =>
this.hasPermission(subCategory.visibility));
}
if (this.activeSubCategory) {
this.setIndicators();
} else {
this.navigateToError();
}
return;
} else {
this.activeSubCategory = null;
}
} else {
this.navigateToError();
return;
}
} else {
this.activeTopic = this.stakeholder.topics.find(topic => this.hasPermission(topic.visibility));
if (this.activeTopic) {
this.activeCategory = this.activeTopic.categories.find(category => this.hasPermission(category.visibility));
if (this.activeCategory) {
this.activeSubCategory = this.activeCategory.subCategories.find(subCategory => this.hasPermission(subCategory.visibility));
if (this.activeSubCategory) {
this.setIndicators();
}
}
}
}
}
filter() {
this.validateYearRange(true);
}
filterChanged($event, navigate: boolean = true) {
let selected = "";
for (let value of $event.value.values) {
if (value.selected) {
selected = value.id;
break;
}
}
if (selected) {
this.queryParams[$event.value.filterId] = StringUtils.quote(StringUtils.URIEncode(selected));
} else {
delete this.queryParams[$event.value.filterId];
}
if (navigate) {
this.router.navigate([], {queryParams: this.queryParams});
this.setIndicators();
}
}
private getfl0() {
if (this.queryParams["relfundinglevel0_id"] && this.filters.length > 0) {
let value = StringUtils.URIDecode(StringUtils.unquote(this.queryParams["relfundinglevel0_id"]));
@ -424,189 +139,23 @@ export class MonitorComponent implements OnInit, OnDestroy {
}
return null;
}
private getCoFunded() {
if (this.queryParams["co-funded"] && this.filters.length > 0) {
return this.queryParams["co-funded"] && StringUtils.URIDecode(StringUtils.unquote(this.queryParams["co-funded"])) == "co-funded-results";
}
return false;
}
clearPeriodFilter() {
if (this.periodFilter.selectedFromValue || this.periodFilter.selectedToValue) {
this.periodFilter.selectedFromValue = "";
this.periodFilter.selectedToValue = "";
if(this.rangeFilter) {
this.rangeFilter.clearFilter();
}
this.filter();
}
}
clearFilterValue(filter: Filter, value: Value) {
value.selected = false;
filter.radioValue = '';
filter.countSelectedValues = filter.countSelectedValues - 1;
this.filterChanged({
value:filter
});
}
private setIndicators() {
this.periodFilter.selectedFromAndToValues = (this.periodFilter.selectedFromValue || this.periodFilter.selectedToValue ? ((this.periodFilter.selectedFromValue && !this.periodFilter.selectedToValue ? "From " : "") + (!this.periodFilter.selectedFromValue && this.periodFilter.selectedToValue ? "Until " : "") + (this.periodFilter.selectedFromValue ? this.periodFilter.selectedFromValue : "") +
(this.periodFilter.selectedFromValue && this.periodFilter.selectedToValue ? " - " : "") + (this.periodFilter.selectedToValue ? this.periodFilter.selectedToValue : "")) : "");
//clear numbers when filters change
this.numberResults.clear();
let urls: Map<string, [number, number][]> = new Map<string, [number, number][]>();
this.activeSubCategory.numbers.forEach((section, i) => {
section.indicators.forEach((number, j) => {
if (this.hasPermission(number.visibility)) {
let url = this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, number.indicatorPaths[0], this.getfl0(), this.periodFilter.selectedFromValue, this.periodFilter.selectedToValue, this.getCoFunded());
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
const indexes = urls.get(pair) ? urls.get(pair) : [];
indexes.push([i, j]);
urls.set(pair, indexes);
}
});
});
urls.forEach((indexes, pair) => {
pair = JSON.parse(pair);
let activeSubcategory = this.activeSubCategory._id;
this.subscriptions.push(this.statisticsService.getNumbers(this.indicatorUtils.getSourceType(pair[0]), pair[1]).subscribe(response => {
if(activeSubcategory === this.activeSubCategory._id) {
indexes.forEach(([i, j]) => {
if( this.activeSubCategory?.numbers[i]?.indicators[j]) {
let result = JSON.parse(JSON.stringify(response));
this.activeSubCategory.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => {
if (result) {
result = result[jsonPath];
}
});
if (typeof result === 'string' || typeof result === 'number') {
result = Number(result);
if (result === Number.NaN) {
result = 0;
}
} else {
result = 0;
}
this.numberResults.set(i + '-' + j, result);
}
});
}
}));
});
this.activeSubCategory.charts.forEach((section, i) => {
section.indicators.forEach((indicator, j) => {
if (indicator.indicatorPaths.length > 0) {
indicator.indicatorPaths[0].safeResourceUrl = this.getUrlByStakeHolder(indicator.indicatorPaths[0]);
this.chartsActiveType.set(i + '-' + j, indicator.indicatorPaths[0]);
}
});
});
if (this.cdr && !(this.cdr as ViewRef).destroyed) {
this.cdr.detectChanges();
}
}
public getUrlByStakeHolder(indicatorPath: IndicatorPath) {
return this.sanitizer.bypassSecurityTrustResourceUrl(
this.indicatorUtils.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, indicatorPath, this.getfl0(), this.periodFilter.selectedFromValue, this.periodFilter.selectedToValue, this.getCoFunded())));
}
public setActiveChart(i: number, j: number, type: string) {
let activeChart = this.activeSubCategory.charts[i].indicators[j].indicatorPaths.filter(indicatorPath => indicatorPath.type === type)[0];
activeChart.safeResourceUrl = this.getUrlByStakeHolder(activeChart);
this.chartsActiveType.set(i + '-' + j, activeChart);
}
private navigateToError() {
this._router.navigate([this.properties.errorLink], {queryParams: {'page': this._router.url}});
}
public quote(param: string): string {
return StringUtils.quote(param);
}
public ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
public isMember(stakeholder: Stakeholder) {
return this.user && (Session.isPortalAdministrator(this.user) || Session.isCurator(stakeholder.type, this.user)
|| Session.isManager(stakeholder.type, stakeholder.alias, this.user) || Session.isMember(stakeholder.type, stakeholder.alias, this.user));
}
public isManager(stakeholder: Stakeholder) {
return this.user && (Session.isPortalAdministrator(this.user) || Session.isCurator(stakeholder.type, this.user) || Session.isManager(stakeholder.type, stakeholder.alias, this.user));
}
public hasPermission(visibility: Visibility): boolean {
if(visibility === 'PUBLIC') {
return true;
} else if(visibility === 'RESTRICTED') {
return (!this.view || this.view === 'RESTRICTED') && this.isMember(this.stakeholder);
} else {
return !this.view && this.isManager(this.stakeholder);
}
}
public countSubCategoriesToShow(category: Category): number {
return category.subCategories.filter(subCategory => this.hasPermission(subCategory.visibility)).length;
}
public countSectionsWithIndicatorsToShow(sections: Section[]):number {
return sections.map(section => this.countIndicatorsToShow(section.indicators)).reduce((sum, current) => sum + current, 0);
}
public countIndicatorsToShow(indicators: Indicator[]): number {
return indicators.filter(indicator => this.hasPermission(indicator.visibility)).length;
public getFullUrl(indicatorPath: IndicatorPath) {
return this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, indicatorPath, this.getfl0(), this.periodFilter.selectedFromValue, this.periodFilter.selectedToValue, this.getCoFunded());
}
public get feedback() {
return "mailto:" + this.properties.feedbackmail + "?subject=%5BOpenAIRE%20Monitor%5D%20" + (this.stakeholder ? this.stakeholder.name : "") + "%20dashboard%20feedback"
}
public getNumberClassBySize(size: IndicatorSize) {
if (size === 'small') {
return 'uk-width-medium@m uk-width-1-1';
} else if (size === 'medium') {
return 'uk-width-1-4@l uk-width-1-2@m uk-width-1-1';
} else {
return 'uk-width-1-2@l uk-width-1-1@m uk-width-1-1';
}
}
public getChartClassBySize(size: IndicatorSize) {
if (size === 'small') {
return 'uk-width-1-3@xl uk-width-1-2@m uk-width-1-1';
} else if (size === 'medium') {
return 'uk-width-1-2@l uk-width-1-1';
} else {
return 'uk-width-1-1';
}
}
public printReport() {
window.print();
}
logIn() {
this.userManagementService.login();
}
toggleDescriptionOverlay(event, indicator: Indicator) {
event.stopPropagation();
indicator.descriptionOverlay = !indicator.descriptionOverlay;
}
closeDescriptionOverlay(event: ClickEvent, indicator: Indicator) {
if(event.clicked && indicator.descriptionOverlay) {
indicator.descriptionOverlay = false;
}
}
}

@ -1 +1 @@
Subproject commit 2b9953503aeadeca356e6942a1e60c43f8b04d5b
Subproject commit 14cd46bdb4ee59fc887e017b1c0ee027b6da3e05

@ -1 +1 @@
Subproject commit 1979f5ec89ca960bf7c927a933a160854ae680b3
Subproject commit 6cef9ebed0db7ecbcca023bae824239106907960

@ -1 +1 @@
Subproject commit df6a0527e9bce69f016da8d28b79885c351104c6
Subproject commit 52eca9abe84c941a7e78a5690f273d8c8e3194f9