Added redirects to home page

This commit is contained in:
Stian Thorgersen 2013-11-25 19:38:56 +00:00
parent 924184f659
commit 89ae28429a
3 changed files with 26 additions and 6 deletions

View file

@ -297,7 +297,8 @@ module.config([ '$routeProvider', function($routeProvider) {
controller : 'ApplicationListCtrl' controller : 'ApplicationListCtrl'
}) })
.when('/', { .when('/', {
templateUrl : 'partials/home.html' templateUrl : 'partials/home.html',
controller : 'HomeCtrl'
}) })
.otherwise({ .otherwise({
templateUrl : 'partials/notfound.html' templateUrl : 'partials/notfound.html'
@ -332,6 +333,8 @@ module.factory('errorInterceptor', function($q, $window, $rootScope, $location,
console.log('session timeout?'); console.log('session timeout?');
Auth.loggedIn = false; Auth.loggedIn = false;
window.location = '/auth-server/rest/saas/login?path=' + $location.path(); window.location = '/auth-server/rest/saas/login?path=' + $location.path();
} else if (response.status == 404) {
Notifications.error("Not found");
} else if (response.status) { } else if (response.status) {
if (response.data && response.data.errorMessage) { if (response.data && response.data.errorMessage) {
Notifications.error(response.data.errorMessage); Notifications.error(response.data.errorMessage);

View file

@ -20,8 +20,25 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, Current, $location
}); });
}); });
module.controller('HomeCtrl', function($scope, Realm, Current) { module.controller('HomeCtrl', function(Realm, $location) {
console.debug("home"); Realm.query(null, function(realms) {
var realm;
if (realms.length == 1) {
realm = realms[0].id;
} else if (realms.length == 2) {
if (realms[0].realm == 'Keycloak Administration') {
realm = realms[1].id;
} else if (realms[1].realm == 'Keycloak Administration') {
realm = realms[0].id;
}
}
if (realm) {
$location.url('/realms/' + realm);
} else {
$location.url('/realms');
}
});
}); });
module.controller('RealmListCtrl', function($scope, Realm, Current) { module.controller('RealmListCtrl', function($scope, Realm, Current) {
@ -145,9 +162,9 @@ module.controller('RealmDetailCtrl', function($scope, Current, Realm, realm, $ht
$scope.remove = function() { $scope.remove = function() {
Dialog.confirmDelete($scope.realm.realm, 'realm', function() { Dialog.confirmDelete($scope.realm.realm, 'realm', function() {
Realm.remove({ id : $scope.realm.id }, function() { Realm.remove({ id : $scope.realm.id }, function() {
Current.realms = Realm.get(); Current.realms = Realm.query();
$location.url("/realms");
Notifications.success("The realm has been deleted."); Notifications.success("The realm has been deleted.");
$location.url("/");
}); });
}); });
}; };

View file

@ -1,7 +1,7 @@
<div class="header rcue"> <div class="header rcue">
<div class="navbar utility"> <div class="navbar utility">
<div class="navbar-inner clearfix container"> <div class="navbar-inner clearfix container">
<h1><a href="#/realms/{{realm.id}}"><strong>Keycloak</strong> Central Login</a></h1> <h1><a href="#/"><strong>Keycloak</strong> Central Login</a></h1>
<ul class="nav pull-right" data-ng-hide="auth.loggedIn"> <ul class="nav pull-right" data-ng-hide="auth.loggedIn">
<li><a href="/auth-server/rest/saas/login?path={{fragment}}">Login</a></li> <li><a href="/auth-server/rest/saas/login?path={{fragment}}">Login</a></li>
<li><a href="/auth-server/rest/saas/registrations">Register</a></li> <li><a href="/auth-server/rest/saas/registrations">Register</a></li>