forked from External/greenlight
Added a Maintenance Window flash (#758)
This commit is contained in:
committed by
Jesus Federico
parent
177bf4d595
commit
9ddc057589
@ -24,4 +24,11 @@ $(document).on('turbolinks:load', function(){
|
||||
//hide the banner at the bottom
|
||||
$(".cookies-banner").attr("style","display:none !important")
|
||||
})
|
||||
|
||||
$("#maintenance-close").click(function(event) {
|
||||
//create a cookie that lasts 1 year
|
||||
var cookieDate = new Date();
|
||||
cookieDate.setFullYear(cookieDate.getFullYear() + 1); //1 year from now
|
||||
document.cookie = "maintenance_window=" + $(event.target).data("date") + "; path=/; expires=" + cookieDate.toUTCString() + ";"
|
||||
})
|
||||
})
|
||||
|
@ -53,7 +53,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def maintenance_mode?
|
||||
if ENV["MAINTENANCE_MODE"] == "true"
|
||||
if Rails.configuration.maintenance_mode
|
||||
render "errors/greenlight_error", status: 503, formats: :html,
|
||||
locals: {
|
||||
status_code: 503,
|
||||
@ -61,6 +61,11 @@ class ApplicationController < ActionController::Base
|
||||
help: I18n.t("errors.maintenance.help"),
|
||||
}
|
||||
end
|
||||
if Rails.configuration.maintenance_window.present?
|
||||
unless cookies[:maintenance_window] == Rails.configuration.maintenance_window
|
||||
flash.now[:maintenance] = I18n.t("maintenance.window_alert", date: Rails.configuration.maintenance_window)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the appropriate locale.
|
||||
|
@ -24,6 +24,11 @@
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<%= value.html_safe %>
|
||||
</div>
|
||||
<% elsif key.eql? "maintenance" %>
|
||||
<div class="alert alert-info alert-dismissible text-center mb-0">
|
||||
<%= value.html_safe %>
|
||||
<button id="maintenance-close" type="button" data-date="<%= Rails.configuration.maintenance_window %>" class="close" data-dismiss="alert">×</button>
|
||||
</div>
|
||||
<% elsif key.eql? "info" %>
|
||||
<div class="alert alert-info alert-dismissible text-center mb-0">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
|
Reference in New Issue
Block a user