ref: refs/heads/use-activeresource
commit b6da1f9e74e394c663fef0cb7205a106584468b6
Author: Stefan Schubert
Date: Mon Sep 14 10:25:11 2009 +0200
installing all patches at once
---
.../app/controllers/patch_updates_controller.rb | 58 +++++++++++++++++++-
.../patch_updates/_patch_installation.html.erb | 20 +++++++
.../views/patch_updates/_patch_summary.html.erb | 7 ++-
3 files changed, 81 insertions(+), 4 deletions(-)
diff --git a/plugins/patch_updates/app/controllers/patch_updates_controller.rb b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
index 10daa3e..7671db0 100644
--- a/plugins/patch_updates/app/controllers/patch_updates_controller.rb
+++ b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
@@ -52,8 +52,62 @@ class PatchUpdatesController < ApplicationController
render :partial => "patches"
end
- # POST /patch_updates/1
- # POST /patch_updates/1.xml
+ # POST /patch_updates/start_install_all
+ # Starting installation of all proposed patches
+ def start_install_all
+ logger.debug "Start installation of all patches"
+
+ flash.clear #no flash from load_proxy
+ respond_to do |format|
+ format.html { render :partial => "patch_installation", :locals => { :patch => _("Installing all patches..."), :error => nil , :go_on => true }}
+ end
+ end
+
+ def stop_install_all
+ logger.debug "Stopping installation of all patches"
+
+ flash.clear #no flash from load_proxy
+ respond_to do |format|
+ format.html { render :partial => "patch_installation", :locals => { :patch => _("Installing stopped"), :error => nil , :go_on => false }}
+ end
+ end
+
+ # POST /patch_updates/install_all
+ # Install each patch. This function will be called periodically from the controll center
+ def install_all
+ logger.debug "Installing one available patch...."
+ error = nil
+ patch_updates = nil
+ begin
+ patch_updates = load_proxy 'org.opensuse.yast.system.patches', :all
+ rescue Exception => e
+ error = e
+ patch_updates = nil
+ end
+
+ last_patch = ""
+ if patch_updates
+ #installing the first available patch
+ ret = true
+ #ret = patch_updates[0].save #install patch
+ logger.info "Installing patch :#{patch_updates[0].name}"
+ last_patch = patch_updates[0].name
+ else
+ erase_redirect_results #reset all redirects
+ erase_render_results
+ end
+
+ respond_to do |format|
+ if last_patch.blank?
+ format.html { render :partial => "patch_installation", :locals => { :patch => _("Installation finished"), :error => error , :go_on => false }}
+ else
+ format.html { render :partial => "patch_installation", :locals => { :patch => last_patch, :error => error , :go_on => true }}
+ end
+ end
+ end
+
+ # POST /patch_updates/install
+ # Installing one or more patches which has given via param
def install
update_array = []
diff --git a/plugins/patch_updates/app/views/patch_updates/_patch_installation.html.erb b/plugins/patch_updates/app/views/patch_updates/_patch_installation.html.erb
new file mode 100644
index 0000000..8336eb9
--- /dev/null
+++ b/plugins/patch_updates/app/views/patch_updates/_patch_installation.html.erb
@@ -0,0 +1,20 @@
+<% javascript_tag do -%>
+ check_var = <%= go_on%>;
+<% end -%>
+
+<%= report_error(error, _("An error occured while installing patches.")) if error %>
+
+<div class="status_patches">
+ <% link_to "patch_updates" do %>
+ <% if error %>
+ <div class="status-icon error"></div>
+ <% else %>
+ <div class="status-icon ok"></div>
+ <% end %>
+ <span><%= patch %></span>
+ <% end %>
+ <% if go_on %>
+ <%= button_to_remote _("Stop"), :update =>"status_patches", :url=>{ :controller => :patch_updates, :action => :stop_install_all}, :confirm => _("Are you sure?") %>
+ <% end %>
+ <%= periodically_call_remote(:condition => "check_var == true",:url=>{ :controller => :patch_updates, :action => :install_all}, :udpate =>"status_patches", :frequency => 15) %>
+</div>
diff --git a/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb b/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb
index 88e3bde..35fcb62 100644
--- a/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb
+++ b/plugins/patch_updates/app/views/patch_updates/_patch_summary.html.erb
@@ -5,6 +5,7 @@
<div class="status-icon warning"></div>
<%= _("No information about patches available") %>
<% else %>
+ <% label = [] %>
<% link_to "patch_updates" do %>
<% if patch[:security]+patch[:important] > 0 %>
<div class="status-icon error"></div>
@@ -14,8 +15,6 @@
<div class="status-icon ok"></div>
<% end %>
-
- <% label = [] %>
<% if patch[:security] > 0 %>
<% label << _("Security Updates: #{patch[:security]}") %>
<% end %>
@@ -30,5 +29,9 @@
<% end %>
<span><%= label.join(", ") %></span>
<% end %>
+ <% if not label.empty? %>
+ <%= button_to_remote "Update All", :update =>"status_patches", :url => { :controller => :patch_updates, :action => :start_install_all}, :confirm => _("Updating all. Are you sure?") %>
+ <% end %>
+
<% end %>
</div>
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org