Add format in number indicators in order to support percentages.
This commit is contained in:
parent
be7fd26f7b
commit
54fa0aa7a6
|
@ -108,7 +108,7 @@
|
||||||
class="uk-text-small uk-text-truncate uk-margin-xsmall-bottom uk-margin-right">{{indicator.name}}</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">
|
<div class="number uk-text-small uk-text-bold">
|
||||||
<span *ngIf="numberResults.get(i + '-' + j)"
|
<span *ngIf="numberResults.get(i + '-' + j)"
|
||||||
[innerHTML]="numberResults.get(i + '-' + j) | numberRound: 2:1"></span>
|
[innerHTML]="(indicator.indicatorPaths[0].format == 'NUMBER'?(numberResults.get(i + '-' + j) | numberRound: 2:1):(numberResults.get(i + '-' + j) | numberPercentage))"></span>
|
||||||
<span *ngIf="!numberResults.get(i + '-' + j)">--</span>
|
<span *ngIf="!numberResults.get(i + '-' + j)">--</span>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="indicator.description || indicator.additionalDescription"
|
<div *ngIf="indicator.description || indicator.additionalDescription"
|
||||||
|
@ -159,7 +159,7 @@
|
||||||
class="uk-text-xsmall uk-text-truncate uk-margin-xsmall-bottom uk-margin-right">{{indicator.name}}</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">
|
<div class="number uk-text-small uk-text-bold">
|
||||||
<span *ngIf="numberResults.get(i + '-' + j)"
|
<span *ngIf="numberResults.get(i + '-' + j)"
|
||||||
[innerHTML]="numberResults.get(i + '-' + j) | numberRound: 2:1"></span>
|
[innerHTML]="(indicator.indicatorPaths[0].format == 'NUMBER'?(numberResults.get(i + '-' + j) | numberRound: 2:1):(numberResults.get(i + '-' + j) | numberPercentage))"></span>
|
||||||
<span *ngIf="!numberResults.get(i + '-' + j)">--</span>
|
<span *ngIf="!numberResults.get(i + '-' + j)">--</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e88bb206dcfbe6da62542c45794d4fe6e552fb09
|
Subproject commit a49970aca66cf98a2ee9cd767e8dc87badc0b80f
|
|
@ -68,7 +68,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-text-small uk-text-truncate uk-margin-xsmall-bottom uk-margin-right">{{indicator.name}}</div>
|
<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">
|
<div class="number uk-text-small uk-text-bold">
|
||||||
<span *ngIf="numberResults.get(i + '-' + j)" [innerHTML]="numberResults.get(i + '-' + j) | numberRound: 2:1"></span>
|
<span *ngIf="numberResults.get(i + '-' + j)" [innerHTML]="(indicator.indicatorPaths[0].format == 'NUMBER'?(numberResults.get(i + '-' + j) | numberRound: 2:1):(numberResults.get(i + '-' + j) | numberPercentage))"></span>
|
||||||
<span *ngIf="!numberResults.get(i + '-' + j)">--</span>
|
<span *ngIf="!numberResults.get(i + '-' + j)">--</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -257,11 +257,16 @@
|
||||||
now</a>
|
now</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="uk-width-1-1">
|
<div class="uk-width-1-2@m">
|
||||||
<div input [formInput]="indicatorPath.get('source')" placeholder="Source"
|
<div input [formInput]="indicatorPath.get('source')" placeholder="Source"
|
||||||
[options]="isAdministrator?indicatorUtils.allSourceTypes:indicatorUtils.sourceTypes" type="select">
|
[options]="isAdministrator?indicatorUtils.allSourceTypes:indicatorUtils.sourceTypes" type="select">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="uk-width-1-2@m">
|
||||||
|
<div input [formInput]="indicatorPath.get('format')" placeholder="Format"
|
||||||
|
[options]="indicatorUtils.formats" type="select">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div formArrayName="jsonPath" class="uk-width-1-1">
|
<div formArrayName="jsonPath" class="uk-width-1-1">
|
||||||
|
@ -297,7 +302,8 @@
|
||||||
<div class="uk-width-1-1 uk-flex uk-flex-center">
|
<div class="uk-width-1-1 uk-flex uk-flex-center">
|
||||||
<div class="uk-flex uk-position-relative">
|
<div class="uk-flex uk-position-relative">
|
||||||
<span class="uk-padding number number-preview uk-flex uk-flex-column uk-flex-center uk-text-center">
|
<span class="uk-padding number number-preview uk-flex uk-flex-column uk-flex-center uk-text-center">
|
||||||
<span *ngIf="numberIndicatorPaths.at(i).get('result').valid && numberIndicatorPaths.at(i).get('result').value !== 0">
|
<span *ngIf="numberIndicatorPaths.at(i).get('result').valid && numberIndicatorPaths.at(i).get('result').value !== 0"
|
||||||
|
[innerHTML]="(numberIndicatorPaths.at(i).get('format').value == 'NUMBER'?(numberIndicatorPaths.at(i).get('result').value | numberRound: 2:1):(numberIndicatorPaths.at(i).get('result').value | numberPercentage))">
|
||||||
{{numberIndicatorPaths.at(i).get('result').value | number}}
|
{{numberIndicatorPaths.at(i).get('result').value | number}}
|
||||||
</span>
|
</span>
|
||||||
<span *ngIf="numberIndicatorPaths.at(i).get('result').valid && numberIndicatorPaths.at(i).get('result').value === 0">
|
<span *ngIf="numberIndicatorPaths.at(i).get('result').valid && numberIndicatorPaths.at(i).get('result').value === 0">
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
ViewChild
|
ViewChild
|
||||||
} from "@angular/core";
|
} from "@angular/core";
|
||||||
import {
|
import {
|
||||||
|
Format,
|
||||||
Indicator,
|
Indicator,
|
||||||
IndicatorPath,
|
IndicatorPath,
|
||||||
IndicatorSize,
|
IndicatorSize,
|
||||||
|
@ -20,7 +21,14 @@ import {
|
||||||
Visibility
|
Visibility
|
||||||
} from "../openaireLibrary/monitor/entities/stakeholder";
|
} from "../openaireLibrary/monitor/entities/stakeholder";
|
||||||
import {IndicatorUtils, StakeholderUtils} from "../utils/indicator-utils";
|
import {IndicatorUtils, StakeholderUtils} from "../utils/indicator-utils";
|
||||||
import {AbstractControl, UntypedFormArray, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators} from "@angular/forms";
|
import {
|
||||||
|
AbstractControl,
|
||||||
|
UntypedFormArray,
|
||||||
|
UntypedFormBuilder,
|
||||||
|
UntypedFormControl,
|
||||||
|
UntypedFormGroup,
|
||||||
|
Validators
|
||||||
|
} from "@angular/forms";
|
||||||
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
|
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
|
||||||
import {StatisticsService} from "../utils/services/statistics.service";
|
import {StatisticsService} from "../utils/services/statistics.service";
|
||||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||||
|
@ -96,9 +104,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
@ViewChild('editNumberNotify', {static: true}) editNumberNotify: NotifyFormComponent;
|
@ViewChild('editNumberNotify', {static: true}) editNumberNotify: NotifyFormComponent;
|
||||||
@ViewChild('editChartNotify', {static: true}) editChartNotify: NotifyFormComponent;
|
@ViewChild('editChartNotify', {static: true}) editChartNotify: NotifyFormComponent;
|
||||||
@ViewChild('deleteNotify', {static: true}) deleteNotify: NotifyFormComponent;
|
@ViewChild('deleteNotify', {static: true}) deleteNotify: NotifyFormComponent;
|
||||||
|
|
||||||
public isFullscreen: boolean = false;
|
public isFullscreen: boolean = false;
|
||||||
|
|
||||||
@HostListener('fullscreenchange', ['$event'])
|
@HostListener('fullscreenchange', ['$event'])
|
||||||
@HostListener('webkitfullscreenchange', ['$event'])
|
@HostListener('webkitfullscreenchange', ['$event'])
|
||||||
@HostListener('mozfullscreenchange', ['$event'])
|
@HostListener('mozfullscreenchange', ['$event'])
|
||||||
|
@ -106,14 +114,14 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
screenChange(event) {
|
screenChange(event) {
|
||||||
this.isFullscreen = !this.isFullscreen;
|
this.isFullscreen = !this.isFullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscriptions
|
* Subscriptions
|
||||||
**/
|
**/
|
||||||
private subscriptions: any[] = [];
|
private subscriptions: any[] = [];
|
||||||
private urlSubscriptions: any[] = [];
|
private urlSubscriptions: any[] = [];
|
||||||
private numberSubscription: any[] = [];
|
private numberSubscription: any[] = [];
|
||||||
|
|
||||||
constructor(private layoutService: LayoutService,
|
constructor(private layoutService: LayoutService,
|
||||||
private stakeholderService: StakeholderService,
|
private stakeholderService: StakeholderService,
|
||||||
private statisticsService: StatisticsService,
|
private statisticsService: StatisticsService,
|
||||||
|
@ -124,7 +132,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
private sanitizer: DomSanitizer) {
|
private sanitizer: DomSanitizer) {
|
||||||
this.filesToUpload = [];
|
this.filesToUpload = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (this.stakeholder) {
|
if (this.stakeholder) {
|
||||||
this.setCharts();
|
this.setCharts();
|
||||||
|
@ -136,7 +144,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.initReorder();
|
this.initReorder();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.subscriptions.forEach(value => {
|
this.subscriptions.forEach(value => {
|
||||||
if (value instanceof Subscriber) {
|
if (value instanceof Subscriber) {
|
||||||
|
@ -156,11 +164,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void {
|
ngAfterViewInit(): void {
|
||||||
this.initReorder();
|
this.initReorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
if (this.canEdit) {
|
if (this.canEdit) {
|
||||||
if (changes.topicIndex || changes.categoryIndex || changes.subcategoryIndex) {
|
if (changes.topicIndex || changes.categoryIndex || changes.subcategoryIndex) {
|
||||||
|
@ -170,7 +178,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initReorder() {
|
initReorder() {
|
||||||
this.subscriptions.forEach(value => {
|
this.subscriptions.forEach(value => {
|
||||||
if (value instanceof Function) {
|
if (value instanceof Function) {
|
||||||
|
@ -223,11 +231,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hide(element: any) {
|
hide(element: any) {
|
||||||
UIkit.dropdown(element).hide();
|
UIkit.dropdown(element).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
setCharts() {
|
setCharts() {
|
||||||
this.chartSections = this.fb.array([]);
|
this.chartSections = this.fb.array([]);
|
||||||
this.charts.forEach(section => {
|
this.charts.forEach(section => {
|
||||||
|
@ -251,7 +259,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setNumbers() {
|
setNumbers() {
|
||||||
this.numberSections = this.fb.array([]);
|
this.numberSections = this.fb.array([]);
|
||||||
this.numberResults.clear();
|
this.numberResults.clear();
|
||||||
|
@ -292,7 +300,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private calculateResults(response: any, indexes: [number, number][]) {
|
private calculateResults(response: any, indexes: [number, number][]) {
|
||||||
indexes.forEach(([i, j]) => {
|
indexes.forEach(([i, j]) => {
|
||||||
let result = JSON.parse(JSON.stringify(response));
|
let result = JSON.parse(JSON.stringify(response));
|
||||||
|
@ -312,7 +320,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.numberResults.set(i + '-' + j, result);
|
this.numberResults.set(i + '-' + j, result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get charts(): Section[] {
|
get charts(): Section[] {
|
||||||
if (this.stakeholder.topics[this.topicIndex] &&
|
if (this.stakeholder.topics[this.topicIndex] &&
|
||||||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex] &&
|
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex] &&
|
||||||
|
@ -322,7 +330,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get numbers(): Section[] {
|
get numbers(): Section[] {
|
||||||
if (this.stakeholder.topics[this.topicIndex] &&
|
if (this.stakeholder.topics[this.topicIndex] &&
|
||||||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex] &&
|
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex] &&
|
||||||
|
@ -332,30 +340,30 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set numbers(sections: Section[]) {
|
set numbers(sections: Section[]) {
|
||||||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers = sections;
|
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers = sections;
|
||||||
}
|
}
|
||||||
|
|
||||||
get open(): boolean {
|
get open(): boolean {
|
||||||
return this.layoutService.open;
|
return this.layoutService.open;
|
||||||
}
|
}
|
||||||
|
|
||||||
get canEdit() {
|
get canEdit() {
|
||||||
return this.stakeholder &&
|
return this.stakeholder &&
|
||||||
this.stakeholder.topics[this.topicIndex] &&
|
this.stakeholder.topics[this.topicIndex] &&
|
||||||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex] &&
|
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex] &&
|
||||||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex];
|
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
public get numberIndicatorPaths(): UntypedFormArray {
|
public get numberIndicatorPaths(): UntypedFormArray {
|
||||||
return this.numberIndicatorFb.get('indicatorPaths') as UntypedFormArray;
|
return this.numberIndicatorFb.get('indicatorPaths') as UntypedFormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public get chartIndicatorPaths(): UntypedFormArray {
|
public get chartIndicatorPaths(): UntypedFormArray {
|
||||||
return this.chartIndicatorFb.get('indicatorPaths') as UntypedFormArray;
|
return this.chartIndicatorFb.get('indicatorPaths') as UntypedFormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNumberClassBySize(size: IndicatorSize) {
|
public getNumberClassBySize(size: IndicatorSize) {
|
||||||
if (size === 'small') {
|
if (size === 'small') {
|
||||||
return 'uk-width-medium@m uk-width-1-1';
|
return 'uk-width-medium@m uk-width-1-1';
|
||||||
|
@ -365,7 +373,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
return 'uk-width-1-2@l uk-width-1-1@m uk-width-1-1';
|
return 'uk-width-1-2@l uk-width-1-1@m uk-width-1-1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getChartClassBySize(size: IndicatorSize) {
|
public getChartClassBySize(size: IndicatorSize) {
|
||||||
if (size === 'small') {
|
if (size === 'small') {
|
||||||
return 'uk-width-1-3@xl uk-width-1-2@m uk-width-1-1';
|
return 'uk-width-1-3@xl uk-width-1-2@m uk-width-1-1';
|
||||||
|
@ -375,7 +383,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
return 'uk-width-1-1';
|
return 'uk-width-1-1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addJsonPath(index: number) {
|
public addJsonPath(index: number) {
|
||||||
if (index == 0 && this.getJsonPath(index).getRawValue()[index].indexOf(",") != -1) {
|
if (index == 0 && this.getJsonPath(index).getRawValue()[index].indexOf(",") != -1) {
|
||||||
//if in the first path there are more than one paths comma separated, split them and autogenerate the forms
|
//if in the first path there are more than one paths comma separated, split them and autogenerate the forms
|
||||||
|
@ -390,13 +398,13 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.getJsonPath(index).push(this.fb.control('', Validators.required));
|
this.getJsonPath(index).push(this.fb.control('', Validators.required));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeJsonPath(i: number, j: number) {
|
public removeJsonPath(i: number, j: number) {
|
||||||
if (this.getJsonPath(i).enabled) {
|
if (this.getJsonPath(i).enabled) {
|
||||||
this.getJsonPath(i).removeAt(j);
|
this.getJsonPath(i).removeAt(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public validateJsonPath(index: number, dirty: boolean = false) {
|
public validateJsonPath(index: number, dirty: boolean = false) {
|
||||||
let indicatorPath: UntypedFormGroup = <UntypedFormGroup>this.numberIndicatorPaths.at(index);
|
let indicatorPath: UntypedFormGroup = <UntypedFormGroup>this.numberIndicatorPaths.at(index);
|
||||||
if (this.indicator.defaultId === null) {
|
if (this.indicator.defaultId === null) {
|
||||||
|
@ -442,33 +450,33 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}, 500);
|
}, 500);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public getJsonPath(index: number): UntypedFormArray {
|
public getJsonPath(index: number): UntypedFormArray {
|
||||||
return this.numberIndicatorPaths.at(index).get('jsonPath') as UntypedFormArray;
|
return this.numberIndicatorPaths.at(index).get('jsonPath') as UntypedFormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCurrentJsonPath(index: number): string[] {
|
public getCurrentJsonPath(index: number): string[] {
|
||||||
return this.section.indicators[this.index].indicatorPaths[index].jsonPath;
|
return this.section.indicators[this.index].indicatorPaths[index].jsonPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getParameters(index: number): UntypedFormArray {
|
public getParameters(index: number): UntypedFormArray {
|
||||||
return this.chartIndicatorPaths.at(index).get('parameters') as UntypedFormArray;
|
return this.chartIndicatorPaths.at(index).get('parameters') as UntypedFormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getParameter(index: number, key: string): UntypedFormControl {
|
public getParameter(index: number, key: string): UntypedFormControl {
|
||||||
return this.getParameters(index).controls.filter(control => control.value.key === key)[0] as UntypedFormControl;
|
return this.getParameters(index).controls.filter(control => control.value.key === key)[0] as UntypedFormControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getSecureUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
private getSecureUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
||||||
return this.sanitizer.bypassSecurityTrustResourceUrl(
|
return this.sanitizer.bypassSecurityTrustResourceUrl(
|
||||||
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)));
|
this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private getUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
private getUrlByStakeHolder(indicatorPath: IndicatorPath) {
|
||||||
return this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath));
|
return this.statisticsService.getChartUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public addNumberIndicatorPath(url: string = '', parameters: UntypedFormArray = new UntypedFormArray([]), source: string = 'stats-tool', jsonPath: UntypedFormArray = new UntypedFormArray([])) {
|
public addNumberIndicatorPath(url: string = '', parameters: UntypedFormArray = new UntypedFormArray([]), source: string = 'stats-tool', jsonPath: UntypedFormArray = new UntypedFormArray([]), format: Format = "NUMBER") {
|
||||||
if (jsonPath.length === 0) {
|
if (jsonPath.length === 0) {
|
||||||
jsonPath.push(this.fb.control('', Validators.required));
|
jsonPath.push(this.fb.control('', Validators.required));
|
||||||
}
|
}
|
||||||
|
@ -476,8 +484,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
url: this.fb.control(url, [Validators.required, StringUtils.urlValidator()]),
|
url: this.fb.control(url, [Validators.required, StringUtils.urlValidator()]),
|
||||||
jsonPath: jsonPath,
|
jsonPath: jsonPath,
|
||||||
result: this.fb.control(0, Validators.required),
|
result: this.fb.control(0, Validators.required),
|
||||||
// parameters: parameters,
|
source: this.fb.control(source, Validators.required),
|
||||||
source: this.fb.control(source, Validators.required)
|
format: this.fb.control(format, Validators.required)
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
let index = this.numberIndicatorPaths.length - 1;
|
let index = this.numberIndicatorPaths.length - 1;
|
||||||
|
@ -523,7 +531,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('jsonPath').valueChanges.subscribe(value => {
|
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('jsonPath').valueChanges.subscribe(value => {
|
||||||
if (this.indicator.indicatorPaths[index]) {
|
if (this.indicator.indicatorPaths[index]) {
|
||||||
this.indicator.indicatorPaths[index].jsonPath = value;
|
this.indicator.indicatorPaths[index].jsonPath = value;
|
||||||
|
@ -543,7 +551,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.numberIndicatorPaths.at(index).get('source').disable();
|
this.numberIndicatorPaths.at(index).get('source').disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public addChartIndicatorPath(value: string = '', parameters: UntypedFormArray = new UntypedFormArray([]), disableUrl: boolean = false, type: string = null) {
|
public addChartIndicatorPath(value: string = '', parameters: UntypedFormArray = new UntypedFormArray([]), disableUrl: boolean = false, type: string = null) {
|
||||||
this.chartIndicatorPaths.push(this.fb.group({
|
this.chartIndicatorPaths.push(this.fb.group({
|
||||||
url: this.fb.control(value, [Validators.required, StringUtils.urlValidator()]),
|
url: this.fb.control(value, [Validators.required, StringUtils.urlValidator()]),
|
||||||
|
@ -586,13 +594,13 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private isStakeholderParametersValid(indicatorPath: IndicatorPath) {
|
private isStakeholderParametersValid(indicatorPath: IndicatorPath) {
|
||||||
return !((indicatorPath.chartObject && Object.keys(indicatorPath.parameters).indexOf("index_id") == -1 && Object.keys(indicatorPath.parameters).indexOf("index_name") == -1 && Object.keys(indicatorPath.parameters).indexOf("index_shortName") == -1)
|
return !((indicatorPath.chartObject && Object.keys(indicatorPath.parameters).indexOf("index_id") == -1 && Object.keys(indicatorPath.parameters).indexOf("index_name") == -1 && Object.keys(indicatorPath.parameters).indexOf("index_shortName") == -1)
|
||||||
|| (!indicatorPath.chartObject && indicatorPath.url.indexOf("index_id") == -1 && indicatorPath.url.indexOf("index_name") == -1 && (indicatorPath.url).indexOf("index_shortName") == -1));
|
|| (!indicatorPath.chartObject && indicatorPath.url.indexOf("index_id") == -1 && indicatorPath.url.indexOf("index_name") == -1 && (indicatorPath.url).indexOf("index_shortName") == -1));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private getJsonPathAsFormArray(indicatorPath: IndicatorPath): UntypedFormArray {
|
private getJsonPathAsFormArray(indicatorPath: IndicatorPath): UntypedFormArray {
|
||||||
let jsonPath = this.fb.array([]);
|
let jsonPath = this.fb.array([]);
|
||||||
if (indicatorPath.jsonPath) {
|
if (indicatorPath.jsonPath) {
|
||||||
|
@ -602,7 +610,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
return jsonPath;
|
return jsonPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getParametersAsFormArray(indicatorPath: IndicatorPath): UntypedFormArray {
|
private getParametersAsFormArray(indicatorPath: IndicatorPath): UntypedFormArray {
|
||||||
let parameters = this.fb.array([]);
|
let parameters = this.fb.array([]);
|
||||||
if (indicatorPath.parameters) {
|
if (indicatorPath.parameters) {
|
||||||
|
@ -624,7 +632,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public editNumberIndicatorOpen(section: Section, id = null) {
|
public editNumberIndicatorOpen(section: Section, id = null) {
|
||||||
this.urlParameterizedMessage = null;
|
this.urlParameterizedMessage = null;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
|
@ -645,7 +653,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
defaultId: this.fb.control(this.indicator.defaultId)
|
defaultId: this.fb.control(this.indicator.defaultId)
|
||||||
});
|
});
|
||||||
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
||||||
this.addNumberIndicatorPath(this.statisticsService.getNumberUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)), indicatorPath.parameters, indicatorPath.source, this.getJsonPathAsFormArray(indicatorPath));
|
this.addNumberIndicatorPath(this.statisticsService.getNumberUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)), indicatorPath.parameters, indicatorPath.source, this.getJsonPathAsFormArray(indicatorPath), indicatorPath.format);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.indicator = new Indicator('', '', '', 'number', 'small', 'small', "PUBLIC", []);
|
this.indicator = new Indicator('', '', '', 'number', 'small', 'small', "PUBLIC", []);
|
||||||
|
@ -685,7 +693,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.editNumberModal.stayOpen = true;
|
this.editNumberModal.stayOpen = true;
|
||||||
this.editNumberModal.open();
|
this.editNumberModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
public editChartIndicatorOpen(section: Section, id = null) {
|
public editChartIndicatorOpen(section: Section, id = null) {
|
||||||
this.urlParameterizedMessage = null;
|
this.urlParameterizedMessage = null;
|
||||||
this.urlSubscriptions.forEach(value => {
|
this.urlSubscriptions.forEach(value => {
|
||||||
|
@ -752,7 +760,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.editChartModal.stayOpen = true;
|
this.editChartModal.stayOpen = true;
|
||||||
this.editChartModal.open();
|
this.editChartModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
saveIndicator() {
|
saveIndicator() {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
if (this.indicator.type === 'chart') {
|
if (this.indicator.type === 'chart') {
|
||||||
|
@ -834,7 +842,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
saveIndicators(sections) {
|
saveIndicators(sections) {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
let path = [
|
let path = [
|
||||||
|
@ -892,10 +900,10 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
this.importLoading = false;
|
this.importLoading = false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reorderIndicators(sectionId: string, type: IndicatorType, reorder: Reorder) {
|
reorderIndicators(sectionId: string, type: IndicatorType, reorder: Reorder) {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
let path = [
|
let path = [
|
||||||
|
@ -916,7 +924,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
hasDifference(index: number): boolean {
|
hasDifference(index: number): boolean {
|
||||||
let hasDifference = false;
|
let hasDifference = false;
|
||||||
this.chartIndicatorPaths.at(index).value.parameters.forEach((parameter) => {
|
this.chartIndicatorPaths.at(index).value.parameters.forEach((parameter) => {
|
||||||
|
@ -928,22 +936,22 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
return hasDifference || this.indicator.indicatorPaths[index].safeResourceUrl.toString() !==
|
return hasDifference || this.indicator.indicatorPaths[index].safeResourceUrl.toString() !==
|
||||||
this.getSecureUrlByStakeHolder(this.indicator.indicatorPaths[index]).toString();
|
this.getSecureUrlByStakeHolder(this.indicator.indicatorPaths[index]).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isAdministrator(): boolean {
|
public get isAdministrator(): boolean {
|
||||||
return Session.isPortalAdministrator(this.user);
|
return Session.isPortalAdministrator(this.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get isCurator(): boolean {
|
public get isCurator(): boolean {
|
||||||
return this.isAdministrator || Session.isCurator(this.stakeholder.type, this.user);
|
return this.isAdministrator || Session.isCurator(this.stakeholder.type, this.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshIndicator() {
|
refreshIndicator() {
|
||||||
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.chartIndicatorFb.value, this.indicator.indicatorPaths, 'chart', true);
|
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.chartIndicatorFb.value, this.indicator.indicatorPaths, 'chart', true);
|
||||||
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
this.indicator.indicatorPaths.forEach(indicatorPath => {
|
||||||
indicatorPath.safeResourceUrl = this.getSecureUrlByStakeHolder(indicatorPath);
|
indicatorPath.safeResourceUrl = this.getSecureUrlByStakeHolder(indicatorPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteIndicatorOpen(section: Section, indicatorId: string, type: string, childrenAction: string = null) {
|
deleteIndicatorOpen(section: Section, indicatorId: string, type: string, childrenAction: string = null) {
|
||||||
this.indicatorChildrenActionOnDelete = null;
|
this.indicatorChildrenActionOnDelete = null;
|
||||||
if (childrenAction == "delete") {
|
if (childrenAction == "delete") {
|
||||||
|
@ -951,7 +959,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
} else if (childrenAction == "disconnect") {
|
} else if (childrenAction == "disconnect") {
|
||||||
this.indicatorChildrenActionOnDelete = childrenAction;
|
this.indicatorChildrenActionOnDelete = childrenAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.section = section;
|
this.section = section;
|
||||||
if (type === 'chart') {
|
if (type === 'chart') {
|
||||||
this.index = this.charts.find(value => value._id == section._id).indicators.findIndex(value => value._id == indicatorId);
|
this.index = this.charts.find(value => value._id == section._id).indicators.findIndex(value => value._id == indicatorId);
|
||||||
|
@ -967,7 +975,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.deleteModal.stayOpen = true;
|
this.deleteModal.stayOpen = true;
|
||||||
this.deleteModal.open();
|
this.deleteModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteIndicator() {
|
deleteIndicator() {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
let path = [
|
let path = [
|
||||||
|
@ -1018,7 +1026,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.deleteModal.cancel();
|
this.deleteModal.cancel();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
changeIndicatorStatus(sectionId: string, indicator: Indicator, visibility: Visibility) {
|
changeIndicatorStatus(sectionId: string, indicator: Indicator, visibility: Visibility) {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
let path = [
|
let path = [
|
||||||
|
@ -1046,7 +1054,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
saveSection(focused: boolean, sectionControl: AbstractControl, index: number, type: IndicatorType = "chart") {
|
saveSection(focused: boolean, sectionControl: AbstractControl, index: number, type: IndicatorType = "chart") {
|
||||||
if (!focused && sectionControl.dirty) {
|
if (!focused && sectionControl.dirty) {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
|
@ -1081,7 +1089,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createSection(index = -1, type: IndicatorType = 'chart') {
|
createSection(index = -1, type: IndicatorType = 'chart') {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
this.section = new Section(type, null, null, this.stakeholder.alias);
|
this.section = new Section(type, null, null, this.stakeholder.alias);
|
||||||
|
@ -1123,7 +1131,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteNumberSectionOpen(section: Section, index: number) {
|
// deleteNumberSectionOpen(section: Section, index: number) {
|
||||||
// this.section = section;
|
// this.section = section;
|
||||||
// this.index = index;
|
// this.index = index;
|
||||||
|
@ -1141,7 +1149,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
// this.deleteChartSectionModal.okButtonText = 'Yes';
|
// this.deleteChartSectionModal.okButtonText = 'Yes';
|
||||||
// this.deleteChartSectionModal.open();
|
// this.deleteChartSectionModal.open();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
deleteSectionOpen(section: Section, index: number, type: IndicatorType, childrenAction: string = null) {
|
deleteSectionOpen(section: Section, index: number, type: IndicatorType, childrenAction: string = null) {
|
||||||
if (!this.editing && !section.defaultId) {
|
if (!this.editing && !section.defaultId) {
|
||||||
this.sectionTypeToDelete = type;
|
this.sectionTypeToDelete = type;
|
||||||
|
@ -1151,7 +1159,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
} else if (childrenAction == "disconnect") {
|
} else if (childrenAction == "disconnect") {
|
||||||
this.sectionChildrenActionOnDelete = childrenAction;
|
this.sectionChildrenActionOnDelete = childrenAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.deleteSectionModal.alertTitle = 'Delete Section';
|
this.deleteSectionModal.alertTitle = 'Delete Section';
|
||||||
|
@ -1161,7 +1169,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.deleteSectionModal.open();
|
this.deleteSectionModal.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteSection() {
|
deleteSection() {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
let path = [
|
let path = [
|
||||||
|
@ -1197,21 +1205,22 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.deleteSectionModal.cancel();
|
this.deleteSectionModal.cancel();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkForSchemaEnhancements(url: string) {
|
private checkForSchemaEnhancements(url: string) {
|
||||||
this.showCheckForSchemaEnhancements = this.isAdministrator && url && !this.properties.useOldStatisticsSchema && this.indicatorUtils.checkForSchemaEnhancements(url);
|
this.showCheckForSchemaEnhancements = this.isAdministrator && url && !this.properties.useOldStatisticsSchema && this.indicatorUtils.checkForSchemaEnhancements(url);
|
||||||
}
|
}
|
||||||
migrateFromOldImportJsonFile(charts){
|
|
||||||
|
migrateFromOldImportJsonFile(charts) {
|
||||||
// first section contains numbers
|
// first section contains numbers
|
||||||
// second contains charts
|
// second contains charts
|
||||||
let hasNumbers = false;
|
let hasNumbers = false;
|
||||||
for (let chart of charts) {
|
for (let chart of charts) {
|
||||||
if (chart['type'] == 'number') {
|
if (chart['type'] == 'number') {
|
||||||
hasNumbers = true;
|
hasNumbers = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let chartsSection = (hasNumbers?1:0); // no numbers: first sections contains charts
|
let chartsSection = (hasNumbers ? 1 : 0); // no numbers: first sections contains charts
|
||||||
for (let chart of charts) {
|
for (let chart of charts) {
|
||||||
if (chart['sectionIndex'] == null) {
|
if (chart['sectionIndex'] == null) {
|
||||||
chart['sectionIndex'] = chart['type'] == 'chart' ? chartsSection : 0;
|
chart['sectionIndex'] = chart['type'] == 'chart' ? chartsSection : 0;
|
||||||
|
@ -1219,7 +1228,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
}
|
}
|
||||||
return charts;
|
return charts;
|
||||||
}
|
}
|
||||||
|
|
||||||
importIndicatorsAndSave(charts: any[]) {
|
importIndicatorsAndSave(charts: any[]) {
|
||||||
let sectionsToSave: Section[] = [];
|
let sectionsToSave: Section[] = [];
|
||||||
let countIndicators = 0;
|
let countIndicators = 0;
|
||||||
|
@ -1246,7 +1255,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
} else if (!chart.url) {
|
} else if (!chart.url) {
|
||||||
invalid_file_message = "No indicator url is specified.";
|
invalid_file_message = "No indicator url is specified.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalid_file_message) {
|
if (invalid_file_message) {
|
||||||
UIkit.notification(invalid_file_message, {
|
UIkit.notification(invalid_file_message, {
|
||||||
status: 'danger',
|
status: 'danger',
|
||||||
|
@ -1257,7 +1266,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.importLoading = false;
|
this.importLoading = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chart.type == "chart") {
|
if (chart.type == "chart") {
|
||||||
indicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(chart.url), chart.url, chart.type, this.stakeholder);
|
indicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(chart.url), chart.url, chart.type, this.stakeholder);
|
||||||
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].charts) {
|
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].charts) {
|
||||||
|
@ -1267,7 +1276,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
exists = true;
|
exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (chart.type == "number") {
|
} else if (chart.type == "number") {
|
||||||
indicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.statisticsService.getNumberSource(chart.url), chart.url, this.stakeholder,
|
indicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.statisticsService.getNumberSource(chart.url), chart.url, this.stakeholder,
|
||||||
|
@ -1279,7 +1288,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
exists = true;
|
exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.isStakeholderParametersValid(indicatorPath)) {
|
if (!this.isStakeholderParametersValid(indicatorPath)) {
|
||||||
|
@ -1290,9 +1299,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
sectionsToSave[chart['sectionIndex']].indicators.push(i);
|
sectionsToSave[chart['sectionIndex']].indicators.push(i);
|
||||||
countIndicators++;
|
countIndicators++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duplicates > 0) {
|
if (duplicates > 0) {
|
||||||
UIkit.notification(duplicates + " urls already exist and will not be imported!", {
|
UIkit.notification(duplicates + " urls already exist and will not be imported!", {
|
||||||
status: 'warning',
|
status: 'warning',
|
||||||
|
@ -1325,7 +1334,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.importLoading = false;
|
this.importLoading = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public exportIndicators(subcategoryIndex) {
|
public exportIndicators(subcategoryIndex) {
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
let indicators = [];
|
let indicators = [];
|
||||||
|
@ -1348,7 +1357,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
});
|
});
|
||||||
index++;
|
index++;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[subcategoryIndex].charts.forEach(section => {
|
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[subcategoryIndex].charts.forEach(section => {
|
||||||
section.indicators.forEach(indicator => {
|
section.indicators.forEach(indicator => {
|
||||||
indicator.indicatorPaths.forEach(indicatorPath => {
|
indicator.indicatorPaths.forEach(indicatorPath => {
|
||||||
|
@ -1365,13 +1374,13 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let topic = this.stakeholder ? this.stakeholder.topics[this.topicIndex] : null;
|
let topic = this.stakeholder ? this.stakeholder.topics[this.topicIndex] : null;
|
||||||
let category = topic ? topic.categories[this.categoryIndex] : null;
|
let category = topic ? topic.categories[this.categoryIndex] : null;
|
||||||
let subCategory = category ? category.subCategories[this.subcategoryIndex] : null;
|
let subCategory = category ? category.subCategories[this.subcategoryIndex] : null;
|
||||||
|
|
||||||
var jsonFileUrl = window.URL.createObjectURL(new Blob([JSON.stringify(indicators)], {type: 'application/json'}));
|
var jsonFileUrl = window.URL.createObjectURL(new Blob([JSON.stringify(indicators)], {type: 'application/json'}));
|
||||||
var a = window.document.createElement('a');
|
var a = window.document.createElement('a');
|
||||||
window.document.body.appendChild(a);
|
window.document.body.appendChild(a);
|
||||||
|
@ -1381,10 +1390,10 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
a.click();
|
a.click();
|
||||||
window.URL.revokeObjectURL(jsonFileUrl);
|
window.URL.revokeObjectURL(jsonFileUrl);
|
||||||
a.remove(); // remove the element
|
a.remove(); // remove the element
|
||||||
|
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fileChangeEvent(fileInput: any, index) {
|
fileChangeEvent(fileInput: any, index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.editing = true;
|
this.editing = true;
|
||||||
|
@ -1392,7 +1401,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.filesToUpload = <Array<File>>fileInput.target.files;
|
this.filesToUpload = <Array<File>>fileInput.target.files;
|
||||||
this.upload();
|
this.upload();
|
||||||
}
|
}
|
||||||
|
|
||||||
upload() {
|
upload() {
|
||||||
if (this.filesToUpload.length == 0) {
|
if (this.filesToUpload.length == 0) {
|
||||||
console.error("There is no selected file to upload.");
|
console.error("There is no selected file to upload.");
|
||||||
|
@ -1417,11 +1426,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.makeFileRequest(this.properties.utilsService + '/upload?type=json', [], this.filesToUpload).then(async (result: string) => {
|
this.makeFileRequest(this.properties.utilsService + '/upload?type=json', [], this.filesToUpload).then(async (result: string) => {
|
||||||
|
|
||||||
let json_result = JSON.parse(result);
|
let json_result = JSON.parse(result);
|
||||||
|
|
||||||
// validate file
|
// validate file
|
||||||
if (!json_result || json_result.length == 0) {
|
if (!json_result || json_result.length == 0) {
|
||||||
UIkit.notification("Importing file is empty", {
|
UIkit.notification("Importing file is empty", {
|
||||||
|
@ -1445,7 +1454,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
this.importLoading = false;
|
this.importLoading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
makeFileRequest(url: string, params: Array<string>, files: Array<File>) {
|
makeFileRequest(url: string, params: Array<string>, files: Array<File>) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const formData: any = new FormData();
|
const formData: any = new FormData();
|
||||||
|
@ -1466,7 +1475,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
||||||
xhr.send(formData);
|
xhr.send(formData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
copyToClipboard(value) {
|
copyToClipboard(value) {
|
||||||
const tempBox = document.createElement('textarea');
|
const tempBox = document.createElement('textarea');
|
||||||
tempBox.style.position = 'fixed';
|
tempBox.style.position = 'fixed';
|
||||||
|
|
|
@ -39,7 +39,6 @@ export class StakeholderUtils {
|
||||||
{icon: 'incognito', value: "PRIVATE", label: 'Private'},
|
{icon: 'incognito', value: "PRIVATE", label: 'Private'},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
visibilityIcon: Map<Visibility, string> = new Map<Visibility, string>([
|
visibilityIcon: Map<Visibility, string> = new Map<Visibility, string>([
|
||||||
["PUBLIC", 'earth'],
|
["PUBLIC", 'earth'],
|
||||||
["PRIVATE", 'incognito'],
|
["PRIVATE", 'incognito'],
|
||||||
|
@ -59,10 +58,8 @@ export class StakeholderUtils {
|
||||||
public createFunderFromDefaultProfile(funder: Stakeholder, defaultTopics: Topic[]): Stakeholder {
|
public createFunderFromDefaultProfile(funder: Stakeholder, defaultTopics: Topic[]): Stakeholder {
|
||||||
funder.topics = HelperFunctions.copy(defaultTopics);
|
funder.topics = HelperFunctions.copy(defaultTopics);
|
||||||
for (let topic of funder.topics) {
|
for (let topic of funder.topics) {
|
||||||
// console.log('id:' + topic._id);
|
|
||||||
topic.defaultId = topic._id;
|
topic.defaultId = topic._id;
|
||||||
topic._id = null;
|
topic._id = null;
|
||||||
// console.log('defaultId:' + topic.defaultId);
|
|
||||||
for (let category of topic.categories) {
|
for (let category of topic.categories) {
|
||||||
category.defaultId = category._id;
|
category.defaultId = category._id;
|
||||||
category._id = null;
|
category._id = null;
|
||||||
|
@ -132,7 +129,6 @@ export class StakeholderUtils {
|
||||||
category.subCategories = subTokeep;
|
category.subCategories = subTokeep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log (funder);
|
|
||||||
return funder;
|
return funder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,6 +188,12 @@ export class IndicatorUtils {
|
||||||
{value: 'statistics', label: 'Statistics'},
|
{value: 'statistics', label: 'Statistics'},
|
||||||
{value: 'stats-tool', label: 'Statistics tool'}
|
{value: 'stats-tool', label: 'Statistics tool'}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
formats: Option[] = [
|
||||||
|
{value: "NUMBER", label: "Number"},
|
||||||
|
{value: "PERCENTAGE", label: "Percentage"}
|
||||||
|
];
|
||||||
|
|
||||||
sourceTypes: Option[] = [
|
sourceTypes: Option[] = [
|
||||||
{value: 'stats-tool', label: 'Statistics tool'}
|
{value: 'stats-tool', label: 'Statistics tool'}
|
||||||
];
|
];
|
||||||
|
@ -311,7 +313,7 @@ export class IndicatorUtils {
|
||||||
indicatorPath.filtersApplied = 0;
|
indicatorPath.filtersApplied = 0;
|
||||||
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
|
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
|
||||||
if (stakeholder.statsProfile) {
|
if (stakeholder.statsProfile) {
|
||||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix).join(stakeholder.statsProfile)
|
replacedUrl = replacedUrl.split(ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix).join(stakeholder.statsProfile);
|
||||||
}
|
}
|
||||||
if (indicatorPath.parameters) {
|
if (indicatorPath.parameters) {
|
||||||
Object.keys(indicatorPath.parameters).forEach(key => {
|
Object.keys(indicatorPath.parameters).forEach(key => {
|
||||||
|
@ -379,7 +381,6 @@ export class IndicatorUtils {
|
||||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName))
|
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName))
|
||||||
}
|
}
|
||||||
//Check apply enhancements return this.applySchemaEnhancements( ..);
|
//Check apply enhancements return this.applySchemaEnhancements( ..);
|
||||||
console.log(replacedUrl);
|
|
||||||
return (indicatorPath.chartObject ? indicatorPath.url + encodeURIComponent(replacedUrl) : replacedUrl);
|
return (indicatorPath.chartObject ? indicatorPath.url + encodeURIComponent(replacedUrl) : replacedUrl);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -432,10 +433,6 @@ export class IndicatorUtils {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let paramFields = queries["query"]["name"].split(".").slice(3);
|
let paramFields = queries["query"]["name"].split(".").slice(3);
|
||||||
// console.debug("Field Params length:" + paramFields.length)
|
|
||||||
// console.debug(paramFields)
|
|
||||||
// console.debug("Parameters length:" + queries["query"]["parameters"].length)
|
|
||||||
|
|
||||||
if ((paramFields.length + 2) == queries["query"]["parameters"].length || (paramFields.length * 2 + 4) == queries["query"]["parameters"].length) {
|
if ((paramFields.length + 2) == queries["query"]["parameters"].length || (paramFields.length * 2 + 4) == queries["query"]["parameters"].length) {
|
||||||
filterApplied = true;
|
filterApplied = true;
|
||||||
if (filterType == "start_year") {
|
if (filterType == "start_year") {
|
||||||
|
@ -453,7 +450,6 @@ export class IndicatorUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.debug(queries["query"])
|
|
||||||
// it is a name query
|
// it is a name query
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -522,7 +518,6 @@ export class IndicatorUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.debug(values);
|
|
||||||
return values.length > 1;
|
return values.length > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,6 +527,7 @@ export class IndicatorUtils {
|
||||||
indicator._id = form._id;
|
indicator._id = form._id;
|
||||||
form.indicatorPaths.forEach((indicatorPath, index) => {
|
form.indicatorPaths.forEach((indicatorPath, index) => {
|
||||||
indicator.indicatorPaths[index].type = indicatorPath.type;
|
indicator.indicatorPaths[index].type = indicatorPath.type;
|
||||||
|
indicator.indicatorPaths[index].format = indicatorPath.format;
|
||||||
if (addParameters) {
|
if (addParameters) {
|
||||||
indicatorPath.parameters.forEach(parameter => {
|
indicatorPath.parameters.forEach(parameter => {
|
||||||
indicator.indicatorPaths[index].parameters[parameter.key] = parameter.value;
|
indicator.indicatorPaths[index].parameters[parameter.key] = parameter.value;
|
||||||
|
@ -590,7 +586,6 @@ export class IndicatorUtils {
|
||||||
indicatorPath.url = indicatorPath.url.split("/")[indicatorPath.url.split("/").length - 1];
|
indicatorPath.url = indicatorPath.url.split("/")[indicatorPath.url.split("/").length - 1];
|
||||||
indicatorPath.chartObject = decodeURIComponent(url.split("json=")[1]);
|
indicatorPath.chartObject = decodeURIComponent(url.split("json=")[1]);
|
||||||
let chart = JSON.parse(indicatorPath.chartObject);
|
let chart = JSON.parse(indicatorPath.chartObject);
|
||||||
// console.debug(indicatorPath);
|
|
||||||
if (indicatorPath.url == "chart?json=") {
|
if (indicatorPath.url == "chart?json=") {
|
||||||
|
|
||||||
if (chart["library"] && (chart["library"] == "HighCharts" || chart["library"] == "eCharts" || chart["library"] == "HighMaps")) {
|
if (chart["library"] && (chart["library"] == "HighCharts" || chart["library"] == "eCharts" || chart["library"] == "HighMaps")) {
|
||||||
|
@ -614,7 +609,6 @@ export class IndicatorUtils {
|
||||||
this.extractStartYear(chart, indicatorPath);
|
this.extractStartYear(chart, indicatorPath);
|
||||||
this.extractEndYear(chart, indicatorPath);
|
this.extractEndYear(chart, indicatorPath);
|
||||||
indicatorPath.chartObject = JSON.stringify(chart);
|
indicatorPath.chartObject = JSON.stringify(chart);
|
||||||
console.log(indicatorPath);
|
|
||||||
}
|
}
|
||||||
} else if (source === 'old') {
|
} else if (source === 'old') {
|
||||||
indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data=";
|
indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data=";
|
||||||
|
@ -634,8 +628,6 @@ export class IndicatorUtils {
|
||||||
indicatorPath.url = url;
|
indicatorPath.url = url;
|
||||||
indicatorPath.type = type;
|
indicatorPath.type = type;
|
||||||
}
|
}
|
||||||
// console.debug(indicatorPath.parameters);
|
|
||||||
// console.debug(indicatorPath.chartObject);
|
|
||||||
if (indicatorPath.type == null) {
|
if (indicatorPath.type == null) {
|
||||||
indicatorPath.type = this.defaultChartType;
|
indicatorPath.type = this.defaultChartType;
|
||||||
}
|
}
|
||||||
|
@ -684,7 +676,7 @@ export class IndicatorUtils {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
||||||
if(query["query"]["profile"]) {
|
if (query["query"]["profile"]) {
|
||||||
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
||||||
}
|
}
|
||||||
if (!query["query"]["filters"]) {
|
if (!query["query"]["filters"]) {
|
||||||
|
@ -713,7 +705,7 @@ export class IndicatorUtils {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
||||||
if(query["query"]["profile"]) {
|
if (query["query"]["profile"]) {
|
||||||
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
||||||
}
|
}
|
||||||
if (!query["query"]["filters"]) {
|
if (!query["query"]["filters"]) {
|
||||||
|
@ -740,7 +732,7 @@ export class IndicatorUtils {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
|
||||||
if(query["query"]["profile"]) {
|
if (query["query"]["profile"]) {
|
||||||
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
|
||||||
}
|
}
|
||||||
if (!query["query"]["filters"]) {
|
if (!query["query"]["filters"]) {
|
||||||
|
@ -971,8 +963,6 @@ export class IndicatorUtils {
|
||||||
}
|
}
|
||||||
url = url.split('json=')[0] + "json=" + encodeURIComponent(JSON.stringify(obj));
|
url = url.split('json=')[0] + "json=" + encodeURIComponent(JSON.stringify(obj));
|
||||||
}
|
}
|
||||||
console.debug(changes);
|
|
||||||
console.debug(url);
|
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue