Added filter to device list "show devices visible to ip-address"

If filter is active it will only show the devices that are visible for the given ip-address. Filter setting is saved until browser tab is closed.
This commit is contained in:
Florian Förderreuther
2017-07-28 02:24:48 +02:00
parent 20ad6891e8
commit 087d66694e
2 changed files with 25 additions and 6 deletions

View File

@@ -134,7 +134,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
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: "", securityInfo: {}};
showDomoticz: false, showSomfy: false, showLifx: false, habridgeversion: {}, viewDevId: "", queueDevId: "", securityInfo: {}, filterDevicesByIpAddress: null};
this.displayWarn = function(errorTitle, error) {
var toastContent = errorTitle;
@@ -3462,6 +3462,21 @@ app.filter('configuredSomfyDevices', function (bridgeService) {
}
});
app.filter('filterDevicesByRequester', function () {
return function(input,search) {
var out = [];
if(input === undefined || input === null || input.length === undefined)
return out;
var pattern = new RegExp(search);
for (var i = 0; i < input.length; i++) {
if(pattern.test(input[i].requesterAddress) || !input[i].requesterAddress || input[i].requesterAddress.length === 0){
out.push(input[i]);
}
}
return out;
}
});
app.controller('LoginController', function ($scope, $location, Auth) {
$scope.failed = false;
$scope.loggedIn = Auth.isLoggedIn();

View File

@@ -31,10 +31,14 @@
</div>
<div class="panel-body">
<p>
<button class="btn btn-primary" type="submit" ng-click="renumberDevices()">Renumber Devices</button>
<button ng-if="bridge.securityInfo.useLinkButton" class="btn btn-primary" type="submit" ng-click="pushLinkButton()">Link</button>
</p>
<div class="form-group">
<button class="btn btn-primary" type="submit" ng-click="renumberDevices()">Renumber Devices</button>
<button ng-if="bridge.securityInfo.useLinkButton" class="btn btn-primary" type="submit" ng-click="pushLinkButton()">Link</button>
<label for="device-ip-filter">Show devices visible to: </label>
<input type="text" id="device-ip-filter" style="width:150px"
ng-model="bridge.state.filterDevicesByIpAddress" placeholder="">
</div>
<scrollable-table watch="bridge.devices">
<table class="table table-bordered table-striped table-hover">
<thead>
@@ -51,7 +55,7 @@
<th>Actions</th>
</tr>
</thead>
<tr ng-repeat="device in bridge.devices" row-id="{{device.id}}" ng-class="{info: bridge.viewDevId == device.id}" >
<tr ng-repeat="device in bridge.devices | orderBy:'name' | filterDevicesByRequester:bridge.state.filterDevicesByIpAddress" row-id="{{device.id}}" ng-class="{info: bridge.viewDevId == device.id}" >
<td>{{$index+1}}</td>
<td>{{device.id}}</td>
<td>{{device.name}}</td>