Merge remote-tracking branch 'origin/new-theme' into privacy-settings

This commit is contained in:
Konstantinos Triantafyllou 2022-09-19 17:15:27 +03:00
commit 5ac6847e65
2 changed files with 146 additions and 128 deletions

@ -1 +1 @@
Subproject commit b8ac4121379c5294d1201932af1ed76be34bdb84 Subproject commit 9939c2707cffbb8f2f15cfa79e80992cd58d6bdf

View File

@ -98,6 +98,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
@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'])
@ -105,6 +106,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
screenChange(event) { screenChange(event) {
this.isFullscreen = !this.isFullscreen; this.isFullscreen = !this.isFullscreen;
} }
/** /**
* Subscriptions * Subscriptions
**/ **/
@ -280,7 +282,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
urls.forEach((indexes, pair) => { urls.forEach((indexes, pair) => {
let parsed = JSON.parse(pair); let parsed = JSON.parse(pair);
let response = this.numberResponses.get(pair); let response = this.numberResponses.get(pair);
if(response) { if (response) {
this.calculateResults(response, indexes); this.calculateResults(response, indexes);
} else { } else {
this.numberSubscription.push(this.statisticsService.getNumbers(this.statisticsService.getSourceType(parsed[0]), parsed[1]).subscribe(response => { this.numberSubscription.push(this.statisticsService.getNumbers(this.statisticsService.getSourceType(parsed[0]), parsed[1]).subscribe(response => {
@ -812,7 +814,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
pos: 'bottom-right' pos: 'bottom-right'
}); });
this.editing = false; this.editing = false;
if(this.indicator.type === "chart") { if (this.indicator.type === "chart") {
this.editChartModal.cancel(); this.editChartModal.cancel();
} else { } else {
this.editNumberModal.cancel(); this.editNumberModal.cancel();
@ -825,7 +827,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
pos: 'bottom-right' pos: 'bottom-right'
}); });
this.editing = false; this.editing = false;
if(this.indicator.type === "chart") { if (this.indicator.type === "chart") {
this.editChartModal.cancel(); this.editChartModal.cancel();
} else { } else {
this.editNumberModal.cancel(); this.editNumberModal.cancel();
@ -886,7 +888,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
NotificationHandler.rise('Indicators have been <b>imported</b> successfully!'); NotificationHandler.rise('Indicators have been <b>imported</b> successfully!');
}, error => { }, error => {
this.chartIndicatorFb = null; this.chartIndicatorFb = null;
NotificationHandler.rise(error.error.message, 'danger'); NotificationHandler.rise('An error has occurred. Please try again later', 'danger');
this.editing = false; this.editing = false;
this.importLoading = false; this.importLoading = false;
})); }));
@ -1046,7 +1048,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
} }
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;
let path = [ let path = [
this.stakeholder._id, this.stakeholder._id,
@ -1199,6 +1201,24 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
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){
// first section contains numbers
// second contains charts
let hasNumbers = false;
for (let chart of charts) {
if (chart['type'] == 'number') {
hasNumbers = true;
break;
}
}
let chartsSection = (hasNumbers?1:0); // no numbers: first sections contains charts
for (let chart of charts) {
if (chart['sectionIndex'] == null) {
chart['sectionIndex'] = chart['type'] == 'chart' ? chartsSection : 0;
}
}
return charts;
}
importIndicatorsAndSave(charts: any[]) { importIndicatorsAndSave(charts: any[]) {
let sectionsToSave: Section[] = []; let sectionsToSave: Section[] = [];
@ -1206,19 +1226,17 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
// name description additionalDescription, height, width, visibility // name description additionalDescription, height, width, visibility
let noValidParams = 0; let noValidParams = 0;
let duplicates = 0; let duplicates = 0;
charts = this.migrateFromOldImportJsonFile(charts);
for (let chart of charts) { for (let chart of charts) {
if(!chart['sectionIndex']){ if (!sectionsToSave[chart['sectionIndex']]) {
chart['sectionIndex'] = chart['type'] == 'chart'?1:0; let sectionToSave = new Section(chart['sectionType'] ? chart['sectionType'] : chart['type'], chart['sectionTitle']);
}
if(!sectionsToSave[chart['sectionIndex']]){
let sectionToSave = new Section(chart['sectionType']?chart['sectionType']:chart['type'], chart['sectionTitle']);
sectionToSave.indicators = []; sectionToSave.indicators = [];
sectionsToSave[chart['sectionIndex']] = sectionToSave; sectionsToSave[chart['sectionIndex']] = sectionToSave;
} }
let exists = false; let exists = false;
let indicatorPath; let indicatorPath;
// validate indicators' schema from file // validate indicators' schema from file
let invalid_file_message = ""; let invalid_file_message;
if (!chart.type) { if (!chart.type) {
invalid_file_message = "No indicator type is specified. Type should be chart or number."; 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") {
@ -1270,7 +1288,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
if (!exists) { 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]);
sectionsToSave[chart['sectionIndex']].indicators.push(i); sectionsToSave[chart['sectionIndex']].indicators.push(i);
countIndicators ++ ; countIndicators++;
} }
} }
@ -1294,7 +1312,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}); });
this.editing = false; this.editing = false;
this.importLoading = false; this.importLoading = false;
} else if (sectionsToSave.length > 0 && countIndicators >0) { } else if (sectionsToSave.length > 0 && countIndicators > 0) {
this.saveIndicators(sectionsToSave) this.saveIndicators(sectionsToSave)
} }
if (sectionsToSave.length == 0 || countIndicators == 0) { if (sectionsToSave.length == 0 || countIndicators == 0) {
@ -1321,14 +1339,14 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
"description": indicator.description, "additionalDescription": indicator.additionalDescription, "description": indicator.description, "additionalDescription": indicator.additionalDescription,
"visibility": indicator.visibility, "width": indicator.width, "height": indicator.height, "visibility": indicator.visibility, "width": indicator.width, "height": indicator.height,
"url": this.statisticsService.getNumberUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)), "url": this.statisticsService.getNumberUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)),
"sectionTitle" : section.title, "sectionTitle": section.title,
"sectionType": section.type, "sectionType": section.type,
"sectionIndex": index "sectionIndex": index
}; };
indexIndicator++; indexIndicator++;
}); });
}); });
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 => {
@ -1339,14 +1357,14 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
"description": indicator.description, "additionalDescription": indicator.additionalDescription, "description": indicator.description, "additionalDescription": indicator.additionalDescription,
"visibility": indicator.visibility, "width": indicator.width, "height": indicator.height, "visibility": indicator.visibility, "width": indicator.width, "height": indicator.height,
"url": this.getUrlByStakeHolder(indicatorPath), "url": this.getUrlByStakeHolder(indicatorPath),
"sectionTitle" : section.title, "sectionTitle": section.title,
"sectionType": section.type, "sectionType": section.type,
"sectionIndex": index "sectionIndex": index
}; };
indexIndicator++; indexIndicator++;
}); });
}); });
index ++ ; index++;
}); });
@ -1459,7 +1477,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
document.body.appendChild(tempBox); document.body.appendChild(tempBox);
tempBox.focus(); tempBox.focus();
tempBox.select(); tempBox.select();
tempBox.setSelectionRange(0,99999); tempBox.setSelectionRange(0, 99999);
document.execCommand('copy'); document.execCommand('copy');
document.body.removeChild(tempBox); document.body.removeChild(tempBox);
NotificationHandler.rise('Copied to clipboard'); NotificationHandler.rise('Copied to clipboard');