[develop | FIXED | CHANGED]: Add stakeholder in export indicators file and import base on this stakeholder.
This commit is contained in:
parent
b6cda48e2f
commit
0c75394621
|
@ -14,16 +14,6 @@
|
||||||
(click)="deleteSectionOpen(number, i, 'number', 'delete')">
|
(click)="deleteSectionOpen(number, i, 'number', 'delete')">
|
||||||
<icon name="close" [flex]="true"></icon>
|
<icon name="close" [flex]="true"></icon>
|
||||||
</a>
|
</a>
|
||||||
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
|
|
||||||
<!-- <button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"-->
|
|
||||||
<!-- [title]="(number.defaultId?'Default sections cannot be deleted':'Delete all related sections')"-->
|
|
||||||
<!-- (click)="deleteSectionOpen(number, i, 'number', 'delete')"><i class="material-icons">highlight_off</i>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
<!-- <button [disabled]="editing || number.defaultId " class="md-btn md-btn-mini"-->
|
|
||||||
<!-- [title]="(number.defaultId?'Default sections cannot be deleted':'Delete section and disconnect related')"-->
|
|
||||||
<!-- (click)="deleteSectionOpen(number, i, 'number', 'disconnect')"><i class="material-icons">link_off</i>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
<!-- </ng-container>-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="numberSections.at(i)" class="uk-margin-medium-bottom">
|
<div *ngIf="numberSections.at(i)" class="uk-margin-medium-bottom">
|
||||||
|
@ -113,16 +103,6 @@
|
||||||
(click)="deleteSectionOpen(chart, i, 'chart', 'delete')">
|
(click)="deleteSectionOpen(chart, i, 'chart', 'delete')">
|
||||||
<icon name="close" [flex]="true"></icon>
|
<icon name="close" [flex]="true"></icon>
|
||||||
</a>
|
</a>
|
||||||
<!-- <ng-container *ngIf="!stakeholder.defaultId">-->
|
|
||||||
<!-- <button [disabled]="editing || chart.defaultId " class="md-btn md-btn-mini"-->
|
|
||||||
<!-- [title]="(chart.defaultId?'Default sections cannot be deleted':'Delete all related sections')"-->
|
|
||||||
<!-- (click)="deleteSectionOpen(chart, i, 'chart', 'delete')"><i class="material-icons">highlight_off</i>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
<!-- <button [disabled]="editing || chart.defaultId " class="md-btn md-btn-mini"-->
|
|
||||||
<!-- [title]="(chart.defaultId?'Default sections cannot be deleted':'Delete section and disconnect related')"-->
|
|
||||||
<!-- (click)="deleteSectionOpen(chart, i, 'chart', 'disconnect')"><i class="material-icons">link_off</i>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
<!-- </ng-container>-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="chartSections.at(i)"
|
<div *ngIf="chartSections.at(i)"
|
||||||
|
@ -187,7 +167,6 @@
|
||||||
<img class="uk-width-1-1 uk-blend-multiply" [ngClass]="'uk-height-' + (indicator.height?indicator.height.toLowerCase():'medium')"
|
<img class="uk-width-1-1 uk-blend-multiply" [ngClass]="'uk-height-' + (indicator.height?indicator.height.toLowerCase():'medium')"
|
||||||
[src]="indicator.indicatorPaths[0].url">
|
[src]="indicator.indicatorPaths[0].url">
|
||||||
</div>
|
</div>
|
||||||
<!--<ng-container *ngTemplateOutlet="description; context: {indicator:indicator}"></ng-container>-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -440,8 +419,6 @@
|
||||||
<iframe *ngIf="indicator.indicatorPaths[i].source !== 'image'" [class.uk-blend-multiply]="!isFullscreen"
|
<iframe *ngIf="indicator.indicatorPaths[i].source !== 'image'" [class.uk-blend-multiply]="!isFullscreen"
|
||||||
[src]="indicator.indicatorPaths[i].safeResourceUrl" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"
|
[src]="indicator.indicatorPaths[i].safeResourceUrl" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"
|
||||||
class="uk-width-1-1 uk-height-large"></iframe>
|
class="uk-width-1-1 uk-height-large"></iframe>
|
||||||
<!-- <div *ngIf="properties.disableFrameLoad && indicator.indicatorPaths[i].source !== 'image'" class="uk-alert uk-alert-danger uk-text-center">I frames-->
|
|
||||||
<!-- preview is disabled</div>-->
|
|
||||||
<div *ngIf="indicator.indicatorPaths[i].source === 'image'">
|
<div *ngIf="indicator.indicatorPaths[i].source === 'image'">
|
||||||
<img class="uk-width-1-1 uk-height-large uk-blend-multiply" [src]="indicator.indicatorPaths[i].url">
|
<img class="uk-width-1-1 uk-height-large uk-blend-multiply" [src]="indicator.indicatorPaths[i].url">
|
||||||
</div>
|
</div>
|
||||||
|
@ -462,25 +439,10 @@
|
||||||
<div *ngIf="indicatorChildrenActionOnDelete == 'delete'" class="uk-text-bold">
|
<div *ngIf="indicatorChildrenActionOnDelete == 'delete'" class="uk-text-bold">
|
||||||
Indicators of all profiles based on this default indicator, will be deleted as well.
|
Indicators of all profiles based on this default indicator, will be deleted as well.
|
||||||
</div>
|
</div>
|
||||||
<!-- <span *ngIf="indicatorChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
|
|
||||||
<!-- Indicators of all profiles based on this default indicator, will not be marked as copied from default anymore.-->
|
|
||||||
<!-- </span>-->
|
|
||||||
Are you sure you want to proceed?
|
Are you sure you want to proceed?
|
||||||
<div #deleteNotify notify-form class="uk-width-1-1 uk-margin-medium-top"></div>
|
<div #deleteNotify notify-form class="uk-width-1-1 uk-margin-medium-top"></div>
|
||||||
</div>
|
</div>
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
<!--<modal-alert #deleteAllModal (alertOutput)="deleteIndicator('delete')">
|
|
||||||
You are about to delete <span class="uk-text-bold" *ngIf="indicator && index !== -1">
|
|
||||||
"{{indicator.name ? indicator.name : indicator.indicatorPaths[0].parameters.title}}"</span> indicator permanently.
|
|
||||||
<span class="uk-text-bold">Indicators of all profiles based on this default indicator, will be deleted as well.</span>
|
|
||||||
Are you sure you want to proceed?
|
|
||||||
</modal-alert>
|
|
||||||
<modal-alert #deleteAndDisconnectModal (alertOutput)="deleteIndicator('disconnect')">
|
|
||||||
You are about to delete <span class="uk-text-bold" *ngIf="indicator && index !== -1">
|
|
||||||
"{{indicator.name ? indicator.name : indicator.indicatorPaths[0].parameters.title}}"</span> indicator permanently.
|
|
||||||
<span class="uk-text-bold">Indicators of all profiles based on this default indicator, will not be marked as copied from default anymore.</span>
|
|
||||||
Are you sure you want to proceed?
|
|
||||||
</modal-alert>-->
|
|
||||||
<modal-alert #deleteSectionModal (alertOutput)="deleteSection()" [overflowBody]="false" classTitle="uk-background-primary uk-light">
|
<modal-alert #deleteSectionModal (alertOutput)="deleteSection()" [overflowBody]="false" classTitle="uk-background-primary uk-light">
|
||||||
<div [class.uk-invisible]="editing" class="uk-position-relative">
|
<div [class.uk-invisible]="editing" class="uk-position-relative">
|
||||||
<div *ngIf="editing">
|
<div *ngIf="editing">
|
||||||
|
@ -490,20 +452,9 @@
|
||||||
<div *ngIf="sectionChildrenActionOnDelete == 'delete' && !stakeholder.defaultId" class="uk-text-bold">
|
<div *ngIf="sectionChildrenActionOnDelete == 'delete' && !stakeholder.defaultId" class="uk-text-bold">
|
||||||
Sections of all profiles based on this default section and their contents, will be deleted as well.
|
Sections of all profiles based on this default section and their contents, will be deleted as well.
|
||||||
</div>
|
</div>
|
||||||
<!-- <span *ngIf="sectionChildrenActionOnDelete == 'disconnect'" class="uk-text-bold">-->
|
|
||||||
<!-- Sections of all profiles based on this default section and their contents, will not be marked as copied from default anymore.-->
|
|
||||||
<!-- </span>-->
|
|
||||||
Are you sure you want to proceed?
|
Are you sure you want to proceed?
|
||||||
</div>
|
</div>
|
||||||
</modal-alert>
|
</modal-alert>
|
||||||
<!--<modal-alert #deleteNumberSectionModal (alertOutput)="deleteSection('number')">
|
|
||||||
You are about to delete this section and its indicators permanently.
|
|
||||||
Are you sure you want to proceed?
|
|
||||||
</modal-alert>
|
|
||||||
<modal-alert #deleteChartSectionModal (alertOutput)="deleteSection()">
|
|
||||||
You are about to delete this section and its indicators permanently.
|
|
||||||
Are you sure you want to proceed?
|
|
||||||
</modal-alert>-->
|
|
||||||
<ng-template #new_section let-type="type">
|
<ng-template #new_section let-type="type">
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="uk-flex uk-flex-center" (click)="createSection(-1, type)">
|
<div class="uk-flex uk-flex-center" (click)="createSection(-1, type)">
|
||||||
|
|
|
@ -504,16 +504,6 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
this.numberIndicatorPaths.at(index).get('result').setValue(null);
|
this.numberIndicatorPaths.at(index).get('result').setValue(null);
|
||||||
if (this.numberIndicatorPaths.at(index).get('url').valid) {
|
if (this.numberIndicatorPaths.at(index).get('url').valid) {
|
||||||
let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.indicatorUtils.getNumberSource(value), value, this.stakeholder, this.numberIndicatorPaths.at(index).get('jsonPath').value, this.indicatorUtils.numberSources.get(this.indicatorUtils.getNumberSource(value)));
|
let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.indicatorUtils.getNumberSource(value), value, this.stakeholder, this.numberIndicatorPaths.at(index).get('jsonPath').value, this.indicatorUtils.numberSources.get(this.indicatorUtils.getNumberSource(value)));
|
||||||
if (!this.isStakeholderParametersValid(indicatorPath)) {
|
|
||||||
// default profile
|
|
||||||
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."
|
|
||||||
} else {
|
|
||||||
this.urlParameterizedMessage = "This indicator couldn't be generated properly. Please make sure chart data is for the current stakeholder."
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.urlParameterizedMessage = null;
|
|
||||||
}
|
|
||||||
this.checkForSchemaEnhancements(this.numberIndicatorPaths.at(index).get('url').value);
|
this.checkForSchemaEnhancements(this.numberIndicatorPaths.at(index).get('url').value);
|
||||||
if (this.indicator.indicatorPaths[index]) {
|
if (this.indicator.indicatorPaths[index]) {
|
||||||
this.indicator.indicatorPaths[index] = indicatorPath;
|
this.indicator.indicatorPaths[index] = indicatorPath;
|
||||||
|
@ -574,16 +564,6 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
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.indicatorUtils.getChartSource(value), value, this.chartIndicatorPaths.at(index).get('type').value, this.stakeholder);
|
let indicatorPath: IndicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.indicatorUtils.getChartSource(value), value, this.chartIndicatorPaths.at(index).get('type').value, this.stakeholder);
|
||||||
if (!this.isStakeholderParametersValid(indicatorPath)) {
|
|
||||||
// default profile
|
|
||||||
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."
|
|
||||||
} else {
|
|
||||||
this.urlParameterizedMessage = "This chart couldn't be generated properly. Please make sure chart data is for the current stakeholder."
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.urlParameterizedMessage = null;
|
|
||||||
}
|
|
||||||
this.checkForSchemaEnhancements(this.chartIndicatorPaths.at(index).get('url').value);
|
this.checkForSchemaEnhancements(this.chartIndicatorPaths.at(index).get('url').value);
|
||||||
(this.chartIndicatorPaths.at(index) as UntypedFormGroup).get('type').setValue(indicatorPath.type);
|
(this.chartIndicatorPaths.at(index) as UntypedFormGroup).get('type').setValue(indicatorPath.type);
|
||||||
(this.chartIndicatorPaths.at(index) as UntypedFormGroup).setControl('parameters', this.getParametersAsFormArray(indicatorPath));
|
(this.chartIndicatorPaths.at(index) as UntypedFormGroup).setControl('parameters', this.getParametersAsFormArray(indicatorPath));
|
||||||
|
@ -601,12 +581,6 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|
||||||
|| (!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) {
|
||||||
|
@ -1159,24 +1133,6 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteNumberSectionOpen(section: Section, index: number) {
|
|
||||||
// this.section = section;
|
|
||||||
// this.index = index;
|
|
||||||
// this.deleteNumberSectionModal.alertTitle = 'Delete Section';
|
|
||||||
// this.deleteNumberSectionModal.cancelButtonText = 'No';
|
|
||||||
// this.deleteNumberSectionModal.okButtonText = 'Yes';
|
|
||||||
// this.deleteNumberSectionModal.open();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// deleteChartSectionOpen(section: Section, index: number) {
|
|
||||||
// this.section = section;
|
|
||||||
// this.index = index;
|
|
||||||
// this.deleteChartSectionModal.alertTitle = 'Delete Section';
|
|
||||||
// this.deleteChartSectionModal.cancelButtonText = 'No';
|
|
||||||
// this.deleteChartSectionModal.okButtonText = 'Yes';
|
|
||||||
// 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;
|
||||||
|
@ -1256,11 +1212,20 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
return charts;
|
return charts;
|
||||||
}
|
}
|
||||||
|
|
||||||
importIndicatorsAndSave(charts: any[]) {
|
importIndicatorsAndSave(stakeholder: Stakeholder, charts: any[]) {
|
||||||
let sectionsToSave: Section[] = [];
|
let sectionsToSave: Section[] = [];
|
||||||
let countIndicators = 0;
|
let countIndicators = 0;
|
||||||
|
if(stakeholder.type !== this.stakeholder.type) {
|
||||||
|
UIkit.notification("The type of this profile is not the same with the file's one!", {
|
||||||
|
status: 'warning',
|
||||||
|
timeout: 6000,
|
||||||
|
pos: 'bottom-right'
|
||||||
|
});
|
||||||
|
this.editing = false;
|
||||||
|
this.importLoading = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
// name description additionalDescription, height, width, visibility
|
// name description additionalDescription, height, width, visibility
|
||||||
let noValidParams = 0;
|
|
||||||
let duplicates = 0;
|
let duplicates = 0;
|
||||||
charts = this.migrateFromOldImportJsonFile(charts);
|
charts = this.migrateFromOldImportJsonFile(charts);
|
||||||
for (let chart of charts) {
|
for (let chart of charts) {
|
||||||
|
@ -1296,7 +1261,7 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chart.type == "chart") {
|
if (chart.type == "chart") {
|
||||||
indicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.indicatorUtils.getChartSource(chart.url), chart.url, chart.type, this.stakeholder);
|
indicatorPath = this.indicatorUtils.generateIndicatorByChartUrl(this.indicatorUtils.getChartSource(chart.url), chart.url, chart.type, 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) {
|
||||||
for (let chart of section.indicators) {
|
for (let chart of section.indicators) {
|
||||||
if (JSON.stringify(chart.indicatorPaths[0].chartObject) == JSON.stringify(indicatorPath.chartObject)) {
|
if (JSON.stringify(chart.indicatorPaths[0].chartObject) == JSON.stringify(indicatorPath.chartObject)) {
|
||||||
|
@ -1304,10 +1269,9 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
exists = true;
|
exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (chart.type == "number") {
|
} else if (chart.type == "number") {
|
||||||
indicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.indicatorUtils.getNumberSource(chart.url), chart.url, this.stakeholder,
|
indicatorPath = this.indicatorUtils.generateIndicatorByNumberUrl(this.indicatorUtils.getNumberSource(chart.url), chart.url, stakeholder,
|
||||||
chart.jsonPath, this.indicatorUtils.numberSources.get(this.indicatorUtils.getNumberSource(chart.url)));
|
chart.jsonPath, this.indicatorUtils.numberSources.get(this.indicatorUtils.getNumberSource(chart.url)));
|
||||||
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].numbers) {
|
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.index].numbers) {
|
||||||
for (let chart of section.indicators) {
|
for (let chart of section.indicators) {
|
||||||
|
@ -1316,20 +1280,14 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
exists = true;
|
exists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.isStakeholderParametersValid(indicatorPath)) {
|
|
||||||
noValidParams++;
|
|
||||||
}
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
let i: Indicator = new Indicator(chart.name, chart.description, chart.additionalDescription, chart.type, chart.width, chart.height, this.showVisibility?"RESTRICTED":this.stakeholderUtils.defaultValue(this.stakeholderUtils.visibilities), [indicatorPath]);
|
let i: Indicator = new Indicator(chart.name, chart.description, chart.additionalDescription, chart.type, chart.width, chart.height, this.showVisibility?"RESTRICTED":this.stakeholderUtils.defaultValue(this.stakeholderUtils.visibilities), [indicatorPath]);
|
||||||
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',
|
||||||
|
@ -1337,19 +1295,7 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
pos: 'bottom-right'
|
pos: 'bottom-right'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (noValidParams > 0 && !(this.stakeholder.type == 'country')) {
|
if (sectionsToSave.length > 0 && countIndicators > 0) {
|
||||||
let noValidMessage = "Some indicators couldn't be generated properly. Please make sure chart data is for the current stakeholder.";
|
|
||||||
if (this.stakeholder.defaultId == null) {
|
|
||||||
noValidMessage = "Some indicators couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly.";
|
|
||||||
}
|
|
||||||
UIkit.notification(noValidMessage, {
|
|
||||||
status: 'danger',
|
|
||||||
timeout: 6000,
|
|
||||||
pos: 'bottom-right'
|
|
||||||
});
|
|
||||||
this.editing = false;
|
|
||||||
this.importLoading = false;
|
|
||||||
} else if (sectionsToSave.length > 0 && countIndicators > 0) {
|
|
||||||
this.saveIndicators(sectionsToSave.filter(section => !!section));
|
this.saveIndicators(sectionsToSave.filter(section => !!section));
|
||||||
}
|
}
|
||||||
if (sectionsToSave.length == 0 || countIndicators == 0) {
|
if (sectionsToSave.length == 0 || countIndicators == 0) {
|
||||||
|
@ -1408,8 +1354,11 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
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[subcategoryIndex] : null;
|
let subCategory = category ? category.subCategories[subcategoryIndex] : null;
|
||||||
|
let json = {
|
||||||
var jsonFileUrl = window.URL.createObjectURL(new Blob([JSON.stringify(indicators)], {type: 'application/json'}));
|
stakeholder: this.stakeholder,
|
||||||
|
indicators: indicators
|
||||||
|
}
|
||||||
|
var jsonFileUrl = window.URL.createObjectURL(new Blob([JSON.stringify(json)], {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);
|
||||||
a.setAttribute('style', 'display: none');
|
a.setAttribute('style', 'display: none');
|
||||||
|
@ -1456,11 +1405,17 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = JSON.parse(result);
|
||||||
let json_result = JSON.parse(result);
|
|
||||||
|
|
||||||
// validate file
|
// validate file
|
||||||
if (!json_result || json_result.length == 0) {
|
if(json && Array.isArray(json)) {
|
||||||
|
UIkit.notification("This file is not supported any more. Please export indicators and try again!", {
|
||||||
|
status: 'danger',
|
||||||
|
timeout: 6000,
|
||||||
|
pos: 'bottom-right'
|
||||||
|
});
|
||||||
|
this.editing = false;
|
||||||
|
this.importLoading = false;
|
||||||
|
} else if (!json || json?.indicators.length == 0) {
|
||||||
UIkit.notification("Importing file is empty", {
|
UIkit.notification("Importing file is empty", {
|
||||||
status: 'danger',
|
status: 'danger',
|
||||||
timeout: 6000,
|
timeout: 6000,
|
||||||
|
@ -1469,7 +1424,7 @@ export class IndicatorsComponent extends IndicatorStakeholderBaseComponent imple
|
||||||
this.editing = false;
|
this.editing = false;
|
||||||
this.importLoading = false;
|
this.importLoading = false;
|
||||||
} else {
|
} else {
|
||||||
this.importIndicatorsAndSave(json_result);
|
this.importIndicatorsAndSave(json.stakeholder, json.indicators);
|
||||||
}
|
}
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
console.error("Error importing files", error);
|
console.error("Error importing files", error);
|
||||||
|
|
Loading…
Reference in New Issue