Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Commit

Permalink
fix(Chart): Fix saving of default persistence service
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Jackson <chris@cd-jackson.com>
  • Loading branch information
cdjackson committed Jun 5, 2016
1 parent 326927a commit 8b45270
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
Binary file modified output/org.openhab.ui.habmin_2.0.0.SNAPSHOT-0.1.6.jar
Binary file not shown.
20 changes: 15 additions & 5 deletions src/app/chart/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ angular.module('HABmin.chart', [
$scope.tooltipSave = locale.getString('chart.SaveChart');
$scope.tooltipDelete = locale.getString('chart.DeleteChart');

if(ChartService.service == null || ChartService.service.length == 0) {
if (ChartService.service == null || ChartService.service.length == 0) {
ChartService.service = UserService.getPersistence();
}

Expand All @@ -320,13 +320,23 @@ angular.module('HABmin.chart', [
function (data) {
$scope.services = data;
if ($scope.services.length > 0) {
$scope.services[0].selected = true;
// Check that the default service exists
if (ChartService.service != null) {
var found = false;
for (var service in $scope.services) {
if ($scope.services[service].name == ChartService.service) {
found = true;
break;
}
}

// Use the first service as the default if there isn't a default set
if(ChartService.service != null) {
return;
if (found == true) {
return;
}
}

// Use the first service as the default if there isn't a default set
$scope.services[0].selected = true;
ChartService.service = $scope.services[0].name;
}
},
Expand Down
14 changes: 10 additions & 4 deletions src/app/user/userConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ angular.module('User.Config', [

$scope.model = {
currentLanguage: UserService.getLanguage(),
currentPersistence: UserService.getPersistence(),
currentPersistence: "",
serverAddress: UserService.getServer()
};
$scope.languages = [];
Expand All @@ -73,9 +73,15 @@ angular.module('User.Config', [
PersistenceServiceModel.getList().then(
function (data) {
$scope.services = data;
if ($scope.services.length > 0) {
$scope.services[0].selected = true;
ChartService.service = $scope.services[0].name;
// if ($scope.services.length > 0) {
// $scope.services[0].selected = true;
// ChartService.service = $scope.services[0].name;
// }
// Find the default service
for (var service in $scope.services) {
if ($scope.services[service].name == UserService.getPersistence()) {
$scope.model.currentPersistence = $scope.services[service];
}
}
},
function (reason) {
Expand Down

0 comments on commit 8b45270

Please sign in to comment.