From 3da311ca0d11f66049a2f45e4fef80372978cb5d Mon Sep 17 00:00:00 2001 From: zhzoo Date: Thu, 15 Feb 2018 08:49:01 -0800 Subject: [PATCH 1/2] array use 1 --- reference-app/app.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reference-app/app.js b/reference-app/app.js index 7dc7d00..7be91ce 100644 --- a/reference-app/app.js +++ b/reference-app/app.js @@ -283,6 +283,9 @@ mainModule.controller('MainCtrl', ['$scope', '$http', '$q', 'remote', 'config', } $scope.setTemperatureValue = function (device, property, value) { setDeviceProperty(device, property, { temperature: value, units: property.units }).then(info => { + if (Array.isArray(info) && info.length>0) { + info = info[0]; + } property.temperature = info.temperature; if (!!info.units) { property.units = info.units; From b684e73f7fb8cbc6510671c9f36d45f091cdfd0b Mon Sep 17 00:00:00 2001 From: zhzoo Date: Thu, 15 Feb 2018 12:23:43 -0800 Subject: [PATCH 2/2] much format; so neat --- reference-app/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reference-app/app.js b/reference-app/app.js index 7be91ce..9756fa8 100644 --- a/reference-app/app.js +++ b/reference-app/app.js @@ -199,7 +199,7 @@ mainModule.controller('MainCtrl', ['$scope', '$http', '$q', 'remote', 'config', return true; } - $scope.getResourceStyle = function(resource) { + $scope.getResourceStyle = function (resource) { let style = {}; if (resource.rt[0] === 'oic.r.colour.rgb') { @@ -283,7 +283,7 @@ mainModule.controller('MainCtrl', ['$scope', '$http', '$q', 'remote', 'config', } $scope.setTemperatureValue = function (device, property, value) { setDeviceProperty(device, property, { temperature: value, units: property.units }).then(info => { - if (Array.isArray(info) && info.length>0) { + if (Array.isArray(info) && info.length > 0) { info = info[0]; } property.temperature = info.temperature; @@ -342,7 +342,7 @@ mainModule.controller('MainCtrl', ['$scope', '$http', '$q', 'remote', 'config', property.activeMode = info.activeMode; addDisplayValue(controlId, property.id, 'activeMode', property.activeMode); property.timer = info.timer; - addDisplayValue(controlId, property.id, 'timer', property.timer); + addDisplayValue(controlId, property.id, 'timer', property.timer); }).catch(error => { logError(error); }); @@ -355,7 +355,7 @@ mainModule.controller('MainCtrl', ['$scope', '$http', '$q', 'remote', 'config', property.activeMode = info.activeMode; addDisplayValue(controlId, property.id, 'activeMode', property.activeMode); property.timer = info.timer; - addDisplayValue(controlId, property.id, 'timer', property.timer); + addDisplayValue(controlId, property.id, 'timer', property.timer); }).catch(error => { logError(error); });