diff --git a/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/js/controllers.configuration.js b/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/js/controllers.configuration.js index d52a6436..54ca4639 100644 --- a/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/js/controllers.configuration.js +++ b/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/js/controllers.configuration.js @@ -182,6 +182,9 @@ angular.module('PaperUI.controllers.configuration', []).controller('Configuratio }, function(configDescription) { if (configDescription) { $scope.parameters = configService.getRenderingModel(configDescription.parameters, configDescription.parameterGroups); + if (!jQuery.isEmptyObject($scope.configuration)) { + $scope.configuration = configService.setConfigDefaults($scope.configuration, $scope.parameters); + } } }); } @@ -197,6 +200,9 @@ angular.module('PaperUI.controllers.configuration', []).controller('Configuratio if (config) { $scope.configuration = config; $scope.configArray = configService.getConfigAsArray(config); + if ($scope.parameters && $scope.parameters.length > 0) { + $scope.configuration = configService.setConfigDefaults($scope.configuration, $scope.parameters); + } } }); } else { @@ -221,6 +227,7 @@ angular.module('PaperUI.controllers.configuration', []).controller('Configuratio if ($scope.expertMode) { $scope.configuration = configService.getConfigAsObject($scope.configArray); } + $scope.configuration = configService.setConfigDefaults($scope.configuration, $scope.parameters); serviceConfigService.updateConfig({ id : (serviceId ? serviceId : $scope.serviceId) }, $scope.configuration, function() { diff --git a/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/js/services.js b/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/js/services.js index 94cd03e2..cdf8c873 100644 --- a/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/js/services.js +++ b/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/js/services.js @@ -181,6 +181,28 @@ angular.module('PaperUI.services', [ 'PaperUI.constants' ]).config(function($htt } }); } + }, + setConfigDefaults : function(configuration, groups) { + for (var i = 0; i < groups.length; i++) { + $.each(groups[i].parameters, function(i, parameter) { + if (parameter.defaultValue !== 'null') { + if (configuration[parameter.name] == null || configuration[parameter.name] == "") { + if (parameter.type === 'TEXT') { + configuration[parameter.name] = parameter.defaultValue + } else if (parameter.type === 'BOOLEAN') { + configuration[parameter.name] = new Boolean(parameter.defaultValue); + } else if (parameter.type === 'INTEGER' || parameter.type === 'DECIMAL') { + configuration[parameter.name] = parseInt(parameter.defaultValue); + } else { + configuration[parameter.name] = parameter.defaultValue; + } + } + } else { + configuration[parameter.name] = ''; + } + }); + } + return configuration; } }; }); \ No newline at end of file diff --git a/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/partials/include.config.html b/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/partials/include.config.html index fefdcbd2..0d4cad14 100644 --- a/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/partials/include.config.html +++ b/extensions/ui/org.eclipse.smarthome.ui.paper/web-src/partials/include.config.html @@ -7,18 +7,18 @@
- {{parameter.description}} -
-+ {{parameter.description}} +
+