Finished updating settings editor and reinit control. Starting number

slider for input.
This commit is contained in:
Admin
2016-02-17 16:41:34 -06:00
parent 13fa5dea73
commit fff30d17d6
13 changed files with 569 additions and 153 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>1.3.8f</version>
<version>1.3.8g</version>
<packaging>jar</packaging>
<name>HA Bridge</name>

View File

@@ -58,7 +58,7 @@ public class SystemControl {
});
// http://ip_address:port/system/settings which returns the bridge configuration settings
put(SYSTEM_CONTEXT + "/settings", "application/json", (request, response) -> {
log.info("save bridge settings requested from " + request.ip() + " with body: " + request.body());
log.debug("save bridge settings requested from " + request.ip() + " with body: " + request.body());
BridgeSettingsDescriptor newBridgeSettings = new Gson().fromJson(request.body(), BridgeSettingsDescriptor.class);
bridgeSettings.save(newBridgeSettings);
response.status(200);
@@ -174,7 +174,7 @@ public class SystemControl {
socket.close();
}
catch (IOException e) {
log.warn("Error pinging listener.", e);
log.warn("Error pinging listener. " + e.getMessage());
}
}

View File

@@ -0,0 +1,18 @@
package com.bwssystems.HABridge.dao;
public class ErrorMessage {
private String message;
public ErrorMessage(String message) {
super();
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}

View File

@@ -20,8 +20,11 @@ import com.bwssystems.HABridge.JsonTransformer;
import com.bwssystems.HABridge.dao.BackupFilename;
import com.bwssystems.HABridge.dao.DeviceDescriptor;
import com.bwssystems.HABridge.dao.DeviceRepository;
import com.bwssystems.HABridge.dao.ErrorMessage;
import com.bwssystems.NestBridge.NestHome;
import com.bwssystems.harmony.HarmonyHome;
import com.bwssystems.luupRequests.Device;
import com.bwssystems.luupRequests.Scene;
import com.bwssystems.vera.VeraHome;
import com.google.gson.Gson;
@@ -88,7 +91,7 @@ public class DeviceResource {
if (devices[i].getContentType() == null || devices[i].getHttpVerb() == null || !supportedVerbs.contains(devices[i].getHttpVerb().toLowerCase())) {
response.status(HttpStatus.SC_BAD_REQUEST);
log.debug("Bad http verb in create a Device(s): " + request.body());
return devices;
return new ErrorMessage("Bad http verb in create a Device(s): " + request.body() + " ");
}
}
}
@@ -118,6 +121,7 @@ public class DeviceResource {
if(deviceEntry == null){
log.debug("Could not save an edited Device Id: " + request.params(":id"));
response.status(HttpStatus.SC_BAD_REQUEST);
return new ErrorMessage("Could not save an edited Device Id: " + request.params(":id") + " ");
}
else
{
@@ -157,8 +161,10 @@ public class DeviceResource {
get (API_CONTEXT + "/:id", "application/json", (request, response) -> {
log.debug("Get a device");
DeviceDescriptor descriptor = deviceRepository.findOne(request.params(":id"));
if(descriptor == null)
if(descriptor == null) {
response.status(HttpStatus.SC_NOT_FOUND);
return new ErrorMessage("Could not find, id: " + request.params(":id") + " ");
}
else
response.status(HttpStatus.SC_OK);
return descriptor;
@@ -168,8 +174,10 @@ public class DeviceResource {
String anId = request.params(":id");
log.debug("Delete a device: " + anId);
DeviceDescriptor deleted = deviceRepository.findOne(anId);
if(deleted == null)
if(deleted == null) {
response.status(HttpStatus.SC_NOT_FOUND);
return new ErrorMessage("Could not delete, id: " + anId + " not found. ");
}
else
{
deviceRepository.delete(deleted);
@@ -182,28 +190,39 @@ public class DeviceResource {
log.debug("Get vera devices");
if(veraHome == null){
response.status(HttpStatus.SC_NOT_FOUND);
return null;
return new ErrorMessage("A Vera is not available.");
}
response.status(HttpStatus.SC_OK);
return veraHome.getDevices();
List<Device> theDevices = veraHome.getDevices();
if(theDevices == null) {
response.status(HttpStatus.SC_SERVICE_UNAVAILABLE);
return new ErrorMessage("A Vera request failed to get devices. Check your Vera IP addresses.");
}
else
response.status(HttpStatus.SC_OK);
return theDevices;
}, new JsonTransformer());
get (API_CONTEXT + "/vera/scenes", "application/json", (request, response) -> {
log.debug("Get vera scenes");
if(veraHome == null){
response.status(HttpStatus.SC_NOT_FOUND);
return null;
return new ErrorMessage("A Vera is not available.");
}
response.status(HttpStatus.SC_OK);
return veraHome.getScenes();
List<Scene> theScenes = veraHome.getScenes();
if(theScenes == null) {
response.status(HttpStatus.SC_SERVICE_UNAVAILABLE);
return new ErrorMessage("A Vera is not available and failed to get scenes. Check your Vera IP addresses.");
}
else
response.status(HttpStatus.SC_OK);
return theScenes;
}, new JsonTransformer());
get (API_CONTEXT + "/harmony/activities", "application/json", (request, response) -> {
log.debug("Get harmony activities");
if(myHarmonyHome == null) {
response.status(HttpStatus.SC_NOT_FOUND);
return null;
return new ErrorMessage("A Harmony is not available.");
}
response.status(HttpStatus.SC_OK);
return myHarmonyHome.getActivities();
@@ -213,7 +232,7 @@ public class DeviceResource {
log.debug("Get harmony current activity");
if(myHarmonyHome == null) {
response.status(HttpStatus.SC_NOT_FOUND);
return null;
return new ErrorMessage("A Harmony is not available.");
}
response.status(HttpStatus.SC_OK);
return myHarmonyHome.getCurrentActivities();
@@ -223,7 +242,7 @@ public class DeviceResource {
log.debug("Get harmony devices");
if(myHarmonyHome == null) {
response.status(HttpStatus.SC_NOT_FOUND);
return null;
return new ErrorMessage("A Harmony is not available.");
}
response.status(HttpStatus.SC_OK);
return myHarmonyHome.getDevices();
@@ -233,7 +252,7 @@ public class DeviceResource {
log.debug("Get nest items");
if(nestHome == null) {
response.status(HttpStatus.SC_NOT_FOUND);
return null;
return new ErrorMessage("A Nest is not available.");
}
response.status(HttpStatus.SC_OK);
return nestHome.getItems();

View File

@@ -245,7 +245,7 @@ public class HueMulator {
DeviceDescriptor device = repository.findOne(lightId);
if (device == null) {
response.status(HttpStatus.SC_NOT_FOUND);
return null;
return "[{\"error\":{\"type\": 3, \"address\": \"/lights/" + lightId + ",\"description\": \"Object not found\"}}]";
} else {
log.debug("found device named: " + device.getName());
}

View File

@@ -13,6 +13,7 @@ import com.bwssystems.HABridge.BridgeSettingsDescriptor;
import com.bwssystems.HABridge.NamedIP;
import com.bwssystems.luupRequests.Device;
import com.bwssystems.luupRequests.Scene;
import com.bwssystems.luupRequests.Sdata;
public class VeraHome {
private static final Logger log = LoggerFactory.getLogger(VeraHome.class);
@@ -35,9 +36,16 @@ public class VeraHome {
ArrayList<Device> deviceList = new ArrayList<Device>();
while(keys.hasNext()) {
String key = keys.next();
Iterator<Device> devices = veras.get(key).getSdata().getDevices().iterator();
while(devices.hasNext()) {
deviceList.add(devices.next());
Sdata theSdata = veras.get(key).getSdata();
if(theSdata != null) {
Iterator<Device> devices = theSdata.getDevices().iterator();
while(devices.hasNext()) {
deviceList.add(devices.next());
}
}
else {
deviceList = null;
break;
}
}
return deviceList;
@@ -48,9 +56,16 @@ public class VeraHome {
ArrayList<Scene> sceneList = new ArrayList<Scene>();
while(keys.hasNext()) {
String key = keys.next();
Iterator<Scene> scenes = veras.get(key).getSdata().getScenes().iterator();
while(scenes.hasNext()) {
sceneList.add(scenes.next());
Sdata theSdata = veras.get(key).getSdata();
if(theSdata != null) {
Iterator<Scene> scenes = theSdata.getScenes().iterator();
while(scenes.hasNext()) {
sceneList.add(scenes.next());
}
}
else {
sceneList = null;
break;
}
}
return sceneList;

View File

@@ -37,16 +37,19 @@ public class VeraInfo {
}
public Sdata getSdata() {
Sdata theSdata = null;
if(!validVera)
return new Sdata();
return theSdata;
String theUrl = "http://" + veraAddress.getIp() + SDATA_REQUEST;
String theData;
theData = doHttpGETRequest(theUrl);
Sdata theSdata = new Gson().fromJson(theData, Sdata.class);
log.debug("GET sdata - full: " + theSdata.getFull() + ", version: " + theSdata.getVersion());
denormalizeSdata(theSdata);
if(theData != null) {
theSdata = new Gson().fromJson(theData, Sdata.class);
log.debug("GET sdata - full: " + theSdata.getFull() + ", version: " + theSdata.getVersion());
denormalizeSdata(theSdata);
}
return theSdata;
}
@@ -91,19 +94,19 @@ public class VeraInfo {
// This function executes the url against the vera
protected String doHttpGETRequest(String url) {
String theContent = null;
log.debug("calling GET on URL: " + url);
HttpGet httpGet = new HttpGet(url);
try {
HttpResponse response = httpClient.execute(httpGet);
String theContent = EntityUtils.toString(response.getEntity()); //read content for data
EntityUtils.consume(response.getEntity()); //close out inputstream ignore content
log.debug("GET on URL responded: " + response.getStatusLine().getStatusCode());
if(response.getStatusLine().getStatusCode() == 200){
return theContent;
theContent = EntityUtils.toString(response.getEntity()); //read content for data
EntityUtils.consume(response.getEntity()); //close out inputstream ignore content
}
} catch (IOException e) {
log.error("Error calling out to HA gateway", e);
log.error("doHttpGETRequest: Error calling out to HA gateway: " + e.getMessage());
}
return null;
return theContent;
}
}

View File

@@ -0,0 +1,75 @@
/* line 2, slider.scss */
slider, [slider] {
display: inline-block;
position: relative;
height: 7px;
width: 100%;
margin: 25px 5px 25px 5px;
vertical-align: middle;
}
/* line 10, slider.scss */
slider div, [slider] div {
white-space: nowrap;
position: absolute;
}
/* line 14, slider.scss */
slider div.bar, [slider] div.bar {
width: 100%;
height: 100%;
border-radius: 7px;
background: #444;
overflow: hidden;
}
/* line 21, slider.scss */
slider div.bar .selection, [slider] div.bar .selection {
width: 0%;
height: 100%;
background: #13b6ff;
}
/* line 28, slider.scss */
slider div.handle, [slider] div.handle {
cursor: pointer;
width: 20px;
height: 20px;
top: -8px;
background-color: #fff;
border: 1px solid #000;
z-index: 2;
border-radius: 100%;
}
/* line 38, slider.scss */
slider div.handle:after, [slider] div.handle:after {
content: '';
background-color: #777;
width: 8px;
height: 8px;
position: absolute;
top: 6px;
left: 6px;
border-radius: 100%;
}
/* line 48, slider.scss */
slider div.handle:after:hover, [slider] div.handle:after:hover {
background-color: #000;
}
/* line 53, slider.scss */
slider div.handle.active:after, [slider] div.handle.active:after {
background-color: #f00;
}
/* line 58, slider.scss */
slider div.bubble, [slider] div.bubble {
display: none;
cursor: default;
top: -22px;
padding: 1px 3px 1px 3px;
font-size: 0.7em;
font-family: sans-serif;
}
/* line 66, slider.scss */
slider div.bubble.active, [slider] div.bubble.active {
display: inline-block;
}
/* line 70, slider.scss */
slider div.bubble.limit, [slider] div.bubble.limit {
color: #777;
}

View File

@@ -8,6 +8,7 @@
<link href="css/main.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/ngToast.min.css" rel="stylesheet">
<link href="css/slider.css" rel="stylesheet">
<!--[if lt IE 9]>
<script type="text/javascript" src="js/html5shiv.min.js"></script>
@@ -58,6 +59,7 @@
<script src="js/angular-route.min.js"></script>
<script src="js/angular-sanitize.min.js"></script>
<script src="js/ngToast.min.js"></script>
<script src="js/slider.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="scripts/app.js"></script>
</body>

View File

@@ -0,0 +1,329 @@
// Generated by CoffeeScript 1.7.1
(function() {
var MODULE_NAME, SLIDER_TAG, angularize, contain, events, gap, halfWidth, hide, module, offset, offsetLeft, pixelize, qualifiedDirectiveDefinition, roundStep, show, sliderDirective, width;
MODULE_NAME = 'ui.slider';
SLIDER_TAG = 'slider';
angularize = function(element) {
return angular.element(element);
};
pixelize = function(position) {
return "" + position + "px";
};
hide = function(element) {
return element.css({
opacity: 0
});
};
show = function(element) {
return element.css({
opacity: 1
});
};
offset = function(element, position) {
return element.css({
left: position
});
};
halfWidth = function(element) {
return element[0].offsetWidth / 2;
};
offsetLeft = function(element) {
return element[0].offsetLeft;
};
width = function(element) {
return element[0].offsetWidth;
};
gap = function(element1, element2) {
return offsetLeft(element2) - offsetLeft(element1) - width(element1);
};
contain = function(value) {
if (isNaN(value)) {
return value;
}
return Math.min(Math.max(0, value), 100);
};
roundStep = function(value, precision, step, floor) {
var decimals, remainder, roundedValue, steppedValue;
if (floor == null) {
floor = 0;
}
if (step == null) {
step = 1 / Math.pow(10, precision);
}
remainder = (value - floor) % step;
steppedValue = remainder > (step / 2) ? value + step - remainder : value - remainder;
decimals = Math.pow(10, precision);
roundedValue = steppedValue * decimals / decimals;
return parseFloat(roundedValue.toFixed(precision));
};
events = {
mouse: {
start: 'mousedown',
move: 'mousemove',
end: 'mouseup'
},
touch: {
start: 'touchstart',
move: 'touchmove',
end: 'touchend'
}
};
sliderDirective = function($timeout) {
return {
restrict: 'E',
scope: {
floor: '@',
ceiling: '@',
values: '=?',
step: '@',
highlight: '@',
precision: '@',
buffer: '@',
dragstop: '@',
ngModel: '=?',
ngModelLow: '=?',
ngModelHigh: '=?',
change: '&'
},
template: '<div class="bar"><div class="selection"></div></div>\n<div class="handle low"></div><div class="handle high"></div>\n<div class="bubble limit low">{{ values.length ? values[floor || 0] : floor }}</div>\n<div class="bubble limit high">{{ values.length ? values[ceiling || values.length - 1] : ceiling }}</div>\n<div class="bubble value low">{{ values.length ? values[local.ngModelLow || local.ngModel || 0] : local.ngModelLow || local.ngModel || 0 }}</div>\n<div class="bubble value high">{{ values.length ? values[local.ngModelHigh] : local.ngModelHigh }}</div>',
compile: function(element, attributes) {
var high, low, range, watchables;
range = (attributes.ngModel == null) && (attributes.ngModelLow != null) && (attributes.ngModelHigh != null);
low = range ? 'ngModelLow' : 'ngModel';
high = 'ngModelHigh';
watchables = ['floor', 'ceiling', 'values', low];
if (range) {
watchables.push(high);
}
return {
post: function(scope, element, attributes) {
var bar, barWidth, bound, ceilBub, dimensions, e, flrBub, handleHalfWidth, highBub, lowBub, maxOffset, maxPtr, maxValue, minOffset, minPtr, minValue, ngDocument, offsetRange, selection, updateDOM, upper, valueRange, w, _i, _j, _len, _len1, _ref, _ref1;
_ref = (function() {
var _i, _len, _ref, _results;
_ref = element.children();
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
e = _ref[_i];
_results.push(angularize(e));
}
return _results;
})(), bar = _ref[0], minPtr = _ref[1], maxPtr = _ref[2], flrBub = _ref[3], ceilBub = _ref[4], lowBub = _ref[5], highBub = _ref[6];
selection = angularize(bar.children()[0]);
if (!range) {
_ref1 = [maxPtr, highBub];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
upper = _ref1[_i];
upper.remove();
}
if (!attributes.highlight) {
selection.remove();
}
}
scope.local = {};
scope.local[low] = scope[low];
scope.local[high] = scope[high];
bound = false;
ngDocument = angularize(document);
handleHalfWidth = barWidth = minOffset = maxOffset = minValue = maxValue = valueRange = offsetRange = void 0;
dimensions = function() {
var value, _j, _len1, _ref2;
if (scope.step == null) {
scope.step = 1;
}
if (scope.floor == null) {
scope.floor = 0;
}
if (scope.precision == null) {
scope.precision = 0;
}
if (!range) {
scope.ngModelLow = scope.ngModel;
}
if ((_ref2 = scope.values) != null ? _ref2.length : void 0) {
if (scope.ceiling == null) {
scope.ceiling = scope.values.length - 1;
}
}
scope.local[low] = scope[low];
scope.local[high] = scope[high];
for (_j = 0, _len1 = watchables.length; _j < _len1; _j++) {
value = watchables[_j];
if (typeof value === 'number') {
scope[value] = roundStep(parseFloat(scope[value]), parseInt(scope.precision), parseFloat(scope.step), parseFloat(scope.floor));
}
}
handleHalfWidth = halfWidth(minPtr);
barWidth = width(bar);
minOffset = 0;
maxOffset = barWidth - width(minPtr);
minValue = parseFloat(scope.floor);
maxValue = parseFloat(scope.ceiling);
valueRange = maxValue - minValue;
return offsetRange = maxOffset - minOffset;
};
updateDOM = function() {
var bind, percentOffset, percentValue, pixelsToOffset, setBindings, setPointers;
dimensions();
percentOffset = function(offset) {
return contain(((offset - minOffset) / offsetRange) * 100);
};
percentValue = function(value) {
return contain(((value - minValue) / valueRange) * 100);
};
pixelsToOffset = function(percent) {
return pixelize(percent * offsetRange / 100);
};
setPointers = function() {
var newHighValue, newLowValue;
offset(ceilBub, pixelize(barWidth - width(ceilBub)));
newLowValue = percentValue(scope.local[low]);
offset(minPtr, pixelsToOffset(newLowValue));
offset(lowBub, pixelize(offsetLeft(minPtr) - (halfWidth(lowBub)) + handleHalfWidth));
offset(selection, pixelize(offsetLeft(minPtr) + handleHalfWidth));
switch (true) {
case range:
newHighValue = percentValue(scope.local[high]);
offset(maxPtr, pixelsToOffset(newHighValue));
offset(highBub, pixelize(offsetLeft(maxPtr) - (halfWidth(highBub)) + handleHalfWidth));
return selection.css({
width: pixelsToOffset(newHighValue - newLowValue)
});
case attributes.highlight === 'right':
return selection.css({
width: pixelsToOffset(110 - newLowValue)
});
case attributes.highlight === 'left':
selection.css({
width: pixelsToOffset(newLowValue)
});
return offset(selection, 0);
}
};
bind = function(handle, bubble, ref, events) {
var changed, currentRef, onEnd, onMove, onStart;
currentRef = ref;
changed = false;
onEnd = function() {
bubble.removeClass('active');
handle.removeClass('active');
ngDocument.unbind(events.move);
ngDocument.unbind(events.end);
if (scope.dragstop) {
scope[high] = scope.local[high];
scope[low] = scope.local[low];
}
currentRef = ref;
scope.$apply();
if (changed) {
return scope.$eval(scope.change);
}
};
onMove = function(event) {
var eventX, newOffset, newPercent, newValue, _ref2, _ref3, _ref4;
eventX = event.clientX || ((_ref2 = event.touches) != null ? _ref2[0].clientX : void 0) || ((_ref3 = event.originalEvent) != null ? (_ref4 = _ref3.changedTouches) != null ? _ref4[0].clientX : void 0 : void 0) || 0;
newOffset = eventX - element[0].getBoundingClientRect().left - handleHalfWidth;
newOffset = Math.max(Math.min(newOffset, maxOffset), minOffset);
newPercent = percentOffset(newOffset);
newValue = minValue + (valueRange * newPercent / 100.0);
if (range) {
switch (currentRef) {
case low:
if (newValue > scope.local[high]) {
currentRef = high;
minPtr.removeClass('active');
lowBub.removeClass('active');
maxPtr.addClass('active');
highBub.addClass('active');
setPointers();
} else if (scope.buffer > 0) {
newValue = Math.min(newValue, scope.local[high] - scope.buffer);
}
break;
case high:
if (newValue < scope.local[low]) {
currentRef = low;
maxPtr.removeClass('active');
highBub.removeClass('active');
minPtr.addClass('active');
lowBub.addClass('active');
setPointers();
} else if (scope.buffer > 0) {
newValue = Math.max(newValue, parseInt(scope.local[low]) + parseInt(scope.buffer));
}
}
}
newValue = roundStep(newValue, parseInt(scope.precision), parseFloat(scope.step), parseFloat(scope.floor));
changed = scope.dragstop && changed || scope.local[currentRef] !== newValue;
scope.local[currentRef] = newValue;
scope.$apply();
setPointers();
if (!scope.dragstop) {
scope[currentRef] = newValue;
if (changed) {
return scope.$eval(scope.change);
}
}
};
onStart = function(event) {
dimensions();
bubble.addClass('active');
handle.addClass('active');
setPointers();
event.stopPropagation();
event.preventDefault();
ngDocument.bind(events.move, onMove);
return ngDocument.bind(events.end, onEnd);
};
return handle.bind(events.start, onStart);
};
setBindings = function() {
var method, _j, _len1, _ref2;
_ref2 = ['touch', 'mouse'];
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
method = _ref2[_j];
bind(minPtr, lowBub, low, events[method]);
bind(maxPtr, highBub, high, events[method]);
}
return bound = true;
};
if (!bound) {
setBindings();
}
return setPointers();
};
$timeout(updateDOM);
for (_j = 0, _len1 = watchables.length; _j < _len1; _j++) {
w = watchables[_j];
scope.$watch(w, updateDOM, true);
}
return window.addEventListener('resize', updateDOM);
}
};
}
};
};
qualifiedDirectiveDefinition = ['$timeout', sliderDirective];
module = function(window, angular) {
return angular.module(MODULE_NAME, []).directive(SLIDER_TAG, qualifiedDirectiveDefinition);
};
module(window, window.angular);
}).call(this);

View File

@@ -1,4 +1,4 @@
var app = angular.module('habridge', ['ngRoute','ngToast']);
var app = angular.module('habridge', ['ngRoute','ngToast','ui.slider']);
app.config(function ($routeProvider) {
$routeProvider.when('/#', {
@@ -43,15 +43,43 @@ app.service('bridgeService', function ($http, $window, ngToast) {
var self = this;
this.state = {base: window.location.origin + "/api/devices", bridgelocation: window.location.origin, systemsbase: window.location.origin + "/system", huebase: window.location.origin + "/api", configs: [], backups: [], devices: [], device: [], settings: [], myToastMsg: [], olddevicename: "", showVera: false, showHarmony: false, showNest: false, habridgeversion: ""};
this.displayWarn = function(errorTitle, error) {
if(error == null) {
error = {status: 200, statusText: "OK", data: []};
error.data = {message: "success"};
}
ngToast.create({
className: "warning",
dismissButton: true,
dismissOnTimeout: false,
content: errorTitle + error.data.message + " with status: " + error.statusText + " - " + error.status});
};
this.displayError = function(errorTitle, error) {
if(error == null) {
error = {status: 200, statusText: "OK", data: []};
error.data = {message: "success"};
}
ngToast.create({
className: "danger",
dismissButton: true,
dismissOnTimeout: false,
content: errorTitle + error.data.message + " with status: " + error.statusText + " - " + error.status});
};
this.displaySuccess = function(theTitle) {
ngToast.create({
className: "success",
content: theTitle});
};
this.viewDevices = function () {
return $http.get(this.state.base).then(
function (response) {
self.state.devices = response.data;
},
function (error) {
ngToast.create({
className: "warning",
content:"Cannot get devices from habridge: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayError("Cannot get devices from habridge: ", error);
}
);
};
@@ -62,9 +90,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.habridgeversion = response.data.version;
},
function (error) {
ngToast.create({
className: "warning",
content:"Cannot get version" + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Cannot get version: ", error);
}
);
};
@@ -97,9 +123,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.updateShowNest();
},
function (error) {
ngToast.create({
className: "warning",
content:"Load Bridge Settings Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Load Bridge Settings Error: ", error);
}
);
};
@@ -110,9 +134,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.backups = response.data;
},
function (error) {
ngToast.create({
className: "warning",
content:"Get Backups Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Get Backups Error: ", error);
}
);
};
@@ -123,9 +145,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.configs = response.data;
},
function (error) {
ngToast.create({
className: "warning",
content:"Get Configs Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Get Configs Error: ", error);
}
);
};
@@ -138,9 +158,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.nestitems = response.data;
},
function (error) {
ngToast.create({
className: "warning",
content:"Get Nest Items Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Get Nest Items Error: ", error);
}
);
};
@@ -153,9 +171,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.veradevices = response.data;
},
function (error) {
ngToast.create({
className: "warning",
content:"Get Vera Devices Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Get Vera Devices Error: ", error);
}
);
};
@@ -168,9 +184,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.verascenes = response.data;
},
function (error) {
ngToast.create({
className: "warning",
content:"Get Vera Scenes Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Get Vera Scenes Error: ", error);
}
);
};
@@ -183,9 +197,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.harmonyactivities = response.data;
},
function (error) {
ngToast.create({
className: "warning",
content:"Get Harmony Activities Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Get Harmony Activities Error: ", error);
}
);
};
@@ -198,9 +210,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.state.harmonydevices = response.data;
},
function (error) {
ngToast.create({
className: "warning",
content:"Get Harmony Devices Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Get Harmony Devices Error: ", error);
}
);
};
@@ -226,9 +236,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
function (response) {
},
function (error) {
ngToast.create({
className: "warning",
content:"Bulk Add new Device Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Bulk Add new Device Error: ", error);
}
);
};
@@ -257,9 +265,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
function (response) {
},
function (error) {
ngToast.create({
className: "warning",
content:"Edit Device Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Edit Device Error: ", error);
}
);
} else {
@@ -281,9 +287,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
function (response) {
},
function (error) {
ngToast.create({
className: "warning",
content:"Add new Device Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Add new Device Error: ", error);
}
);
}
@@ -297,9 +301,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.viewBackups();
},
function (error) {
ngToast.create({
className: "warning",
content:"Backup Device Db Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Backup Device Db Error: ", error);
}
);
};
@@ -313,9 +315,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.viewDevices();
},
function (error) {
ngToast.create({
className: "warning",
content:"Backup Db Restore Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Backup Db Restore Error: ", error);
}
);
};
@@ -328,9 +328,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.viewBackups();
},
function (error) {
ngToast.create({
className: "warning",
content:"Delete Backup Db File Error:" + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Delete Backup Db File Error:", error);
}
);
};
@@ -354,16 +352,10 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.stop = function() {
return $http.put(this.state.systemsbase + "/control/stop").then(
function (response) {
ngToast.create({
className: "danger",
dismissButton: true,
dismissOnTimeout: false,
content:"HABridge is now stopped. Restart must occur from the server."});
self.displayError("HABridge is now stopped. Restart must occur from the server.", null);
},
function (error) {
ngToast.create({
className: "warning",
content:"HABRidge Stop Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayError("HABRidge Stop Error: ", error);
}
);
};
@@ -381,9 +373,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
}, 2000);
},
function (error) {
ngToast.create({
className: "warning",
content:"HABRidge Reinit Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("HABRidge Reinit Error: ", error);
}
);
};
@@ -394,9 +384,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.reinit();
},
function (error) {
ngToast.create({
className: "warning",
content:"Save Settings Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Save Settings Error: ", error);
}
);
@@ -410,9 +398,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.viewConfigs();
},
function (error) {
ngToast.create({
className: "warning",
content:"Backup Settings Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Backup Settings Error: ", error);
}
);
};
@@ -426,9 +412,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.viewDevices();
},
function (error) {
ngToast.create({
className: "warning",
content:"Backup Settings Restore Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Backup Settings Restore Error: ", error);
}
);
};
@@ -441,9 +425,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.viewConfigs();
},
function (error) {
ngToast.create({
className: "warning",
content:"Delete Backup Settings File Error: " + "unknown error" || error.data.message + " with status: " + error.status});
self.displayWarn("Delete Backup Settings File Error: ", error);
}
);
};
@@ -454,9 +436,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
self.viewDevices();
},
function (error) {
ngToast.create({
className: "warning",
content:"Delete Device Error: " + "unknown error" || error.data.message + " with status: " + error.status});
nself.displayWarn("Delete Device Error: ", error);
}
);
};
@@ -474,17 +454,19 @@ app.service('bridgeService', function ($http, $window, ngToast) {
};
this.testUrl = function (device, type) {
var msgDescription = "unknown";
if(type == "on") {
$http.put(this.state.huebase + "/test/lights/" + device.id + "/state", "{\"on\":true}").then(
function (response) {
ngToast.create({
className: "success",
content:"Request Exceuted: " + response.statusText});
if(typeof(response.data[0].success) != 'undefined')
msgDescription = "success " + angular.toJson(response.data[0].success);
if(typeof(response.data[0].error) != 'undefined')
msgDescription = "error " + angular.toJson(response.data[0].error);
self.displaySuccess("Request Exceuted: " + msgDescription);
},
function (error) {
ngToast.create({
className: "warning",
content:"Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log."});
self.displayWarn("Request Error, Pleae look in your habridge log: ", error);
}
);
return;
@@ -492,14 +474,15 @@ app.service('bridgeService', function ($http, $window, ngToast) {
else {
$http.put(this.state.huebase + "/test/lights/" + device.id + "/state", "{\"on\":false}").then(
function (response) {
ngToast.create({
className: "success",
content:"Request Exceuted: " + response.statusText});
if(typeof(response.data[0].success) != 'undefined')
msgDescription = "success " + angular.toJson(response.data[0].success);
if(typeof(response.data[0].error) != 'undefined')
msgDescription = "error " + angular.toJson(response.data[0].error);
self.displaySuccess("Request Exceuted: " + msgDescription);
},
function (error) {
ngToast.create({
className: "warning",
content:"Request Error: " + error.statusText + ", with status: " + error.status + ", Pleae look in your console log."});
self.displayWarn("Request Error, Pleae look in your habridge log: ", error);
}
);
return;
@@ -1073,11 +1056,6 @@ app.filter('configuredButtons', function() {
}
});
app.controller('ErrorsController', function ($scope, bridgeService) {
$scope.bridge = bridgeService.state;
});
app.controller('VersionController', function ($scope, bridgeService) {
$scope.bridge = bridgeService.state;
});

View File

@@ -9,20 +9,6 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul>
<div ng-controller="ErrorsController">
<div ng-if="bridge.error"
class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h2 ng-show='bridge.error != ""'>ERROR</h2>
<div ng-show='bridge.error != ""'>{{bridge.error}}</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">Current devices ({{bridge.devices.length}}) </h2>
@@ -53,6 +39,7 @@
<td>{{device.deviceType}}</td>
<td>{{device.targetDevice}}</td>
<td>
<p>
<button class="btn btn-info" type="submit"
ng-click="testUrl(device, 'on')">Test ON</button>
<button class="btn btn-info" type="submit"
@@ -61,6 +48,10 @@
ng-click="editDevice(device)">Edit/Copy</button>
<button class="btn btn-danger" type="submit"
ng-click="deleteDevice(device)">Delete</button>
</p>
<p>
<slider floor="0" ceiling="100" step="1" precision="2" ng-model="devicePercentage"></slider>
</p>
</td>
</tr>
</table>

View File

@@ -9,20 +9,6 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul>
<div ng-controller="ErrorsController">
<div ng-if="bridge.error"
class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h2 ng-show='bridge.error != ""'>ERROR</h2>
<div ng-show='bridge.error != ""'>{{bridge.error}}</div>
</div>
</div>
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h1 class="panel-title">Bridge Settings</h1>