ref: refs/heads/basesystem
commit 90d7751815f5390c6f8b16e0ac0d46f572d85cd7
Author: Ladislav Slezak
Date: Fri Aug 28 10:05:19 2009 +0200
services - display currect statuses (via AJAX)
- use partial render for status text rendering
- sort services by name in the index view
---
.../app/controllers/services_controller.rb | 10 ++++++++
plugins/services/app/views/services/_status.rhtml | 24 +++++++++++++++++++
plugins/services/app/views/services/index.rhtml | 25 ++++++++++++-------
3 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/plugins/services/app/controllers/services_controller.rb b/plugins/services/app/controllers/services_controller.rb
index 0e84f95..f4aa94b 100644
--- a/plugins/services/app/controllers/services_controller.rb
+++ b/plugins/services/app/controllers/services_controller.rb
@@ -22,6 +22,13 @@ class ServicesController < ApplicationController
def initialize
end
+ def show_status
+ return unless client_permissions
+
+ @response = @client.find(params[:id])
+ render(:partial =>'status', :object => @response.status, :params => params)
+ end
+
# GET /services
# GET /services.xml
def index
@@ -34,6 +41,9 @@ class ServicesController < ApplicationController
flash[:error] = YaST::ServiceResource.error(e)
end
+ # sort services by name (case insensitive)
+ @services.sort! {|s1,s2| s1.name.downcase <=> s2.name.downcase } unless @services.nil?
+
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @services }
diff --git a/plugins/services/app/views/services/_status.rhtml b/plugins/services/app/views/services/_status.rhtml
new file mode 100644
index 0000000..e8e5569
--- /dev/null
+++ b/plugins/services/app/views/services/_status.rhtml
@@ -0,0 +1,24 @@
+<%
+# Status values (see /etc/init.d/skeleton):
+#
+# 0 - service up and running
+# 1 - service dead, but /var/run/ pid file exists
+# 2 - service dead, but /var/lock/ lock file exists
+# 3 - service not running (unused)
+# 4 - service status unknown :-(
+# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
+-%>
+<%=
+case status
+ when nil, 4
+ _("(unknown)")
+ when 0
+ _("(running)")
+ when 1,2
+ _("(dead)")
+ when 3
+ _("(not running)")
+ else
+ _("(unknown: #{status})")
+end
+%>
diff --git a/plugins/services/app/views/services/index.rhtml b/plugins/services/app/views/services/index.rhtml
index 5adbd9b..12e5281 100644
--- a/plugins/services/app/views/services/index.rhtml
+++ b/plugins/services/app/views/services/index.rhtml
@@ -1,3 +1,5 @@
+<%= javascript_include_tag :defaults %>
+
<!-- begin: dialog box -->
<div id="resultdlg">
</div>
@@ -24,15 +26,20 @@ end
<ul>
<% @services.each do |service| %>
<li><b><%=h service.name %></b>
- <%=
- if service.status == 0
- _("(running)")
- elsif service.status.nil?
- _("(unknown)")
- else
- _("(stopped: #{service.status})")
- end
- %>
+
+<span class='service_status' id='service_status_<%=service.name%>'>
+<% if service.status.nil? %>
+ <img src="/images/working.gif" height="12" width="12" border="0" />
+<% javascript_tag do %>
+$(document).ready( function() {
+ <%= remote_function(:update => "service_status_#{service.name}",
+ :url => { :controller => :services, :action => :show_status, :id => service.name }) %>
+});
+<% end %>
+<% else %>
+<%= render :partial => 'status', :object => service.status %>
+<% end %>
+</span>
<% [ "start", "stop" ].each do |cmd|
if @permissions[:execute] %>
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org