Class: UI::ServiceStatus Deprecated
- Inherits:
-
Object
- Object
- UI::ServiceStatus
- Includes:
- Yast::I18n, Yast::Logger, Yast::UIShortcuts
- Defined in:
- library/general/src/lib/ui/service_status.rb
Overview
Use CWM::ServiceWidget instead.
Widgets for managing the status of services (both currently and on system boot) and the behavior associated to those widgets
As long as #handle_input is invoked in the event loop, the widget will handle interactive starting and stopping of the service on user demand.
It also provides checkboxes (reload_flag and enabled_flag) for the user to specify whether the service must be reloaded/restarted after configuration changes and whether it must be enabled at boot time.
Instance Attribute Summary collapse
-
#id_prefix ⇒ Object
readonly
protected
Returns the value of attribute id_prefix.
Instance Method Summary collapse
-
#enabled_flag? ⇒ Boolean
Checks if the user requested the service to be enabled on boot.
-
#handle_input(input) ⇒ Symbol
Handles the input triggered by the widgets, this method must be called in the event loop of the dialog using the component.
-
#help ⇒ Object
Content for the help.
-
#initialize(service, reload_flag: true, reload_flag_label: :reload) ⇒ ServiceStatus
constructor
A new instance of ServiceStatus.
- #label_and_action_widgets ⇒ Object protected
-
#on_boot_widget ⇒ Object
protected
Widget to configure the status on boot.
-
#refresh ⇒ Object
Updates the widget to reflect the current status of the service and the settings.
-
#reload_flag? ⇒ Boolean
Checks if the user requested the service to be reloaded when saving.
-
#reload_widget ⇒ Object
protected
Widget to configure reloading of the running service.
-
#status_widget ⇒ Object
protected
Widget displaying the status and associated buttons.
- #widget ⇒ YaST::Term
Constructor Details
#initialize(service, reload_flag: true, reload_flag_label: :reload) ⇒ ServiceStatus
Returns a new instance of ServiceStatus.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'library/general/src/lib/ui/service_status.rb', line 51 def initialize(service, reload_flag: true, reload_flag_label: :reload) @service = service @reload_flag = reload_flag @enabled_flag = @service.enabled? @id_prefix = "_srv_status_#{@service.name}" textdomain "base" @reload_label = if reload_flag_label == :restart _("Restart After Saving Settings") else _("Reload After Saving Settings") end end |
Instance Attribute Details
#id_prefix ⇒ Object (readonly, protected)
Returns the value of attribute id_prefix.
150 151 152 |
# File 'library/general/src/lib/ui/service_status.rb', line 150 def id_prefix @id_prefix end |
Instance Method Details
#enabled_flag? ⇒ Boolean
Checks if the user requested the service to be enabled on boot
116 117 118 |
# File 'library/general/src/lib/ui/service_status.rb', line 116 def enabled_flag? @enabled_flag end |
#handle_input(input) ⇒ Symbol
Handles the input triggered by the widgets, this method must be called in the event loop of the dialog using the component.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'library/general/src/lib/ui/service_status.rb', line 82 def handle_input(input) case input when "#{id_prefix}_stop" @service.stop refresh :stop when "#{id_prefix}_start" @service.start refresh :start when "#{id_prefix}_reload" @reload_flag = Yast::UI.QueryWidget(Id(input), :Value) :reload_flag when "#{id_prefix}_enabled" @enabled_flag = Yast::UI.QueryWidget(Id(input), :Value) :enabled_flag else log.info "Input not handled by ServiceStatus: #{input}" :ignored end end |
#help ⇒ Object
Content for the help
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'library/general/src/lib/ui/service_status.rb', line 128 def help # TRANSLATORS: do not modify %{reload_label} format(_( "<p><b><big>Current status</big></b><br>\n"\ "Displays the current status of the service. The status will remain "\ "the same after saving the settings, independently of the value of "\ "'start service during boot'.</p>\n"\ "<p><b><big>%{reload_label}</big></b><br>\n"\ "Only applicable if the service is currently running. "\ "Ensures the running service reloads the new configuration after "\ "saving it (either finishing the dialog or pressing the apply "\ "button).</p>\n"\ "<p><b><big>Start During System Boot</big></b><br>\n"\ "Check this field to enable the service at system boot. "\ "Un-check it to disable the service. "\ "This does not affect the current status of the service in the already "\ "running system.</p>\n" ), reload_label: @reload_label) end |
#label_and_action_widgets ⇒ Object (protected)
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'library/general/src/lib/ui/service_status.rb', line 189 def # use active and not running. See https://bugzilla.suse.com/show_bug.cgi?id=1080738#c3 if @service.active? [ # TRANSLATORS: status of a service Label(_("running")), Label(" "), PushButton(Id("#{id_prefix}_stop"), _("Stop now")) ] else [ # TRANSLATORS: status of a service Label(_("stopped")), Label(" "), PushButton(Id("#{id_prefix}_start"), _("Start now")) ] end end |
#on_boot_widget ⇒ Object (protected)
Widget to configure the status on boot
164 165 166 167 168 169 170 171 172 173 |
# File 'library/general/src/lib/ui/service_status.rb', line 164 def Left( CheckBox( Id("#{id_prefix}_enabled"), Opt(:notify), _("Start During System Boot"), @enabled_flag ) ) end |
#refresh ⇒ Object
Updates the widget to reflect the current status of the service and the settings
106 107 108 109 110 111 |
# File 'library/general/src/lib/ui/service_status.rb', line 106 def refresh Yast::UI.ChangeWidget(Id("#{id_prefix}_reload"), :Enabled, @service.active?) Yast::UI.ChangeWidget(Id("#{id_prefix}_reload"), :Value, @service.active? && @reload_flag) Yast::UI.ChangeWidget(Id("#{id_prefix}_enabled"), :Value, @enabled_flag) Yast::UI.ReplaceWidget(Id("#{id_prefix}_status"), ) end |
#reload_flag? ⇒ Boolean
Checks if the user requested the service to be reloaded when saving
123 124 125 |
# File 'library/general/src/lib/ui/service_status.rb', line 123 def reload_flag? @reload_flag end |
#reload_widget ⇒ Object (protected)
Widget to configure reloading of the running service
176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'library/general/src/lib/ui/service_status.rb', line 176 def opts = [:notify] opts << :disabled unless @service.active? Left( CheckBox( Id("#{id_prefix}_reload"), Opt(*opts), @reload_label, @service.active? && @reload_flag ) ) end |
#status_widget ⇒ Object (protected)
Widget displaying the status and associated buttons
153 154 155 156 157 158 159 160 161 |
# File 'library/general/src/lib/ui/service_status.rb', line 153 def Left( HBox( Label(_("Current status:")), Label(" "), * ) ) end |
#widget ⇒ YaST::Term
66 67 68 69 70 71 72 73 74 75 76 |
# File 'library/general/src/lib/ui/service_status.rb', line 66 def Frame( _("Service Status"), VBox( ReplacePoint(Id("#{id_prefix}_status"), ), , VSpacing(), ) ) end |