Merge pull request #20 from patriot1burke/master

improvements
This commit is contained in:
Bill Burke 2013-08-04 18:54:24 -07:00
commit eabc775286
3 changed files with 34 additions and 16 deletions

View file

@ -5,7 +5,7 @@ var module = angular.module('keycloak.controllers', [ 'keycloak.services' ]);
var realmslist = {}; var realmslist = {};
module.controller('GlobalCtrl', function($scope, $http, Auth, $location, Notifications) { module.controller('GlobalCtrl', function($scope, $http, Auth, Current, $location, Notifications) {
$scope.addMessage = function() { $scope.addMessage = function() {
Notifications.success("test"); Notifications.success("test");
}; };
@ -19,6 +19,7 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, $location, Notific
}); });
$http.get('/auth-server/rest/saas/admin/realms').success(function(data) { $http.get('/auth-server/rest/saas/admin/realms').success(function(data) {
Current.realms = data;
var count = 0; var count = 0;
var showrealm = false; var showrealm = false;
var id = null; var id = null;
@ -34,6 +35,7 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, $location, Notific
if (showrealm) { if (showrealm) {
console.log('redirecting'); console.log('redirecting');
Current.realm = Current.realms[id];
$location.url("/realms/" + id); $location.url("/realms/" + id);
} else { } else {
console.log('not redirecting'); console.log('not redirecting');
@ -158,22 +160,30 @@ module.controller('RealmListCtrl', function($scope, Realm, Current) {
Current.realms = $scope.realms; Current.realms = $scope.realms;
}); });
module.controller('RealmDropdownCtrl', function($scope, Realm, Current, $location) { module.controller('RealmDropdownCtrl', function($scope, Realm, Current, Auth, $location) {
console.log('test log writing'); // Current.realms = Realm.get();
Current.realms = Realm.get();
$scope.current = Current; $scope.current = Current;
$scope.changeRealm = function() { $scope.changeRealm = function() {
console.log('select box changed');
for (var id in Current.realms) { for (var id in Current.realms) {
var val = Current.realms[id]; var val = Current.realms[id];
console.log('checking: ' + val);
if (val == Current.realm) { if (val == Current.realm) {
console.log("redirect to: /realms/" + id);
$location.url("/realms/" + id); $location.url("/realms/" + id);
break; break;
} }
} }
}; };
$scope.showNav = function() {
var show = false;
for (var key in Current.realms) {
if (typeof Current.realms[key] != "function") {
if (Current.realms[key] == Current.realm) {
$scope.currentRealmId = key;
}
show = true;
}
}
return Auth.loggedIn && show;
}
}); });
module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, $location, Dialog, Notifications) { module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, $location, Dialog, Notifications) {
@ -275,10 +285,6 @@ module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, $lo
var data = Realm.get(function() { var data = Realm.get(function() {
Current.realms = data; Current.realms = data;
Current.realm = Current.realms[id]; 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); $location.url("/realms/" + id);
Notifications.success("Created realm"); Notifications.success("Created realm");

View file

@ -12,8 +12,10 @@
</ul> </ul>
</li> </li>
</ul> --> </ul> -->
<h3 data-ng-show="auth.loggedIn"><span class="gray pull-left">Realm: </span></h3> <ul class="nav pull-left" data-ng-show="showNav()">
<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"> <li class="divider-vertical-right"><a href="#/realms/{{currentRealmId}}">Realm</a></li>
</ul>
<select class="nav pull-left" data-ng-show="showNav()" ng-change="changeRealm()" ng-model="current.realm" ng-options="name for (id, name) in current.realms">
</select> </select>
<!-- <select class="nav pull-left" ng-options="r.name for r in current.realms"></select> --> <!-- <select class="nav pull-left" ng-options="r.name for r in current.realms"></select> -->
</div> </div>
@ -30,7 +32,7 @@
</li> </li>
</ul> </ul>
<ul class="nav pull-right" data-ng-show="auth.loggedIn"> <ul class="nav pull-right" data-ng-show="auth.loggedIn">
<li class="divider-vertical-left" data-ng-class="path[0] == 'realms' && 'active'" <li class="divider-vertical-left" data-ng-class="path[0] == 'create' && path[1] == 'realm' && 'active'"
data-ng-show="auth.loggedIn"><a href="#/create/realm">New Realm</a></li> data-ng-show="auth.loggedIn"><a href="#/create/realm">New Realm</a></li>
</ul> </ul>
</nav> </nav>

View file

@ -1,11 +1,21 @@
<div data-ng-hide="createRealm"> <div data-ng-hide="createRealm">
<nav id="local-nav"> <nav id="local-nav">
<ul class="nav nav-list"> <ul class="nav nav-list">
<li data-ng-class="!path[2] && 'active'"><a href="#/realms/{{realm.id}}">Realm Settings</a> <li data-ng-class="!path[2] && 'active'"><a href="#/realms/{{realm.id}}">Realm Settings</a></li>
<li data-ng-class="path[2] == 'roles' && 'active'"><a href="#/realms/{{realm.id}}/roles">Realm Roles</a>
<ul class="sub-items">
<li data-ng-class="path[0] == 'create' && path[1] == 'role' && 'active'"><a
href="#/create/role/{{realm.id}}">Add Role</a></li>
</ul>
</li> </li>
<li data-ng-class="path[2] == 'users' && 'active'"><a href="#/realms/{{realm.id}}/users">Realm Users</a> <li data-ng-class="path[2] == 'users' && 'active'"><a href="#/realms/{{realm.id}}/users">Realm Users</a>
<ul class="sub-items">
<li data-ng-class="path[0] == 'create' && path[1] == 'user' && 'active'"><a
href="#/create/user/{{realm.id}}">Add User</a></li>
<li data-ng-class="path[0] == 'find' && path[1] == 'user' && 'active'"><a
href="#/find/user/{{realm.id}}">Find User</a></li>
</ul>
</li> </li>
<li data-ng-class="path[2] == 'roles' && 'active'"><a href="#/realms/{{realm.id}}/roles">Realm Roles</a></li>
</ul> </ul>
</nav> </nav>
</div> </div>