Class: Kennel::Models::Screen
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,
:new_id
]).freeze
- SCREEN_DEFAULTS =
{ template_variables: [] }.freeze
Constants inherited
from Base
Base::LOCK, Base::REQUEST_DEFAULTS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
all_keys, included
included
Methods inherited from Base
defaults, #diff, inherited, #kennel_id, #name, settings, #to_json, #tracking_id, validate_setting_exists
#recursive_subclasses, #subclasses
Constructor Details
#initialize(project, *args) ⇒ Screen
45
46
47
48
|
# File 'lib/kennel/models/screen.rb', line 45
def initialize(project, *args)
@project = project
super(*args)
end
|
Instance Attribute Details
#project ⇒ Object
Returns the value of attribute project.
43
44
45
|
# File 'lib/kennel/models/screen.rb', line 43
def project
@project
end
|
Class Method Details
.api_resource ⇒ Object
50
51
52
|
# File 'lib/kennel/models/screen.rb', line 50
def self.api_resource
"screen"
end
|
.normalize(expected, actual) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/kennel/models/screen.rb', line 69
def self.normalize(expected, actual)
super
(actual[:widgets] || []).each do |w|
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/kennel/models/screen.rb', line 54
def as_json
return @json if @json
@json = {
id: id,
board_title: "#{board_title}#{LOCK}",
description: description,
widgets: render_widgets,
template_variables: render_template_variables
}
validate_json(@json) if validate
@json
end
|
#resolve_linked_tracking_ids(id_map) ⇒ Object
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/kennel/models/screen.rb', line 90
def resolve_linked_tracking_ids(id_map)
as_json[:widgets].each do |widget|
case widget[:type]
when "uptime"
resolve_link(widget, [:monitor, :id], id_map)
when "alert_graph"
resolve_link(widget, [:alert_id], id_map)
end
end
end
|
#url(id) ⇒ Object
86
87
88
|
# File 'lib/kennel/models/screen.rb', line 86
def url(id)
Utils.path_to_url "/screen/#{id}"
end
|