diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb new file mode 100644 index 0000000..1726066 --- /dev/null +++ b/app/controllers/errors_controller.rb @@ -0,0 +1,13 @@ +class ErrorsController < ApplicationController + def not_found; end + + def internal_server_error; end + + def unprocessable_entity; end + + def unauthorized; end + + def forbidden; end + + def service_unavailable; end +end diff --git a/app/views/courses/add_lecturers.html.erb b/app/views/courses/add_lecturers.html.erb index e6f564d..2ce2ff8 100644 --- a/app/views/courses/add_lecturers.html.erb +++ b/app/views/courses/add_lecturers.html.erb @@ -9,7 +9,8 @@
diff --git a/app/views/errors/forbidden.html.erb b/app/views/errors/forbidden.html.erb new file mode 100644 index 0000000..492f2b3 --- /dev/null +++ b/app/views/errors/forbidden.html.erb @@ -0,0 +1,37 @@ +<% content_for :hide_breadcrumbs, true %> +<% content_for :hide_toggler, true %> + +
+
+ +

+ 403 +

+ +

+ Forbidden +

+ +

+ Sorry, you are not authorized to view this page. +

+ +
+ + <%= link_to "Return to Dashboard", + root_path, + class: + "cursor-pointer bg-slate-600 hover:bg-slate-700 text-white font-bold py-3.5 px-8 rounded-xl shadow-lg shadow-slate-500/20 hover:shadow-slate-500/30 transition-all transform active:scale-95 text-sm sm:text-base inline-flex justify-center items-center" %> + +
+
+
diff --git a/app/views/errors/internal_server_error.html.erb b/app/views/errors/internal_server_error.html.erb new file mode 100644 index 0000000..79db9f0 --- /dev/null +++ b/app/views/errors/internal_server_error.html.erb @@ -0,0 +1,37 @@ +<% content_for :hide_breadcrumbs, true %> +<% content_for :hide_toggler, true %> + +
+
+ +

+ 500 +

+ +

+ Internal Server Error +

+ +

+ Sorry, an unexpected error occurred. Please try again later. +

+ +
+ + <%= link_to "Return to Dashboard", + root_path, + class: + "cursor-pointer bg-slate-600 hover:bg-slate-700 text-white font-bold py-3.5 px-8 rounded-xl shadow-lg shadow-slate-500/20 hover:shadow-slate-500/30 transition-all transform active:scale-95 text-sm sm:text-base inline-flex justify-center items-center" %> + +
+
+
diff --git a/app/views/errors/not_found.html.erb b/app/views/errors/not_found.html.erb new file mode 100644 index 0000000..d34f59f --- /dev/null +++ b/app/views/errors/not_found.html.erb @@ -0,0 +1,38 @@ +<% content_for :hide_breadcrumbs, true %> +<% content_for :hide_toggler, true %> + +
+
+ +

+ 404 +

+ +

+ Page not found +

+ +

+ Sorry, we couldn't find the page you're looking for. It probably doesn't + exist, or might have been moved or deleted. +

+ +
+ + <%= link_to "Return to Dashboard", + root_path, + class: + "cursor-pointer bg-slate-600 hover:bg-slate-700 text-white font-bold py-3.5 px-8 rounded-xl shadow-lg shadow-slate-500/20 hover:shadow-slate-500/30 transition-all transform active:scale-95 text-sm sm:text-base inline-flex justify-center items-center" %> + +
+
+
diff --git a/app/views/errors/service_unavailable.html.erb b/app/views/errors/service_unavailable.html.erb new file mode 100644 index 0000000..ea2f788 --- /dev/null +++ b/app/views/errors/service_unavailable.html.erb @@ -0,0 +1,37 @@ +<% content_for :hide_breadcrumbs, true %> +<% content_for :hide_toggler, true %> + +
+
+ +

+ 503 +

+ +

+ Service Unavailable +

+ +

+ Sorry, this page is undergoing maintenance. Please try again later. +

+ +
+ + <%= link_to "Return to Dashboard", + root_path, + class: + "cursor-pointer bg-slate-600 hover:bg-slate-700 text-white font-bold py-3.5 px-8 rounded-xl shadow-lg shadow-slate-500/20 hover:shadow-slate-500/30 transition-all transform active:scale-95 text-sm sm:text-base inline-flex justify-center items-center" %> + +
+
+
diff --git a/app/views/errors/unauthorized.html.erb b/app/views/errors/unauthorized.html.erb new file mode 100644 index 0000000..52ae824 --- /dev/null +++ b/app/views/errors/unauthorized.html.erb @@ -0,0 +1,38 @@ +<% content_for :hide_breadcrumbs, true %> +<% content_for :hide_toggler, true %> + +
+
+ +

+ 401 +

+ +

+ Unauthorized +

+ +

+ Sorry, you must be authenticated to view this page. Please login to + continue. +

+ +
+ + <%= link_to "Go to Login", + login_path, + class: + "cursor-pointer bg-slate-600 hover:bg-slate-700 text-white font-bold py-3.5 px-8 rounded-xl shadow-lg shadow-slate-500/20 hover:shadow-slate-500/30 transition-all transform active:scale-95 text-sm sm:text-base inline-flex justify-center items-center" %> + +
+
+
diff --git a/app/views/errors/unprocessable_entity.html.erb b/app/views/errors/unprocessable_entity.html.erb new file mode 100644 index 0000000..eace760 --- /dev/null +++ b/app/views/errors/unprocessable_entity.html.erb @@ -0,0 +1,38 @@ +<% content_for :hide_breadcrumbs, true %> +<% content_for :hide_toggler, true %> + +
+
+ +

+ 422 +

+ +

+ Unprocessable Entity +

+ +

+ Sorry, an error occurred. If you had just submitted a form before this + error occurred. please try resubmitting again. +

+ +
+ + <%= link_to "Return to Dashboard", + root_path, + class: + "cursor-pointer bg-slate-600 hover:bg-slate-700 text-white font-bold py-3.5 px-8 rounded-xl shadow-lg shadow-slate-500/20 hover:shadow-slate-500/30 transition-all transform active:scale-95 text-sm sm:text-base inline-flex justify-center items-center" %> + +
+
+
diff --git a/config/application.rb b/config/application.rb index ae8f567..c3a633b 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,6 +28,10 @@ class Application < Rails::Application # view constants thresholds config.participants_threshold = 500 config.supervisors_threshold = 100 + config.participants_pagination_threshold = 25 + + # redirect error routes to use custom design + config.exceptions_app = routes end end diff --git a/config/routes.rb b/config/routes.rb index 4979349..d21fa8b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -84,6 +84,12 @@ # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. # Can be used by load balancers and uptime monitors to verify that the app is live. get 'up' => 'rails/health#show', as: :rails_health_check + match '/404', to: 'errors#not_found', via: :all + match '/500', to: 'errors#internal_server_error', via: :all + match '/401', to: 'errors#unauthorized', via: :all + match '/403', to: 'errors#forbidden', via: :all + match '/503', to: 'errors#service_unavailable', via: :all + match '/422', to: 'errors#unprocessable_entity', via: :all # Render dynamic PWA files from app/views/pwa/* (remember to link manifest in application.html.erb) # get "manifest" => "rails/pwa#manifest", as: :pwa_manifest