');c.addClass("scrollable-resizing");h.addClass("active");e.element(".scrollableContainer").append(p);p.css("left",o);f.bind("mousemove",function(e){var n=e.pageX-a,r=t(p.css("left"))-o,i=s.width(),u=t(s.css("min-width")),f=s.next().width(),l=t(s.next().css("min-width"));a=e.pageX;e.preventDefault();if(n>0&&f-r<=l||n<0&&i+r<=u){return}p.css("left",t(p.css("left"))+n)});f.bind("mouseup",function(n){n.preventDefault();p.remove();c.removeClass("scrollable-resizing");h.removeClass("active");f.unbind("mousemove");f.unbind("mouseup");var r=t(p.css("left"))-o,i=s.width(),a=t(s.css("min-width")),d=s.next().width(),v=t(s.next().css("min-width")),m=u.getTableElement().find(".scrollArea table");if(m.css("table-layout")==="auto"){m.find("th .th-inner").each(function(t,n){n=e.element(n);var r=n.parent().width();n.parent().css("width",r)})}m.css("table-layout","fixed");if(r>0&&d-r<=v){r=d-v}s.next().removeAttr("style");i+=r;s.css("width",Math.max(a,i));s.next().css("width",d-r);u.renderTalble().then(l())})}}}}])})(angular)
\ No newline at end of file
+!function(e){"use strict";function t(e){return parseInt(e.replace(/px|%/,""),10)}var n=navigator.userAgent.toLowerCase().indexOf("firefox")>-1;e.module("scrollable-table",[]).directive("scrollableTable",["$timeout","$q","$parse",function(i,r,s){return{transclude:!0,restrict:"E",scope:{rows:"=watch",sortFn:"="},template:'
',controller:["$scope","$element","$attrs",function(a,l,o){function c(e,t){var n=a.sortExpr.match(/(.+)\s+as\s+(.+)/),i={};i[n[1]]=e;var r=s(n[2])(i);i[n[1]]=t;var l=s(n[2])(i);return r===l?0:r>l?1:-1}function d(e){var t=l.find(".headerSpacer").height(),n=l.find(".scrollArea").scrollTop();l.find(".scrollArea").scrollTop(n+e.position().top-t)}function h(){function e(){0===l.find("table:visible").length?i(e,100):t.resolve()}var t=r.defer();return i(e),t.promise}function f(){l.find("thead th .th-inner").length||l.find("thead th").wrapInner('
'),l.find("thead th .th-inner:not(:has(.box))").length&&l.find("thead th .th-inner:not(:has(.box))").wrapInner('
'),l.find("table th .th-inner:visible").each(function(n,i){i=e.element(i);var r=i.parent().width(),s=l.find("table th:visible:last"),a=r;if("center"!==s.css("text-align")){var o=l.find(".scrollArea").height()
',link:function(t,n,i,r){var s=i.on||"a as a."+i.col;t.element=e.element(n),t.isActive=function(){return r.getSortExpr()===s},t.toggleSort=function(e){t.isActive()?r.toggleSort():r.setSortExpr(s),r.doSort(t[i.comparatorFn]),e.preventDefault()},t.isAscending=function(){return!(!t.focused||t.isActive())||r.isAsc()},t.enter=function(){t.focused=!0},t.leave=function(){t.focused=!1},t.isLastCol=function(){return n.parent().find("th:last-child").get(0)===n.get(0)}}}}]).directive("resizable",["$compile",function(n){return{restrict:"A",priority:0,scope:!1,require:"scrollableTable",link:function(i,r,s,a){function l(){var t=r.find("table th:not(:last-child) .th-inner");if(0==t.find(".resize-rod").length){a.getTableElement().find(".scrollArea table").css("table-layout","auto");var s=e.element('');h.addClass("scrollable-resizing"),f.addClass("active"),e.element(".scrollableContainer").append(u),u.css("left",l),d.bind("mousemove",function(e){var n=e.pageX-o,i=t(u.css("left"))-l,r=s.width(),a=s.nextAll("th:visible").first(),c=t(s.css("min-width")),d=a.width(),h=t(a.css("min-width"));o=e.pageX,e.preventDefault(),n>0&&d-i<=h||n<0&&r+i<=c||u.css("left",t(u.css("left"))+n)}),d.bind("mouseup",function(n){n.preventDefault(),u.remove(),h.removeClass("scrollable-resizing"),f.removeClass("active"),d.unbind("mousemove"),d.unbind("mouseup");var i=t(u.css("left"))-l,r=s.width(),o=t(s.css("min-width")),v=s.nextAll("th:visible").first(),p=v.width(),b=t(v.css("min-width")),g=a.getTableElement().find(".scrollArea table");"auto"===g.css("table-layout")&&g.find("th .th-inner").each(function(t,n){n=e.element(n);var i=n.parent().width();n.parent().css("width",i)}),g.css("table-layout","fixed"),i>0&&p-i<=b&&(i=p-b),v.removeAttr("style"),r+=i,s.css("width",Math.max(o,r)),v.css("width",p-i),a.renderTalble().then(c())})}}}}])}(angular);
\ No newline at end of file
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index e73742f..f01e6ee 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -62,6 +62,7 @@ app.config (function ($locationProvider, $routeProvider) {
app.run( function (bridgeService) {
bridgeService.loadBridgeSettings();
bridgeService.getHABridgeVersion();
+ bridgeService.getTestUser();
bridgeService.viewMapTypes();
});
@@ -79,7 +80,7 @@ String.prototype.replaceAll = function (search, replace)
app.service ('bridgeService', function ($http, $window, ngToast) {
var self = this;
- this.state = {base: "./api/devices", bridgelocation: ".", systemsbase: "./system", huebase: "./api", configs: [], backups: [], devices: [], device: {}, mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, showHal: false, showMqtt: false, showHass: false, showDomoticz: false, showSomfy: false, showLifx: false, habridgeversion: ""};
+ this.state = {base: "./api/devices", bridgelocation: ".", systemsbase: "./system", huebase: "./api", configs: [], backups: [], devices: [], device: {}, mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, showHal: false, showMqtt: false, showHass: false, showDomoticz: false, showSomfy: false, showLifx: false, habridgeversion: "", viewDevId: "", queueDevId: ""};
this.displayWarn = function(errorTitle, error) {
var toastContent = errorTitle;
@@ -151,7 +152,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
this.clearDevice = function () {
self.state.device = {};
- self.state.olddevicename = "";
+ self.state.olddevicename = null;
};
this.getHABridgeVersion = function () {
@@ -165,6 +166,17 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
);
};
+ this.getTestUser = function () {
+ return $http.get(this.state.systemsbase + "/habridge/testuser").then(
+ function (response) {
+ self.state.testuser = response.data.user;
+ },
+ function (error) {
+ self.displayWarn("Cannot get testuser: ", error);
+ }
+ );
+ };
+
this.aContainsB = function (a, b) {
return a.indexOf(b) >= 0;
}
@@ -538,6 +550,20 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
type = self.getMapType(s.type[0])
s.type = type[0]
}
+ if(s.delay === "" || s.delay === null)
+ delete s.delay;
+ if(s.count === "" || s.count === null)
+ delete s.count;
+ if(s.filterIPs === "" || s.filterIPs === null)
+ delete s.filterIPs;
+ if(s.httpVerb === "" || s.httpVerb === null)
+ delete s.httpVerb;
+ if(s.httpBody === "" || s.httpBody === null)
+ delete s.httpBody;
+ if(s.httpHeaders === "" || s.httpHeaders === null)
+ delete s.httpHeaders;
+ if(s.contentType === "" || s.contentType === null)
+ delete s.contentType;
}
}
return theDevices
@@ -799,7 +825,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
this.testUrl = function (device, type, value) {
var msgDescription = "unknown";
- var testUrl = this.state.huebase + "/test/lights/" + device.id + "/state";
+ var testUrl = this.state.huebase + "/" + this.state.testuser + "/lights/" + device.id + "/state";
var testBody = "{\"on\":";
if (type === "off") {
testBody = testBody + "false";
@@ -1140,6 +1166,26 @@ app.controller('LogsController', function ($scope, $location, $http, $window, br
};
});
+app.directive('postrenderAction', postrenderAction);
+/* @ngInject */
+function postrenderAction($timeout) {
+ // ### Directive Interface
+ // Defines base properties for the directive.
+ var directive = {
+ restrict: 'A',
+ priority: 101,
+ link: link
+ };
+ return directive;
+
+ // ### Link Function
+ // Provides functionality for the directive during the DOM building/data binding stage.
+ function link(scope, element, attrs) {
+ $timeout(function() {
+ scope.$evalAsync(attrs.postrenderAction);
+ }, 0);
+ }
+}
app.controller('ViewingController', function ($scope, $location, $http, $window, bridgeService, ngDialog) {
bridgeService.viewDevices();
@@ -1205,7 +1251,16 @@ app.controller('ViewingController', function ($scope, $location, $http, $window,
else
$scope.imgBkUrl = "glyphicon glyphicon-plus";
};
-});
+
+ $scope.goToRow = function() {
+ if (bridgeService.state.queueDevId !== null && bridgeService.state.queueDevId !== "") {
+ bridgeService.state.viewDevId = bridgeService.state.queueDevId;
+ $scope.$broadcast("rowSelected", bridgeService.state.viewDevId);
+ console.log("Go to Row selected Id <<" + bridgeService.state.viewDevId + ">>")
+ bridgeService.state.queueDevId = null;
+ }
+ };
+ });
app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.slider = {
@@ -2622,20 +2677,25 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
if (copy) {
$scope.device.id = null;
$scope.device.uniqueid = null;
- $scope.device.mapId = $scope.device.mapId + "-copy";
+ if($scope.bridge.olddevicename !== null && $scope.bridge.olddevicename !== "")
+ $scope.device.mapId = $scope.device.mapId + "-copy";
}
if($scope.mapTypeSelected !== undefined && $scope.mapTypeSelected !== null)
$scope.device.mapType = $scope.mapTypeSelected[0];
else
$scope.device.mapType = null;
+
if ($scope.onDevices !== null)
$scope.device.onUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.onDevices));
if ($scope.dimDevices !== null)
$scope.device.dimUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.dimDevices));
if ($scope.offDevices !== null)
$scope.device.offUrl = angular.toJson(bridgeService.updateCallObjectsType($scope.offDevices));
+
bridgeService.addDevice($scope.device).then(
function () {
+ bridgeService.state.queueDevId = $scope.device.id;
+ console.log("Device updated for Q Id <<" + bridgeService.state.queueDevId + ">>")
$scope.clearDevice();
$location.path('/');
},
@@ -2653,7 +2713,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
if ($scope.onDevices === null)
$scope.onDevices = [];
$scope.onDevices.push(newitem);
- $scope.newOnItem = [];
+ $scope.newOnItem = {};
};
$scope.removeItemOn = function (anItem) {
for(var i = $scope.onDevices.length - 1; i >= 0; i--) {
@@ -2670,7 +2730,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
if ($scope.dimDevices === null)
$scope.dimDevices = [];
$scope.dimDevices.push(newitem);
- $scope.newDimItem = [];
+ $scope.newDimItem = {};
};
$scope.removeItemDim = function (anItem) {
for(var i = $scope.dimDevices.length - 1; i >= 0; i--) {
@@ -2687,7 +2747,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
if ($scope.offDevices === null)
$scope.offDevices = [];
$scope.offDevices.push(newitem);
- $scope.newOffItem = [];
+ $scope.newOffItem = {};
};
$scope.removeItemOff = function (anItem) {
for(var i = $scope.offDevices.length - 1; i >= 0; i--) {
diff --git a/src/main/resources/public/views/configuration.html b/src/main/resources/public/views/configuration.html
index 14dc9b4..3cb3123 100644
--- a/src/main/resources/public/views/configuration.html
+++ b/src/main/resources/public/views/configuration.html
@@ -24,7 +24,7 @@
LIFX Devices
Add/Edit
-
+
Current devices ({{bridge.devices.length}})
@@ -34,7 +34,6 @@
Renumber Devices
-
@@ -42,6 +41,7 @@
Row
ID
Name
+ Description
Type
Target
Inactive
@@ -49,10 +49,11 @@
Actions
-
+
{{$index+1}}
{{device.id}}
{{device.name}}
+ {{device.description}}
{{device.deviceType}}
{{device.targetDevice}}
{{device.inactive}}
@@ -76,6 +77,7 @@
+
+
+ Description
+
+
+
+
+ Comments
+
+
+
Inactive
{{device.noState}}
+
+ Off State Resets Bri
+ {{device.offState}}
+
Filter Address (comma separated list)
MQTT Messages
HomeAssistant Devices
Domoticz Devices
+ Somfy Devices
LIFX Devices
Add/Edit
diff --git a/src/test/java/com/bwssystems/color/test/ConvertCIEColorTestCase.java b/src/test/java/com/bwssystems/color/test/ConvertCIEColorTestCase.java
new file mode 100644
index 0000000..4d148be
--- /dev/null
+++ b/src/test/java/com/bwssystems/color/test/ConvertCIEColorTestCase.java
@@ -0,0 +1,21 @@
+package com.bwssystems.color.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.bwssystems.HABridge.hue.ColorDecode;
+
+public class ConvertCIEColorTestCase {
+
+ @Test
+ public void testColorConversion() {
+ ArrayList xy = new ArrayList(Arrays.asList(new Double(0.3972), new Double(0.4564)));
+
+ String colorDecode = ColorDecode.convertCIEtoRGB(xy);
+ Assert.assertEquals(colorDecode, null);
+ }
+
+}