Skip to content

Commit

Permalink
Added delete dialog for confirmation. Fixed bug with text in
Browse files Browse the repository at this point in the history
intensity.byte for vera device tab. Fixed issue with parsing replies for
http requests. Fixed Hue device bulk add. recommit


Fixes #100
Fixes #102
Fixes #104
Fixes #105
  • Loading branch information
bwssytems committed May 4, 2016
1 parent 5d1f0ce commit c773477
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 40 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>2.0.3</version>
<version>2.0.4</version>
<packaging>jar</packaging>

<name>HA Bridge</name>
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,10 @@ protected String doHttpRequest(String url, String httpVerb, String contentType,
response = httpClient.execute(request);
log.debug((httpVerb == null?"GET":httpVerb) + " execute on URL responded: " + response.getStatusLine().getStatusCode());
if(response.getStatusLine().getStatusCode() >= 200 && response.getStatusLine().getStatusCode() < 300){
theContent = EntityUtils.toString(response.getEntity(), Charset.forName("UTF-8")); //read content for data
EntityUtils.consume(response.getEntity()); //close out inputstream ignore content
if(response.getEntity() != null ) {
theContent = EntityUtils.toString(response.getEntity(), Charset.forName("UTF-8")); //read content for data
EntityUtils.consume(response.getEntity()); //close out inputstream ignore content
}
}
} catch (IOException e) {
log.warn("Error calling out to HA gateway: IOException in log", e);
Expand Down
87 changes: 66 additions & 21 deletions src/main/resources/public/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ app.run( function (bridgeService) {

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: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, habridgeversion: ""};
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: [], mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, habridgeversion: ""};

this.displayWarn = function(errorTitle, error) {
var toastContent = errorTitle;
Expand Down Expand Up @@ -324,6 +324,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
this.bulkAddDevice = function (devices) {
return $http.post(this.state.base, devices).then(
function (response) {
self.displaySuccess("Bulk device add successful.");
},
function (error) {
self.displayWarn("Bulk Add new Device Error: ", error);
Expand Down Expand Up @@ -724,7 +725,12 @@ app.controller('ViewingController', function ($scope, $location, $http, $window,
bridgeService.testUrl(device, type);
};
$scope.deleteDevice = function (device) {
bridgeService.deleteDevice(device.id);
$scope.bridge.device = device;
ngDialog.open({
template: 'deleteDialog',
controller: 'DeleteDialogCtrl',
className: 'ngdialog-theme-default'
});
};
$scope.editDevice = function (device) {
bridgeService.editDevice(device);
Expand Down Expand Up @@ -789,7 +795,36 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
};
});

app.controller('VeraController', function ($scope, $location, $http, bridgeService) {
app.controller('DeleteDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device;
$scope.deleteDevice = function (device) {
ngDialog.close('ngdialog1');
bridgeService.deleteDevice(device.id);
bridgeService.viewDevices();
$scope.bridge.device = null;
$scope.bridge.type = "";
};
});

app.controller('DeleteMapandIdDialogCtrl', function ($scope, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state;
$scope.mapandid = $scope.bridge.mapandid;
$scope.deleteMapandId = function (mapandid) {
ngDialog.close('ngdialog1');
bridgeService.deleteDeviceByMapId(mapandid.id, mapandid.mapType);
bridgeService.viewDevices();
bridgeService.viewVeraDevices();
bridgeService.viewVeraScenes();
bridgeService.viewHarmonyActivities();
bridgeService.viewHarmonyDevices();
bridgeService.viewNestItems();
bridgeService.viewHueDevices();
$scope.bridge.mapandid = null;
};
});

app.controller('VeraController', function ($scope, $location, $http, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device;
$scope.device_dim_control = "";
Expand Down Expand Up @@ -919,15 +954,17 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
};

$scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType);
bridgeService.viewDevices();
bridgeService.viewVeraDevices();
bridgeService.viewVeraScenes();
$scope.bridge.mapandid = { id, mapType };
ngDialog.open({
template: 'deleteMapandIdDialog',
controller: 'DeleteMapandIdDialogCtrl',
className: 'ngdialog-theme-default'
});
};

});

app.controller('HarmonyController', function ($scope, $location, $http, bridgeService) {
app.controller('HarmonyController', function ($scope, $location, $http, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device;
bridgeService.viewHarmonyActivities();
Expand Down Expand Up @@ -996,15 +1033,17 @@ app.controller('HarmonyController', function ($scope, $location, $http, bridgeSe
};

$scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType);
bridgeService.viewDevices();
bridgeService.viewHarmonyActivities();
bridgeService.viewHarmonyDevices();
$scope.bridge.mapandid = { id, mapType };
ngDialog.open({
template: 'deleteMapandIdDialog',
controller: 'DeleteMapandIdDialogCtrl',
className: 'ngdialog-theme-default'
});
};

});

app.controller('NestController', function ($scope, $location, $http, bridgeService) {
app.controller('NestController', function ($scope, $location, $http, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device;
bridgeService.viewNestItems();
Expand Down Expand Up @@ -1116,14 +1155,17 @@ app.controller('NestController', function ($scope, $location, $http, bridgeServi
};

$scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType);
bridgeService.viewDevices();
bridgeService.viewNestItems();
$scope.bridge.mapandid = { id, mapType };
ngDialog.open({
template: 'deleteMapandIdDialog',
controller: 'DeleteMapandIdDialogCtrl',
className: 'ngdialog-theme-default'
});
};

});

app.controller('HueController', function ($scope, $location, $http, bridgeService) {
app.controller('HueController', function ($scope, $location, $http, bridgeService, ngDialog) {
$scope.bridge = bridgeService.state;
$scope.device = $scope.bridge.device;
$scope.bulk = { devices: [] };
Expand Down Expand Up @@ -1168,7 +1210,7 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
var devicesList = [];
for(var i = 0; i < $scope.bulk.devices.length; i++) {
for(var x = 0; x < bridgeService.state.huedevices.length; x++) {
if(bridgeService.state.huedevices[x].id == $scope.bulk.devices[i]) {
if(bridgeService.state.huedevices[x].device.uniqueid == $scope.bulk.devices[i]) {
$scope.buildDeviceUrls(bridgeService.state.huedevices[x]);
devicesList[i] = {
name: $scope.device.name,
Expand Down Expand Up @@ -1217,9 +1259,12 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
};

$scope.deleteDeviceByMapId = function (id, mapType) {
bridgeService.deleteDeviceByMapId(id, mapType);
bridgeService.viewDevices();
bridgeService.viewHueDevices();
$scope.bridge.mapandid = { id, mapType };
ngDialog.open({
template: 'deleteMapandIdDialog',
controller: 'DeleteMapandIdDialogCtrl',
className: 'ngdialog-theme-default'
});
};

});
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/public/views/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,14 @@ <h2>Select value</h2>
<button type="button" class="ngdialog-button ngdialog-button-primary" ng-click="setValue()">Set</button>
</div>
</script>
<script type="text/ng-template" id="deleteDialog">
<div class="ngdialog-message">
<h2>Device to Delete?</h2>
<p>{{device.name}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteDevice(device)">Delete</button>
</div>
</script>

14 changes: 12 additions & 2 deletions src/main/resources/public/views/harmonyactivity.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul>

<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Harmony Activity List</h2>
</div>
Expand Down Expand Up @@ -75,7 +75,7 @@ <h2 class="panel-title">Already Configured Activities <a ng-click="toggleButtons
</li>
</ul>
</div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Add a Bridge Device for a Harmony Activity</h2>
</div>
Expand Down Expand Up @@ -121,3 +121,13 @@ <h2 class="panel-title">Add a Bridge Device for a Harmony Activity</h2>
</li>
</ul>
</div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>
14 changes: 12 additions & 2 deletions src/main/resources/public/views/harmonydevice.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul>

<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Harmony Device List</h2>
</div>
Expand Down Expand Up @@ -96,7 +96,7 @@ <h2 class="panel-title">Already Configured Harmony Buttons <a ng-click="toggleBu
</li>
</ul>
</div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Add a Bridge Device for Harmony Buttons</h2>
</div>
Expand Down Expand Up @@ -142,3 +142,13 @@ <h2 class="panel-title">Add a Bridge Device for Harmony Buttons</h2>
</li>
</ul>
</div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>
20 changes: 15 additions & 5 deletions src/main/resources/public/views/huedevice.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul>

<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Hue Device List ({{bridge.huedevices.length}})</h2>
</div>
Expand All @@ -36,7 +36,7 @@ <h2 class="panel-title">Hue Device List ({{bridge.huedevices.length}})</h2>
</thead>
<tr ng-repeat="huedevice in bridge.huedevices | availableHueDeviceId">
<td>{{$index+1}}</td>
<td><input type="checkbox" name="bulk.devices[]" value="{{huedevice.id}}" ng-checked="bulk.devices.indexOf(huedevice.id) > -1" ng-click="toggleSelection(huedevice.id)"> {{huedevice.device.name}}</td>
<td><input type="checkbox" name="bulk.devices[]" value="{{huedevice.device.uniqueid}}" ng-checked="bulk.devices.indexOf(huedevice.device.uniqueid) > -1" ng-click="toggleSelection(huedevice.device.uniqueid)"> {{huedevice.device.name}}</td>
<td>{{huedevice.device.uniqueid}}</td>
<td>{{huedevice.huename}}</td>
<td>
Expand All @@ -48,7 +48,7 @@ <h2 class="panel-title">Hue Device List ({{bridge.huedevices.length}})</h2>
</scrollable-table>
<p>
<button class="btn btn-success" type="submit"
ng-click="bulkHueDevices()">Bulk Add ({{bulk.devices.length}})</button>
ng-click="bulkAddDevices()">Bulk Add ({{bulk.devices.length}})</button>
</p>
</li>
</ul>
Expand All @@ -75,15 +75,15 @@ <h2 class="panel-title">Already Configured Hue Devices <a ng-click="toggleButton
<td>{{huedevice.huename}}</td>
<td>
<button class="btn btn-danger" type="submit"
ng-click="deleteDeviceByMapId(huedevice.uniqueid, 'hueDevice')">Delete</button>
ng-click="deleteDeviceByMapId(huedevice.device.uniqueid, 'hueDevice')">Delete</button>
</td>
</tr>
</table>
</scrollable-table>
</li>
</ul>
</div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Add Bridge Device for a Hue Device</h2>
</div>
Expand Down Expand Up @@ -117,3 +117,13 @@ <h2 class="panel-title">Add Bridge Device for a Hue Device</h2>
</li>
</ul>
</div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>
14 changes: 12 additions & 2 deletions src/main/resources/public/views/nestactions.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul>

<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Nest Items List</h2>
</div>
Expand Down Expand Up @@ -97,7 +97,7 @@ <h2 class="panel-title">Already Configured Nest Items <a ng-click="toggleButtons
</li>
</ul>
</div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Add a Bridge Device for a Nest Item</h2>
</div>
Expand Down Expand Up @@ -143,3 +143,13 @@ <h2 class="panel-title">Add a Bridge Device for a Nest Item</h2>
</li>
</ul>
</div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>
16 changes: 13 additions & 3 deletions src/main/resources/public/views/veradevice.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<li role="presentation"><a href="#/editor">Manual Add</a></li>
</ul>

<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Vera Device List ({{bridge.veradevices.length}})</h2>
</div>
Expand All @@ -24,7 +24,7 @@ <h2 class="panel-title">Vera Device List ({{bridge.veradevices.length}})</h2>
control you would like to be generated:
<select name="device-dim-control" id="device-dim-control" ng-model="device_dim_control">
<option value="">none</option>
<option value="${intensity..byte}">Pass-thru Value</option>
<option value="${intensity.byte}">Pass-thru Value</option>
<option value="${intensity.percent}">Percentage</option>
<option value="${intensity.math(X*1)}">Custom Math</option>
</select>
Expand Down Expand Up @@ -100,7 +100,7 @@ <h2 class="panel-title">Already Configured Vera Devices <a ng-click="toggleButto
</li>
</ul>
</div>
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
<div class="panel panel-default bridgeServer">
<div class="panel-heading">
<h2 class="panel-title">Add Bridge Device for a Vera Device</h2>
</div>
Expand Down Expand Up @@ -155,3 +155,13 @@ <h2 class="panel-title">Add Bridge Device for a Vera Device</h2>
</li>
</ul>
</div>
<script type="text/ng-template" id="deleteMapandIdDialog">
<div class="ngdialog-message">
<h2>Device Map and Id?</h2>
<p>{{mapandid.mapType}} with {{mapandid.id}}</p>
<p>Are you Sure?</p>
</div>
<div class="ngdialog-buttons mt">
<button type="button" class="ngdialog-button ngdialog-button-error" ng-click="deleteMapandId(mapandid)">Delete</button>
</div>
</script>
Loading

0 comments on commit c773477

Please sign in to comment.