aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-12-19 10:59:07 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-12-19 10:59:07 +0100
commit14211c7c028056ce00756aaeee88e1256c16dc6e (patch)
tree78d56f825bb93bac5753e5aba176ef93c2d8cfaf
parent7e60267ea6b1a11bac6ae7331ec0c609a4468c6a (diff)
downloadsonarqube-14211c7c028056ce00756aaeee88e1256c16dc6e.tar.gz
sonarqube-14211c7c028056ce00756aaeee88e1256c16dc6e.zip
Fix sorting by time + fix sorting in list widget
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterRow.java8
-rw-r--r--sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterSql.java73
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_list.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb22
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb15
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb15
-rw-r--r--sonar-server/src/main/webapp/stylesheets/layout.css15
9 files changed, 70 insertions, 88 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
index 787986ec9fd..e0ec07ada5c 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -394,7 +394,7 @@ measure_filter.shared_with_all_users=Shared with all users
measure_filter.private=Private
measure_filter.manage.shared_filters=Shared Filters
measure_filter.manage.my_filters=My Filters
-measure_filter.criteria.what=What?
+measure_filter.criteria.what=What? Projects, files...
measure_filter.criteria.age=Age
measure_filter.criteria.date=Date
measure_filter.criteria.only_favourites=Favourites only
diff --git a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterRow.java b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterRow.java
index a168e340111..3ad737195db 100644
--- a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterRow.java
+++ b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterRow.java
@@ -21,14 +21,14 @@ package org.sonar.core.measure;
import org.apache.commons.lang.StringUtils;
-import java.sql.Date;
+import java.sql.Timestamp;
public class MeasureFilterRow {
private final long snapshotId;
private final long resourceId;
private final long resourceRootId;
private String sortText = null;
- private Date sortDate = null;
+ private Timestamp sortDate = null;
private Double sortDouble = null;
MeasureFilterRow(long snapshotId, long resourceId, long resourceRootId) {
@@ -57,11 +57,11 @@ public class MeasureFilterRow {
this.sortText = StringUtils.defaultString(s);
}
- Date getSortDate() {
+ Timestamp getSortDate() {
return sortDate;
}
- void setSortDate(Date sortDate) {
+ void setSortDate(Timestamp sortDate) {
this.sortDate = sortDate;
}
diff --git a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterSql.java b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterSql.java
index 78de713e2b6..d8f2d8a4149 100644
--- a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterSql.java
+++ b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterSql.java
@@ -22,7 +22,6 @@ package org.sonar.core.measure;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
-import com.google.common.primitives.Doubles;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.core.persistence.Database;
@@ -36,6 +35,7 @@ import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Timestamp;
import java.util.Comparator;
import java.util.List;
@@ -272,67 +272,34 @@ class MeasureFilterSql {
}
Ordering sortFieldOrdering(boolean ascending) {
- if (ascending) {
- return Ordering.from(new Comparator<Double>() {
- public int compare(@Nullable Double left, @Nullable Double right) {
- if (left == null) {
- return 1;
- }
- if (right == null) {
- return -1;
- }
-
- return Doubles.compare(left, right);
- }
- });
- }
- return Ordering.from(new Comparator<Double>() {
- public int compare(@Nullable Double left, @Nullable Double right) {
- if (left == null) {
- return 1;
- }
- if (right == null) {
- return -1;
- }
-
- return -Doubles.compare(left, right);
- }
- });
+ return newObjectOrdering(ascending);
}
}
static class DateSortRowProcessor extends RowProcessor {
MeasureFilterRow fetch(ResultSet rs) throws SQLException {
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3));
- row.setSortDate(rs.getDate(4));
+ row.setSortDate(rs.getTimestamp(4));
return row;
}
Function sortFieldFunction() {
- return new Function<MeasureFilterRow, Date>() {
- public Date apply(MeasureFilterRow row) {
+ return new Function<MeasureFilterRow, Timestamp>() {
+ public Timestamp apply(MeasureFilterRow row) {
return row.getSortDate();
}
};
}
Ordering sortFieldOrdering(boolean ascending) {
- if (ascending) {
- return Ordering.from(new Comparator<Date>() {
- public int compare(@Nullable Date left, @Nullable Date right) {
- if (left == null) {
- return 1;
- }
- if (right == null) {
- return -1;
- }
-
- return left.compareTo(right);
- }
- });
- }
- return Ordering.from(new Comparator<Date>() {
- public int compare(@Nullable Date left, @Nullable Date right) {
+ return newObjectOrdering(ascending);
+ }
+ }
+
+ private static Ordering newObjectOrdering(boolean ascending) {
+ if (ascending) {
+ return Ordering.from(new Comparator<Comparable>() {
+ public int compare(@Nullable Comparable left, @Nullable Comparable right) {
if (left == null) {
return 1;
}
@@ -340,9 +307,21 @@ class MeasureFilterSql {
return -1;
}
- return -left.compareTo(right);
+ return left.compareTo(right);
}
});
}
+ return Ordering.from(new Comparator<Comparable>() {
+ public int compare(@Nullable Comparable left, @Nullable Comparable right) {
+ if (left == null) {
+ return 1;
+ }
+ if (right == null) {
+ return -1;
+ }
+
+ return -left.compareTo(right);
+ }
+ });
}
}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_list.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_list.rb
index 2a109537790..4d139b0e998 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_list.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter_display_list.rb
@@ -20,7 +20,7 @@
require 'set'
class MeasureFilterDisplayList < MeasureFilterDisplay
KEY = :list
- MAX_PAGE_SIZE = 200
+ MAX_PAGE_SIZE = 250
class Column
attr_reader :key, :metric, :period
@@ -87,7 +87,7 @@ class MeasureFilterDisplayList < MeasureFilterDisplay
filter.set_criteria_default_value(:cols, ['metric:alert_status', 'name', 'date', 'metric:ncloc', 'metric:violations', 'links'])
filter.set_criteria_default_value(:sort, 'name')
filter.set_criteria_default_value(:asc, true)
- filter.set_criteria_default_value(:pageSize, 30)
+ filter.set_criteria_default_value(:pageSize, 100)
filter.set_criteria_value(:pageSize, MAX_PAGE_SIZE) if filter.criteria(:pageSize).to_i>MAX_PAGE_SIZE
@columns = []
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb
index 019edbafc84..8ccf9a9e876 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_copy_form.html.erb
@@ -9,10 +9,6 @@
<p class="error"><%= h msg -%></p>
<% end %>
<div class="form-field">
- <label>Copy</label>
- <input type="text" size="50" maxlength="100" value="<%= h @filter.name -%>" disabled="disabled"/>
- </div>
- <div class="form-field">
<label for="name"><%= h message('name') -%> <em class="mandatory">*</em></label>
<input id="name" name="name" type="text" size="50" maxlength="100" value=""/>
</div>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb
index 83654fa0081..597df3699a8 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_list.html.erb
@@ -1,14 +1,16 @@
<div id="measure_filter_list<%= widget_id -%>">
<% content_for :script do %>
<script>
+ var filterCriteria<%= widget_id -%> = <%= filter.criteria.to_json -%>;
+
function refreshList<%= widget_id -%>(sort, asc, page) {
$j('#measure_filter_foot<%= widget_id -%>_pages').hide();
$j('#measure_filter_foot<%= widget_id -%>_loading').show();
- filterCriteria['sort']=sort;
- filterCriteria['asc']=asc;
- filterCriteria['page']=page;
- var url=baseUrl + '/measures/search/?' + $j.param(filterCriteria);
+ filterCriteria<%= widget_id -%>['sort']=sort;
+ filterCriteria<%= widget_id -%>['asc']=asc;
+ filterCriteria<%= widget_id -%>['page']=page;
+ var url=baseUrl + '/measures/search/<%= filter.id -%>?widget_id=<%= widget_id -%>&' + $j.param(filterCriteria<%= widget_id -%>);
<% if widget_id %>
$j('#measure_filter_list<%= widget_id -%>').load(url);
@@ -37,7 +39,7 @@
}
}
function rightCol(id) {
- var cols = filterCriteria['cols']||[];
+ var cols = filterCriteria<%= widget_id -%>['cols']||[];
var cell = $j('#measures-table tr td[index=' + id + ']');
var columnIndex = cell.parent().children().index(cell);
@@ -46,7 +48,7 @@
}
}
function moveCol(from, to) {
- var cols = filterCriteria['cols']||[];
+ var cols = filterCriteria<%= widget_id -%>['cols']||[];
var temp = cols[from-colOffset];
cols[from-colOffset] = cols[to-colOffset];
cols[to-colOffset] = temp;
@@ -64,7 +66,7 @@
});
}
function deleteCol(id) {
- var cols = filterCriteria['cols']||[];
+ var cols = filterCriteria<%= widget_id -%>['cols']||[];
var cell = $j('#measures-table tr td[index=' + id + ']');
var columnIndex = cell.parent().children().index(cell);
cols.splice(columnIndex-colOffset, 1);
@@ -98,7 +100,7 @@
});
$j("#add-metric").on("click", function (e) {
- var cols = filterCriteria['cols']||[];
+ var cols = filterCriteria<%= widget_id -%>['cols']||[];
var columnKey = $j("#select-metric option:selected").val();
var period = $j("#select-period option:selected").val();
if (period.length > 0) {
@@ -106,11 +108,11 @@
}
cols.push(columnKey);
filterCriteria['edit']='true';
- window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria);
+ window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria<%= widget_id -%>);
});
$j("#exit-edit").on("click", function (e) {
delete filterCriteria['edit'];
- window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria);
+ window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria<%= widget_id -%>);
});
});
</script>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb
index 9715c75e694..9c6915325fd 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/_display_treemap.html.erb
@@ -1,3 +1,6 @@
+<script>
+ var filterCriteria<%= widget_id -%> = <%= filter.criteria.to_json -%>;
+</script>
<%
treemap_id = (defined? widget) ? widget.id : 1
unless edit_mode
@@ -57,17 +60,17 @@
<script>
$j(document).ready(function () {
$j("#update-treemap").on("click", function (e) {
- filterCriteria['tmSize']=$j('#select-tm-size').val();
+ filterCriteria<%= widget_id -%>['tmSize']=$j('#select-tm-size').val();
var color = $j('#select-tm-color').val();
if (color != null && color != '') {
- filterCriteria['tmColor']=color;
+ filterCriteria<%= widget_id -%>['tmColor']=color;
}
- filterCriteria['edit']=true;
- window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria);
+ filterCriteria<%= widget_id -%>['edit']=true;
+ window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria<%= widget_id -%>);
});
$j("#exit-edit").on("click", function (e) {
- delete filterCriteria['edit'];
- window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria);
+ delete filterCriteria<%= widget_id -%>['edit'];
+ window.location = baseUrl + '/measures/search/<%= filter.id -%>?' + $j.param(filterCriteria<%= widget_id -%>);
});
});
</script>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb
index 6b3b340579c..54d231c9d23 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb
@@ -1,11 +1,9 @@
-<div>
+<div xmlns="http://www.w3.org/1999/html">
<div class="page-split-left">
<%= render :partial => 'measures/sidebar' -%>
</div>
<% if @filter && @filter.display %>
- <script>var filterCriteria = <%= @filter.criteria.to_json -%>;</script>
-
<div class="page-split-right">
<div id="content">
<div class="line-block marginbottom10">
@@ -46,6 +44,7 @@
</ul>
<div class="page_title" id="filter-title">
<% if @filter.id && @filter.name.present? %>
+ <p>
<span class="h3"><%= h @filter.name -%></span>
<span class="note">
<% if !@filter.shared %>
@@ -58,12 +57,14 @@
[<%= message 'shared_by' -%> Sonar]
<% end %>
</span>
- <% if @filter.description.present? %>
- - <span class="note"><%= h @filter.description -%></span>
- <% end %>
<% if @filter.owner?(current_user) %>
- &nbsp;<a href="<%= url_for :action => 'edit_form', :id => @filter.id -%>" class="open-modal" id="edit-filter"><%= image_tag 'pencil-small.png', :alt => message('edit') -%></a>
+ &nbsp;<a href="<%= url_for :action => 'edit_form', :id => @filter.id -%>" class="open-modal" id="edit-filter"><%= image_tag 'pencil-small.png', :alt => message('edit') -%></a>
+ <% end %>
+ </p>
+ <% if @filter.description.present? %>
+ <p class="note"><%= h @filter.description -%></p>
<% end %>
+
<% end %>
</div>
</div>
diff --git a/sonar-server/src/main/webapp/stylesheets/layout.css b/sonar-server/src/main/webapp/stylesheets/layout.css
index 1d706ab8baf..036f40c8f20 100644
--- a/sonar-server/src/main/webapp/stylesheets/layout.css
+++ b/sonar-server/src/main/webapp/stylesheets/layout.css
@@ -175,7 +175,7 @@ body, a {
}
#body {
-/* position: relative;*/
+ /* position: relative;*/
}
#footer {
@@ -193,7 +193,7 @@ body, a {
#sidebar {
width: 150px;
- float:left;
+ float: left;
margin: 0 0 0 10px;
top: 0;
left: 0;
@@ -238,11 +238,11 @@ ul.sidebar li.spacer {
margin: 0;
padding: 0;
}
+
ul.sidebar select, ul.sidebar input {
font-size: 93%;
}
-
#logo {
text-align: center;
padding: 10px 0 0 0;
@@ -266,18 +266,19 @@ ul.sidebar select, ul.sidebar input {
max-width: 200px;
width: 200px;
margin: 0;
- display: block;
+ display: table-cell;
vertical-align: top;
border-top: none;
border-left: none;
- float: left;
}
.page-split-right {
- display: block;
+ position: relative;
+ display: table-cell;
margin: 0;
vertical-align: top;
- padding: 0 0 0 200px;
+ padding: 0;
+ width: 100%;
}
.gray-sidebar {