2023-11-13 14:00:05 +01:00
|
|
|
import {Directive} from "@angular/core";
|
|
|
|
import {BaseComponent} from "../../sharedComponents/base/base.component";
|
|
|
|
import {IndicatorUtils, StakeholderUtils} from "./indicator-utils";
|
2024-01-09 10:50:05 +01:00
|
|
|
import {ConnectHelper} from "../../connect/connectHelper";
|
2024-07-25 09:31:08 +02:00
|
|
|
import {Indicator, IndicatorSize} from "../../monitor/entities/stakeholder";
|
2024-06-17 09:02:40 +02:00
|
|
|
import {statsToolParser} from "./cache-indicators/cache-indicators";
|
2023-11-13 14:00:05 +01:00
|
|
|
|
|
|
|
@Directive()
|
|
|
|
export abstract class StakeholderBaseComponent extends BaseComponent {
|
|
|
|
|
|
|
|
stakeholderUtils: StakeholderUtils = new StakeholderUtils();
|
|
|
|
|
|
|
|
get entities() {
|
|
|
|
return this.stakeholderUtils.entities;
|
|
|
|
}
|
|
|
|
|
|
|
|
get showVisibility() {
|
|
|
|
return this.stakeholderUtils.showField(this.stakeholderUtils.visibilities);
|
|
|
|
}
|
|
|
|
|
|
|
|
get showType() {
|
|
|
|
return this.stakeholderUtils.showField(this.stakeholderUtils.types);
|
|
|
|
}
|
|
|
|
|
|
|
|
get showFunderType() {
|
|
|
|
return this.stakeholderUtils.showField(this.stakeholderUtils.funderTypes);
|
|
|
|
}
|
|
|
|
|
2023-11-16 10:45:07 +01:00
|
|
|
getFunderTypeLabel(value: any) {
|
|
|
|
return this.stakeholderUtils.getLabel(this.stakeholderUtils.funderTypes, value);
|
|
|
|
}
|
|
|
|
|
2023-11-13 14:00:05 +01:00
|
|
|
get showLocale() {
|
|
|
|
return this.stakeholderUtils.showField(this.stakeholderUtils.locales);
|
|
|
|
}
|
2023-11-15 09:35:44 +01:00
|
|
|
|
|
|
|
protected navigateToError() {
|
|
|
|
this._router.navigate([this.properties.errorLink], {queryParams: {'page': this._router.url}});
|
|
|
|
}
|
2024-01-09 10:50:05 +01:00
|
|
|
|
|
|
|
setProperties(id, type = null, configurationService) {
|
|
|
|
this.properties.adminToolsCommunity = id;
|
|
|
|
if (type) {
|
|
|
|
this.properties.adminToolsPortalType = type;
|
|
|
|
} else {
|
|
|
|
ConnectHelper.setPortalTypeFromPid(id);
|
|
|
|
}
|
|
|
|
configurationService.initPortal(this.properties, this.properties.adminToolsCommunity);
|
|
|
|
}
|
2023-11-13 14:00:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Directive()
|
|
|
|
export abstract class IndicatorStakeholderBaseComponent extends StakeholderBaseComponent {
|
|
|
|
|
|
|
|
indicatorUtils: IndicatorUtils = new IndicatorUtils();
|
2024-07-25 09:31:08 +02:00
|
|
|
indicator: Indicator;
|
2024-06-17 09:02:40 +02:00
|
|
|
|
|
|
|
public getNumberClassBySize(size: IndicatorSize): string {
|
|
|
|
if (size === 'small') {
|
|
|
|
return 'uk-width-medium';
|
|
|
|
} else if (size === 'medium') {
|
2024-06-18 09:07:44 +02:00
|
|
|
return 'uk-width-max-content';
|
2024-06-17 09:02:40 +02:00
|
|
|
} else {
|
2024-06-18 09:07:44 +02:00
|
|
|
return 'uk-width-max-content';
|
2024-06-17 09:02:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public getChartClassBySize(size: IndicatorSize): string {
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
}
|
2024-07-25 09:31:08 +02:00
|
|
|
|
|
|
|
public getActivePathIndex(indicator: Indicator = this.indicator): number {
|
|
|
|
return indicator?.activePath ? indicator.activePath : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getActiveIndicatorPath(indicator: Indicator = this.indicator) {
|
|
|
|
if(indicator?.indicatorPaths.length > this.getActivePathIndex(indicator)) {
|
|
|
|
return indicator.indicatorPaths[this.getActivePathIndex(indicator)];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2023-11-13 14:00:05 +01:00
|
|
|
}
|