Class: Kennel::Models::Screen
- Includes:
- OptionalValidations, TemplateVariables
- Defined in:
- lib/kennel/models/screen.rb
Constant Summary collapse
- API_LIST_INCOMPLETE =
true
- COPIED_WIDGET_VALUES =
[:board_id, :isShared].freeze
- WIDGET_DEFAULTS =
{ time: {}, timeframe: "1h" }.freeze
- READONLY_ATTRIBUTES =
(Base::READONLY_ATTRIBUTES + [ :disableCog, :disableEditing, :isIntegration, :isShared, :original_title, :read_only, :resource, :title, :title_edited, :created_by, :board_bgtype, :height, :width, :showGlobalTimeOnboarding, :originalHeight, :originalWidth ]).freeze
- SCREEN_DEFAULTS =
{ template_variables: [] }.freeze
Constants inherited from Base
Base::LOCK, Base::REQUEST_DEFAULTS
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(project, *args) ⇒ Screen
constructor
A new instance of Screen.
- #resolve_linked_tracking_ids(id_map) ⇒ Object
- #url(id) ⇒ Object
Methods included from OptionalValidations
Methods included from TemplateVariables
Methods inherited from Base
defaults, #diff, inherited, #kennel_id, #name, settings, #to_json, #tracking_id, validate_setting_exists
Methods included from SubclassTracking
#recursive_subclasses, #subclasses
Constructor Details
#initialize(project, *args) ⇒ Screen
Returns a new instance of Screen.
44 45 46 47 |
# File 'lib/kennel/models/screen.rb', line 44 def initialize(project, *args) @project = project super(*args) end |
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
42 43 44 |
# File 'lib/kennel/models/screen.rb', line 42 def project @project end |
Class Method Details
.api_resource ⇒ Object
49 50 51 |
# File 'lib/kennel/models/screen.rb', line 49 def self.api_resource "screen" end |
.normalize(expected, actual) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/kennel/models/screen.rb', line 68 def self.normalize(expected, actual) super (actual[:widgets] || []).each do |w| # api randomly returns time.live_span or timeframe or empty time hash if w.dig(:time, :live_span) w[:timeframe] = w[:time].delete(:live_span) end COPIED_WIDGET_VALUES.each { |v| w.delete v } end ignore_default expected, actual, SCREEN_DEFAULTS ignore_defaults expected[:widgets], actual[:widgets], WIDGET_DEFAULTS ignore_request_defaults expected, actual, :widgets, :tile_def end |
Instance Method Details
#as_json ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/kennel/models/screen.rb', line 53 def as_json return @json if @json @json = { id: id, board_title: "#{board_title}#{LOCK}", description: description, widgets: , template_variables: render_template_variables } validate_json(@json) if validate @json end |
#resolve_linked_tracking_ids(id_map) ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/kennel/models/screen.rb', line 89 def resolve_linked_tracking_ids(id_map) as_json[:widgets].each do || case [:type] when "uptime" resolve_link(, [:monitor, :id], id_map) when "alert_graph" resolve_link(, [:alert_id], id_map) end end end |
#url(id) ⇒ Object
85 86 87 |
# File 'lib/kennel/models/screen.rb', line 85 def url(id) Utils.path_to_url "/screen/#{id}" end |