@resource = Project.by_key(params[:id])
if (@resource && has_role?(:user, @resource))
+ params[:layout]='false'
@snapshot=@resource.last_snapshot
- params[:layout]='false'
load_extensions()
if @extension
end
end
- selected_tab_id=params[:tab]
- @extension=@extensions.find{|extension| extension.getId()==selected_tab_id} unless selected_tab_id.blank?
+ if !params[:tab].blank?
+ @extension=@extensions.find{|extension| extension.getId()==params[:tab]}
+
+ elsif !params[:metric].blank?
+ metric=Metric.by_key(params[:metric])
+ @extension=@extensions.find{|extension| extension.getDefaultTabForMetrics().include?(metric.key)}
+
+ end
@extension=@extensions.find{|extension| extension.isDefaultTab()} if @extension==nil
end
end
filter_lines_by_date()
- render :action => 'index'
+ render :action => 'index', :layout => !request.xhr?
end
end
end
end
- render :action => 'index'
+ render :action => 'index', :layout => !request.xhr?
end
def render_source
load_sources()
filter_lines_by_date()
- render :action => 'index'
+ render :action => 'index', :layout => !request.xhr?
end
def render_extension()
- render :action => 'extension'
+ render :action => 'extension', :layout => !request.xhr?
end
def render_nothing()
- render :action => 'nothing'
+ render :action => 'nothing', :layout => !request.xhr?
end
end
\ No newline at end of file
<table class="col">
<tr>
- <td><%= image_tag 'priority/BLOCKER.png'-%></td>
+ <td><%= image_tag 'priority/BLOCKER.png' -%></td>
<td class="name">Blocker:</td>
<td class="value"><%= format_measure('blocker_violations', :default => 0) -%></td>
</tr>
+ </table>
+ <table class="col">
<tr>
- <td><%= image_tag 'priority/CRITICAL.png'-%></td>
+ <td><%= image_tag 'priority/CRITICAL.png' -%></td>
<td class="name">Critical:</td>
<td class="value"><%= format_measure('critical_violations', :default => 0) -%></td>
</tr>
+ </table>
+ <table class="col">
<tr>
- <td><%= image_tag 'priority/MAJOR.png'-%></td>
+ <td><%= image_tag 'priority/MAJOR.png' -%></td>
<td class="name">Major:</td>
<td class="value"><%= format_measure('major_violations', :default => 0) -%></td>
</tr>
+ </table>
+ <table class="col">
<tr>
- <td><%= image_tag 'priority/MINOR.png'-%></td>
+ <td><%= image_tag 'priority/MINOR.png' -%></td>
<td class="name">Minor:</td>
<td class="value"><%= format_measure('minor_violations', :default => 0) -%></td>
</tr>
+ </table>
+ <table class="col">
<tr>
- <td><%= image_tag 'priority/INFO.png'-%></td>
+ <td><%= image_tag 'priority/INFO.png' -%></td>
<td class="name">Info:</td>
<td class="value"><%= format_measure('info_violations', :default => 0) -%></td>
</tr>
rule_options<<["#{h rule.name} (#{rule_counts[rule.id]})", rule.key]
end
%>
-<select id="rule" name="rule" class="small" onchange="submit()">
+<select id="rule" name="rule" class="small" onchange="applyOptions()">
<option value="">No filters</option>
<optgroup label="Severity">
<% if blocker_violations && blocker_violations.value>0 %>
</div>
<ul id="source_tabs" class="tabs">
- <% @extensions.each do |extension| %>
- <li><a href="<%= url_for(:overwrite_params => {:tab => extension.getId()}) -%>" class="<%= 'selected' if @extension.getId()==extension.getId() -%>"><%= extension.getTitle() -%></a></li>
+ <% if request.xhr? %>
+ <% @extensions.each do |extension| %>
+ <li><a href="#" onclick="loadAjaxTab('<%= @resource.id -%>','<%= extension.getId() -%>')" class="<%= 'selected' if @extension.getId()==extension.getId() -%>"><%= extension.getTitle() -%></a></li>
+ <% end %>
+ <% else %>
+ <script>function loadTab(url) {$('resource-loading').show();document.location.href=url;return false;}</script>
+ <% @extensions.each do |extension| %>
+ <li><a href="#" onClick="loadTab('<%= url_for(:overwrite_params => {:tab => extension.getId()}) -%>')" class="<%= 'selected' if @extension.getId()==extension.getId() -%>"><%= extension.getTitle() -%></a></li>
+ <% end %>
<% end %>
+ <img src="<%= ApplicationController.root_context -%>/images/loading.gif" id="resource-loading" style="display:none"/>
</ul>
<%= render :partial => 'tabs' -%>
<% if @extension.isGwt() %>
- <%= render :partial => 'gwt/base', :locals => {:resource => @resource, :popup => false, :metric => nil} -%>
- <div id="gwtpage"> </div>
+ <% if request.xhr? %>
+ <div id="gwtpage"> </div>
+ <script>loadGWT('<%= @extension.getId() -%>',<%= @resource.id -%>,'<%= @resource.key -%>', '<%= @resource.name -%>', '<%= @resource.scope -%>', '<%= @resource.qualifier -%>', '<%= @resource.language -%>');</script>
- <!-- for SmartGWT -->
- <script> var isomorphicDir = "<%= "#{ApplicationController.root_context}/deploy/gwt/#{@extension.getId()}" -%>/sc/";</script>
-
-
- <script src="<%= ApplicationController.root_context -%>/deploy/gwt/<%= @extension.getId() -%>/<%= @extension.getId() -%>.nocache.js?<%= sonar_version -%>"></script>
+ <% else %>
+ <%= render :partial => 'gwt/base', :locals => {:resource => @resource, :popup => false, :metric => nil} -%>
+ <div id="gwtpage"> </div>
+ <!-- for SmartGWT -->
+ <script>var isomorphicDir = "<%= "#{ApplicationController.root_context}/deploy/gwt/#{@extension.getId()}" -%>/sc/";</script>
+ <script src="<%= ApplicationController.root_context -%>/deploy/gwt/<%= @extension.getId() -%>/<%= @extension.getId() -%>.nocache.js?<%= sonar_version -%>"></script>
+ <% end %>
<% else # ruby on rails page %>
<%= render :inline => @page.getTemplate() %>
<% end %>
<div id="source_options">
- <form method="GET" action="<%= url_for :controller => 'browse', :id => @resource.key -%>">
+ <script>
+ applyOptions=function() {
+ $('resource-loading').show();
+ <% if request.xhr? %>
+ var params = Form.serialize($('options-form'));
+ new Ajax.Updater('resource_container', '<%= url_for :controller => 'browse', :id => @resource.key -%>', {asynchronous:true, parameters:params});
+ return true;
+ <% else %>
+ $('options-form').submit();
+ return false;
+ <% end %>
+ };
+ </script>
+ <form method="GET" action="<%= url_for :controller => 'browse', :id => @resource.key -%>" id="options-form">
<input type="hidden" name="tab" value="<%= params[:tab] -%>"/>
+ <input type="hidden" name="metric" value="<%= params[:metric] -%>"/>
<% if @scm_available %>
- <input type="checkbox" value="true" name="scm" id="scm" <%= 'checked' if @display_scm -%> onclick="submit()"/>
+ <input type="checkbox" value="true" name="scm" id="scm" <%= 'checked' if @display_scm -%> onclick="applyOptions()"/>
<label for="scm">Authors</label>
<% end %>
<% if @snapshot.project_snapshot.periods? %>
- <select id="period" name="period" class="small" onchange="submit()">
+ <select id="period" name="period" class="small" onchange="applyOptions()">
<option value="">Time changes...</option>
<%= period_select_options(@snapshot, 1) -%>
<%= period_select_options(@snapshot, 2) -%>
<% end %>
<% if @expandable %>
- <input type="checkbox" value="true" name="expand" id="expand" <%= 'checked' if @expanded -%> onclick="submit()"/>
+ <input type="checkbox" value="true" name="expand" id="expand" <%= 'checked' if @expanded -%> onclick="applyOptions()"/>
<label for="expand">Expand</label>
<% end %>
<%= render :partial => 'gwt/base', :locals => {:resource => @highlighted_resource, :popup => false, :metric => @metric.key} %>
<%= render :partial => 'gwt/resource_viewers', :locals => {:resource => @drilldown.highlighted_resource || @project} %>
+<script>
+ /* display resource */
+ function d(resourceId) {
+ new Ajax.Updater('resource_container', '<%= ApplicationController.root_context-%>/browse/' + resourceId + '?metric=<%= @metric.key -%>', {asynchronous:true, evalScripts:true});
+ return false;
+ }
+
+ function loadAjaxTab(resourceId, tab) {
+ $('resource-loading').show();
+ new Ajax.Updater('resource_container', '<%= ApplicationController.root_context-%>/browse/' + resourceId + '?tab=' + tab, {asynchronous:true, evalScripts:true});
+ return false;
+ }
+
+ /* display GWT component, executed from tabs */
+ function loadGWT(gwtId, resourceId, resourceKey, resourceName, resourceScope, resourceQualifier, resourceLanguage) {
+ config["resource"]=[{"id": resourceId, "key": resourceKey, "name" : resourceName, "scope": resourceScope, "qualifier": resourceQualifier, "lang": resourceLanguage}];
+ modules[gwtId]();
+ }
+</script>
<div class="dashbox">
<% if @characteristic %>
<h3><%= @highlighted_metric.short_name -%> / <%= h(@characteristic.name(true)) -%></h3>
<%= link_to(resource.name, {:only_path => true, :overwrite_params => {:rids => nil, :id => resource.copy_resource_id}}) -%>
<% else %>
<%= qualifier_icon(resource) %>
- <a href="#" onclick="sr('<%= resource.id -%>');" alt="<%= resource.name(true) -%>" title="<%= resource.name(true) -%>"><%= resource.name(false) -%></a>
+ <a href="#" onclick="d(<%= resource.id -%>)" alt="<%= resource.name(true) -%>" title="<%= resource.name(true) -%>"><%= resource.name(false) -%></a>
<% end
else %>
<%= link_to(image_tag('zoom.png'), {:id => resource.id, :metric => @metric.id}, {:class => 'nolink'}) %>
$$('#col_<%= column.scope -%> tr.selected').each(function(item) {item.scrollIntoView(true);});
<% end %>
</script>
-<div id="pageselector"> </div>
\ No newline at end of file
+
+<div id="resource_container"> </div>