|
|
|
@ -34,6 +34,7 @@ import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
|
|
|
|
|
import {Notification} from "../openaireLibrary/notifications/notifications";
|
|
|
|
|
import {NotificationUtils} from "../openaireLibrary/notifications/notification-utils";
|
|
|
|
|
import {NotifyFormComponent} from "../openaireLibrary/notifications/notify-form/notify-form.component";
|
|
|
|
|
import {NotificationService} from "../openaireLibrary/notifications/notification.service";
|
|
|
|
|
|
|
|
|
|
declare var UIkit;
|
|
|
|
|
|
|
|
|
@ -45,9 +46,6 @@ declare var UIkit;
|
|
|
|
|
export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit {
|
|
|
|
|
filesToUpload: Array<File>;
|
|
|
|
|
errorMessage = "";
|
|
|
|
|
import_loading: boolean = false;
|
|
|
|
|
export_loading: boolean = false;
|
|
|
|
|
|
|
|
|
|
@Input()
|
|
|
|
|
public properties: EnvProperties = null;
|
|
|
|
|
@Input()
|
|
|
|
@ -85,32 +83,36 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
/** Safe Urls*/
|
|
|
|
|
public safeUrls: Map<string, SafeResourceUrl> = new Map<string, SafeResourceUrl>([]);
|
|
|
|
|
public numberResults: Map<string, number> = new Map<string, number>();
|
|
|
|
|
/** Import / Export Indicators */
|
|
|
|
|
importLoading: boolean = false;
|
|
|
|
|
exportLoading: boolean = false;
|
|
|
|
|
private subscriptions: any[] = [];
|
|
|
|
|
private urlSubscriptions: any[] = [];
|
|
|
|
|
@ViewChild('editChartModal', { static: true }) editChartModal: AlertModal;
|
|
|
|
|
@ViewChild('editNumberModal', { static: true }) editNumberModal: AlertModal;
|
|
|
|
|
@ViewChild('deleteModal', { static: true }) deleteModal: AlertModal;
|
|
|
|
|
@ViewChild('editChartModal', {static: true}) editChartModal: AlertModal;
|
|
|
|
|
@ViewChild('editNumberModal', {static: true}) editNumberModal: AlertModal;
|
|
|
|
|
@ViewChild('deleteModal', {static: true}) deleteModal: AlertModal;
|
|
|
|
|
//@ViewChild('deleteAllModal') deleteAllModal: AlertModal;
|
|
|
|
|
//@ViewChild('deleteAndDisconnectModal') deleteAndDisconnectModal: AlertModal;
|
|
|
|
|
//@ViewChild('deleteChartSectionModal') deleteChartSectionModal: AlertModal;
|
|
|
|
|
//@ViewChild('deleteNumberSectionModal') deleteNumberSectionModal: AlertModal;
|
|
|
|
|
@ViewChild('deleteSectionModal', { static: true }) deleteSectionModal: AlertModal;
|
|
|
|
|
@ViewChild('importModal', { static: true }) importModal: AlertModal;
|
|
|
|
|
@ViewChild('deleteSectionModal', {static: true}) deleteSectionModal: AlertModal;
|
|
|
|
|
public sectionTypeToDelete: string;
|
|
|
|
|
public sectionChildrenActionOnDelete: string;
|
|
|
|
|
public indicatorChildrenActionOnDelete: string;
|
|
|
|
|
private firstLoad: boolean = true;
|
|
|
|
|
|
|
|
|
|
urlParameterizedMessage = null;
|
|
|
|
|
showCheckForSchemaEnhancements:boolean = false;
|
|
|
|
|
showCheckForSchemaEnhancements: boolean = false;
|
|
|
|
|
private notification: Notification;
|
|
|
|
|
@ViewChild('editNumberNotify', { static: true }) editNumberNotify: NotifyFormComponent;
|
|
|
|
|
@ViewChild('editChartNotify', { static: true }) editChartNotify: NotifyFormComponent;
|
|
|
|
|
@ViewChild('deleteNotify', { static: true }) deleteNotify: NotifyFormComponent;
|
|
|
|
|
@ViewChild('editNumberNotify', {static: true}) editNumberNotify: NotifyFormComponent;
|
|
|
|
|
@ViewChild('editChartNotify', {static: true}) editChartNotify: NotifyFormComponent;
|
|
|
|
|
@ViewChild('deleteNotify', {static: true}) deleteNotify: NotifyFormComponent;
|
|
|
|
|
|
|
|
|
|
constructor(private layoutService: LayoutService,
|
|
|
|
|
private stakeholderService: StakeholderService,
|
|
|
|
|
private statisticsService: StatisticsService,
|
|
|
|
|
private userManagementService: UserManagementService,
|
|
|
|
|
private notificationService: NotificationService,
|
|
|
|
|
private fb: FormBuilder,
|
|
|
|
|
private router: Router,
|
|
|
|
|
private cdr: ChangeDetectorRef,
|
|
|
|
@ -664,11 +666,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)
|
|
|
|
|
|| (!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): FormArray {
|
|
|
|
|
let jsonPath = this.fb.array([]);
|
|
|
|
|
if (indicatorPath.jsonPath) {
|
|
|
|
@ -760,7 +764,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
}
|
|
|
|
|
this.editNumberModal.open();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public editChartIndicatorOpen(section: Section, id = null) {
|
|
|
|
|
this.urlParameterizedMessage = null;
|
|
|
|
|
this.urlSubscriptions.forEach(value => {
|
|
|
|
@ -820,7 +824,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
} else {
|
|
|
|
|
this.editChartModal.alertTitle = 'Edit chart indicator\'s information';
|
|
|
|
|
this.editChartModal.okButtonText = 'Save Changes';
|
|
|
|
|
this.notification = NotificationUtils.editIndicator(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name);;
|
|
|
|
|
this.notification = NotificationUtils.editIndicator(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name);
|
|
|
|
|
;
|
|
|
|
|
this.editChartNotify.reset(this.notification.message);
|
|
|
|
|
}
|
|
|
|
|
this.editChartModal.open();
|
|
|
|
@ -852,9 +857,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
}
|
|
|
|
|
this.notification.entity = indicator._id;
|
|
|
|
|
this.notification.stakeholder = this.stakeholder.alias;
|
|
|
|
|
this.notification.stakeholderType = this.stakeholder.type;
|
|
|
|
|
this.notification.groups = [Role.curator( this.stakeholder.type)];
|
|
|
|
|
if(this.stakeholder.defaultId) {
|
|
|
|
|
this.notification.stakeholderType = this.stakeholder.type;
|
|
|
|
|
this.notification.groups = [Role.curator(this.stakeholder.type)];
|
|
|
|
|
if (this.stakeholder.defaultId) {
|
|
|
|
|
this.notification.groups.push(Role.manager(this.stakeholder.type, this.stakeholder.alias));
|
|
|
|
|
if (this.indicator.type === "chart") {
|
|
|
|
|
this.filterCharts();
|
|
|
|
@ -866,7 +871,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
this.editNumberNotify.sendNotification(this.notification);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL, null, this.stakeholder._id).subscribe(stakeholders => {
|
|
|
|
|
this.stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL, null, this.stakeholder._id).subscribe(stakeholders => {
|
|
|
|
|
stakeholders.forEach(value => {
|
|
|
|
|
this.notification.groups.push(Role.manager(value.type, value.alias))
|
|
|
|
|
});
|
|
|
|
@ -897,7 +902,8 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
this.editing = false;
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
saveIndicators(indicators:Indicator[]) {
|
|
|
|
|
|
|
|
|
|
saveIndicators(indicators: Indicator[]) {
|
|
|
|
|
this.editing = true;
|
|
|
|
|
let path = [
|
|
|
|
|
this.stakeholder._id,
|
|
|
|
@ -911,8 +917,51 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
this.buildSections();
|
|
|
|
|
this.filterCharts();
|
|
|
|
|
this.filterNumbers();
|
|
|
|
|
this.initReorder();
|
|
|
|
|
this.notification = NotificationUtils.importIndicators(this.user.fullname, this.stakeholder.alias);
|
|
|
|
|
this.notification.entity = this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id;
|
|
|
|
|
this.notification.name = this.user.firstname;
|
|
|
|
|
this.notification.surname = this.user.lastname;
|
|
|
|
|
this.notification.stakeholder = this.stakeholder.alias;
|
|
|
|
|
this.notification.stakeholderType = this.stakeholder.type;
|
|
|
|
|
this.notification.groups = [Role.curator(this.stakeholder.type)];
|
|
|
|
|
if (this.stakeholder.defaultId) {
|
|
|
|
|
this.notification.groups.push(Role.manager(this.stakeholder.type, this.stakeholder.alias));
|
|
|
|
|
this.notificationService.sendNotification(this.notification).subscribe(notification => {
|
|
|
|
|
UIkit.notification('A notification has been <b>sent</b> successfully', {
|
|
|
|
|
status: 'success',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
}, error => {
|
|
|
|
|
UIkit.notification('An error has occurred. Please try again later', {
|
|
|
|
|
status: 'danger',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL, null, this.stakeholder._id).subscribe(stakeholders => {
|
|
|
|
|
stakeholders.forEach(value => {
|
|
|
|
|
this.notification.groups.push(Role.manager(value.type, value.alias))
|
|
|
|
|
});
|
|
|
|
|
this.notificationService.sendNotification(this.notification).subscribe(notification => {
|
|
|
|
|
UIkit.notification('A notification has been <b>sent</b> successfully', {
|
|
|
|
|
status: 'success',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
}, error => {
|
|
|
|
|
UIkit.notification('An error has occurred. Please try again later', {
|
|
|
|
|
status: 'danger',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
UIkit.notification("Success! Indicated were imported", {
|
|
|
|
|
status: 'success',
|
|
|
|
|
timeout: 6000,
|
|
|
|
@ -926,11 +975,12 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reorderIndicators(sectionId: string, type: IndicatorType, reorder: Reorder) {
|
|
|
|
|
this.editing = true;
|
|
|
|
|
let path = [
|
|
|
|
@ -1027,13 +1077,13 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
});
|
|
|
|
|
this.notification.entity = this.indicator._id;
|
|
|
|
|
this.notification.stakeholder = this.stakeholder.alias;
|
|
|
|
|
this.notification.stakeholderType = this.stakeholder.type;
|
|
|
|
|
this.notification.groups = [Role.curator( this.stakeholder.type)];
|
|
|
|
|
if(this.stakeholder.defaultId) {
|
|
|
|
|
this.notification.stakeholderType = this.stakeholder.type;
|
|
|
|
|
this.notification.groups = [Role.curator(this.stakeholder.type)];
|
|
|
|
|
if (this.stakeholder.defaultId) {
|
|
|
|
|
this.notification.groups.push(Role.manager(this.stakeholder.type, this.stakeholder.alias));
|
|
|
|
|
this.deleteNotify.sendNotification(this.notification);
|
|
|
|
|
} else {
|
|
|
|
|
this.stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL, null, this.stakeholder._id).subscribe(stakeholders => {
|
|
|
|
|
this.stakeholderService.getStakeholders(this.properties.monitorServiceAPIURL, null, this.stakeholder._id).subscribe(stakeholders => {
|
|
|
|
|
stakeholders.forEach(value => {
|
|
|
|
|
this.notification.groups.push(Role.manager(value.type, value.alias))
|
|
|
|
|
});
|
|
|
|
@ -1224,41 +1274,43 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
this.editing = false;
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
private checkForSchemaEnhancements(url:string){
|
|
|
|
|
|
|
|
|
|
private checkForSchemaEnhancements(url: string) {
|
|
|
|
|
//new schema
|
|
|
|
|
this.showCheckForSchemaEnhancements = this.isAdministrator && url && !this.properties.useOldStatisticsSchema && this.indicatorUtils.checkForSchemaEnhancements(url);
|
|
|
|
|
}
|
|
|
|
|
importIndicatorsAndSave( charts:any[]){
|
|
|
|
|
let indicators:Indicator[] = [];
|
|
|
|
|
// name description additionalDescription, height, width, visibility
|
|
|
|
|
let noValidParams = 0;
|
|
|
|
|
let duplicates = 0;
|
|
|
|
|
for(let chart of charts) {
|
|
|
|
|
let exists = false;
|
|
|
|
|
|
|
|
|
|
importIndicatorsAndSave(charts: any[]) {
|
|
|
|
|
let indicators: Indicator[] = [];
|
|
|
|
|
// name description additionalDescription, height, width, visibility
|
|
|
|
|
let noValidParams = 0;
|
|
|
|
|
let duplicates = 0;
|
|
|
|
|
for (let chart of charts) {
|
|
|
|
|
let exists = false;
|
|
|
|
|
let indicatorPath;
|
|
|
|
|
// validate indicators' schema from file
|
|
|
|
|
let invalid_file_message = "";
|
|
|
|
|
if (!chart.type) {
|
|
|
|
|
invalid_file_message = "No indicator type is specified. Type should be chart or number.";
|
|
|
|
|
} else if(chart.type != "chart" && chart.type != "number") {
|
|
|
|
|
} else if (chart.type != "chart" && chart.type != "number") {
|
|
|
|
|
invalid_file_message = "Invalid indicator type. Type should be chart or number.";
|
|
|
|
|
} else if(chart.type == "number" && !chart.jsonPath) {
|
|
|
|
|
} else if (chart.type == "number" && !chart.jsonPath) {
|
|
|
|
|
invalid_file_message = "No jsonPath is specified for number indicator."
|
|
|
|
|
} else if(!chart.url) {
|
|
|
|
|
} else if (!chart.url) {
|
|
|
|
|
invalid_file_message = "No indicator url is specified.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(invalid_file_message) {
|
|
|
|
|
|
|
|
|
|
if (invalid_file_message) {
|
|
|
|
|
UIkit.notification(invalid_file_message, {
|
|
|
|
|
status: 'danger',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (chart.type == "chart") {
|
|
|
|
|
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.subcategoryIndex].charts) {
|
|
|
|
@ -1268,9 +1320,9 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
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,
|
|
|
|
|
chart.jsonPath, this.statisticsService.numberSources.get(this.statisticsService.getNumberSource(chart.url)));
|
|
|
|
|
for (let section of this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex].numbers) {
|
|
|
|
@ -1280,26 +1332,26 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
exists = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!this.isStakeholderParametersValid(indicatorPath)) {
|
|
|
|
|
noValidParams++;
|
|
|
|
|
}
|
|
|
|
|
if (!exists) {
|
|
|
|
|
let i: Indicator = new Indicator(chart.name, chart.description, chart.additionalDescription, chart.type, chart.width, chart.height,"RESTRICTED", [indicatorPath]);
|
|
|
|
|
let i: Indicator = new Indicator(chart.name, chart.description, chart.additionalDescription, chart.type, chart.width, chart.height, "RESTRICTED", [indicatorPath]);
|
|
|
|
|
indicators.push(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(duplicates > 0 ){
|
|
|
|
|
if (duplicates > 0) {
|
|
|
|
|
UIkit.notification(duplicates + " urls already exist and will not be imported!", {
|
|
|
|
|
status: 'warning',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if(noValidParams > 0 ){
|
|
|
|
|
if (noValidParams > 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.";
|
|
|
|
@ -1310,36 +1362,27 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
}else if(indicators.length > 0){
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
} else if (indicators.length > 0) {
|
|
|
|
|
console.log(indicators);
|
|
|
|
|
this.saveIndicators(indicators)
|
|
|
|
|
}
|
|
|
|
|
if(indicators.length == 0){
|
|
|
|
|
UIkit.notification( " No urls imported!", {
|
|
|
|
|
if (indicators.length == 0) {
|
|
|
|
|
UIkit.notification(" No urls imported!", {
|
|
|
|
|
status: 'warning',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public clickImportIndicators(){
|
|
|
|
|
this.importModal.cancelButton = false;
|
|
|
|
|
this.importModal.okButtonLeft = false;
|
|
|
|
|
this.importModal.alertMessage = false;
|
|
|
|
|
this.importModal.alertTitle = 'Import Indicators';
|
|
|
|
|
this.importModal.okButtonText = 'Cancel';
|
|
|
|
|
this.importModal.open();
|
|
|
|
|
}
|
|
|
|
|
public export_indicators() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public exportIndicators() {
|
|
|
|
|
this.editing = true;
|
|
|
|
|
this.export_loading = true;
|
|
|
|
|
|
|
|
|
|
this.exportLoading = true;
|
|
|
|
|
let indicators = [];
|
|
|
|
|
let index: number = 0;
|
|
|
|
|
|
|
|
|
|
this.displayNumbers.forEach(section => {
|
|
|
|
|
section.indicators.forEach(indicator => {
|
|
|
|
|
indicator.indicatorPaths.forEach(indicatorPath => {
|
|
|
|
@ -1354,7 +1397,7 @@ public clickImportIndicators(){
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.displayCharts.forEach(section => {
|
|
|
|
|
section.indicators.forEach(indicator => {
|
|
|
|
|
indicator.indicatorPaths.forEach(indicatorPath => {
|
|
|
|
@ -1369,11 +1412,11 @@ public clickImportIndicators(){
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let topic = this.stakeholder ? this.stakeholder.topics[this.topicIndex] : null;
|
|
|
|
|
let category = topic ? topic.categories[this.categoryIndex] : null;
|
|
|
|
|
let subCategory = category ? category.subCategories[this.subcategoryIndex] : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var jsonFileUrl = window.URL.createObjectURL(new Blob([JSON.stringify(indicators)], {type: 'application/json'}));
|
|
|
|
|
var a = window.document.createElement('a');
|
|
|
|
|
window.document.body.appendChild(a);
|
|
|
|
@ -1383,19 +1426,18 @@ public clickImportIndicators(){
|
|
|
|
|
a.click();
|
|
|
|
|
window.URL.revokeObjectURL(jsonFileUrl);
|
|
|
|
|
a.remove(); // remove the element
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.export_loading = false;
|
|
|
|
|
this.exportLoading = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileChangeEvent(fileInput: any) {
|
|
|
|
|
this.editing = true;
|
|
|
|
|
this.import_loading = true;
|
|
|
|
|
this.importLoading = true;
|
|
|
|
|
this.filesToUpload = <Array<File>>fileInput.target.files;
|
|
|
|
|
this.upload();
|
|
|
|
|
this.importModal.cancel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
upload() {
|
|
|
|
|
if (this.filesToUpload.length == 0) {
|
|
|
|
|
console.error("There is no selected file to upload.");
|
|
|
|
@ -1405,7 +1447,7 @@ public clickImportIndicators(){
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
if (this.filesToUpload[0].name.indexOf(".json") == -1 || (this.filesToUpload[0].type != "application/json")) {
|
|
|
|
@ -1416,25 +1458,25 @@ public clickImportIndicators(){
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// this.loading.open();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.makeFileRequest(this.properties.utilsService + '/upload?type=json', [], this.filesToUpload).then(async (result: string) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let json_result = JSON.parse(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// validate file
|
|
|
|
|
if(!json_result || json_result.length == 0) {
|
|
|
|
|
if (!json_result || json_result.length == 0) {
|
|
|
|
|
UIkit.notification("Importing file is empty", {
|
|
|
|
|
status: 'danger',
|
|
|
|
|
timeout: 6000,
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.importIndicatorsAndSave(json_result);
|
|
|
|
|
}
|
|
|
|
@ -1446,10 +1488,10 @@ public clickImportIndicators(){
|
|
|
|
|
pos: 'bottom-right'
|
|
|
|
|
});
|
|
|
|
|
this.editing = false;
|
|
|
|
|
this.import_loading = false;
|
|
|
|
|
this.importLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
makeFileRequest(url: string, params: Array<string>, files: Array<File>) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
const formData: any = new FormData();
|
|
|
|
|