From 71fd0863f7b55ee5bae33202074d98ba31cbfbed Mon Sep 17 00:00:00 2001 From: Sebastian Drost Date: Fri, 17 Nov 2023 12:04:49 +0100 Subject: [PATCH 1/3] Add template form warning messages --- .../kommonitor-admin.template.html | 10 ++++++++ ...kommonitor-data-exchange-service.module.js | 25 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/components/kommonitorAdmin/kommonitor-admin.template.html b/app/components/kommonitorAdmin/kommonitor-admin.template.html index 0c3aa1a2b..0f1c9b5c2 100644 --- a/app/components/kommonitorAdmin/kommonitor-admin.template.html +++ b/app/components/kommonitorAdmin/kommonitor-admin.template.html @@ -273,6 +273,16 @@

Achtung



 	    
+
+    
       
     
   
diff --git a/app/util/genericServices/kommonitorDataExchangeService/kommonitor-data-exchange-service.module.js b/app/util/genericServices/kommonitorDataExchangeService/kommonitor-data-exchange-service.module.js
index 6019da742..0a0024739 100644
--- a/app/util/genericServices/kommonitorDataExchangeService/kommonitor-data-exchange-service.module.js
+++ b/app/util/genericServices/kommonitorDataExchangeService/kommonitor-data-exchange-service.module.js
@@ -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
 

From 1a4dc0fbd65972f793103e7fc4936cd1a1b168ac Mon Sep 17 00:00:00 2001
From: Sebastian Drost 
Date: Fri, 17 Nov 2023 12:06:21 +0100
Subject: [PATCH 2/3] Add error and warning messages for unsupported mapping
 table configurations or formats

---
 ...itor-batch-update-helper-service.module.js | 116 +++++++++++-------
 1 file changed, 72 insertions(+), 44 deletions(-)

diff --git a/app/util/genericServices/kommonitorBatchUpdateHelperService/kommonitor-batch-update-helper-service.module.js b/app/util/genericServices/kommonitorBatchUpdateHelperService/kommonitor-batch-update-helper-service.module.js
index 48cbb33fd..587c4135d 100644
--- a/app/util/genericServices/kommonitorBatchUpdateHelperService/kommonitor-batch-update-helper-service.module.js
+++ b/app/util/genericServices/kommonitorBatchUpdateHelperService/kommonitor-batch-update-helper-service.module.js
@@ -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 
@@ -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);
@@ -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
Date: Fri, 17 Nov 2023 14:30:31 +0100
Subject: [PATCH 3/3] Improve supported data source and converters handling for
 batch update

---
 ...eoresource-batch-update-modal.component.js | 26 +++++++++++++++++++
 ...oresource-batch-update-modal.template.html |  4 +--
 .../indicator-batch-update-modal.component.js | 26 +++++++++++++++++++
 ...indicator-batch-update-modal.template.html |  4 +--
 4 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/app/components/kommonitorAdmin/adminGeoresourcesManagement/georesourceBatchUpdateModal/georesource-batch-update-modal.component.js b/app/components/kommonitorAdmin/adminGeoresourcesManagement/georesourceBatchUpdateModal/georesource-batch-update-modal.component.js
index 14e5bce1b..e75e8523b 100644
--- a/app/components/kommonitorAdmin/adminGeoresourcesManagement/georesourceBatchUpdateModal/georesource-batch-update-modal.component.js
+++ b/app/components/kommonitorAdmin/adminGeoresourcesManagement/georesourceBatchUpdateModal/georesource-batch-update-modal.component.js
@@ -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;
@@ -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;
diff --git a/app/components/kommonitorAdmin/adminGeoresourcesManagement/georesourceBatchUpdateModal/georesource-batch-update-modal.template.html b/app/components/kommonitorAdmin/adminGeoresourcesManagement/georesourceBatchUpdateModal/georesource-batch-update-modal.template.html
index a8c9a6711..3d909afa4 100644
--- a/app/components/kommonitorAdmin/adminGeoresourcesManagement/georesourceBatchUpdateModal/georesource-batch-update-modal.template.html
+++ b/app/components/kommonitorAdmin/adminGeoresourcesManagement/georesourceBatchUpdateModal/georesource-batch-update-modal.template.html
@@ -120,7 +120,7 @@ 
 											
 											
 												
 											
@@ -233,7 +233,7 @@ 
 											
 											
 												
diff --git a/app/components/kommonitorAdmin/adminIndicatorsManagement/indicatorBatchUpdateModal/indicator-batch-update-modal.component.js b/app/components/kommonitorAdmin/adminIndicatorsManagement/indicatorBatchUpdateModal/indicator-batch-update-modal.component.js
index 3b44ecc25..4966d45af 100644
--- a/app/components/kommonitorAdmin/adminIndicatorsManagement/indicatorBatchUpdateModal/indicator-batch-update-modal.component.js
+++ b/app/components/kommonitorAdmin/adminIndicatorsManagement/indicatorBatchUpdateModal/indicator-batch-update-modal.component.js
@@ -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;
@@ -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)
diff --git a/app/components/kommonitorAdmin/adminIndicatorsManagement/indicatorBatchUpdateModal/indicator-batch-update-modal.template.html b/app/components/kommonitorAdmin/adminIndicatorsManagement/indicatorBatchUpdateModal/indicator-batch-update-modal.template.html
index 861ebf0d5..be36c444f 100644
--- a/app/components/kommonitorAdmin/adminIndicatorsManagement/indicatorBatchUpdateModal/indicator-batch-update-modal.template.html
+++ b/app/components/kommonitorAdmin/adminIndicatorsManagement/indicatorBatchUpdateModal/indicator-batch-update-modal.template.html
@@ -88,7 +88,7 @@ 
 											
 											
 												
 											
@@ -152,7 +152,7 @@