Skip to content

Commit

Permalink
Added capability to sort by last seen (#69)
Browse files Browse the repository at this point in the history
Merged PR to add sorting to the device's last seen date.
  • Loading branch information
franzo15 authored and vortex-5 committed Jan 12, 2020
1 parent 1f76b8a commit 67a936c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bwmon/www/bwmon.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@
</span>
UP Rate
</th>
<th class="cell-right hidden-xs">
<th class="cell-right hidden-xs clickable" ng-click="setSortBy(sortOptions.LAST_SEEN)">
<div class="cell-padding">
<span ng-show="sortBy === sortOptions.LAST_SEEN">
<img src="arrow-left.png" class="arrow-up" ng-hide="sortReverse">
<img src="arrow-left.png" class="arrow-down" ng-show="sortReverse">
</span>
Last Seen
</div>
</th>
Expand Down
8 changes: 6 additions & 2 deletions bwmon/www/bwmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ bwmon.controller('MainController', ['$scope', '$interval', '$http', '$location',
POST_DOWN: 'POST_DOWN',
POST_UP: 'POST_UP',
DOWN_RATE: 'DOWN_RATE',
UP_RATE: 'UP_RATE'
UP_RATE: 'UP_RATE',
LAST_SEEN: 'LAST_SEEN'
}
$scope.sortReverse = true;
$scope.sortBy = $scope.sortOptions.TOTAL;
Expand Down Expand Up @@ -689,7 +690,7 @@ bwmon.controller('MainController', ['$scope', '$interval', '$http', '$location',
}
return total;
};

$scope.isZeroUsage = function(device) {
return $scope.getDeviceTotal(device) + $scope.getDownRate(device) + $scope.getUpRate(device) <= 0;
};
Expand All @@ -713,6 +714,9 @@ bwmon.controller('MainController', ['$scope', '$interval', '$http', '$location',
case $scope.sortOptions.UP_RATE:
metric = $scope.getUpRate(device);
break;
case $scope.sortOptions.LAST_SEEN:
metric = device.date;
break;
default:
metric = device.postUp + device.postDown;
}
Expand Down

0 comments on commit 67a936c

Please sign in to comment.