diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-03 12:04:28 +0100 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-03-03 12:04:28 +0100 |
commit | 60b4d628841dd0463591825fa29cff5899e5d301 (patch) | |
tree | d5fede46d294bd95b6f2bd1e6aade6abeecec51d /sonar-server | |
parent | cb07114c603f03d49958e731b2b2e01d53769aff (diff) | |
download | sonarqube-60b4d628841dd0463591825fa29cff5899e5d301.tar.gz sonarqube-60b4d628841dd0463591825fa29cff5899e5d301.zip |
SONAR-2218 integrate new resource viewers to measures drilldown
Diffstat (limited to 'sonar-server')
7 files changed, 88 insertions, 29 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb index 4a1642a57ea..a2df02fae1a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/browse_controller.rb @@ -26,9 +26,9 @@ class BrowseController < ApplicationController @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 @@ -62,8 +62,14 @@ class BrowseController < ApplicationController 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 @@ -136,7 +142,7 @@ class BrowseController < ApplicationController end filter_lines_by_date() - render :action => 'index' + render :action => 'index', :layout => !request.xhr? end @@ -191,7 +197,7 @@ class BrowseController < ApplicationController end end end - render :action => 'index' + render :action => 'index', :layout => !request.xhr? end @@ -200,7 +206,7 @@ class BrowseController < ApplicationController def render_source load_sources() filter_lines_by_date() - render :action => 'index' + render :action => 'index', :layout => !request.xhr? end @@ -265,10 +271,10 @@ class BrowseController < ApplicationController 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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_header_violations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_header_violations.html.erb index ad5aadeed0d..d519d2566b4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_header_violations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_header_violations.html.erb @@ -7,27 +7,35 @@ <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> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_rules_filter.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_rules_filter.html.erb index ea36a4da8d1..5caa1f63b3b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_rules_filter.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_rules_filter.html.erb @@ -18,7 +18,7 @@ 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 %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_tabs.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_tabs.html.erb index bfa00de46dd..7eb35e6517b 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_tabs.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/_tabs.html.erb @@ -162,7 +162,15 @@ span.rulename a:hover { </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> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/extension.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/extension.html.erb index f45db54fb12..9310d500de3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/extension.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/extension.html.erb @@ -1,15 +1,18 @@ <%= 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() %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb index d4b5f7db905..b005c15c064 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/browse/index.html.erb @@ -14,15 +14,29 @@ <% 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) -%> @@ -33,7 +47,7 @@ <% 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 %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb index 6698666f014..12fa8ac1ec2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/drilldown/measures.html.erb @@ -1,6 +1,25 @@ <%= 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> @@ -42,7 +61,7 @@ <%= 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'}) %> @@ -70,4 +89,5 @@ $$('#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> |