nav ui fixes
This commit is contained in:
parent
d11876f58e
commit
fb45fcc5fd
9 changed files with 131 additions and 62 deletions
|
@ -4,6 +4,7 @@ var module = angular.module('keycloak.controllers', [ 'keycloak.services' ]);
|
|||
|
||||
var realmslist = {};
|
||||
|
||||
|
||||
module.controller('GlobalCtrl', function($scope, $http, Auth, $location, Notifications) {
|
||||
$scope.addMessage = function() {
|
||||
Notifications.success("test");
|
||||
|
@ -152,20 +153,30 @@ module.controller('ApplicationDetailCtrl', function($scope, application, Applica
|
|||
});
|
||||
|
||||
|
||||
module.controller('RealmListCtrl', function($scope, Realm) {
|
||||
module.controller('RealmListCtrl', function($scope, Realm, Current) {
|
||||
$scope.realms = Realm.get();
|
||||
realmslist = $scope.realms;
|
||||
Current.realms = $scope.realms;
|
||||
});
|
||||
|
||||
module.controller('RealmDropdownCtrl', function($scope, Realm) {
|
||||
module.controller('RealmDropdownCtrl', function($scope, Realm, Current, $location) {
|
||||
console.log('test log writing');
|
||||
realmslist = Realm.get();
|
||||
$scope.realmslist = function() {
|
||||
return realmslist;
|
||||
Current.realms = Realm.get();
|
||||
$scope.current = Current;
|
||||
$scope.changeRealm = function() {
|
||||
console.log('select box changed');
|
||||
for (var id in Current.realms) {
|
||||
var val = Current.realms[id];
|
||||
console.log('checking: ' + val);
|
||||
if (val == Current.realm) {
|
||||
console.log("redirect to: /realms/" + id);
|
||||
$location.url("/realms/" + id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
module.controller('RealmDetailCtrl', function($scope, Realm, realm, $location, Dialog, Notifications) {
|
||||
module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, $location, Dialog, Notifications) {
|
||||
$scope.realm = angular.copy(realm);
|
||||
$scope.createRealm = !realm.id;
|
||||
|
||||
|
@ -260,13 +271,21 @@ module.controller('RealmDetailCtrl', function($scope, Realm, realm, $location, D
|
|||
Realm.save(realmCopy, function(data, headers) {
|
||||
var l = headers().location;
|
||||
var id = l.substring(l.lastIndexOf("/") + 1);
|
||||
realmslist = Realm.get();
|
||||
|
||||
var data = Realm.get(function() {
|
||||
Current.realms = data;
|
||||
Current.realm = Current.realms[id];
|
||||
console.log('Current.realms[id]: ' + Current.realms[id]);
|
||||
console.log('data[id]: ' + data[id]);
|
||||
console.log('Current.realm.name: ' + Current.realm.name);
|
||||
|
||||
});
|
||||
$location.url("/realms/" + id);
|
||||
Notifications.success("Created realm");
|
||||
});
|
||||
} else {
|
||||
Realm.update(realmCopy, function() {
|
||||
realmslist = Realm.get();
|
||||
Current.realms = Realm.get();
|
||||
$scope.changed = false;
|
||||
realm = angular.copy($scope.realm);
|
||||
Notifications.success("Saved changes to realm");
|
||||
|
@ -290,7 +309,7 @@ module.controller('RealmDetailCtrl', function($scope, Realm, realm, $location, D
|
|||
$scope.remove = function() {
|
||||
Dialog.confirmDelete($scope.realm.name, 'realm', function() {
|
||||
Realm.remove($scope.realm, function() {
|
||||
realmslist = Realm.get();
|
||||
Current.realms = Realm.get();
|
||||
$location.url("/realms");
|
||||
Notifications.success("Deleted realm");
|
||||
});
|
||||
|
|
|
@ -158,3 +158,10 @@ module.factory('Role', function($resource) {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
module.factory('Current', function($resource) {
|
||||
return {
|
||||
realm : null,
|
||||
realms : {}
|
||||
};
|
||||
});
|
|
@ -3,32 +3,36 @@
|
|||
<div class="container">
|
||||
<div class="nav-collapse">
|
||||
<nav id="global-nav">
|
||||
<div data-ng-controller="RealmDropdownCtrl">
|
||||
<div data-ng-controller="RealmDropdownCtrl" > <!--
|
||||
<ul class="nav pull-left" data-ng-show="auth.loggedIn">
|
||||
<li class="dropdown"><a data-toggle="dropdown" class="dropdown-toggle" href="#"> Realms <i class="caret"></i></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li ng-repeat="(id, name) in realmslist()"><a href="#/realms/{{id}}">{{name}}</a>
|
||||
<li ng-repeat="(id, name) in current.realms"><a href="#/realms/{{id}}">{{name}}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</ul> -->
|
||||
<h3 data-ng-show="auth.loggedIn"><span class="gray pull-left">Realm: </span></h3>
|
||||
<select class="nav pull-left" data-ng-show="auth.loggedIn" ng-change="changeRealm()" ng-model="current.realm" ng-options="name for (id, name) in current.realms">
|
||||
</select>
|
||||
<!-- <select class="nav pull-left" ng-options="r.name for r in current.realms"></select> -->
|
||||
</div>
|
||||
<ul class="nav">
|
||||
<li class="divider-vertical-left" data-ng-class="path[0] == 'realms' && 'active'"
|
||||
data-ng-show="auth.loggedIn"><a href="#/create/realm">New Realm</a></li>
|
||||
</ul>
|
||||
<ul class="nav pull-right" data-ng-hide="auth.loggedIn">
|
||||
<li><a href="/auth-server/saas/saas-login.jsp">Login</a></li>
|
||||
<li><a href="/auth-server/saas/saas-register.jsp">Register</a></li>
|
||||
</ul>
|
||||
<ul class="nav pull-right" data-ng-show="auth.loggedIn">
|
||||
<li class="dropdown"><a data-toggle="dropdown" class="dropdown-toggle" href="#"><i
|
||||
<li class="divider-vertical-left dropdown"><a data-toggle="dropdown" class="dropdown-toggle" href="#"><i
|
||||
class="icon-user icon-gray"></i> Welcome: <b>{{auth.user.displayName}}</b> <i class="caret"></i></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/auth-server/rest/saas/logout">Sign Out</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav pull-right" data-ng-show="auth.loggedIn">
|
||||
<li class="divider-vertical-left" data-ng-class="path[0] == 'realms' && 'active'"
|
||||
data-ng-show="auth.loggedIn"><a href="#/create/realm">New Realm</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<h1 data-ng-show="createRealm"><span class="gray">New Realm</span></h1>
|
||||
|
||||
<h1 data-ng-hide="createRealm">
|
||||
<span class="gray">{{realm.realm}}</span>
|
||||
<span class="gray">Realm Settings</span>
|
||||
</h1>
|
||||
|
||||
<div data-ng-show="realmForm.showErrors && realmForm.$error.required" class="alert alert-error">Please fill
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
<div data-ng-hide="createRealm">
|
||||
<nav id="local-nav">
|
||||
<ul class="nav nav-list">
|
||||
<li>
|
||||
<div>
|
||||
<span class="toggle">Realm: </span> {{realm.realm}}
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<ul class="sub-items">
|
||||
<li data-ng-class="!path[2] && 'active'"><a href="#/realms/{{realm.id}}">Settings</a>
|
||||
<li data-ng-class="!path[2] && 'active'"><a href="#/realms/{{realm.id}}">Realm Settings</a>
|
||||
</li>
|
||||
<li data-ng-class="path[2] == 'users' && 'active'"><a href="#/realms/{{realm.id}}/users">Users</a>
|
||||
<li data-ng-class="path[2] == 'users' && 'active'"><a href="#/realms/{{realm.id}}/users">Realm Users</a>
|
||||
</li>
|
||||
<li data-ng-class="path[2] == 'roles' && 'active'"><a href="#/realms/{{realm.id}}/roles">Roles</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<li data-ng-class="path[2] == 'roles' && 'active'"><a href="#/realms/{{realm.id}}/roles">Realm Roles</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
|
@ -7,7 +7,7 @@
|
|||
<h1 data-ng-show="create"><span class="gray">New Role</span></h1>
|
||||
|
||||
<h1 data-ng-hide="create">
|
||||
<span class="gray">Role {{role.name}}</span>
|
||||
<span class="gray">Realm Role {{role.name}}</span>
|
||||
</h1>
|
||||
|
||||
<div data-ng-show="roleForm.showErrors && roleForm.$error.required" class="alert alert-error">Please fill in
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<a class="btn btn-small pull-right" href="#/create/role/{{realm.id}}">Add Role</a>
|
||||
|
||||
<h1>
|
||||
<span class="gray">{{realm.realm}}</span> roles
|
||||
<span class="gray">Realm Roles</span>
|
||||
</h1>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package org.keycloak.services.resources.admin;
|
||||
|
||||
import org.jboss.resteasy.annotations.cache.NoCache;
|
||||
import org.jboss.resteasy.logging.Logger;
|
||||
import org.keycloak.representations.idm.ResourceRepresentation;
|
||||
import org.keycloak.services.managers.RealmManager;
|
||||
import org.keycloak.services.managers.ResourceManager;
|
||||
import org.keycloak.services.models.RealmModel;
|
||||
import org.keycloak.services.models.ResourceModel;
|
||||
import org.keycloak.services.models.UserModel;
|
||||
import org.keycloak.services.resources.Transaction;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
public class RealmResourceResource {
|
||||
protected static final Logger logger = Logger.getLogger(RealmAdminResource.class);
|
||||
protected UserModel admin;
|
||||
protected RealmModel realm;
|
||||
protected ResourceModel resourceModel;
|
||||
|
||||
public RealmResourceResource(UserModel admin, RealmModel realm, ResourceModel resourceModel) {
|
||||
this.admin = admin;
|
||||
this.realm = realm;
|
||||
this.resourceModel = resourceModel;
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public void update(final ResourceRepresentation rep) {
|
||||
new Transaction() {
|
||||
@Override
|
||||
protected void runImpl() {
|
||||
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
|
||||
resourceManager.updateResource(rep, resourceModel);
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@NoCache
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ResourceRepresentation getResource(final @PathParam("id") String id) {
|
||||
return new Transaction() {
|
||||
@Override
|
||||
protected ResourceRepresentation callImpl() {
|
||||
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
|
||||
return resourceManager.toRepresentation(resourceModel);
|
||||
}
|
||||
}.call();
|
||||
}
|
||||
}
|
|
@ -71,38 +71,18 @@ public class RealmResourcesResource {
|
|||
}
|
||||
|
||||
@Path("{id}")
|
||||
@PUT
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public void update(final @PathParam("id") String id, final ResourceRepresentation rep) {
|
||||
new Transaction() {
|
||||
@Override
|
||||
protected void runImpl() {
|
||||
ResourceModel resourceModel = realm.getResourceById(id);
|
||||
if (resourceModel == null) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
|
||||
resourceManager.updateResource(rep, resourceModel);
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
|
||||
@Path("{id}")
|
||||
@GET
|
||||
@NoCache
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ResourceRepresentation getResource(final @PathParam("id") String id) {
|
||||
public RealmResourceResource getResource(final @PathParam("id") String id) {
|
||||
return new Transaction() {
|
||||
@Override
|
||||
protected ResourceRepresentation callImpl() {
|
||||
protected RealmResourceResource callImpl() {
|
||||
ResourceModel resourceModel = realm.getResourceById(id);
|
||||
if (resourceModel == null) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
ResourceManager resourceManager = new ResourceManager(new RealmManager(session));
|
||||
return resourceManager.toRepresentation(resourceModel);
|
||||
return new RealmResourceResource(admin, realm, resourceModel);
|
||||
}
|
||||
}.call();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue