Skip to content
Permalink
Browse files

Merge pull request #1911 from privacyidea/1817/the-policy-table-shoul…

…d-be-sortable-and-filterable

1817/the policy table should be sortable and filterable
  • Loading branch information...
cornelinux committed Oct 28, 2019
2 parents 07505a8 + 194f45a commit f21cdb1214bd46c0011800a25eed85e61dd2fc6e
@@ -2,10 +2,20 @@
<table class="table table-bordered table-responsive table-striped">
<thead>
<tr>
<th translate>Priority</th>
<th translate>Active</th>
<th translate>Policy Name</th>
<th translate>Scope</th>
<th>
<button class="btn btn-default unsorted" pi-sort-by="priority" translate>Priority</button>
</th>
<th>
<button class="btn btn-default unsorted" pi-sort-by="active" translate>Active</button>
</th>
<th class="pifilter">
<button class="btn btn-default unsorted" pi-sort-by="name" translate>Policy Name</button>
<pi-filter ng-model="filter.name" ng-change="$apply()"></pi-filter>
</th>
<th class="pifilter">
<button class="btn btn-default unsorted" pi-sort-by="scope" translate>Scope</button>
<pi-filter ng-model="filter.scope" ng-change="$apply()"></pi-filter>
</th>
<th translate>Action</th>
<th translate>Realm</th>
<th translate>User</th>
@@ -14,7 +24,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="policy in policies">
<tr ng-repeat="policy in policies | filter:filter | orderBy:sortby:reverse">
<td>
<input type="number" ng-model="policy.priority"
class="form-control" min="1"
@@ -81,7 +81,7 @@ myApp.directive("piSortBy", function(){
link: function(scope, element, attr) {
element.on('click', function() {
var column = attr.piSortBy;
scope.params.sortby=column;
scope.sortby=column;
scope.reverse=!scope.reverse;
$(".sortUp").addClass("unsorted");
$(".sortDown").addClass("unsorted");
@@ -93,7 +93,10 @@ myApp.directive("piSortBy", function(){
} else {
element.addClass("sortUp");
}
scope.get();

// scope.get() is what we call, when sorting is done on the server. For client-side sorting $apply() is
// used to rerender the list with the new sorting.
scope.get ? scope.get() : scope.$apply();
});
}
};
@@ -17,6 +17,7 @@ myApp.controller("tokenChallengesController", function ($scope,
// define functions
$scope.get = function () {
$scope.params.serial = "*" + ($scope.serialFilter || "") + "*";
$scope.params.sortBy = $scope.sortBy;
if ($scope.reverse) {
$scope.params.sortdir = "desc";
} else {
@@ -45,6 +45,7 @@ myApp.controller("tokenController", function (TokenFactory, ConfigFactory,
$scope.params.userid = "*" + ($scope.userIdFilter || "") + "*";
$scope.params.resolver = "*" + ($scope.resolverFilter || "") + "*";
$scope.params.pagesize = $scope.token_page_size;
$scope.params.sortBy = $scope.sortBy;
if ($scope.reverse) {
$scope.params.sortdir = "desc";
} else {
@@ -1,6 +1 @@
#tablemachinelist th.pifilter { white-space: nowrap; }
#tableauditlog th.pifilter { white-space: nowrap; }
#tableuserlist th.pifilter { white-space: nowrap; }
#tabletokenchallenges th.pifilter { white-space: nowrap; }
#tabletokenlist th.pifilter { white-space: nowrap; }

th.pifilter { white-space: nowrap; }

0 comments on commit f21cdb1

Please sign in to comment.
You can’t perform that action at this time.