Vera device and scene creation testing and added Copy capability to add

an already configured device with a different name.

Fixes #32
Fixes #38
This commit is contained in:
Admin
2016-02-02 12:04:48 -06:00
parent 49c3b85894
commit a1708f2a88
4 changed files with 33 additions and 7 deletions

View File

@@ -38,7 +38,7 @@ app.run( function (bridgeService) {
app.service('bridgeService', function ($http, $window) {
var self = this;
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", backups: [], devices: [], device: [], settings: [], error: "", showVera: false, showHarmony: false, showNest: false, habridgeversion: ""};
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", backups: [], devices: [], device: [], settings: [], olddevicename: "", error: "", showVera: false, showHarmony: false, showNest: false, habridgeversion: ""};
this.viewDevices = function () {
this.state.error = "";
@@ -386,6 +386,7 @@ app.service('bridgeService', function ($http, $window) {
this.editDevice = function (device) {
self.state.device = device;
self.state.olddevicename = device.name;
};
this.testUrl = function (device, type) {
@@ -507,6 +508,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
$scope.device.contentType = null;
$scope.device.contentBody = null;
$scope.device.contentBodyOff = null;
$scope.bridge.olddevice.name = "";
};
$scope.buildUrlsUsingDevice = function (dim_control) {
@@ -700,6 +702,27 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
};
$scope.copyDevice = function () {
if($scope.device.name == "" && $scope.device.onUrl == "") {
$scope.clearDevice();
return;
}
if($scope.device.name == $scope.bridge.olddevicename) {
$scope.clearDevice();
return;
}
$scope.device.id = null;
bridgeService.addDevice($scope.device).then(
function () {
$scope.clearDevice();
},
function (error) {
}
);
};
$scope.bulkAddDevices = function(dim_control) {
for(var i = 0; i < $scope.bulk.devices.length; i++) {
for(var x = 0; x < bridgeService.state.veradevices.length; x++) {