FEATURE: report on admin dashboard when favicon is failing to load
This commit is contained in:
parent
d402a45781
commit
56e47c8d7e
|
@ -106,7 +106,8 @@ class StaticController < ApplicationController
|
||||||
file.unlink
|
file.unlink
|
||||||
data
|
data
|
||||||
rescue => e
|
rescue => e
|
||||||
Rails.logger.warn("Invalid favicon_url #{SiteSetting.favicon_url}: #{e}\n#{e.backtrace}")
|
AdminDashboardData.add_problem_message('dashboard.bad_favicon_url', 1800)
|
||||||
|
Rails.logger.debug("Invalid favicon_url #{SiteSetting.favicon_url}: #{e}\n#{e.backtrace}")
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,7 +37,7 @@ class AdminDashboardData
|
||||||
@problem_syms.push(*syms) if syms
|
@problem_syms.push(*syms) if syms
|
||||||
@problem_blocks << blk if blk
|
@problem_blocks << blk if blk
|
||||||
end
|
end
|
||||||
class << self; attr_reader :problem_syms, :problem_blocks; end
|
class << self; attr_reader :problem_syms, :problem_blocks, :problem_messages; end
|
||||||
|
|
||||||
def problems
|
def problems
|
||||||
problems = []
|
problems = []
|
||||||
|
@ -47,6 +47,9 @@ class AdminDashboardData
|
||||||
AdminDashboardData.problem_blocks.each do |blk|
|
AdminDashboardData.problem_blocks.each do |blk|
|
||||||
problems << instance_exec(&blk)
|
problems << instance_exec(&blk)
|
||||||
end
|
end
|
||||||
|
AdminDashboardData.problem_messages.each do |i18n_key|
|
||||||
|
problems << AdminDashboardData.problem_message_check(i18n_key)
|
||||||
|
end
|
||||||
problems.compact
|
problems.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,6 +57,7 @@ class AdminDashboardData
|
||||||
def self.reset_problem_checks
|
def self.reset_problem_checks
|
||||||
@problem_syms = []
|
@problem_syms = []
|
||||||
@problem_blocks = []
|
@problem_blocks = []
|
||||||
|
@problem_messages = ['dashboard.bad_favicon_url']
|
||||||
|
|
||||||
add_problem_check :rails_env_check, :ruby_version_check, :host_names_check,
|
add_problem_check :rails_env_check, :ruby_version_check, :host_names_check,
|
||||||
:gc_checks, :ram_check, :google_oauth2_config_check,
|
:gc_checks, :ram_check, :google_oauth2_config_check,
|
||||||
|
@ -83,6 +87,26 @@ class AdminDashboardData
|
||||||
AdminDashboardData.new.problems
|
AdminDashboardData.new.problems
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.problem_message_check(i18n_key)
|
||||||
|
$redis.get(problem_message_key(i18n_key)) ? I18n.t(i18n_key) : nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.add_problem_message(i18n_key, expire_seconds=nil)
|
||||||
|
if expire_seconds.to_i > 0
|
||||||
|
$redis.setex problem_message_key(i18n_key), expire_seconds.to_i, 1
|
||||||
|
else
|
||||||
|
$redis.set problem_message_key(i18n_key), 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.clear_problem_message(i18n_key)
|
||||||
|
$redis.del problem_message_key(i18n_key)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.problem_message_key(i18n_key)
|
||||||
|
"admin-problem:#{i18n_key}"
|
||||||
|
end
|
||||||
|
|
||||||
def as_json(_options = nil)
|
def as_json(_options = nil)
|
||||||
@json ||= {
|
@json ||= {
|
||||||
global_reports: AdminDashboardData.reports(GLOBAL_REPORTS),
|
global_reports: AdminDashboardData.reports(GLOBAL_REPORTS),
|
||||||
|
|
|
@ -790,6 +790,7 @@ en:
|
||||||
email_polling_errored_recently:
|
email_polling_errored_recently:
|
||||||
one: "Email polling has generated an error in the past 24 hours. Look at <a href='/logs' target='_blank'>the logs</a> for more details."
|
one: "Email polling has generated an error in the past 24 hours. Look at <a href='/logs' target='_blank'>the logs</a> for more details."
|
||||||
other: "Email polling has generated %{count} errors in the past 24 hours. Look at <a href='/logs' target='_blank'>the logs</a> for more details."
|
other: "Email polling has generated %{count} errors in the past 24 hours. Look at <a href='/logs' target='_blank'>the logs</a> for more details."
|
||||||
|
bad_favicon_url: "The favicon is failing to load. Check your favicon_url setting in <a href='/admin/site_settings'>Site Settings</a>."
|
||||||
|
|
||||||
site_settings:
|
site_settings:
|
||||||
censored_words: "Words that will be automatically replaced with ■■■■"
|
censored_words: "Words that will be automatically replaced with ■■■■"
|
||||||
|
|
|
@ -278,4 +278,26 @@ describe AdminDashboardData do
|
||||||
include_examples 'stats cachable'
|
include_examples 'stats cachable'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#problem_message_check' do
|
||||||
|
let(:key) { AdminDashboardData.problem_messages.first }
|
||||||
|
|
||||||
|
before do
|
||||||
|
described_class.clear_problem_message(key)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns nil if message has not been added' do
|
||||||
|
expect(described_class.problem_message_check(key)).to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a message if it was added' do
|
||||||
|
described_class.add_problem_message(key)
|
||||||
|
expect(described_class.problem_message_check(key)).to eq(I18n.t(key))
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns a message if it was added with an expiry' do
|
||||||
|
described_class.add_problem_message(key, 300)
|
||||||
|
expect(described_class.problem_message_check(key)).to eq(I18n.t(key))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue