Mailinglist Archive: yast-commit (1914 mails)

< Previous Next >
[yast-commit] <web-client> basesystem : First iteration for the vendor bugzilla url in the crash page:
  • From: Duncan Mac-Vicar P <dmacvicar@xxxxxxx>
  • Date: Thu, 27 Aug 2009 19:21:18 +0200
  • Message-id: <E1Mlexg-0003kD-PO@xxxxxxxxxxxxxxxx>
ref: refs/heads/basesystem
commit 2f581d594b22b64504ff388ca2d95c633ee8b7cd
Author: Duncan Mac-Vicar P <dmacvicar@xxxxxxx>
Date: Thu Aug 27 19:21:18 2009 +0200

First iteration for the vendor bugzilla url in the crash page:

- improve exception handling for Ajax requests, that is, if an exception
is thrown with an ajax request, we dont show the rescue page inside
the updated div, but a custom much more compact partial, with a
balloon popup to see details

For this the partial has to generate much more smart divs containing
the exception information, because they may be multiple rescue
partials at the same time.

The generated divs are named:
error-12345677-backtrace
error-12345566-details-link

and so on, where the number is the object_id of the Exception thrown.
---
.../app/controllers/patch_updates_controller.rb | 27 ++++++++---------
.../app/controllers/application_controller.rb | 9 +++++-
webclient/app/views/layouts/main.rhtml | 5 ++-
.../app/views/shared/_exception_trap.html.erb | 30 ++++++++++++++++++++
4 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/plugins/patch_updates/app/controllers/patch_updates_controller.rb
b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
index b7a0320..02623fe 100644
--- a/plugins/patch_updates/app/controllers/patch_updates_controller.rb
+++ b/plugins/patch_updates/app/controllers/patch_updates_controller.rb
@@ -21,27 +21,26 @@ class PatchUpdatesController < ApplicationController
patch_updates = nil
end

- unless patch_updates
+ patches_summary = nil
+
+ if patch_updates
+ patches_summary = { :security => 0, :important => 0, :optional => 0}
+
+ [:security, :important, :optional].each do |patch_type|
+ patches_summary[patch_type] = patch_updates.collect { |p| p.kind ==
patch_type.to_s }.size
+ end
+ else
erase_redirect_results #reset all redirects
erase_render_results
flash.clear #no flash from load_proxy
- render :partial => "patch_summary", :locals => { :patch => nil }
- return false
end

- patches = { :security => 0, :important => 0, :optional => 0}
-
- patch_updates.each do |patch|
- case patch.kind
- when "security": patches[:security] += 1
- when "important": patches[:important] += 1
- when "optional": patches[:optional] += 1
- else
- logger.warn "unknown patch kind #{patch.kind}"
- end
+ respond_to do |format|
+ format.html { render :partial => "patch_summary", :locals => { :patch =>
patches_summary } }
+ format.json { render :json => patches_summary }
end

- render :partial => "patch_summary", :locals => { :patch => patches }
+
end

def load_filtered
diff --git a/webclient/app/controllers/application_controller.rb
b/webclient/app/controllers/application_controller.rb
index 3d208e1..6197576 100644
--- a/webclient/app/controllers/application_controller.rb
+++ b/webclient/app/controllers/application_controller.rb
@@ -23,7 +23,14 @@ class ApplicationController < ActionController::Base

def exception_trap(e)
logger.error "***" + e.to_s
- #render :text => "I am sorry"
+
+ # for ajax request render a different template, much less verbose
+ if request.xhr?
+ logger.error "Error during ajax request"
+ render :partial => "shared/exception_trap", :locals => {:error => e} and
return
+ #render :text => "shit" and return
+ end
+
render :template => "shared/exception_trap", :locals => {:error => e}
return
end
diff --git a/webclient/app/views/layouts/main.rhtml
b/webclient/app/views/layouts/main.rhtml
index 182e6e8..fc8618f 100644
--- a/webclient/app/views/layouts/main.rhtml
+++ b/webclient/app/views/layouts/main.rhtml
@@ -7,7 +7,8 @@
<link rel="stylesheet" href="/stylesheets/yast.css" type="text/css"
media="screen" title="default" charset="utf-8" />
<link rel="stylesheet" href="/stylesheets/style.css" type="text/css"
media="screen" title="default" charset="utf-8" />
<link rel="stylesheet" href="/stylesheets/jquery.jqplot.css" type="text/css"
media="screen" title="default" charset="utf-8" />
-
+ <!-- buble tooltips -->
+ <link rel="stylesheet" href="/stylesheets/jquery.bt.css" type="text/css"
media="screen" title="default" charset="utf-8" />

<script type="text/javascript" charset="utf-8" src="/inc/jquery.js"></script>
<script type="text/javascript" charset="utf-8"
src="/inc/jquery.query.js"></script>
@@ -18,6 +19,8 @@

<script type="text/javascript" charset="utf-8"
src="/javascripts/script.js"></script>
<script type="text/javascript" charset="utf-8"
src="/javascripts/jquery.validate.js"></script>
+ <!-- buble tooltips -->
+ <script type="text/javascript" charset="utf-8"
src="/javascripts/jquery.bt.js"></script>

<!-- browser detection -->
<script type="text/javascript" charset="utf-8"
src="/javascripts/jqbrowser-compressed.js"></script>
diff --git a/webclient/app/views/shared/_exception_trap.html.erb
b/webclient/app/views/shared/_exception_trap.html.erb
new file mode 100644
index 0000000..3e53577
--- /dev/null
+++ b/webclient/app/views/shared/_exception_trap.html.erb
@@ -0,0 +1,30 @@
+
+<% error_id = error.nil? ? rand(10000) : error.object_id %>
+
+<script type="text/javascript">
+$(document).ready(
+ function() {
+ $('#error-<%= error_id %>-balloon-content').hide();
+ $('#error-<%= error_id %>-details-link').click(
+ $('#error-<%= error_id %>-details-link').bt({
+ contentSelector: "$('#error-<%= error_id %>-balloon-content').html()",
+ trigger: 'click',
+ positions: ['left', 'right', 'bottom']
+ }));
+ $('#error-<%= error_id %>-show-backtrace-link').click(function() {
$('#error-<%= error_id %>-backtrace').hide();$(this).next().show();return
false; });
+ });
+</script>
+
+<div id="error-<%= error_id %>-balloon-content">
+ <p><strong>Error message:</strong>: <%= error.message %></p>
+ <p><a
href="https://bugzilla.novell.com/enter_bug.cgi?classification=7340&product=openSUSE+11.2&submit=Use+This+Product&component=WebYaST&format=guided";>Report
bug</a></p>
+ <p><a href="#" id="error-<%= error_id %>-show-backtrace-link">Show
details</a>
+ <pre id="error-<%= error_id %>-backtrace" style="display: none"><%=
(error.nil? || error.backtrace.nil? || error.backtrace.blank?) ? "No
information available" : error.backtrace.join("\n") %></pre>
+</div>
+
+<div class="status-icon error"></div><div>There was a problem retrieving the
information (<a href="#" id="error-<%= error_id
%>-details-link">more..</a>)</div>
+
+<pre id="backtrace-<%= error_id %>" style="display: none">
+<%= (error.nil? || error.backtrace.nil? || error.backtrace.blank?) ? "No
information available" : error.backtrace.join("\n") %>
+</pre>
+
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages