From fb2c2c91b774823c54855f35c4fd2bef06e2f925 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Fri, 20 Sep 2013 20:17:27 -0400 Subject: [PATCH] roles --- .../main/webapp/saas/admin/js/controllers.js | 62 ++++++------ .../admin/partials/application-detail.html | 14 ++- .../saas/admin/partials/application-list.html | 11 ++- .../saas/admin/partials/realm-detail.html | 4 +- .../saas/admin/partials/realm-menu.html | 2 +- .../saas/admin/partials/role-detail.html | 95 +++++++++---------- .../webapp/saas/admin/partials/role-list.html | 73 ++++++++++---- .../saas/admin/partials/user-detail.html | 8 +- .../webapp/saas/admin/partials/user-list.html | 14 +-- .../resources/admin/RealmAdminResource.java | 1 + 10 files changed, 166 insertions(+), 118 deletions(-) diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/controllers.js b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/controllers.js index cbe254a1a4f..9147e17d5b7 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/controllers.js +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/js/controllers.js @@ -183,8 +183,6 @@ module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, $ht module.controller('UserListCtrl', function($scope, realm, User) { $scope.realm = realm; - $scope.users = []; - //$scope.search = "Search..."; $scope.searchQuery = function() { console.log('search: ' + $scope.search); @@ -253,9 +251,15 @@ module.controller('UserDetailCtrl', function($scope, realm, user, User, $locatio }; }); -module.controller('RoleListCtrl', function($scope, realm, roles) { +module.controller('RoleListCtrl', function($scope, $location, realm, roles) { $scope.realm = realm; $scope.roles = roles; + + $scope.$watch(function() { + return $location.path(); + }, function() { + $scope.path = $location.path().substring(1).split("/"); + }); }); module.controller('RoleDetailCtrl', function($scope, realm, role, Role, $location, Dialog, Notifications) { @@ -265,6 +269,12 @@ module.controller('RoleDetailCtrl', function($scope, realm, role, Role, $locatio $scope.changed = $scope.create; + $scope.$watch(function() { + return $location.path(); + }, function() { + $scope.path = $location.path().substring(1).split("/"); + }); + $scope.$watch('role', function() { if (!angular.equals($scope.role, role)) { $scope.changed = true; @@ -272,34 +282,28 @@ module.controller('RoleDetailCtrl', function($scope, realm, role, Role, $locatio }, true); $scope.save = function() { - if ($scope.roleForm.$valid) { + if ($scope.create) { + Role.save({ + realm: realm.id + }, $scope.role, function (data, headers) { + $scope.changed = false; + role = angular.copy($scope.role); - if ($scope.create) { - Role.save({ - realm: realm.id - }, $scope.role, function (data, headers) { - $scope.changed = false; - role = angular.copy($scope.role); + var l = headers().location; + var id = l.substring(l.lastIndexOf("/") + 1); + $location.url("/realms/" + realm.id + "/roles/" + id); + Notifications.success("Created role"); - var l = headers().location; - var id = l.substring(l.lastIndexOf("/") + 1); - $location.url("/realms/" + realm.id + "/roles/" + id); - Notifications.success("Created role"); - - }); - } else { - Role.update({ - realm : realm.id, - roleId : role.id - }, $scope.role, function() { - $scope.changed = false; - role = angular.copy($scope.role); - Notifications.success("Saved changes to role"); - }); - } - - } else { - $scope.roleForm.showErrors = true; + }); + } else { + Role.update({ + realm : realm.id, + roleId : role.id + }, $scope.role, function() { + $scope.changed = false; + role = angular.copy($scope.role); + Notifications.success("Saved changes to role"); + }); } }; diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/application-detail.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/application-detail.html index ddf08bc63e1..8bd656f9ba7 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/application-detail.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/application-detail.html @@ -2,16 +2,24 @@
-
+ +

New Application

Application {{application.name}}

diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/application-list.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/application-list.html index 4128751ace9..174f65d544e 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/application-list.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/application-list.html @@ -2,18 +2,19 @@
-
+

Applications

- + + - + - +
Table of realm applicationsTable of realm applicationsNo configured applications...
@@ -30,7 +31,7 @@
Base URL
diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-detail.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-detail.html index b997e5dc4ad..cd3d0ba18bd 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-detail.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-detail.html @@ -4,9 +4,9 @@
diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-menu.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-menu.html index cee7ac9ccbe..73f0ae592c5 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-menu.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/realm-menu.html @@ -1,5 +1,5 @@
    -
  • Realm Settings
  • +
  • Realm Settings
  • Users
  • Applications
  • diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-detail.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-detail.html index 0c68075d409..0aeae235525 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-detail.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-detail.html @@ -1,60 +1,59 @@
    - -
    - -
    -

    New Role

    - -

    - Realm Role {{role.name}} -

    - -
    Please fill in - all required fields +
    +
    + -

    * Required fields

    +
    +

    New Realm Role

    +

    Realm Role {{role.name}}

    +

    * Required fields

    +
    +
    + Details +
    + * - -
    - Details -
    - - -
    - +
    + +
    +
    + + +
    + +
    +
    +
    +
    + +
    -
    - - -
    - -
    +
    + + +
    -
    -
    - - -
    -
    - - - -
    - -
    + +
    diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-list.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-list.html index 7f27c7cf49a..a8194521cf1 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-list.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/role-list.html @@ -1,26 +1,57 @@
    - -
    - -
    -

    - Realm Roles -

    - - - - - - - - - - - - -
    NameDescription
    {{role.name}}{{role.description}}
    +
    +
    + +
    +

    Realm Roles

    + + + + + + + + + + + + + + + + + + + + + + + +
    Table of realm rolesNo configured realm roles...
    +
    + + +
    +
    Role NameDescription
    + +
    {{role.name}}{{role.description}}
    +
    -
    \ No newline at end of file +
    diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/user-detail.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/user-detail.html index 0a5f7b27e3e..655c7f70e41 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/user-detail.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/user-detail.html @@ -4,12 +4,16 @@
      +
    • New User
    • +
    • Query Users
    • Attributes
    • Credentials
    • Role Mappings
    • diff --git a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/user-list.html b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/user-list.html index 3e1e1042889..d87de2ec2aa 100755 --- a/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/user-list.html +++ b/examples/as7-eap-demo/server/src/main/webapp/saas/admin/partials/user-list.html @@ -4,14 +4,14 @@

      Query Users

      - + - + @@ -34,7 +34,7 @@ - + - - - + + +
      Table of realm usersTable of realm users
      @@ -26,7 +26,7 @@
      Username Last Name First Name
      @@ -49,9 +49,9 @@
      {{user.username}}{{user.lastName{{user.firstName{{user.email{{user.lastName}}{{user.firstName}}{{user.email}}
      diff --git a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java index 524b9f839f7..32bc8543cf5 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/RealmAdminResource.java @@ -65,6 +65,7 @@ public class RealmAdminResource { List roles = new ArrayList(); for (RoleModel roleModel : roleModels) { RoleRepresentation role = new RoleRepresentation(roleModel.getName(), roleModel.getDescription()); + role.setId(roleModel.getId()); roles.add(role); } return roles;