diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-21 12:12:17 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-21 12:12:17 +0200 |
commit | c93e1fea3a623d6d214c3fcb7b33cdd93c774937 (patch) | |
tree | 65da779b62904e18bc1fbfd441da1c347d1139dd /sonar-server/src/main | |
parent | b6b56822d8206c05510da48678dea8021b5be109 (diff) | |
download | sonarqube-c93e1fea3a623d6d214c3fcb7b33cdd93c774937.tar.gz sonarqube-c93e1fea3a623d6d214c3fcb7b33cdd93c774937.zip |
SONAR-4301 Add sort on issue search page
Diffstat (limited to 'sonar-server/src/main')
9 files changed, 75 insertions, 16 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java b/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java index 515b240daab..f0fb6517564 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java @@ -46,6 +46,7 @@ import org.sonar.core.user.AuthorizationDao; import org.sonar.server.platform.UserSession; import javax.annotation.CheckForNull; + import java.util.Collection; import java.util.List; import java.util.Map; @@ -117,7 +118,7 @@ public class DefaultIssueFinder implements IssueFinder { Set<Long> pagedIssueIds = pagedIssueIds(authorizedIssues, paging); // 4. Load issues and their related data (rules, components, comments, action plans, ...) - Collection<IssueDto> pagedIssues = issueDao.selectByIds(pagedIssueIds, sqlSession); + Collection<IssueDto> pagedIssues = issueDao.selectByIds(pagedIssueIds, query.sort(), query.asc(), sqlSession); Map<String, DefaultIssue> issuesByKey = newHashMap(); List<Issue> issues = newArrayList(); Set<Integer> ruleIds = Sets.newHashSet(); diff --git a/sonar-server/src/main/java/org/sonar/server/issue/PublicRubyIssueService.java b/sonar-server/src/main/java/org/sonar/server/issue/PublicRubyIssueService.java index eac63549e25..f9ffe8071f9 100644 --- a/sonar-server/src/main/java/org/sonar/server/issue/PublicRubyIssueService.java +++ b/sonar-server/src/main/java/org/sonar/server/issue/PublicRubyIssueService.java @@ -32,6 +32,7 @@ import org.sonar.api.web.UserRole; import org.sonar.server.util.RubyUtils; import javax.annotation.Nullable; + import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -84,7 +85,8 @@ public class PublicRubyIssueService implements RubyIssueService { builder.pageIndex(RubyUtils.toInteger(props.get("pageIndex"))); String sort = (String) props.get("sort"); if (sort != null) { - builder.sort(IssueQuery.Sort.valueOf(sort)); + builder.sort(IssueQuery.Sort.valueOf(sort.toUpperCase())); + builder.asc(RubyUtils.toBoolean(props.get("asc"))); } return builder.build(); } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb index c10e77552b6..ff855c03b5c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/issues_controller.rb @@ -32,7 +32,6 @@ class IssuesController < ApplicationController @filter.criteria=criteria_params @filter.execute - # TODO replace by project from issues result API @project = Project.by_key(@filter.criteria('componentRoots')).root_project if @filter.criteria('componentRoots') end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 2b8617e2bff..013da3c1bb8 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -912,5 +912,4 @@ module ApplicationHelper html end - end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/issues_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/issues_helper.rb new file mode 100644 index 00000000000..fe629dc62da --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/issues_helper.rb @@ -0,0 +1,32 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2008-2013 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +module IssuesHelper + + def column_html(filter, column_label, column_tooltip, sort) + filter_sort = filter.criteria[:sort] + filter_asc = filter.criteria[:asc] == 'true' ? true : false + html = link_to_function(h(column_label), "refreshList('#{escape_javascript sort}',#{!filter_asc}, #{filter.criteria[:page]||1})", :title => h(column_tooltip)) + if sort == filter_sort + html << (filter_asc ? image_tag("asc12.png") : image_tag("desc12.png")) + end + html + end + +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/issue_filter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/issue_filter.rb index 32d30ee96bf..5bce516bb72 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/issue_filter.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/issue_filter.rb @@ -20,9 +20,6 @@ require 'set' class IssueFilter - CRITERIA_SEPARATOR = '|' - CRITERIA_KEY_VALUE_SEPARATOR = ',' - attr_reader :paging, :issues, :issues_result def criteria(key=nil) @@ -75,7 +72,9 @@ class IssueFilter @issues_result = nil @paging = nil @issues = nil - criteria['pageSize'] = 25 + criteria['pageSize'] = 100 + criteria['sort'] ||= 'CREATION_DATE' + criteria['asc'] ||= 'false' self end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb index 3bd595a6eac..f4e75cd8afe 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_list.html.erb @@ -1,3 +1,22 @@ +<% content_for :script do %> + <script> + var filterCriteria = <%= @filter.criteria.to_json -%>; + + function refreshList(sort, asc, page) { + $j('#issue-filter-foot_pages').hide(); + $j('#issue-filter-foot_loading').show(); + + filterCriteria['sort']=sort; + filterCriteria['asc']=asc; + filterCriteria['pageIndex']=page; + var url=baseUrl + '/issues/search?' + $j.param(filterCriteria); + + window.location = url; + return false; + } + </script> +<% end %> + <% if @filter.issues && !@filter.issues.empty? colspan = 8 @@ -7,10 +26,10 @@ <thead> <tr> <th width="1%" nowrap> - <%= message('severity_abbreviated') -%> + <%= column_html(@filter, message('severity_abbreviated'), message('severity'), 'SEVERITY') %> </th> <th width="1%" nowrap> - <%= message('status_abbreviated') -%> + <%= column_html(@filter, message('status_abbreviated'), message('status'), 'STATUS') %> </th> <th> <%= message('description') -%> @@ -19,16 +38,16 @@ <%= message('component') -%> </th> <th> - <%= message('issue_filter.header.assignee') -%> + <%= column_html(@filter, message('issue_filter.header.assignee'), message('issue_filter.header.assignee'), 'ASSIGNEE') %> </th> <th> <%= message('issue_filter.header.action_plan') -%> </th> <th> - <%= message('issue_filter.header.creation_date') -%> + <%= column_html(@filter, message('issue_filter.header.creation_date'), message('issue_filter.header.creation_date'), 'CREATION_DATE') %> </th> <th> - <%= message('issue_filter.header.update_date') -%> + <%= column_html(@filter, message('issue_filter.header.update_date'), message('issue_filter.header.update_date'), 'UPDATE_DATE') %> </th> </tr> </thead> @@ -44,7 +63,7 @@ <img src="<%= ApplicationController.root_context -%>/images/status/<%= issue.status -%>.png" title="<%= message(issue.status.downcase).capitalize -%>"/> </td> <td> - <%= link_to h(issue.message), :controller => 'issue', :action => 'view', :id => issue.key -%> + <%= link_to h(truncate(issue.message, :length => 100)), :controller => 'issue', :action => 'view', :id => issue.key -%> </td> <td> <%= h @filter.issues_result.component(issue).name -%> @@ -72,7 +91,7 @@ <% end %> </tbody> - <%= paginate_java(@filter.paging, :colspan => colspan, :include_loading_icon => true) { |label, page_id| + <%= paginate_java(@filter.paging, :colspan => colspan, :id => 'issue-filter-foot', :include_loading_icon => true) { |label, page_id| link_to(label, @filter.criteria.merge({:pageIndex => page_id})) } -%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb index 21c332a60c2..102b50aab1f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/_sidebar.html.erb @@ -1,10 +1,13 @@ <ul class="sidebar gray-sidebar"> <form method="GET" action="<%= ApplicationController.root_context -%>/issues/search" > + + <input type="hidden" name="sort" value="<%= @filter.criteria('sort')-%>"/> + <input type="hidden" name="asc" value="<%= @filter.criteria('asc') -%>"/> + <li class="sidebar-title"> <%= message('issue_filter.new_search') -%> </li> <li id="criteria-project" class="marginbottom5"> - <!-- TODO replace by project from issues result API--> <% selected_project = @project if @filter.criteria('componentRoots') %> <%= message 'issue_filter.criteria.project' -%>: <%= resource_select_tag 'componentRoots', :resource_type_property => 'supportsGlobalDashboards', :width => '100%', diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb index 1234b293a22..ffc32f12e80 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/issues/search.html.erb @@ -3,9 +3,14 @@ <%= render :partial => 'issues/sidebar' -%> </div> + <div class="page-split-right"> <div id="content"> <div class="marginbottom10"> + <% if @filter.issues_result && @filter.issues_result.securityExclusions() %> + <p class="notes"><%= message('results_not_display_due_to_security') -%></p> + <% end %> + <%= render :partial => 'list' -%> </div> </div> |