|
|
@ -76,7 +76,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Toggles
|
|
|
|
* Toggles
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// public grid: boolean = true;
|
|
|
|
// public grid: boolean = true;
|
|
|
|
public editing: boolean = false;
|
|
|
|
public editing: boolean = false;
|
|
|
|
/** Safe Urls*/
|
|
|
|
/** Safe Urls*/
|
|
|
|
public safeUrls: Map<string, SafeResourceUrl> = new Map<string, SafeResourceUrl>([]);
|
|
|
|
public safeUrls: Map<string, SafeResourceUrl> = new Map<string, SafeResourceUrl>([]);
|
|
|
@ -96,7 +96,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
public indicatorChildrenActionOnDelete: string;
|
|
|
|
public indicatorChildrenActionOnDelete: string;
|
|
|
|
|
|
|
|
|
|
|
|
urlParameterizedMessage = "";
|
|
|
|
urlParameterizedMessage = "";
|
|
|
|
constructor(private layoutService: LayoutService,
|
|
|
|
|
|
|
|
|
|
|
|
constructor(private layoutService: LayoutService,
|
|
|
|
private stakeholderService: StakeholderService,
|
|
|
|
private stakeholderService: StakeholderService,
|
|
|
|
private statisticsService: StatisticsService,
|
|
|
|
private statisticsService: StatisticsService,
|
|
|
|
private userManagementService: UserManagementService,
|
|
|
|
private userManagementService: UserManagementService,
|
|
|
@ -112,7 +113,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
|
|
|
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
|
|
|
|
this.stakeholder = stakeholder;
|
|
|
|
this.stakeholder = stakeholder;
|
|
|
|
if(this.stakeholder) {
|
|
|
|
if (this.stakeholder) {
|
|
|
|
this.buildFilters();
|
|
|
|
this.buildFilters();
|
|
|
|
this.buildSections();
|
|
|
|
this.buildSections();
|
|
|
|
this.filterCharts();
|
|
|
|
this.filterCharts();
|
|
|
@ -153,7 +154,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
let urls: Map<string, [number, number][]> = new Map<string, [number, number][]>();
|
|
|
|
let urls: Map<string, [number, number][]> = new Map<string, [number, number][]>();
|
|
|
|
this.numbers.forEach((section, i) => {
|
|
|
|
this.numbers.forEach((section, i) => {
|
|
|
|
section.indicators.forEach((number, j) => {
|
|
|
|
section.indicators.forEach((number, j) => {
|
|
|
|
let url =this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, number.indicatorPaths[0]);
|
|
|
|
let url = this.indicatorUtils.getFullUrlWithFilters(this.stakeholder, number.indicatorPaths[0]);
|
|
|
|
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
|
|
|
|
const pair = JSON.stringify([number.indicatorPaths[0].source, url]);
|
|
|
|
const indexes = urls.get(pair) ? urls.get(pair) : [];
|
|
|
|
const indexes = urls.get(pair) ? urls.get(pair) : [];
|
|
|
|
indexes.push([i, j]);
|
|
|
|
indexes.push([i, j]);
|
|
|
@ -162,7 +163,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
});
|
|
|
|
});
|
|
|
|
urls.forEach((indexes, pair) => {
|
|
|
|
urls.forEach((indexes, pair) => {
|
|
|
|
pair = JSON.parse(pair);
|
|
|
|
pair = JSON.parse(pair);
|
|
|
|
this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => {
|
|
|
|
this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => {
|
|
|
|
indexes.forEach(([i, j]) => {
|
|
|
|
indexes.forEach(([i, j]) => {
|
|
|
|
let result = JSON.parse(JSON.stringify(response));
|
|
|
|
let result = JSON.parse(JSON.stringify(response));
|
|
|
|
this.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => {
|
|
|
|
this.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => {
|
|
|
@ -170,7 +171,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
result = result[jsonPath];
|
|
|
|
result = result[jsonPath];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if(typeof result == 'string') {
|
|
|
|
if (typeof result == 'string') {
|
|
|
|
this.numberResults.set(i + '-' + j, Number(result));
|
|
|
|
this.numberResults.set(i + '-' + j, Number(result));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -179,9 +180,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setPreview() {
|
|
|
|
setPreview() {
|
|
|
|
if(this.stakeholder){
|
|
|
|
if (this.stakeholder) {
|
|
|
|
this.preview = '/' + this.stakeholder.alias;
|
|
|
|
this.preview = '/' + this.stakeholder.alias;
|
|
|
|
if(this.stakeholder.topics[this.topicIndex]) {
|
|
|
|
if (this.stakeholder.topics[this.topicIndex]) {
|
|
|
|
this.preview = '/' + this.stakeholder.alias + '/' + this.stakeholder.topics[this.topicIndex].alias;
|
|
|
|
this.preview = '/' + this.stakeholder.alias + '/' + this.stakeholder.topics[this.topicIndex].alias;
|
|
|
|
if (this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]) {
|
|
|
|
if (this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]) {
|
|
|
|
this.preview += '/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].alias;
|
|
|
|
this.preview += '/' + this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].alias;
|
|
|
@ -330,7 +331,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private filterStatus(sections: Section[], value): Section[] {
|
|
|
|
private filterStatus(sections: Section[], value): Section[] {
|
|
|
|
if (value !== 'all') {
|
|
|
|
if (value !== 'all') {
|
|
|
|
sections.forEach(section =>
|
|
|
|
sections.forEach(section =>
|
|
|
@ -344,7 +344,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
sections.forEach(section =>
|
|
|
|
sections.forEach(section =>
|
|
|
|
section.indicators = section.indicators.filter(indicator => (indicator.name && indicator.name.toLowerCase().includes(value.toLowerCase()))
|
|
|
|
section.indicators = section.indicators.filter(indicator => (indicator.name && indicator.name.toLowerCase().includes(value.toLowerCase()))
|
|
|
|
|| (indicator.description && indicator.description.toLowerCase().includes(value.toLowerCase()))
|
|
|
|
|| (indicator.description && indicator.description.toLowerCase().includes(value.toLowerCase()))
|
|
|
|
|| (indicator.additionalDescription && indicator.additionalDescription.toLowerCase().includes(value.toLowerCase()))
|
|
|
|
|| (indicator.additionalDescription && indicator.additionalDescription.toLowerCase().includes(value.toLowerCase()))
|
|
|
|
|| indicator.indicatorPaths.filter(indicatorPath => (indicatorPath.parameters && indicatorPath.parameters.title &&
|
|
|
|
|| indicator.indicatorPaths.filter(indicatorPath => (indicatorPath.parameters && indicatorPath.parameters.title &&
|
|
|
|
indicatorPath.parameters.title.includes(value.toLowerCase()))).length > 0));
|
|
|
|
indicatorPath.parameters.title.includes(value.toLowerCase()))).length > 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -404,11 +404,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 paaths comma separated, split them and autogenerate the forms
|
|
|
|
//if in the first path there are more than one paaths comma separated, split them and autogenerate the forms
|
|
|
|
let paths = this.getJsonPath(index).getRawValue()[index].split(",");
|
|
|
|
let paths = this.getJsonPath(index).getRawValue()[index].split(",");
|
|
|
|
for(let i = 0; i< paths.length; i++){
|
|
|
|
for (let i = 0; i < paths.length; i++) {
|
|
|
|
if(i !=0){
|
|
|
|
if (i != 0) {
|
|
|
|
this.getJsonPath(index).push(this.fb.control('', Validators.required));
|
|
|
|
this.getJsonPath(index).push(this.fb.control('', Validators.required));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -418,15 +418,43 @@ 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) {
|
|
|
|
this.getJsonPath(i).removeAt(j);
|
|
|
|
this.getJsonPath(i).removeAt(j);
|
|
|
|
this.getJsonPath(i).markAsDirty();
|
|
|
|
if (this.getJsonPath(i).length !== this.getCurrentJsonPath(i).length) {
|
|
|
|
|
|
|
|
this.getJsonPath(i).markAsDirty();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public validateJsonPath(index: number) {
|
|
|
|
|
|
|
|
let indicatorPath: FormGroup = <FormGroup>this.numberIndicatorPaths.at(index);
|
|
|
|
|
|
|
|
this.getJsonPath(index).disable();
|
|
|
|
|
|
|
|
this.statisticsService.getNumbers(null, indicatorPath.get('url').value).subscribe(response => {
|
|
|
|
|
|
|
|
let result = JSON.parse(JSON.stringify(response));
|
|
|
|
|
|
|
|
this.getJsonPath(index).controls.forEach(jsonPath => {
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
|
|
result = result[jsonPath.value];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout( () => {
|
|
|
|
|
|
|
|
if (typeof result == 'string') {
|
|
|
|
|
|
|
|
this.getJsonPath(index).enable();
|
|
|
|
|
|
|
|
this.getJsonPath(index).setErrors(null);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.getJsonPath(index).enable();
|
|
|
|
|
|
|
|
this.getJsonPath(index).setErrors({invalid: true});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public getJsonPath(index: number): FormArray {
|
|
|
|
public getJsonPath(index: number): FormArray {
|
|
|
|
return this.numberIndicatorPaths.at(index).get('jsonPath') as FormArray;
|
|
|
|
return this.numberIndicatorPaths.at(index).get('jsonPath') as FormArray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getCurrentJsonPath(index: number): string[] {
|
|
|
|
|
|
|
|
return this.section.indicators[this.index].indicatorPaths[index].jsonPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public getParameters(index: number): FormArray {
|
|
|
|
public getParameters(index: number): FormArray {
|
|
|
|
return this.chartIndicatorPaths.at(index).get('parameters') as FormArray;
|
|
|
|
return this.chartIndicatorPaths.at(index).get('parameters') as FormArray;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -444,8 +472,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
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: FormArray = new FormArray([]), source: string = 'search', jsonPath: FormArray = new FormArray([])) {
|
|
|
|
public addNumberIndicatorPath(url: string = '', parameters: FormArray = new FormArray([]), source: string = 'search', jsonPath: FormArray = new FormArray([])) {
|
|
|
|
if(jsonPath.length === 0) {
|
|
|
|
if (jsonPath.length === 0) {
|
|
|
|
jsonPath.push(this.fb.control('', Validators.required));
|
|
|
|
jsonPath.push(this.fb.control('', Validators.required));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.numberIndicatorPaths.push(this.fb.group({
|
|
|
|
this.numberIndicatorPaths.push(this.fb.group({
|
|
|
@ -456,55 +484,43 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
}
|
|
|
|
}
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
|
|
for(let index = 0; index < this.numberIndicatorPaths.length; index++) {
|
|
|
|
for (let index = 0; index < this.numberIndicatorPaths.length; index++) {
|
|
|
|
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('url').valueChanges.subscribe(value => {
|
|
|
|
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('url').valueChanges.subscribe(value => {
|
|
|
|
if (this.numberIndicatorPaths.at(index).get('url').valid) {
|
|
|
|
if (this.numberIndicatorPaths.at(index).get('url').valid) {
|
|
|
|
let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.statisticsService.getNumberSource(value), value, this.stakeholder,this.numberIndicatorPaths.at(index).get('jsonPath').value );
|
|
|
|
let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.statisticsService.getNumberSource(value), value, this.stakeholder, this.numberIndicatorPaths.at(index).get('jsonPath').value);
|
|
|
|
if((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 )
|
|
|
|
if ((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)) {
|
|
|
|
// default profile
|
|
|
|
// default profile
|
|
|
|
if(this.stakeholder.defaultId == null){
|
|
|
|
if (this.stakeholder.defaultId == null) {
|
|
|
|
this.urlParameterizedMessage = "This indicator couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly."
|
|
|
|
this.urlParameterizedMessage = "This indicator couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly."
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
this.urlParameterizedMessage = "This indicator couldn't be generated properly. Please make sure chart data is for the current stakeholder."
|
|
|
|
this.urlParameterizedMessage = "This indicator couldn't be generated properly. Please make sure chart data is for the current stakeholder."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
this.urlParameterizedMessage = "";
|
|
|
|
this.urlParameterizedMessage = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* if(value != indicatorPath.url) {
|
|
|
|
/* if(value != indicatorPath.url) {
|
|
|
|
(this.numberIndicatorPaths.at(index) as FormGroup).get('url').setValue( indicatorPath.url);
|
|
|
|
(this.numberIndicatorPaths.at(index) as FormGroup).get('url').setValue( indicatorPath.url);
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
if (!this.indicator.indicatorPaths[index]) {
|
|
|
|
this.indicator.indicatorPaths[index] = indicatorPath;
|
|
|
|
this.indicator.indicatorPaths[index] = indicatorPath;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.indicator.indicatorPaths[index] = indicatorPath;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(this.numberIndicatorPaths.at(index) as FormGroup).get('source').setValue(indicatorPath.source);
|
|
|
|
(this.numberIndicatorPaths.at(index) as FormGroup).get('source').setValue(indicatorPath.source);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
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]) {
|
|
|
|
this.indicator.indicatorPaths[index].jsonPath = value;
|
|
|
|
this.indicator.indicatorPaths[index].jsonPath = value;
|
|
|
|
//this.getJsonPath(index).setErrors({invalid: true});
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.indicator.indicatorPaths[index].jsonPath = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('source').valueChanges.subscribe(value => {
|
|
|
|
this.subscriptions.push(this.numberIndicatorPaths.at(index).get('source').valueChanges.subscribe(value => {
|
|
|
|
if (!this.indicator.indicatorPaths[index]) {
|
|
|
|
this.indicator.indicatorPaths[index].source = value;
|
|
|
|
this.indicator.indicatorPaths[index].source = value;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.indicator.indicatorPaths[index].source = value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public addChartIndicatorPath(value: string = '', parameters: FormArray = new FormArray([]), disableUrl: boolean = false, type:string=null) {
|
|
|
|
public addChartIndicatorPath(value: string = '', parameters: FormArray = new FormArray([]), 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,
|
|
|
|
url: this.fb.control(value, [Validators.required,
|
|
|
|
Validators.pattern('https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' +
|
|
|
|
Validators.pattern('https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' +
|
|
|
@ -514,23 +530,23 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
type: this.fb.control(type)
|
|
|
|
type: this.fb.control(type)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
));
|
|
|
|
));
|
|
|
|
if(disableUrl) {
|
|
|
|
if (disableUrl) {
|
|
|
|
for(let index = 0; index < this.chartIndicatorPaths.length; index++) {
|
|
|
|
for (let index = 0; index < this.chartIndicatorPaths.length; index++) {
|
|
|
|
this.chartIndicatorPaths.at(index).get('url').disable();
|
|
|
|
this.chartIndicatorPaths.at(index).get('url').disable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
for(let index = 0; index < this.chartIndicatorPaths.length; index++) {
|
|
|
|
for (let index = 0; index < this.chartIndicatorPaths.length; index++) {
|
|
|
|
this.urlSubscriptions.push(this.chartIndicatorPaths.at(index).get('url').valueChanges.subscribe(value => {
|
|
|
|
this.urlSubscriptions.push(this.chartIndicatorPaths.at(index).get('url').valueChanges.subscribe(value => {
|
|
|
|
if (this.chartIndicatorPaths.at(index).get('url').valid) {
|
|
|
|
if (this.chartIndicatorPaths.at(index).get('url').valid) {
|
|
|
|
let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(value), value, this.chartIndicatorPaths.at(index).get('type').value, this.stakeholder);
|
|
|
|
let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.statisticsService.getChartSource(value), value, this.chartIndicatorPaths.at(index).get('type').value, this.stakeholder);
|
|
|
|
if(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 ){
|
|
|
|
if (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) {
|
|
|
|
// default profile
|
|
|
|
// default profile
|
|
|
|
if(this.stakeholder.defaultId == null){
|
|
|
|
if (this.stakeholder.defaultId == null) {
|
|
|
|
this.urlParameterizedMessage = "This chart couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly."
|
|
|
|
this.urlParameterizedMessage = "This chart couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly."
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
this.urlParameterizedMessage = "This chart couldn't be generated properly. Please make sure chart data is for the current stakeholder."
|
|
|
|
this.urlParameterizedMessage = "This chart couldn't be generated properly. Please make sure chart data is for the current stakeholder."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
} else {
|
|
|
|
this.urlParameterizedMessage = "";
|
|
|
|
this.urlParameterizedMessage = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(this.chartIndicatorPaths.at(index) as FormGroup).get('type').setValue(indicatorPath.type);
|
|
|
|
(this.chartIndicatorPaths.at(index) as FormGroup).get('type').setValue(indicatorPath.type);
|
|
|
@ -600,10 +616,10 @@ 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));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.indicator = new Indicator('', '', '','number', 'small', "PUBLIC", []);
|
|
|
|
this.indicator = new Indicator('', '', '', 'number', 'small', "PUBLIC", []);
|
|
|
|
this.numberIndicatorFb = this.fb.group({
|
|
|
|
this.numberIndicatorFb = this.fb.group({
|
|
|
|
_id: this.fb.control(this.indicator._id),
|
|
|
|
_id: this.fb.control(this.indicator._id),
|
|
|
|
name: this.fb.control(this.indicator.name, Validators.required),
|
|
|
|
name: this.fb.control(this.indicator.name, Validators.required),
|
|
|
@ -657,7 +673,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
indicatorPath.safeResourceUrl = this.getSecureUrlByStakeHolder(indicatorPath);
|
|
|
|
indicatorPath.safeResourceUrl = this.getSecureUrlByStakeHolder(indicatorPath);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.indicator = new Indicator('', '', '', 'chart', 'medium', "PUBLIC",[]);
|
|
|
|
this.indicator = new Indicator('', '', '', 'chart', 'medium', "PUBLIC", []);
|
|
|
|
this.chartIndicatorFb = this.fb.group({
|
|
|
|
this.chartIndicatorFb = this.fb.group({
|
|
|
|
_id: this.fb.control(this.indicator._id),
|
|
|
|
_id: this.fb.control(this.indicator._id),
|
|
|
|
name: this.fb.control(this.indicator.name),
|
|
|
|
name: this.fb.control(this.indicator.name),
|
|
|
@ -692,8 +708,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.numberIndicatorFb.value, this.indicator.indicatorPaths, this.indicator.type, false);
|
|
|
|
this.indicator = this.indicatorUtils.generateIndicatorByForm(this.numberIndicatorFb.value, this.indicator.indicatorPaths, this.indicator.type, false);
|
|
|
|
this.section = this.numbers.find(section => section._id === this.section._id);
|
|
|
|
this.section = this.numbers.find(section => section._id === this.section._id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.debug("Indicator to svae");
|
|
|
|
|
|
|
|
console.debug(this.indicator);
|
|
|
|
|
|
|
|
let path = [
|
|
|
|
let path = [
|
|
|
|
this.stakeholder._id,
|
|
|
|
this.stakeholder._id,
|
|
|
|
this.stakeholder.topics[this.topicIndex]._id,
|
|
|
|
this.stakeholder.topics[this.topicIndex]._id,
|
|
|
@ -707,7 +721,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.section.indicators.push(indicator);
|
|
|
|
this.section.indicators.push(indicator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.indicator.type === "chart") {
|
|
|
|
if (this.indicator.type === "chart") {
|
|
|
|
this.filterCharts();
|
|
|
|
this.filterCharts();
|
|
|
|
this.chartIndicatorFb = null;
|
|
|
|
this.chartIndicatorFb = null;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -769,7 +783,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -777,9 +791,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
|
|
|
|
|
|
|
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") {
|
|
|
|
this.indicatorChildrenActionOnDelete = childrenAction;
|
|
|
|
this.indicatorChildrenActionOnDelete = childrenAction;
|
|
|
|
} else if(childrenAction == "disconnect") {
|
|
|
|
} else if (childrenAction == "disconnect") {
|
|
|
|
this.indicatorChildrenActionOnDelete = childrenAction;
|
|
|
|
this.indicatorChildrenActionOnDelete = childrenAction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -830,7 +844,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
changeIndicatorStatus(sectionId: string, indicator: Indicator, visibility:Visibility) {
|
|
|
|
changeIndicatorStatus(sectionId: string, indicator: Indicator, visibility: Visibility) {
|
|
|
|
this.editing = true;
|
|
|
|
this.editing = true;
|
|
|
|
let path = [
|
|
|
|
let path = [
|
|
|
|
this.stakeholder._id,
|
|
|
|
this.stakeholder._id,
|
|
|
@ -980,7 +994,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
this.sectionChildrenActionOnDelete = null;
|
|
|
|
this.sectionChildrenActionOnDelete = null;
|
|
|
|
if (childrenAction == "delete") {
|
|
|
|
if (childrenAction == "delete") {
|
|
|
|