Updated not found and forbidden access to show a proper page instead of just notification

This commit is contained in:
Stian Thorgersen 2015-04-16 10:35:52 +02:00
parent d42c917448
commit 9c5e38a023
7 changed files with 62 additions and 38 deletions

View file

@ -64,7 +64,7 @@
<div data-ng-include data-src="resourceUrl + '/partials/menu.html'"></div>
</header>
<div class="container" data-ng-show="auth.hasAnyAccess">
<div class="container">
<div data-ng-view id="view"></div>
<div id="loading" class="loading-backdrop">
<div class="loading">

View file

@ -908,8 +908,6 @@ module.config([ '$routeProvider', function($routeProvider) {
},
controller : 'ProtocolListCtrl'
})
.when('/server-info', {
templateUrl : resourceUrl + '/partials/server-info.html'
})
@ -917,8 +915,14 @@ module.config([ '$routeProvider', function($routeProvider) {
templateUrl : resourceUrl + '/partials/home.html',
controller : 'LogoutCtrl'
})
.otherwise({
.when('/notfound', {
templateUrl : resourceUrl + '/partials/notfound.html'
})
.when('/forbidden', {
templateUrl : resourceUrl + '/partials/forbidden.html'
})
.otherwise({
templateUrl : resourceUrl + '/partials/pagenotfound.html'
});
} ]);
@ -942,29 +946,6 @@ module.config(function($httpProvider) {
});
module.factory('errorInterceptor', function($q, $window, $rootScope, $location, Notifications, Auth) {
return function(promise) {
return promise.then(function(response) {
return response;
}, function(response) {
if (response.status == 401) {
Auth.authz.logout();
} else if (response.status == 403) {
Notifications.error("Forbidden");
} else if (response.status == 404) {
Notifications.error("Not found");
} else if (response.status) {
if (response.data && response.data.errorMessage) {
Notifications.error(response.data.errorMessage);
} else {
Notifications.error("An unexpected server error has occurred");
}
}
return $q.reject(response);
});
};
});
module.factory('spinnerInterceptor', function($q, $window, $rootScope, $location) {
return function(promise) {
return promise.then(function(response) {
@ -992,6 +973,29 @@ module.factory('spinnerInterceptor', function($q, $window, $rootScope, $location
};
});
module.factory('errorInterceptor', function($q, $window, $rootScope, $location, Notifications, Auth) {
return function(promise) {
return promise.then(function(response) {
return response;
}, function(response) {
if (response.status == 401) {
Auth.authz.logout();
} else if (response.status == 403) {
$location.path('/forbidden');
} else if (response.status == 404) {
$location.path('/notfound');
} else if (response.status) {
if (response.data && response.data.errorMessage) {
Notifications.error(response.data.errorMessage);
} else {
Notifications.error("An unexpected server error has occurred");
}
}
return $q.reject(response);
});
};
});
// collapsable form fieldsets
module.directive('collapsable', function() {
return function(scope, element, attrs) {

View file

@ -121,12 +121,8 @@ module.controller('RealmDropdownCtrl', function($scope, Realm, Current, Auth, $l
$scope.changeRealm = function(selectedRealm) {
$location.url("/realms/" + selectedRealm);
};
$scope.showNav = function() {
var show = Current.realms.length > 0;
return Auth.loggedIn && show;
}
$scope.refresh = function() {
Current.refresh();
}

View file

@ -0,0 +1,7 @@
<div id="content-area" class="col-sm-12" role="main">
<div class="error-container">
<h2>Forbidden</h2>
<p class="instruction">You don't have access to the requested resource.</p>
<a href="#" class="link-right">Go to the home page &raquo;</a>
</div>
</div>

View file

@ -26,8 +26,8 @@
</li>
</ul>
<ul class="nav navbar-nav navbar-primary persistent-secondary" data-ng-controller="RealmDropdownCtrl">
<li class="dropdown context" data-ng-show="showNav()">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<li class="dropdown context" data-ng-show="current.realm.realm">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
{{current.realm.realm}}
<b class="caret" data-ng-show="current.realms.length > 1"></b>
</a>
@ -37,6 +37,17 @@
</li>
</ul>
</li>
<li class="dropdown context" data-ng-show="!current.realm.realm">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Select realm...
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li data-ng-repeat="realm in current.realms">
<a href="" ng-click="changeRealm(realm.realm)">{{realm.realm}}</a>
</li>
</ul>
</li>
<li class="active pull-right" data-ng-show="auth.user && access.createRealm">
<a class="button primary" href="#/create/realm" data-ng-class="path[0] == 'create' && path[1] == 'realm' && 'active'"
data-ng-show="auth.user">Add Realm</a>
@ -45,6 +56,7 @@
</div>
</div>
</nav>
<!-- TODO remove once this page is properly styled -->
<style type="text/css">
.icon-spinner6 {

View file

@ -1,9 +1,7 @@
<div id="content-area" class="col-sm-12" role="main">
<div class="error-container">
<h2>Page <strong>not found</strong>...</h2>
<p class="instruction">We could not find the page you are looking for. Please make sure the URL you entered is correct.</p>
<h2>Resource <strong>not found</strong>...</h2>
<p class="instruction">We could not find the resource you are looking for. Please make sure the URL you entered is correct.</p>
<a href="#" class="link-right">Go to the home page &raquo;</a>
<!-- <a href="#" class="link-right">Go to the realm page &raquo;</a> -->
</div>
</div>

View file

@ -0,0 +1,7 @@
<div id="content-area" class="col-sm-12" role="main">
<div class="error-container">
<h2>Page <strong>not found</strong>...</h2>
<p class="instruction">We could not find the page you are looking for. Please make sure the URL you entered is correct.</p>
<a href="#" class="link-right">Go to the home page &raquo;</a>
</div>
</div>