Class: Tiler::Dashboard
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Tiler::Dashboard
- Defined in:
- app/models/tiler/dashboard.rb
Constant Summary collapse
- REFRESH_OPTIONS =
{ 0 => "No auto-refresh", 30 => "Every 30 seconds", 60 => "Every minute", 300 => "Every 5 minutes" }.freeze
- HEX_COLOR_RE =
Theme — per-dashboard CSS token overrides stored in settings JSON. Each accessor returns a validated hex color string or nil (so the design-system default applies). Tokens are emitted as inline style on the .tiler-dashboard wrapper so descendants inherit naturally.
page_bg -> --paper (page background) tile_bg -> --paper-2 (panel surface) tile_header_bg -> --paper-3 (panel header strip) gutter_bg -> --border (grid gutters) /\A#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})\z/i- THEME_KEYS =
%w[page_bg tile_bg tile_header_bg gutter_bg].freeze
Instance Method Summary collapse
- #gutter_bg ⇒ Object
- #page_bg ⇒ Object
-
#settings_hash ⇒ Object
Per-dashboard settings stored as a JSON text column.
-
#theme_inline_style ⇒ Object
Returns { token => hex } for every set theme key, ready to splat into an inline style attribute.
- #tile_bg ⇒ Object
- #tile_header_bg ⇒ Object
- #to_param ⇒ Object
- #tv_mode? ⇒ Boolean
Instance Method Details
#gutter_bg ⇒ Object
56 |
# File 'app/models/tiler/dashboard.rb', line 56 def gutter_bg; theme_color("gutter_bg"); end |
#page_bg ⇒ Object
53 |
# File 'app/models/tiler/dashboard.rb', line 53 def page_bg; theme_color("page_bg"); end |
#settings_hash ⇒ Object
Per-dashboard settings stored as a JSON text column. Today: { tv_mode }. Returns the parsed Hash; safe even when the column is nil/blank.
31 32 33 34 35 |
# File 'app/models/tiler/dashboard.rb', line 31 def settings_hash JSON.parse(settings.presence || "{}") rescue JSON::ParserError {} end |
#theme_inline_style ⇒ Object
Returns { token => hex } for every set theme key, ready to splat into an inline style attribute. Empty hash when nothing is themed.
60 61 62 63 64 65 66 67 68 |
# File 'app/models/tiler/dashboard.rb', line 60 def theme_inline_style mapping = { "page_bg" => "--paper", "tile_bg" => "--paper-2", "tile_header_bg" => "--paper-3", "gutter_bg" => "--border" } pairs = THEME_KEYS.filter_map do |key| v = theme_color(key) v ? "#{mapping[key]}: #{v};" : nil end pairs.join(" ") end |
#tile_bg ⇒ Object
54 |
# File 'app/models/tiler/dashboard.rb', line 54 def tile_bg; theme_color("tile_bg"); end |
#tile_header_bg ⇒ Object
55 |
# File 'app/models/tiler/dashboard.rb', line 55 def tile_header_bg; theme_color("tile_header_bg"); end |
#to_param ⇒ Object
25 26 27 |
# File 'app/models/tiler/dashboard.rb', line 25 def to_param slug end |
#tv_mode? ⇒ Boolean
37 38 39 |
# File 'app/models/tiler/dashboard.rb', line 37 def tv_mode? !!settings_hash["tv_mode"] end |