Skip to content

Business intelligence made simple

Added support for images

Andrew Kane6dcc5cf34752
diff --git a/app/assets/stylesheets/blazer/application.css b/app/assets/stylesheets/blazer/application.css
index ade4ffb3..a8d9774b 100644
--- a/app/assets/stylesheets/blazer/application.css
+++ b/app/assets/stylesheets/blazer/application.css
@@ -24,6 +24,11 @@ body {
background-color: #fff;
}
+.results-table img {
+ max-width: 200px;
+ max-height: 200px;
+}
+
input.search {
border: none;
box-shadow: none;
diff --git a/app/helpers/blazer/base_helper.rb b/app/helpers/blazer/base_helper.rb
index 7d5b885f..072fcca3 100644
--- a/app/helpers/blazer/base_helper.rb
+++ b/app/helpers/blazer/base_helper.rb
@@ -9,12 +9,20 @@ module Blazer
end
BLAZER_URL_REGEX = /\Ahttps?:\/\/[\S]+\z/
+ BLAZER_IMAGE_EXT = %w[png jpg jpeg gif]
def blazer_format_value(key, value)
if value.is_a?(Integer) && !key.to_s.end_with?("id")
number_with_delimiter(value)
elsif value =~ BLAZER_URL_REGEX
- link_to value, value, target: "_blank"
+ # see if image or link
+ if Blazer.images && BLAZER_IMAGE_EXT.include?(value.split(".").last.split("?").first.try(:downcase))
+ link_to value, target: "_blank" do
+ image_tag value, referrerpolicy: "no-referrer"
+ end
+ else
+ link_to value, value, target: "_blank"
+ end
else
value
end
diff --git a/lib/blazer.rb b/lib/blazer.rb
index 683d42ef..72211e7d 100644
--- a/lib/blazer.rb
+++ b/lib/blazer.rb
@@ -24,12 +24,14 @@ module Blazer
attr_accessor :check_schedules
attr_accessor :anomaly_checks
attr_accessor :async
+ attr_accessor :images
end
self.audit = true
self.user_name = :name
self.check_schedules = ["5 minutes", "1 hour", "1 day"]
self.anomaly_checks = false
self.async = false
+ self.images = false
TIMEOUT_MESSAGE = "Query timed out :("
TIMEOUT_ERRORS = [
diff --git a/lib/blazer/engine.rb b/lib/blazer/engine.rb
index 2a0b1be6..f6b938a1 100644
--- a/lib/blazer/engine.rb
+++ b/lib/blazer/engine.rb
@@ -35,6 +35,8 @@ module Blazer
if Blazer.async
require "blazer/run_statement_job"
end
+
+ Blazer.images = Blazer.settings["images"] || false
end
end
end