roles.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. module.controller('RoleMembersCtrl', function($scope, realm, role, RoleMembership, Dialog, Notifications, $location, RealmRoleRemover) {
  2. $scope.realm = realm;
  3. $scope.page = 0;
  4. $scope.role = role;
  5. $scope.query = {
  6. realm: realm.realm,
  7. role: role.name,
  8. max : 5,
  9. first : 0
  10. }
  11. $scope.remove = function() {
  12. RealmRoleRemover.remove($scope.role, realm, Dialog, $location, Notifications);
  13. };
  14. $scope.firstPage = function() {
  15. $scope.query.first = 0;
  16. $scope.searchQuery();
  17. }
  18. $scope.previousPage = function() {
  19. $scope.query.first -= parseInt($scope.query.max);
  20. if ($scope.query.first < 0) {
  21. $scope.query.first = 0;
  22. }
  23. $scope.searchQuery();
  24. }
  25. $scope.nextPage = function() {
  26. $scope.query.first += parseInt($scope.query.max);
  27. $scope.searchQuery();
  28. }
  29. $scope.searchQuery = function() {
  30. console.log("query.search: " + $scope.query.search);
  31. $scope.searchLoaded = false;
  32. $scope.users = RoleMembership.query($scope.query, function() {
  33. console.log('search loaded');
  34. $scope.searchLoaded = true;
  35. $scope.lastSearch = $scope.query.search;
  36. });
  37. };
  38. $scope.searchQuery();
  39. });