mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Finished config up/down load impl and Finished startup action implementation
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>5.2.next_e</version>
|
<version>5.3.0RC1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -437,6 +437,41 @@ public class SystemControl {
|
|||||||
return stop();
|
return stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// http://ip_address:port/system/devices/backup/download CORS request
|
||||||
|
options(SYSTEM_CONTEXT + "/backup/download", "application/json", (request, response) -> {
|
||||||
|
response.status(HttpStatus.SC_OK);
|
||||||
|
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
|
||||||
|
response.header("Access-Control-Allow-Methods", "PUT");
|
||||||
|
response.header("Access-Control-Allow-Headers", request.headers("Access-Control-Request-Headers"));
|
||||||
|
response.header("Content-Type", "text/html; charset=utf-8");
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
put (SYSTEM_CONTEXT + "/backup/download", "application/json", (request, response) -> {
|
||||||
|
log.debug("Create download: {}", request.body());
|
||||||
|
BackupFilename aFilename = new Gson().fromJson(request.body(), BackupFilename.class);
|
||||||
|
String backupContent = bridgeSettings.downloadBackup(aFilename.getFilename());
|
||||||
|
return backupContent;
|
||||||
|
}, new JsonTransformer());
|
||||||
|
|
||||||
|
// http://ip_address:port/system/devices/backup/upload CORS request
|
||||||
|
options(SYSTEM_CONTEXT + "/backup/upload/:filename", "application/json", (request, response) -> {
|
||||||
|
response.status(HttpStatus.SC_OK);
|
||||||
|
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
|
||||||
|
response.header("Access-Control-Allow-Methods", "PUT");
|
||||||
|
response.header("Access-Control-Allow-Headers", request.headers("Access-Control-Request-Headers"));
|
||||||
|
response.header("Content-Type", "text/html; charset=utf-8");
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
put (SYSTEM_CONTEXT + "/backup/upload/:filename", "application/json", (request, response) -> {
|
||||||
|
log.debug("Create upload: {} - {}", request.params(":filename"), request.body());
|
||||||
|
String theSuccess = bridgeSettings.uploadBackup(request.params(":filename"), request.body());
|
||||||
|
if(theSuccess.contains("Error:"))
|
||||||
|
response.status(HttpStatus.SC_METHOD_FAILURE);
|
||||||
|
else
|
||||||
|
response.status(HttpStatus.SC_OK);
|
||||||
|
return theSuccess;
|
||||||
|
}, new JsonTransformer());
|
||||||
|
|
||||||
// http://ip_address:port/system/backup/available returns a list of config backup filenames
|
// http://ip_address:port/system/backup/available returns a list of config backup filenames
|
||||||
get (SYSTEM_CONTEXT + "/backup/available", (request, response) -> {
|
get (SYSTEM_CONTEXT + "/backup/available", (request, response) -> {
|
||||||
log.debug("Get backup filenames");
|
log.debug("Get backup filenames");
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ public class DeviceDescriptor{
|
|||||||
@SerializedName("lockDeviceId")
|
@SerializedName("lockDeviceId")
|
||||||
@Expose
|
@Expose
|
||||||
private boolean lockDeviceId;
|
private boolean lockDeviceId;
|
||||||
|
@SerializedName("startupActions")
|
||||||
|
@Expose
|
||||||
|
private String startupActions;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@@ -344,4 +347,12 @@ public class DeviceDescriptor{
|
|||||||
public void setLockDeviceId(boolean lockDeviceId) {
|
public void setLockDeviceId(boolean lockDeviceId) {
|
||||||
this.lockDeviceId = lockDeviceId;
|
this.lockDeviceId = lockDeviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getStartupActions() {
|
||||||
|
return startupActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartupActions(String startupActions) {
|
||||||
|
this.startupActions = startupActions;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -202,15 +202,33 @@ public class DeviceRepository extends BackupHandler {
|
|||||||
List<DeviceDescriptor> list = new ArrayList<DeviceDescriptor>(devices.values());
|
List<DeviceDescriptor> list = new ArrayList<DeviceDescriptor>(devices.values());
|
||||||
Iterator<DeviceDescriptor> deviceIterator = list.iterator();
|
Iterator<DeviceDescriptor> deviceIterator = list.iterator();
|
||||||
Map<String, DeviceDescriptor> newdevices = new HashMap<String, DeviceDescriptor>();
|
Map<String, DeviceDescriptor> newdevices = new HashMap<String, DeviceDescriptor>();
|
||||||
|
List<String> lockedIds = new ArrayList<String>();
|
||||||
nextId = seedId;
|
|
||||||
String hexValue;
|
String hexValue;
|
||||||
Integer newValue;
|
Integer newValue;
|
||||||
DeviceDescriptor theDevice;
|
DeviceDescriptor theDevice;
|
||||||
log.debug("Renumber devices with seed: {}", seedId);
|
boolean findNext = true;
|
||||||
|
|
||||||
|
|
||||||
|
nextId = seedId;
|
||||||
|
while(deviceIterator.hasNext()) {
|
||||||
|
theDevice = deviceIterator.next();
|
||||||
|
if(theDevice.isLockDeviceId()) {
|
||||||
|
lockedIds.add(theDevice.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.debug("Renumber devices starting with: {}", nextId);
|
||||||
|
deviceIterator = list.iterator();
|
||||||
while (deviceIterator.hasNext()) {
|
while (deviceIterator.hasNext()) {
|
||||||
theDevice = deviceIterator.next();
|
theDevice = deviceIterator.next();
|
||||||
if (!theDevice.isLockDeviceId()) {
|
if (!theDevice.isLockDeviceId()) {
|
||||||
|
findNext = true;
|
||||||
|
while(findNext) {
|
||||||
|
if(lockedIds.contains(String.valueOf(nextId))) {
|
||||||
|
nextId++;
|
||||||
|
} else {
|
||||||
|
findNext = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
theDevice.setId(String.valueOf(nextId));
|
theDevice.setId(String.valueOf(nextId));
|
||||||
newValue = nextId % 256;
|
newValue = nextId % 256;
|
||||||
if (newValue <= 0)
|
if (newValue <= 0)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.awt.Color;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,6 +78,7 @@ public class HueMulator {
|
|||||||
// This function sets up the sparkjava rest calls for the hue api
|
// This function sets up the sparkjava rest calls for the hue api
|
||||||
public void setupServer() {
|
public void setupServer() {
|
||||||
log.info("Hue emulator service started....");
|
log.info("Hue emulator service started....");
|
||||||
|
startupDeviceCall();
|
||||||
before(HUE_CONTEXT + "/*", (request, response) -> {
|
before(HUE_CONTEXT + "/*", (request, response) -> {
|
||||||
// This currently causes an error with Spark replies
|
// This currently causes an error with Spark replies
|
||||||
// String path = request.pathInfo();
|
// String path = request.pathInfo();
|
||||||
@@ -1671,4 +1673,50 @@ public class HueMulator {
|
|||||||
|
|
||||||
return responseString;
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startupDeviceCall() {
|
||||||
|
String aUserId = bridgeSettingMaster.getBridgeSecurity().createWhitelistUser("test_ha_bridge");
|
||||||
|
List<DeviceDescriptor> deviceList = repository.findAll();
|
||||||
|
String aChangeBody;
|
||||||
|
String[] components;
|
||||||
|
boolean comma = false;
|
||||||
|
|
||||||
|
for (DeviceDescriptor aDevice : deviceList) {
|
||||||
|
if(aDevice.getStartupActions() != null && !aDevice.getStartupActions().isEmpty()) {
|
||||||
|
log.info("Startup call for {} with startupActions {}", aDevice.getName(), aDevice.getStartupActions());
|
||||||
|
aChangeBody = "{";
|
||||||
|
components = aDevice.getStartupActions().split(":");
|
||||||
|
if(components.length > 0 && components[0] != null && components[0].length() > 0) {
|
||||||
|
if(components[0].equals("On")) {
|
||||||
|
aChangeBody = aChangeBody + "\"on\":true";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
aChangeBody = aChangeBody + "\"on\":false";
|
||||||
|
}
|
||||||
|
comma = true;
|
||||||
|
}
|
||||||
|
if(components.length > 1 && components[1] != null && components[1].length() > 0 && !(components.length > 2 && components[2] != null && components[2].length() > 0)) {
|
||||||
|
if(comma)
|
||||||
|
aChangeBody = aChangeBody + ",";
|
||||||
|
aChangeBody = aChangeBody + "\"bri\":" + components[1];
|
||||||
|
comma = true;
|
||||||
|
}
|
||||||
|
if(components.length > 2 && components[2] != null && components[2].length() > 0) {
|
||||||
|
if(comma)
|
||||||
|
aChangeBody = aChangeBody + ",";
|
||||||
|
String theRGB = components[2].substring(components[2].indexOf('(') + 1, components[2].indexOf(')'));
|
||||||
|
String[] RGB = theRGB.split(",");
|
||||||
|
float[] hsb = new float[3];
|
||||||
|
Color.RGBtoHSB(Integer.parseInt(RGB[0]), Integer.parseInt(RGB[1]), Integer.parseInt(RGB[2]), hsb);
|
||||||
|
float hue = hsb[0] * (float) 360.0;
|
||||||
|
float sat = hsb[1] * (float) 100.0;
|
||||||
|
float bright = hsb[2] * (float) 100.0;
|
||||||
|
aChangeBody = String.format("%s\"hue\":%.2f,\"sat\":%.2f,\"bri\":%d", aChangeBody, hue, sat, Math.round(bright));
|
||||||
|
}
|
||||||
|
aChangeBody = aChangeBody + "}";
|
||||||
|
log.info("Startup call to set state for {} with body {}", aDevice.getName(), aChangeBody);
|
||||||
|
changeState(aUserId, aDevice.getId(), aChangeBody, "localhost", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1279,7 +1279,7 @@ app.service('bridgeService', function ($rootScope, $http, $base64, $location, ng
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.downloadBackup = function (afilename) {
|
this.downloadDeviceBackup = function (afilename) {
|
||||||
return $http.put(this.state.base + "/backup/download", {
|
return $http.put(this.state.base + "/backup/download", {
|
||||||
filename: afilename
|
filename: afilename
|
||||||
}).then(
|
}).then(
|
||||||
@@ -1459,6 +1459,54 @@ app.service('bridgeService', function ($rootScope, $http, $base64, $location, ng
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.downloadConfigBackup = function (afilename) {
|
||||||
|
return $http.put(this.state.systemsbase + "/backup/download", {
|
||||||
|
filename: afilename
|
||||||
|
}).then(
|
||||||
|
function (response) {
|
||||||
|
self.state.backupContent = response.data;
|
||||||
|
var blob = new Blob([self.state.backupContent], {
|
||||||
|
type: 'text/plain'
|
||||||
|
});
|
||||||
|
var downloadLink = angular.element('<a></a>');
|
||||||
|
downloadLink.attr('href', window.URL.createObjectURL(blob));
|
||||||
|
downloadLink.attr('download', afilename);
|
||||||
|
downloadLink[0].click();
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
if (error.status === 401)
|
||||||
|
$rootScope.$broadcast('securityReinit', 'done');
|
||||||
|
else
|
||||||
|
self.displayWarn("Download Backup Config File Error:", error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.uploadConfigFile = function (filename, file) {
|
||||||
|
file.upload = Upload.http({
|
||||||
|
url: this.state.systemsbase + "/backup/upload/" + filename,
|
||||||
|
method: 'PUT',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': file.type
|
||||||
|
},
|
||||||
|
data: file
|
||||||
|
});
|
||||||
|
|
||||||
|
file.upload.then(function (response) {
|
||||||
|
file.result = response.data;
|
||||||
|
self.viewConfigs();
|
||||||
|
}, function (response) {
|
||||||
|
if (response.status === 401)
|
||||||
|
$rootScope.$broadcast('securityReinit', 'done');
|
||||||
|
else if (response.status > 0)
|
||||||
|
self.displayWarn('Upload Backup Config File Error:' + response.status + ': ' + response.data);
|
||||||
|
});
|
||||||
|
|
||||||
|
file.upload.progress(function (evt) {
|
||||||
|
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.deleteDevice = function (id) {
|
this.deleteDevice = function (id) {
|
||||||
return $http.delete(this.state.base + "/" + id).then(
|
return $http.delete(this.state.base + "/" + id).then(
|
||||||
function (response) {
|
function (response) {
|
||||||
@@ -2074,6 +2122,17 @@ app.controller('SystemController', function ($scope, $location, bridgeService, n
|
|||||||
$scope.deleteSettingsBackup = function (backupname) {
|
$scope.deleteSettingsBackup = function (backupname) {
|
||||||
bridgeService.deleteSettingsBackup(backupname);
|
bridgeService.deleteSettingsBackup(backupname);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.downloadBackup = function (backupname) {
|
||||||
|
bridgeService.downloadConfigBackup(backupname);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.uploadConfigFile = function (aFilename, aConfigFile) {
|
||||||
|
if (aConfigFile != null) {
|
||||||
|
bridgeService.uploadConfigFile(aFilename, aConfigFile);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$scope.toggle = function () {
|
$scope.toggle = function () {
|
||||||
$scope.visible = !$scope.visible;
|
$scope.visible = !$scope.visible;
|
||||||
if ($scope.visible)
|
if ($scope.visible)
|
||||||
@@ -2349,12 +2408,41 @@ app.controller('ViewingController', function ($scope, $location, bridgeService,
|
|||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
};
|
};
|
||||||
|
$scope.setStartupAction = function(device) {
|
||||||
|
$scope.bridge.device = device;
|
||||||
|
ngDialog.open({
|
||||||
|
template: 'startupActionDialog',
|
||||||
|
controller: 'StartupActionDialogCtrl',
|
||||||
|
className: 'ngdialog-theme-default'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$scope.renumberDevices = function () {
|
$scope.renumberDevices = function () {
|
||||||
bridgeService.renumberDevices();
|
bridgeService.renumberDevices();
|
||||||
};
|
};
|
||||||
$scope.pushLinkButton = function () {
|
$scope.pushLinkButton = function () {
|
||||||
bridgeService.pushLinkButton();
|
bridgeService.pushLinkButton();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.toggleLock = function (device) {
|
||||||
|
if(device.lockDeviceId) {
|
||||||
|
device.lockDeviceId = false;
|
||||||
|
} else {
|
||||||
|
device.lockDeviceId = true;
|
||||||
|
}
|
||||||
|
console.log("toggle lock device called: " + device.name);
|
||||||
|
bridgeService.addDevice(device).then(
|
||||||
|
function () {
|
||||||
|
bridgeService.state.queueDevId = device.id;
|
||||||
|
console.log("Device updated for Q Id <<" + bridgeService.state.queueDevId + ">>");
|
||||||
|
$location.path('/');
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
bridgeService.displayWarn("Error updating lock id for device....", error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
$scope.manageLinksButton = function () {
|
$scope.manageLinksButton = function () {
|
||||||
ngDialog.open({
|
ngDialog.open({
|
||||||
template: 'views/managelinksdialog.html',
|
template: 'views/managelinksdialog.html',
|
||||||
@@ -2372,7 +2460,7 @@ app.controller('ViewingController', function ($scope, $location, bridgeService,
|
|||||||
bridgeService.deleteBackup(backupname);
|
bridgeService.deleteBackup(backupname);
|
||||||
};
|
};
|
||||||
$scope.downloadBackup = function (backupname) {
|
$scope.downloadBackup = function (backupname) {
|
||||||
bridgeService.downloadBackup(backupname);
|
bridgeService.downloadDeviceBackup(backupname);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.uploadDeviceFile = function (aFilename, aDeviceFile) {
|
$scope.uploadDeviceFile = function (aFilename, aDeviceFile) {
|
||||||
@@ -2408,23 +2496,23 @@ app.controller('ViewingController', function ($scope, $location, bridgeService,
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
||||||
|
$scope.bridge = bridgeService.state;
|
||||||
|
$scope.valueType = "percentage";
|
||||||
$scope.slider = {
|
$scope.slider = {
|
||||||
value: 100,
|
value: Math.round($scope.bridge.device.deviceState.bri / 2.55),
|
||||||
options: {
|
options: {
|
||||||
floor: 1,
|
floor: 1,
|
||||||
ceil: 100,
|
ceil: 100,
|
||||||
showSelectionBar: true
|
showSelectionBar: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.bridge = bridgeService.state;
|
|
||||||
$scope.valueType = "percentage";
|
|
||||||
$scope.changeScale = function () {
|
$scope.changeScale = function () {
|
||||||
if ($scope.valueType === "raw") {
|
if ($scope.valueType === "raw") {
|
||||||
$scope.slider.options.ceil = 254;
|
$scope.slider.options.ceil = 254;
|
||||||
$scope.slider.value = 254;
|
$scope.slider.value = $scope.bridge.device.deviceState.bri;
|
||||||
} else {
|
} else {
|
||||||
$scope.slider.options.ceil = 100;
|
$scope.slider.options.ceil = 100;
|
||||||
$scope.slider.value = 100;
|
$scope.slider.value = Math.round($scope.bridge.device.deviceState.bri / 2.55);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.setValue = function () {
|
$scope.setValue = function () {
|
||||||
@@ -2473,6 +2561,57 @@ app.controller('DeleteDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.controller('StartupActionDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
||||||
|
$scope.bridge = bridgeService.state;
|
||||||
|
$scope.device = $scope.bridge.device;
|
||||||
|
$scope.setDim = false;
|
||||||
|
var components = [];
|
||||||
|
if($scope.device.startupActions != undefined) {
|
||||||
|
components = $scope.device.startupActions.split(":");
|
||||||
|
if(components[1] != undefined && components[1].length > 0)
|
||||||
|
$scope.setDim = true;
|
||||||
|
} else {
|
||||||
|
components = "::".split(":");
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.slider = {
|
||||||
|
value: parseInt(components[1]),
|
||||||
|
options: {
|
||||||
|
floor: 1,
|
||||||
|
ceil: 254,
|
||||||
|
showSelectionBar: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$scope.rgbPicker = {
|
||||||
|
color: components[2]
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.theState = components[0];
|
||||||
|
|
||||||
|
$scope.startupActionSave = function (device) {
|
||||||
|
console.log("Startup action set for device called: " + device.name);
|
||||||
|
ngDialog.close('ngdialog1');
|
||||||
|
var theValue = 1;
|
||||||
|
if($scope.setDim) {
|
||||||
|
theValue = $scope.theState + ":" + $scope.slider.value + ":" + $scope.rgbPicker.color;
|
||||||
|
} else {
|
||||||
|
theValue = $scope.theState + "::" + $scope.rgbPicker.color;
|
||||||
|
}
|
||||||
|
if(theValue == "::")
|
||||||
|
theValue = "";
|
||||||
|
device.startupActions = theValue;
|
||||||
|
bridgeService.addDevice(device).then(
|
||||||
|
function () {
|
||||||
|
bridgeService.state.queueDevId = device.id;
|
||||||
|
console.log("Device updated for Q Id <<" + bridgeService.state.queueDevId + ">>");
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
bridgeService.displayWarn("Error updating lock id for device....", error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
app.controller('VeraController', function ($scope, $location, bridgeService, ngDialog) {
|
app.controller('VeraController', function ($scope, $location, bridgeService, ngDialog) {
|
||||||
$scope.bridge = bridgeService.state;
|
$scope.bridge = bridgeService.state;
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
|
|||||||
@@ -68,9 +68,9 @@
|
|||||||
<th sortable-header col="id" comparator-fn="comparatorUniqueId">ID</th>
|
<th sortable-header col="id" comparator-fn="comparatorUniqueId">ID</th>
|
||||||
<th sortable-header col="name">Name</th>
|
<th sortable-header col="name">Name</th>
|
||||||
<th sortable-header col="description">Description</th>
|
<th sortable-header col="description">Description</th>
|
||||||
<th sortable-header col="devicestate">Device State</th>
|
|
||||||
<th sortable-header col="deviceType">Type</th>
|
<th sortable-header col="deviceType">Type</th>
|
||||||
<th sortable-header col="targetDevice">Target</th>
|
<th sortable-header col="targetDevice">Target</th>
|
||||||
|
<th sortable-header col="startupAction">Startup Action</th>
|
||||||
<th sortable-header col="inactive">Inactive</th>
|
<th sortable-header col="inactive">Inactive</th>
|
||||||
<th sortable-header col="noState">No State</th>
|
<th sortable-header col="noState">No State</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
@@ -79,14 +79,17 @@
|
|||||||
<tr ng-repeat="device in bridge.devices | filterDevicesByRequester:bridge.state.filterDevicesByIpAddress:bridge.state.filterDevicesOnlyFiltered:bridge.state.filterDeviceType"
|
<tr ng-repeat="device in bridge.devices | filterDevicesByRequester:bridge.state.filterDevicesByIpAddress:bridge.state.filterDevicesOnlyFiltered:bridge.state.filterDeviceType"
|
||||||
row-id="{{device.id}}" ng-class="{info: bridge.viewDevId == device.id}">
|
row-id="{{device.id}}" ng-class="{info: bridge.viewDevId == device.id}">
|
||||||
<td>{{$index+1}}</td>
|
<td>{{$index+1}}</td>
|
||||||
<td>{{device.id}}</td>
|
<td title="Locked: {{device.lockDeviceId}} - Click to Toggle" ng-click="toggleLock(device)">
|
||||||
<td>{{device.name}}</td>
|
<b ng-if="device.lockDeviceId">{{device.id}}</b>
|
||||||
<td class="cr">{{device.description}}</td>
|
<p ng-if="!device.lockDeviceId">{{device.id}}</p>
|
||||||
<td class="cr">
|
|
||||||
on={{device.deviceState.on}},bri={{device.deviceState.bri}},hue={{device.deviceState.hue}},sat={{device.deviceState.sat}},effect={{device.deviceState.effect}},ct={{device.deviceState.ct}},alert={{device.deviceState.alert}},colormode={{device.deviceState.colormode}},reachable={{device.deviceState.reachable}},XYList={{device.deviceState.xy}}
|
|
||||||
</td>
|
</td>
|
||||||
|
<td
|
||||||
|
title="on={{device.deviceState.on}},bri={{device.deviceState.bri}},hue={{device.deviceState.hue}},sat={{device.deviceState.sat}},effect={{device.deviceState.effect}},ct={{device.deviceState.ct}},alert={{device.deviceState.alert}},colormode={{device.deviceState.colormode}},reachable={{device.deviceState.reachable}},XYList={{device.deviceState.xy}}">
|
||||||
|
{{device.name}}</td>
|
||||||
|
<td class="cr">{{device.description}}</td>
|
||||||
<td>{{device.deviceType}}</td>
|
<td>{{device.deviceType}}</td>
|
||||||
<td>{{device.targetDevice}}</td>
|
<td>{{device.targetDevice}}</td>
|
||||||
|
<td class="cr" title="Click to set actions for device on ha-bridge startup." ng-click="setStartupAction(device)">{{device.startupActions}}</td>
|
||||||
<td>{{device.inactive}}</td>
|
<td>{{device.inactive}}</td>
|
||||||
<td>{{device.noState}}</td>
|
<td>{{device.noState}}</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -139,13 +142,13 @@
|
|||||||
<input type="file" ngf-select="" ng-model="deviceFile" name="file">
|
<input type="file" ngf-select="" ng-model="deviceFile" name="file">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button ng-disabled="!myForm.$valid" type="submit" class="btn btn-primary"
|
<button ng-disabled="!myForm.$valid" type="submit" class="btn btn-primary"
|
||||||
ng-click="uploadDeviceFile(deviceFile.name, deviceFile)">Upload</button>
|
ng-click="uploadDeviceFile(deviceFile.name, deviceFile)">Upload</button>
|
||||||
<span class="progress" ng-show="deviceFile.progress >= 0">
|
<span class="progress" ng-show="deviceFile.progress >= 0">
|
||||||
<div style="width:{{deviceFile.progress}}%" ng-bind="deviceFile.progress + '%'"
|
<div style="width:{{deviceFile.progress}}%" ng-bind="deviceFile.progress + '%'" class="ng-binding">
|
||||||
class="ng-binding"></div>
|
</div>
|
||||||
</span>
|
</span>
|
||||||
<span ng-show="deviceFile.result">Upload Successful</span>
|
<span ng-show="deviceFile.result">Upload Successful</span>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<table class="table table-bordered table-striped table-hover">
|
<table class="table table-bordered table-striped table-hover">
|
||||||
@@ -201,4 +204,44 @@
|
|||||||
<div class="ngdialog-buttons mt">
|
<div class="ngdialog-buttons mt">
|
||||||
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteDevice(device)">Delete</button>
|
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteDevice(device)">Delete</button>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
<script type="text/ng-template" id="startupActionDialog">
|
||||||
|
<div class="ngdialog-message">
|
||||||
|
<h2>Select Actions for startup on {{device.name}}</h2>
|
||||||
|
<table class="table table-bordered table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Setting</th>
|
||||||
|
<th>Value</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr>
|
||||||
|
<td>State</td>
|
||||||
|
<td>
|
||||||
|
<select name="the-state" id="the-state" ng-model="theState">
|
||||||
|
<option value="">---None---</option>
|
||||||
|
<!-- not selected / blank option -->
|
||||||
|
<option value="On">On</option>
|
||||||
|
<option value="Off">Off</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Dim</td>
|
||||||
|
<td>
|
||||||
|
<input type="checkbox"
|
||||||
|
ng-model="setDim" ng-true-value=true
|
||||||
|
ng-false-value=false>
|
||||||
|
<rzslider rz-slider-model="slider.value" rz-slider-options="slider.options"></rzslider>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Color RGB</td>
|
||||||
|
<td><input colorpicker="rgb" ng-model="rgbPicker.color" type="text"></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="ngdialog-buttons mt">
|
||||||
|
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="startupActionSave(device)">Save</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
@@ -985,6 +985,22 @@
|
|||||||
Settings</button>
|
Settings</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<form class="form-horizontal" name="myForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xs-12 col-sm-2 control-label" for="backup-name">Config File to upload</label>
|
||||||
|
<div class="col-xs-8 col-sm-7">
|
||||||
|
<input type="file" ngf-select="" ng-model="configFile" name="file">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button ng-disabled="!myForm.$valid" type="submit" class="btn btn-primary"
|
||||||
|
ng-click="uploadConfigFile(configFile.name, configFile)">Upload</button>
|
||||||
|
<span class="progress" ng-show="configFile.progress >= 0">
|
||||||
|
<div style="width:{{configFile.progress}}%" ng-bind="configFile.progress + '%'"
|
||||||
|
class="ng-binding"></div>
|
||||||
|
</span>
|
||||||
|
<span ng-show="configFile.result">Upload Successful</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
<table class="table table-bordered table-striped table-hover">
|
<table class="table table-bordered table-striped table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -993,7 +1009,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr ng-repeat="backup in bridge.configs">
|
<tr ng-repeat="backup in bridge.configs">
|
||||||
<td>{{backup}}</td>
|
<td><a class="btn" ng-click="downloadBackup(backup)" ng-href="{{ url }}">{{backup}}</a></td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-danger" type="submit"
|
<button class="btn btn-danger" type="submit"
|
||||||
ng-click="restoreSettings(backup)">Restore</button>
|
ng-click="restoreSettings(backup)">Restore</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user