Skip to content

Commit

Permalink
add dashboard widget
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger authored and mvidner committed Jan 25, 2017
1 parent e834d99 commit 09a36cb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/lib/installation/clients/inst_casp_overview.rb
Expand Up @@ -110,6 +110,7 @@ def quadrant_layout(upper_left:, lower_left:, upper_right:, lower_right:)

# Returns a UI widget-set for the dialog
def content
dashboard = Installation::Widgets::DashboardPlace.new
quadrant_layout(
upper_left: VBox(
::Widgets::RegistrationCode.new,
Expand All @@ -118,7 +119,8 @@ def content
::Y2Country::Widgets::KeyboardSelectionCombo.new("english-us")
),
lower_left: VBox(
Installation::Widgets::SystemRole.new,
Installation::Widgets::SystemRole.new(dashboard),
dashboard,
Tune::Widgets::SystemInformation.new
),
upper_right: VBox(
Expand Down
48 changes: 42 additions & 6 deletions src/lib/installation/widgets/system_role.rb
Expand Up @@ -29,31 +29,67 @@

module Installation
module Widgets
# TODO: steal / refactor Installation::SelectSystemRole
# from src/lib/installation/select_system_role.rb
class DashboardURL < CWM::InputField
def label
# intentional no translation for CAASP
"Dashboard URL"
end

def store
# TODO: implement it together with init and some validation
end
end

class DashboardPlace < CWM::ReplacePoint
def initialize
@dashboard = DashboardURL.new
@empty = CWM::Empty.new("no_dashboard")
super(widget: @empty)
end

def show
replace(@dashboard)
end

def hide
replace(@empty)
end
end

class SystemRole < CWM::ComboBox
class << self
# once the user selects a role, remember it in case they come back
attr_accessor :original_role_id
end

def initialize
def initialize(dashboard_widget)
textdomain "installation"
@dashboard_widget = dashboard_widget
end

def label
Yast::ProductControl.GetTranslatedText("roles_caption")
end

def opt
[:hstretch]
[:hstretch, :notify]
end

def init
self.class.original_role_id ||= roles_attributes.first[:id]
self.class.original_role_id ||= roles_description.first[:id]
self.value = self.class.original_role_id
end

def handle
if value == "worker_role"
@dashboard_widget.show
else
@dashboard_widget.hide
end

nil
end

def items
roles_description.map do |attr|
[attr[:id], attr[:label]]
Expand All @@ -62,7 +98,7 @@ def items

def help
Yast::ProductControl.GetTranslatedText("roles_help") + "\n\n"
roles_description.map { |r| r[:label] + "\n\n" + r[:description] + "\n\n\n"}
roles_description.map { |r| r[:label] + "\n\n" + r[:description]}.join("\n\n\n")
end

NON_OVERLAY_ATTRIBUTES = [
Expand Down

0 comments on commit 09a36cb

Please sign in to comment.