Import/ Exprort: only for curators, import: set Restricted for indicators
This commit is contained in:
parent
26d31191af
commit
e009a7526f
|
@ -1,8 +1,8 @@
|
|||
<div *ngIf="stakeholder && canEdit">
|
||||
<div class="uk-text-right uk-width-expand">
|
||||
<div *ngIf="isCurator" class="uk-text-right uk-width-expand">
|
||||
<a class="uk-margin-bottom uk-margin-right " [attr.uk-icon]="export_loading ? null : 'icon:download'" title="Export indicators (JSON file)"
|
||||
(click)="export_indicators()">
|
||||
<span class="uk-text-small">Export</span>
|
||||
<span class="">Export</span>
|
||||
<span *ngIf="export_loading" class="uk-margin-small-left uk-icon icon-button"><loading [top_margin]="false"></loading></span>
|
||||
</a>
|
||||
<div uk-form-custom class="js-upload uk-margin-top">
|
||||
|
|
|
@ -1228,7 +1228,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
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;
|
||||
|
@ -1236,12 +1235,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
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) {
|
||||
invalid_file_message = "No jsonPath is specified for number indicator."
|
||||
|
@ -1250,7 +1248,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
}
|
||||
|
||||
if(invalid_file_message) {
|
||||
UIkit.notification("Error on indicators' schema. Type should be chart or number, url is needed and for number indicators, jsonPath is needed as well.", {
|
||||
UIkit.notification(invalid_file_message, {
|
||||
status: 'danger',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
|
@ -1288,7 +1286,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
noValidParams++;
|
||||
}
|
||||
if (!exists) {
|
||||
let i: Indicator = new Indicator(chart.name, chart.description, chart.additionalDescription, chart.type, chart.width, chart.height, chart.visibility, [indicatorPath]);
|
||||
let i: Indicator = new Indicator(chart.name, chart.description, chart.additionalDescription, chart.type, chart.width, chart.height,"RESTRICTED", [indicatorPath]);
|
||||
indicators.push(i);
|
||||
}
|
||||
|
||||
|
@ -1301,11 +1299,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
});
|
||||
}
|
||||
if(noValidParams > 0 ){
|
||||
let noValidMesseage = "Some indicators couldn't be generated properly. Please make sure chart data is for the current stakeholder.";
|
||||
let noValidMessage = "Some indicators couldn't be generated properly. Please make sure chart data is for the current stakeholder.";
|
||||
if (this.stakeholder.defaultId == null) {
|
||||
noValidMesseage = "Some indicators couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly.";
|
||||
noValidMessage = "Some indicators couldn't be generated properly. Stakeholders based on this profile may not inherit the data correctly.";
|
||||
}
|
||||
UIkit.notification(noValidMesseage, {
|
||||
UIkit.notification(noValidMessage, {
|
||||
status: 'danger',
|
||||
timeout: 6000,
|
||||
pos: 'bottom-right'
|
||||
|
@ -1328,8 +1326,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
}
|
||||
|
||||
public export_indicators() {
|
||||
console.debug("Export indicators");
|
||||
|
||||
this.editing = true;
|
||||
this.export_loading = true;
|
||||
|
||||
|
@ -1339,7 +1335,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
this.displayNumbers.forEach(section => {
|
||||
section.indicators.forEach(indicator => {
|
||||
indicator.indicatorPaths.forEach(indicatorPath => {
|
||||
console.debug("export number: ", this.statisticsService.getNumberUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)));
|
||||
// console.debug("export number: ", this.statisticsService.getNumberUrl(indicatorPath.source, this.indicatorUtils.getFullUrl(this.stakeholder, indicatorPath)));
|
||||
indicators[index] = {
|
||||
"type": indicator.type, "name": indicator.name, "jsonPath": indicatorPath.jsonPath,
|
||||
"description": indicator.description, "additionalDescription": indicator.additionalDescription,
|
||||
|
@ -1354,7 +1350,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
this.displayCharts.forEach(section => {
|
||||
section.indicators.forEach(indicator => {
|
||||
indicator.indicatorPaths.forEach(indicatorPath => {
|
||||
console.debug("export chart: " + this.getUrlByStakeHolder(indicatorPath));
|
||||
// console.debug("export chart: " + this.getUrlByStakeHolder(indicatorPath));
|
||||
indicators[index] = {
|
||||
"type": indicator.type, "name": indicator.name,
|
||||
"description": indicator.description, "additionalDescription": indicator.additionalDescription,
|
||||
|
@ -1393,7 +1389,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
|
|||
}
|
||||
|
||||
upload() {
|
||||
console.debug(this.filesToUpload);
|
||||
if (this.filesToUpload.length == 0) {
|
||||
console.error("There is no selected file to upload.");
|
||||
UIkit.notification("There is no selected file to upload.", {
|
||||
|
|
Loading…
Reference in New Issue