From d42c9174485265409bbbcb03b013545eae907c5c Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Thu, 16 Apr 2015 09:32:37 +0200 Subject: [PATCH 1/2] Fix styling on not found page --- .../admin/resources/partials/notfound.html | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/notfound.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/notfound.html index bdbb9976f6..52a38f403e 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/notfound.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/notfound.html @@ -1,14 +1,9 @@ -
-
-
-
-
-

Page not found...

-

We could not find the page you are looking for. Please make sure the URL you entered is correct.

- Go to the home page » - -
-
-
+ +
+
+

Page not found...

+

We could not find the page you are looking for. Please make sure the URL you entered is correct.

+ Go to the home page » +
\ No newline at end of file From 9c5e38a0231078705450d35db343c364f0d8ee35 Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Thu, 16 Apr 2015 10:35:52 +0200 Subject: [PATCH 2/2] Updated not found and forbidden access to show a proper page instead of just notification --- .../main/resources/theme/base/admin/index.ftl | 2 +- .../theme/base/admin/resources/js/app.js | 56 ++++++++++--------- .../admin/resources/js/controllers/realm.js | 6 +- .../admin/resources/partials/forbidden.html | 7 +++ .../base/admin/resources/partials/menu.html | 16 +++++- .../admin/resources/partials/notfound.html | 6 +- .../resources/partials/pagenotfound.html | 7 +++ 7 files changed, 62 insertions(+), 38 deletions(-) create mode 100755 forms/common-themes/src/main/resources/theme/base/admin/resources/partials/forbidden.html create mode 100755 forms/common-themes/src/main/resources/theme/base/admin/resources/partials/pagenotfound.html diff --git a/forms/common-themes/src/main/resources/theme/base/admin/index.ftl b/forms/common-themes/src/main/resources/theme/base/admin/index.ftl index 20e21b744f..3883361ace 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/index.ftl +++ b/forms/common-themes/src/main/resources/theme/base/admin/index.ftl @@ -64,7 +64,7 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js index f45453c744..1fe34408b1 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/app.js @@ -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) { diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js index 97c1bdaa7a..387aa53b32 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js @@ -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(); } diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/forbidden.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/forbidden.html new file mode 100755 index 0000000000..6a0d5bfcb9 --- /dev/null +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/forbidden.html @@ -0,0 +1,7 @@ +
+
+

Forbidden

+

You don't have access to the requested resource.

+ Go to the home page » +
+
\ No newline at end of file diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/menu.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/menu.html index 76ace6b93f..66f58c909e 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/menu.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/menu.html @@ -26,8 +26,8 @@ +
  • Add Realm @@ -45,6 +56,7 @@
  • +