Class: Superset::Dashboard::Copy
- Defined in:
- lib/superset/dashboard/copy.rb
Constant Summary
Constants inherited from Request
Instance Attribute Summary collapse
-
#clear_shared_label_colors ⇒ Object
readonly
Returns the value of attribute clear_shared_label_colors.
-
#duplicate_slices ⇒ Object
readonly
Returns the value of attribute duplicate_slices.
-
#source_dashboard_id ⇒ Object
readonly
Returns the value of attribute source_dashboard_id.
Attributes inherited from Request
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(source_dashboard_id:, duplicate_slices: false, clear_shared_label_colors: false) ⇒ Copy
constructor
A new instance of Copy.
- #params ⇒ Object
- #perform ⇒ Object
- #response ⇒ Object
Methods inherited from Request
call, #query_params, #result, #superset_host
Methods included from Superset::Display
#display_headers, #headings, #list, #list_attributes, #result, #rows, #table, #title
Constructor Details
#initialize(source_dashboard_id:, duplicate_slices: false, clear_shared_label_colors: false) ⇒ Copy
Returns a new instance of Copy.
11 12 13 14 15 |
# File 'lib/superset/dashboard/copy.rb', line 11 def initialize(source_dashboard_id: , duplicate_slices: false, clear_shared_label_colors: false) @source_dashboard_id = source_dashboard_id @duplicate_slices = duplicate_slices # boolean indicates whether to duplicate charts OR keep the new dashboard pointing to the same charts as the original @clear_shared_label_colors = clear_shared_label_colors end |
Instance Attribute Details
#clear_shared_label_colors ⇒ Object (readonly)
Returns the value of attribute clear_shared_label_colors.
9 10 11 |
# File 'lib/superset/dashboard/copy.rb', line 9 def clear_shared_label_colors @clear_shared_label_colors end |
#duplicate_slices ⇒ Object (readonly)
Returns the value of attribute duplicate_slices.
9 10 11 |
# File 'lib/superset/dashboard/copy.rb', line 9 def duplicate_slices @duplicate_slices end |
#source_dashboard_id ⇒ Object (readonly)
Returns the value of attribute source_dashboard_id.
9 10 11 |
# File 'lib/superset/dashboard/copy.rb', line 9 def source_dashboard_id @source_dashboard_id end |
Instance Method Details
#id ⇒ Object
39 40 41 |
# File 'lib/superset/dashboard/copy.rb', line 39 def id response["result"]["id"] end |
#params ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/superset/dashboard/copy.rb', line 26 def params { "css" => "{}", "dashboard_title" => "#{source_dashboard.title}", "duplicate_slices" => duplicate_slices, "json_metadata" => .to_json, } end |
#perform ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/superset/dashboard/copy.rb', line 17 def perform raise "Error: source_dashboard_id integer is required" unless source_dashboard_id.present? && source_dashboard_id.is_a?(Integer) raise "Error: duplicate_slices must be a boolean" unless duplicate_slices_is_boolean? response Superset::Dashboard::Get.new(id).perform # return the full new dashboard object end |
#response ⇒ Object
35 36 37 |
# File 'lib/superset/dashboard/copy.rb', line 35 def response @response ||= client.post(route, params) end |