Class: Prof::OpsManager::WebAppInternals::Page::TileSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/prof/ops_manager/web_app_internals/page/tile_settings.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ TileSettings

Returns a new instance of TileSettings.



20
21
22
23
24
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 20

def initialize(opts = {})
  @page = opts.fetch(:page)

  check_on_settings!
end

Instance Method Details

#configure(configuration) ⇒ Object



49
50
51
52
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 49

def configure(configuration)
  configuration.each { |sidebar_name, config| sidebar(sidebar_name).update(config) }
  return_to_dashboard
end

#current_uriObject



77
78
79
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 77

def current_uri
  URI(page.current_url)
end

#return_to_dashboardObject



72
73
74
75
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 72

def return_to_dashboard
  page.click_on 'Installation Dashboard'
  Dashboard.new(page: page)
end

#set_field_value(setting_name, field_name, field_value) ⇒ Object



30
31
32
33
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 30

def set_field_value(setting_name, field_name, field_value)
  sidebar(setting_name)
  update(field_name => field_value)
end

#setting_namesObject



26
27
28
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 26

def setting_names
  page.all('.sidebar li').map(&:text)
end

#settings_for(setting_name) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 35

def settings_for(setting_name)
  sidebar(setting_name)

  config = {}
  page.all(".content #{fields_selector}").each do |input|
    config[input['name']] = if config[input['name']]
                              [input.value] + Array(config[input['name']])
                            else
                              input.value
                            end
  end
  config
end


59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 59

def sidebar(next_settings_name, &_block)
  return self if next_settings_name == current_setting_name

  page.find('li a', text: /^\s*#{next_settings_name}\s*$/).click

  if block_given?
    yield page
    return_to_dashboard
  else
    TileSettings.new(page: page)
  end
end

#update(config = {}, &block) ⇒ Object



54
55
56
57
# File 'lib/prof/ops_manager/web_app_internals/page/tile_settings.rb', line 54

def update(config = {}, &block)
  form.update config, &block
  self
end