ref: refs/heads/master
commit 2a425d2f32f98f09cb5a106ae50ef66892a00aab
Author: Josef Reidinger
Date: Tue Jul 14 15:23:39 2009 +0200
make robust to problems with proxy also for patch commit
---
.../app/controllers/patch_updates_controller.rb | 40 ++----
.../app/views/patch_updates/index.html.erb | 130 ++++++++++----------
2 files changed, 80 insertions(+), 90 deletions(-)
diff --git a/plugins/patch_updates/app/controllers/patch_updates_controller.rb b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
index c25499c..6291dab 100644
--- a/plugins/patch_updates/app/controllers/patch_updates_controller.rb
+++ b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
@@ -4,25 +4,18 @@ class PatchUpdatesController < ApplicationController
before_filter :login_required
layout 'main'
-
+ include ProxyLoader
# GET /patch_updates
# GET /patch_updates.xml
def index
- @proxy = YaST::ServiceResource.proxy_for('org.opensuse.yast.system.patches')
- begin
- @patch_updates = @proxy.find(:all) || []
- rescue ActiveResource::ClientError => e
- flash[:error] = YaST::ServiceResource.error(e)
- end
+ @patch_updates = load_proxy 'org.opensuse.yast.system.patches', :all
logger.debug "Available patches: #{@patch_updates.inspect}"
end
# POST /patch_updates/1
# POST /patch_updates/1.xml
- def install
- proxy = YaST::ServiceResource.proxy_for('org.opensuse.yast.system.patches')
- ok = true
+ def install
update_array = []
#search for patches and collect the ids
@@ -31,25 +24,20 @@ class PatchUpdatesController < ApplicationController
update_array << value
end
}
- update_array.each { |patch_id|
- begin
- update = proxy.find(patch_id)
- rescue ActiveResource::ClientError => e
- flash[:error] = YaST::ServiceResource.error(e)
- ok = false
- end
-
- if ok
+ update_array.each do |patch_id|
+ update = load_proxy 'org.opensuse.yast.system.patches', patch_id
+
+ if update
begin
- ok = update.save
+ update.save
logger.debug "updated #{patch_id}"
- rescue ActiveResource::ClientError => e
- flash[:error] = YaST::ServiceResource.error(e)
- ok = false
- end
- flash[:notice] = _("Patch has been installed.") if ok
+ flash[:notice] = _("Patch has been installed.")
+ rescue ActiveResource::ClientError => e
+ flash[:error] = YaST::ServiceResource.error(e)
+ ExceptionLogger.log_exception e
+ end
end
- }
+ end
redirect_to({:controller=>"patch_updates", :action=>"index"})
end
end
diff --git a/plugins/patch_updates/app/views/patch_updates/index.html.erb b/plugins/patch_updates/app/views/patch_updates/index.html.erb
index b255f01..83d2b64 100644
--- a/plugins/patch_updates/app/views/patch_updates/index.html.erb
+++ b/plugins/patch_updates/app/views/patch_updates/index.html.erb
@@ -1,84 +1,86 @@
-<%= javascript_include_tag 'jquery' %>
-<%= javascript_include_tag 'jquery-form' %>
-<%= javascript_include_tag 'application' %>
-<%= javascript_include_tag 'effects.core' %>
-<%= javascript_include_tag 'effects.highlight' %>
-<script type="text/javascript">
- $(document).ready(function() {
+<% if @permissions and @patch_updates %>
+ <%= javascript_include_tag 'jquery' %>
+ <%= javascript_include_tag 'jquery-form' %>
+ <%= javascript_include_tag 'application' %>
+ <%= javascript_include_tag 'effects.core' %>
+ <%= javascript_include_tag 'effects.highlight' %>
+ <script type="text/javascript">
+ $(document).ready(function() {
- $('#All').click(function() {
- var counter = document.getElementById("counter").value;
- var mode = document.getElementById("All").checked;
- for(var i = 0; i < counter; i++) {
- try {
- document.getElementById(i).checked = mode;
- document.getElementById("Security").checked = mode;
- document.getElementById("Important").checked = mode;
- document.getElementById("Green").checked = mode;
- document.getElementById("Optional").checked = mode;
- } catch(err) {
- //alert("error");
- }
- }
- });
-
- $('#selector').click(function(){
- var match = document.getElementById("selector").value;
- var counter = document.getElementById("counter").value;
-
- if (match == "all") {
+ $('#All').click(function() {
+ var counter = document.getElementById("counter").value;
+ var mode = document.getElementById("All").checked;
for(var i = 0; i < counter; i++) {
try {
- document.getElementById("row_" + i).style.display="";
+ document.getElementById(i).checked = mode;
+ document.getElementById("Security").checked = mode;
+ document.getElementById("Important").checked = mode;
+ document.getElementById("Green").checked = mode;
+ document.getElementById("Optional").checked = mode;
} catch(err) {
- alert("error");
+ //alert("error");
}
}
- } else {
- for(var i = 0; i < counter; i++) {
- if ( !(document.getElementById(i).name == match + "_" + i) ) {
+ });
+
+ $('#selector').click(function(){
+ var match = document.getElementById("selector").value;
+ var counter = document.getElementById("counter").value;
+
+ if (match == "all") {
+ for(var i = 0; i < counter; i++) {
try {
- document.getElementById("row_" + i).style.display="none";
+ document.getElementById("row_" + i).style.display="";
} catch(err) {
alert("error");
}
- } else {
- document.getElementById("row_" + i).style.display="";
+ }
+ } else {
+ for(var i = 0; i < counter; i++) {
+ if ( !(document.getElementById(i).name == match + "_" + i) ) {
+ try {
+ document.getElementById("row_" + i).style.display="none";
+ } catch(err) {
+ alert("error");
+ }
+ } else {
+ document.getElementById("row_" + i).style.display="";
+ }
}
}
- }
+ });
});
- });
-</script>
-<style type="text/css">
+ </script>
+ <style type="text/css">
- option[value=security]:before { content:url('/icons/kupdateapplet_red.png'); }
- option[value=important]:before { content:url('/icons/kupdateapplet_yellow.png'); }
- option[value=green]:before { content:url('/icons/kupdateapplet_green.png'); }
- option[value=optional]:before { content:url('/icons/kupdateapplet_optional.png'); }
+ option[value=security]:before { content:url('/icons/kupdateapplet_red.png'); }
+ option[value=important]:before { content:url('/icons/kupdateapplet_yellow.png'); }
+ option[value=green]:before { content:url('/icons/kupdateapplet_green.png'); }
+ option[value=optional]:before { content:url('/icons/kupdateapplet_optional.png'); }
-</style>
+ </style>
-<div class="loading"></div>
-<% if @patch_updates.empty? %>
- <p><%=_("Your system is up to date.") %></p>
-<% else %>
- <p><%=_("Updates available") %></p>
-<% end %>
+ <div class="loading"></div>
+ <% if @patch_updates.empty? %>
+ <p><%=_("Your system is up to date.") %></p>
+ <% else %>
+ <p><%=_("Updates available") %></p>
+ <% end %>
-<% form_for :patch_updates, :url => { :action => "install" }, :html => {:id => "patches-form"} do |form| %>
- <select name="selector" id="selector" size="1">
- <option value="all">All</option>
- <option value="security">Security</option>
- <option value="important">Important</option>
- <option value="green">Green</option>
- <option value="optional">Optional</option>
- </select>
- <div id="patch-table"><%= render :partial => "patches"%></div>
+ <% form_for :patch_updates, :url => { :action => "install" }, :html => {:id => "patches-form"} do |form| %>
+ <select name="selector" id="selector" size="1">
+ <option value="all">All</option>
+ <option value="security">Security</option>
+ <option value="important">Important</option>
+ <option value="green">Green</option>
+ <option value="optional">Optional</option>
+ </select>
+ <div id="patch-table"><%= render :partial => "patches"%></div>
- <input type="checkbox" name="All" id="All">All</input>
+ <input type="checkbox" name="All" id="All">All</input>
-<%= submit_tag _("Update"), :onclick=>"Element.show('progress')", :action => 'install', :class => 'button' -%>
-<a href="/" class="button"><%=_("Back")%></a>
-<% end %>
+ <%= submit_tag _("Update"), :onclick=>"Element.show('progress')", :action => 'install', :class => 'button' -%>
+ <a href="/" class="button"><%=_("Back")%></a>
+ <% end %>
+<% end %>
\ No newline at end of file
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org