Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ angular.module('georesourceBatchUpdateModal').component('georesourceBatchUpdateM
this.kommonitorImporterHelperServiceInstance = kommonitorImporterHelperService;
this.kommonitorBatchUpdateHelperServiceInstance = kommonitorBatchUpdateHelperService;

const supportedDatasourceTypes = ["FILE", "INLINE", "HTTP"];
const supportedConverters = ["GeoJSON", "Shapefile (ZIP-Ordner mit .shp, .dbf, .prj)", "Tabelle_Geokodierung_Adresse_strukturierte_Einzelspalten", "Tabelle_Geokodierung_Strasse_Hausnummer_Stadt", "Tabelle_Geokodierung_beliebige_Zeichenkette", "Tabelle_XY_Koordinate_zu_Punkt", "WFS_v1"];

$scope.isFirstStart = true;
$scope.lastUpdateResponseObj;
$scope.keepMissingValues = true;
Expand Down Expand Up @@ -62,9 +65,32 @@ angular.module('georesourceBatchUpdateModal').component('georesourceBatchUpdateM
}
});

$scope.getSupportedDatasourceTypes = function() {
var result = [];
kommonitorImporterHelperService.availableDatasourceTypes.forEach((dt) => {
if (supportedDatasourceTypes.includes(dt.type)) {
result.push(dt);
}
});
return result;
}

$scope.getSupportedConverters = function() {
var result = [];
kommonitorImporterHelperService.availableConverters.forEach((c) => {
if (supportedConverters.includes(c.name)) {
result.push(c);
}
});
return result;
}

// initializes the modal
$scope.initialize = function() {

$scope.availableDatasourceTypes = $scope.getSupportedDatasourceTypes();
$scope.availableConverters = $scope.getSupportedConverters();

if($scope.isFirstStart) {
kommonitorBatchUpdateHelperService.addNewRowToBatchList("georesource", $scope.batchList)
$scope.isFirstStart = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h4 class="modal-title">Batch-Update</h4>
<!-- Geodaten-Quellformat -->
<td>
<select class="form-control" ng-model="georesource.selectedConverter"
ng-options="converter as converter.name for converter in $ctrl.kommonitorImporterHelperServiceInstance.availableConverters | filter:$ctrl.kommonitorImporterHelperServiceInstance.filterConverters('georesource')" required>
ng-options="converter as converter.name for converter in availableConverters" required>
<option disabled selected value> -- Geodaten-Quellformat w&auml;hlen -- </option>
</select>
</td>
Expand Down Expand Up @@ -233,7 +233,7 @@ <h4 class="modal-title">Batch-Update</h4>
<!-- Datenquelltyp -->
<td>
<select ng-model="georesource.selectedDatasourceType"
ng-options="datasourceType as datasourceType.type for datasourceType in $ctrl.kommonitorImporterHelperServiceInstance.availableDatasourceTypes"
ng-options="datasourceType as datasourceType.type for datasourceType in availableDatasourceTypes"
class="form-control" required>
<option disabled selected value> -- Quelltyp w&auml;hlen -- </option>
</select>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ angular.module('indicatorBatchUpdateModal').component('indicatorBatchUpdateModal
this.kommonitorDataExchangeServiceInstance = kommonitorDataExchangeService;
this.kommonitorImporterHelperServiceInstance = kommonitorImporterHelperService;
this.kommonitorBatchUpdateHelperServiceInstance = kommonitorBatchUpdateHelperService;

const supportedDatasourceTypes = ["FILE", "INLINE", "HTTP"];
const supportedConverters = ["GeoJSON", "Shapefile (ZIP-Ordner mit .shp, .dbf, .prj)", "Tabelle_Zeitreihe_zu_Indikator", "WFS_v1"];

$scope.isFirstStart = true;
$scope.lastUpdateResponseObj;
Expand Down Expand Up @@ -61,9 +64,32 @@ angular.module('indicatorBatchUpdateModal').component('indicatorBatchUpdateModal
}
});

$scope.getSupportedDatasourceTypes = function() {
var result = [];
kommonitorImporterHelperService.availableDatasourceTypes.forEach((dt) => {
if (supportedDatasourceTypes.includes(dt.type)) {
result.push(dt);
}
});
return result;
}

$scope.getSupportedConverters = function() {
var result = [];
kommonitorImporterHelperService.availableConverters.forEach((c) => {
if (supportedConverters.includes(c.name)) {
result.push(c);
}
});
return result;
}


// initializes the modal
$scope.initialize = function() {

$scope.availableDatasourceTypes = $scope.getSupportedDatasourceTypes();
$scope.availableConverters = $scope.getSupportedConverters();

if($scope.isFirstStart) {
kommonitorBatchUpdateHelperService.addNewRowToBatchList("indicator", $scope.batchList)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h4 class="modal-title">Batch-Update</h4>
<!-- Datensatz-Quellformat -->
<td>
<select class="form-control" ng-model="indicator.selectedConverter"
ng-options="converter as converter.name for converter in $ctrl.kommonitorImporterHelperServiceInstance.availableConverters | filter:$ctrl.kommonitorImporterHelperServiceInstance.filterConverters('indicator')" required>
ng-options="converter as converter.name for converter in availableConverters" required>
<option disabled selected value> -- Datensatz-Quellformat w&auml;hlen -- </option>
</select>
</td>
Expand Down Expand Up @@ -152,7 +152,7 @@ <h4 class="modal-title">Batch-Update</h4>
<!-- Datenquelltyp -->
<td>
<select ng-model="indicator.selectedDatasourceType"
ng-options="datasourceType as datasourceType.type for datasourceType in $ctrl.kommonitorImporterHelperServiceInstance.availableDatasourceTypes"
ng-options="datasourceType as datasourceType.type for datasourceType in availableDatasourceTypes"
class="form-control" required>
<option disabled selected value> -- Quelltyp w&auml;hlen -- </option>
</select>
Expand Down
10 changes: 10 additions & 0 deletions app/components/kommonitorAdmin/kommonitor-admin.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ <h4><i class="icon fa fa-ban"></i>Achtung</h4>
<br />
<pre ng-bind-html="$ctrl.kommonitorDataExchangeServiceInstance.errorMessage"></pre>
</div>

<div style="position: absolute; left: 12%; top: 200px; width: 75%;" hidden
class="alert alert-warning alert-dismissable adminWarningAlert">
<button type="button" class="close" ng-click="$ctrl.kommonitorDataExchangeServiceInstance.hideWarningAlert()"
aria-hidden="true">&times;</button>
<h4><i class="icon fa fa-ban"></i>Achtung</h4>
Sie haben eine fehlerhafte Eingabe vorgenommen. Die Fehlermeldung lautet:
<br />
<pre ng-bind-html="$ctrl.kommonitorDataExchangeServiceInstance.warningMessage"></pre>
</div>

</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ angular
let thisService = this; // to enable access to service methods from inside other functions (e. g. $timeout) where 'this' references something else
let timeseriesMappingReference;

const unsupportedDatasourceWarningMessage = "Nicht unterstützte Datenquelle: Die in der Mappintabelle angegebene Datenquelle wird für ein Batch-Update noch nicht unterstützt. Bitte geben Sie eine andere Datenquelle an!";
const unsupportedConverterWarningMessage = "Nicht unterstützter Converter: Der in der Mappintabelle angegebene Converter wird für ein Batch-Update noch nicht unterstützt. Bitte geben Sie einen anderen Converter an!";
const invalidMappingTableErrorMessage = "Die Mappingtabelle konnte nicht gelesen werden oder hat ein fehlerhaftes Format.";

// Maps the values of the "name" property in the converter's parameter array to the property names used in the batch update
// We can't use the parameters array directly because we have to bind angularjs variables to object properties, not array elements
// Used in converterParametersArrayToProperties and converterPropertiesToParametersArray
Expand Down Expand Up @@ -596,7 +600,11 @@ angular

// Remove all properties that are not part of the selected converter.
// This is usually needed when the user switches to a different converter.
let paramNames = selectedConverter.parameters.map(obj => obj.name);
let paramNames = [];
if(selectedConverter.parameters) {
paramNames = selectedConverter.parameters.map(obj => obj.name);
}

for(var i=oldConverter.parameters.length-1; i>=0; i--) {
if(!paramNames.includes(oldConverter.parameters[i].name)) {
oldConverter.parameters.splice(i, 1);
Expand Down Expand Up @@ -1057,62 +1065,82 @@ angular

this.onMappingTableSelected = function(resourceType, event, rowIndex, file, batchList) {

let mappingObj = JSON.parse(event.target.result);
let mappingObj;
try {
mappingObj = JSON.parse(event.target.result);

batchList[rowIndex].mappingTableName = file.name;

mappingObj.converter = this.converterParametersArrayToProperties(mappingObj.converter);
mappingObj.dataSource = this.dataSourceParametersArrayToProperty(mappingObj.dataSource);

// set value of column "Datensatz-Quellformat*" by converter name
let converterName = mappingObj.converter.name
for(let i=0; i<kommonitorImporterHelperService.availableConverters.length; i++) {
let avConverterName = kommonitorImporterHelperService.availableConverters[i].name
if(converterName == avConverterName) {
$timeout(function() {
batchList[rowIndex].selectedConverter = kommonitorImporterHelperService.availableConverters[i];
});
break;
if (mappingObj.dataSource.type === "OGCAPI_FEATURES") {
kommonitorDataExchangeService.displayAdminWarning(unsupportedDatasourceWarningMessage);
return;
}
}

// set value of column "Datenquelltyp*" by dataSource type
if(mappingObj.dataSource) {
let dataSourceType = mappingObj.dataSource.type;
for(let i=0; i<kommonitorImporterHelperService.availableDatasourceTypes.length; i++) {
let avDataSourceType = kommonitorImporterHelperService.availableDatasourceTypes[i].type
if(dataSourceType == avDataSourceType) {

if (mappingObj.converter.name === "Geopackage (*.gpkg)") {
kommonitorDataExchangeService.displayAdminWarning(unsupportedConverterWarningMessage);
return;
}


batchList[rowIndex].mappingTableName = file.name;

mappingObj.converter = this.converterParametersArrayToProperties(mappingObj.converter);
mappingObj.dataSource = this.dataSourceParametersArrayToProperty(mappingObj.dataSource);

// set value of column "Datensatz-Quellformat*" by converter name
let converterName = mappingObj.converter.name
for(let i=0; i<kommonitorImporterHelperService.availableConverters.length; i++) {
let avConverterName = kommonitorImporterHelperService.availableConverters[i].name
if(converterName == avConverterName) {
$timeout(function() {
batchList[rowIndex].selectedDatasourceType = kommonitorImporterHelperService.availableDatasourceTypes[i];
batchList[rowIndex].selectedConverter = kommonitorImporterHelperService.availableConverters[i];
});
break;
}
}
}

// set value of column "Datenquelltyp*" by dataSource type
if(mappingObj.dataSource) {
let dataSourceType = mappingObj.dataSource.type;
for(let i=0; i<kommonitorImporterHelperService.availableDatasourceTypes.length; i++) {
let avDataSourceType = kommonitorImporterHelperService.availableDatasourceTypes[i].type
if(dataSourceType == avDataSourceType) {
$timeout(function() {
batchList[rowIndex].selectedDatasourceType = kommonitorImporterHelperService.availableDatasourceTypes[i];
});
break;
}
}
}


if(resourceType === "indicator") {
// set value of column "Ziel-Raumebene*" by target spatial unit name
let targetSpatialUnitName = mappingObj.targetSpatialUnitName;
let spatialUnitObject = this.getSpatialUnitObjectByName(targetSpatialUnitName);
if(resourceType === "indicator") {
// set value of column "Ziel-Raumebene*" by target spatial unit name
let targetSpatialUnitName = mappingObj.targetSpatialUnitName;
let spatialUnitObject = this.getSpatialUnitObjectByName(targetSpatialUnitName);
$timeout(function() {
batchList[rowIndex].selectedTargetSpatialUnit = spatialUnitObject;
});
}

// do not import file name
if(mappingObj.dataSource) {
if(mappingObj.dataSource.type == "FILE") {
mappingObj.dataSource.name = "";
}
}

//apply to scope
$timeout(function() {
batchList[rowIndex].selectedTargetSpatialUnit = spatialUnitObject;
batchList[rowIndex].mappingObj = mappingObj;
if(resourceType === "georesource")
thisService.initializeGeoresourceDatepickerFields(batchList);
});
}

// do not import file name
if(mappingObj.dataSource) {
if(mappingObj.dataSource.type == "FILE") {
mappingObj.dataSource.name = "";
}
}

//apply to scope
$timeout(function() {
batchList[rowIndex].mappingObj = mappingObj;
if(resourceType === "georesource")
thisService.initializeGeoresourceDatepickerFields(batchList);
});
catch(error) {
kommonitorDataExchangeService.displayMapApplicationError(invalidMappingTableErrorMessage);
console.error(error);
}

}

this.onClickSaveColDefaultValue = function(resourceType, selectedCol, newValue, replaceAll, batchList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,31 @@ angular
}, 1000);

};

this.warningMessage = undefined;
this.hideWarningAlert = function(){
$(".adminWarningAlert").hide();
};

this.displayAdminWarning = function(warning){
$timeout(function () {
if(warning.data){
self.warningMessage = self.syntaxHighlightJSON(warning.data);
}
if(warning.message){
self.warningMessage = self.syntaxHighlightJSON(warning.message);
}
else{
self.warningMessage = self.syntaxHighlightJSON(warning);
}

// $rootScope.$apply();
$rootScope.$broadcast("hideLoadingIconOnMap");

$(".adminWarningAlert").show();
}, 500);

};

// SPATIAL UNITS

Expand Down