Mailinglist Archive: yast-commit (1926 mails)

< Previous Next >
[yast-commit] <web-client> dmacvicar_log_viewer : different UI for custom and standard services
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Mon, 24 Aug 2009 15:37:54 +0200
  • Message-id: <E1Mlmr3-00060D-CA@xxxxxxxxxxxxxxxx>
ref: refs/heads/dmacvicar_log_viewer
commit 5ed72639e4dbf4fa8834c0d146a7713deb26dba7
Author: Jiri Suchomel <jsuchome@xxxxxxx>
Date: Wed Aug 19 16:09:19 2009 +0200

different UI for custom and standard services
---
.../app/controllers/services_controller.rb | 10 ++--
plugins/services/app/views/services/_result.rhtml | 10 +++-
plugins/services/app/views/services/index.rhtml | 25 +++++++---
plugins/services/shortcuts.yml | 9 ++++
.../test/functional/services_controller_test.rb | 49 +++++++------------
5 files changed, 59 insertions(+), 44 deletions(-)

diff --git a/plugins/services/app/controllers/services_controller.rb
b/plugins/services/app/controllers/services_controller.rb
index 9d86f9d..2b72bf6 100644
--- a/plugins/services/app/controllers/services_controller.rb
+++ b/plugins/services/app/controllers/services_controller.rb
@@ -26,9 +26,10 @@ class ServicesController < ApplicationController
# GET /services.xml
def index
return unless client_permissions
+
@services = []
begin
- @services = @client.find(:all)
+ @services = @client.find(:all, :params => params)
rescue ActiveResource::ClientError => e
flash[:error] = YaST::ServiceResource.error(e)
end
@@ -40,9 +41,10 @@ class ServicesController < ApplicationController
end

def execute
+
return unless client_permissions
- @service = @client.find(params[:service_id])

+ # PUT /services/1.xml
response = @client.put(params[:service_id], :execute => params[:id])

# we get a hash with exit, stderr, stdout
@@ -54,10 +56,10 @@ class ServicesController < ApplicationController
@result_string << ret["stdout"] if ret["stdout"]
@result_string << ret["stderr"] if ret["stderr"]
@error_string = ret["exit"].to_s
- if ret["exit"] == 0
+ if ret["exit"] == 0 || ret["exit"] == "0"
@error_string = _("success")
end
- render(:partial =>'result')
+ render(:partial =>'result', :params => params)
end


diff --git a/plugins/services/app/views/services/_result.rhtml
b/plugins/services/app/views/services/_result.rhtml
index 3af3d5f..7e38e85 100644
--- a/plugins/services/app/views/services/_result.rhtml
+++ b/plugins/services/app/views/services/_result.rhtml
@@ -15,6 +15,12 @@
<td class="last"><%=h @result_string %></td>
</tr>
</table>
- <p><a href="services" class="button"><%=_("Back")%></a></p>
+ <p>
+ <% if params.has_key?("custom") -%>
+ <a href="services?custom=1" class="button"><%=_("Back")%></a>
+ <% else -%>
+ <a href="services" class="button"><%=_("Back")%></a>
+ </p>
+ <% end -%>
+ </div>
</div>
- </div>
\ No newline at end of file
diff --git a/plugins/services/app/views/services/index.rhtml
b/plugins/services/app/views/services/index.rhtml
index 6e44625..3ff8399 100644
--- a/plugins/services/app/views/services/index.rhtml
+++ b/plugins/services/app/views/services/index.rhtml
@@ -6,7 +6,15 @@
<div class='plugin-icon'><img src='/icons/yast-online_update.png'/></div>
<div class='plugin-content'>

-<h2><%=_("Services")%></h2>
+<h2><%=
+
+if params.has_key?("custom")
+ _("Custom Services")
+else
+ _("System Services")
+end
+%></h2>
+
<br>

<% unless @permissions[:execute] %>
@@ -19,12 +27,15 @@
<% [ "start", "stop" ].each do |cmd|
if @permissions[:execute] %>
<%=
- link_to_remote cmd,
- :update => "resultdlg",
- :url=>{ :id=> cmd,
- :action => "execute",
- :service_id=> service.name
- }
+ url = {
+ :id => cmd,
+ :action => "execute",
+ :service_id => service.name
+ }
+ url[:custom] = 1 if params.has_key?("custom")
+ link_to_remote cmd,
+ :update => "resultdlg",
+ :url => url
%>
<%
else %>
diff --git a/plugins/services/shortcuts.yml b/plugins/services/shortcuts.yml
index 9fd76ab..af2b2f8 100644
--- a/plugins/services/shortcuts.yml
+++ b/plugins/services/shortcuts.yml
@@ -6,3 +6,12 @@ main:
tags: [ init, script, service ]
title: System Services
description: Manage the LSB init scripts
+
+custom:
+# FIXME: use the correct icon
+ icon: '/icons/yast-online_update.png'
+ url: /services?custom=1
+ groups: [ Services ]
+ tags: [ init, script, service ]
+ title: Custom Services
+ description: Manage custom service
diff --git a/plugins/services/test/functional/services_controller_test.rb
b/plugins/services/test/functional/services_controller_test.rb
index f3dd307..a43049e 100644
--- a/plugins/services/test/functional/services_controller_test.rb
+++ b/plugins/services/test/functional/services_controller_test.rb
@@ -1,45 +1,32 @@
require 'test_helper'

class ServicesControllerTest < ActionController::TestCase
- def test_should_get_index
- get :index
- assert_response :success
- assert_not_nil assigns(:services)
- end

- def test_should_get_new
- get :new
- assert_response :success
- end

- def test_should_create_service
- assert_difference('Service.count') do
- post :create, :service => { }
+ class Proxy
+ attr_accessor :result, :permissions, :timeout
+ def find
+ return result
end
-
- assert_redirected_to service_path(assigns(:service))
end

- def test_should_show_service
- get :show, :id => services(:one).id
- assert_response :success
+ def setup
+ ServicesController.any_instance.stubs(:login_required)
+ @controller = ServicesController.new
+ @request = ActionController::TestRequest.new
+ # http://railsforum.com/viewtopic.php?id=1719
+ @request.session[:account_id] = 1 # defined in fixtures
+ @permissions = { :read => true, :execute => true }
+ @proxy = Proxy.new
+ @proxy.permissions = @permissions
+ @proxy.result = @result
end

- def test_should_get_edit
- get :edit, :id => services(:one).id
+ def test_should_get_index
+
YaST::ServiceResource.stubs(:proxy_for).with('org.opensuse.yast.modules.yapi.services').returns(@proxy)
+ get :index
assert_response :success
+ assert_not_nil assigns(:services)
end

- def test_should_update_service
- put :update, :id => services(:one).id, :service => { }
- assert_redirected_to service_path(assigns(:service))
- end
-
- def test_should_destroy_service
- assert_difference('Service.count', -1) do
- delete :destroy, :id => services(:one).id
- end
-
- assert_redirected_to services_path
- end
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages