aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/measures/search.html.erb17
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb30
-rw-r--r--sonar-server/src/main/webapp/javascripts/navigator/filters/metric-filters.js137
-rw-r--r--sonar-server/src/main/webapp/javascripts/navigator/measures-app.js33
-rw-r--r--sonar-server/src/main/webapp/stylesheets/navigator.css4
-rw-r--r--sonar-server/src/main/webapp/stylesheets/navigator.less5
-rw-r--r--sonar-server/wro.xml1
8 files changed, 227 insertions, 2 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb
index 8d6cfb0f0f9..dceb971cd62 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_head.html.erb
@@ -58,9 +58,9 @@
<%= javascript_include_tag 'navigator/filters/range-filters' %>
<%= javascript_include_tag 'navigator/filters/checkbox-filters' %>
<%= javascript_include_tag 'navigator/filters/string-filters' %>
+ <%= javascript_include_tag 'navigator/filters/metric-filters' %>
<%= javascript_include_tag 'navigator/filters/favorite-filters' %>
<%= javascript_include_tag 'navigator/filters/more-criteria-filters' %>
- <%= javascript_include_tag 'navigator/filters/more-criteria-filters' %>
<%= javascript_include_tag 'navigator/issues-app' %>
<%= javascript_include_tag 'navigator/measures-app' %>
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 fe2529c8155..7ba067da273 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
@@ -50,6 +50,13 @@
_.extend(window.SS, {
languages: <%= render :partial => 'measures/languages' -%>,
+ <% condition_metrics = Metric.all.select { |m| m.numeric? && !m.hidden } %>
+ metrics: <%= condition_metrics.to_json -%>,
+ metricPeriods: {
+ '1': '<%= Api::Utils.period_label(1) -%>',
+ '2': '<%= Api::Utils.period_label(2) -%>',
+ '3': '<%= Api::Utils.period_label(3) -%>'
+ },
favorites: <%= render :partial => 'measures/favourites2' -%>
});
@@ -66,7 +73,15 @@
<% end %>
{ key: 'onFavourites', value: <%= @filter.criteria['onFavourites']=='true' -%> },
{ key: 'keySearch', value: '<%= h @filter.criteria['keySearch'] -%>' },
- { key: 'languages[]', value: <%= @filter.criteria['languages'].to_json -%> }
+ { key: 'languages[]', value: <%= @filter.criteria['languages'].to_json -%> },
+
+ <% for i in 1..3 %>
+ { key: '<%= "c#{i}_metric" -%>', value: '<%= h @filter.criteria("c#{i}_metric") -%>' },
+ { key: '<%= "c#{i}_period" -%>', value: '<%= h @filter.criteria("c#{i}_period") -%>' },
+ { key: '<%= "c#{i}_op" -%>', value: '<%= h @filter.criteria("c#{i}_op") -%>' },
+ { key: '<%= "c#{i}_val" -%>', value: '<%= h @filter.criteria("c#{i}_val") -%>' },
+ <% end %>
+
];
window.SS.MeasuresNavigatorApp.start();
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb
index beedea8a1f7..bcdfc8c597e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/navigator/_filter_templates.html.erb
@@ -64,6 +64,36 @@
</div>
</script>
+<script id="metricFilterTemplate" type="text/template">
+ <div class="navigator-filter-details-inner">
+ <select name="metric">
+ <option></option>
+ {[ _.each(groupedMetrics, function(group) { ]}
+ <optgroup label="{{ group.domain }}">
+ {[ _.each(group.metrics, function(metric) { ]}
+ <option value="{{ metric.name }}">{{ metric.short_name }}</option>
+ {[ }); ]}
+ </optgroup>
+ {[ }); ]}
+ </select>
+
+ <select name="period">
+ <option value="0">Value</option>
+ {[ _.each(periods, function(period, key) { ]}
+ <option value="{{ key }}">{{ period }}</option>
+ {[ }); ]}
+ </select>
+
+ <select name="op">
+ {[ _.each(operations, function(op, key) { ]}
+ <option value="{{ key }}">{{ op }}</option>
+ {[ }); ]}
+ </select>
+
+ <input type="text" name="val">
+ </div>
+</script>
+
<script id="favoriteFilterTemplate" type="text/template">
<div class="navigator-filter-favorite-toggle"></div>
</script>
diff --git a/sonar-server/src/main/webapp/javascripts/navigator/filters/metric-filters.js b/sonar-server/src/main/webapp/javascripts/navigator/filters/metric-filters.js
new file mode 100644
index 00000000000..e070a1c845c
--- /dev/null
+++ b/sonar-server/src/main/webapp/javascripts/navigator/filters/metric-filters.js
@@ -0,0 +1,137 @@
+/* global _:false, $j:false */
+
+window.SS = typeof window.SS === 'object' ? window.SS : {};
+
+(function() {
+
+ var DetailsMetricFilterView = window.SS.DetailsFilterView.extend({
+ template: '#metricFilterTemplate',
+
+
+ events: {
+ 'change :input': 'inputChanged'
+ },
+
+
+ inputChanged: function() {
+ var value = {
+ metric: this.$('[name=metric]').val(),
+ metricText: this.$('[name=metric] option:selected').text(),
+ period: this.$('[name=period]').val(),
+ periodText: this.$('[name=period] option:selected').text(),
+ op: this.$('[name=op]').val(),
+ opText: this.$('[name=op] option:selected').text(),
+ val: this.$('[name=val]').val()
+ };
+ this.model.set('value', value);
+ },
+
+
+ onRender: function() {
+ var value = this.model.get('value') || {};
+ this.$('[name=metric]').val(value.metric);
+ this.$('[name=period]').val(value.period);
+ this.$('[name=op]').val(value.op);
+ this.$('[name=val]').val(value.val);
+ this.inputChanged();
+ }
+
+ });
+
+
+
+ var MetricFilterView = window.SS.BaseFilterView.extend({
+
+ initialize: function() {
+ window.SS.BaseFilterView.prototype.initialize.call(this, {
+ detailsView: DetailsMetricFilterView
+ });
+
+ this.groupMetrics();
+ },
+
+
+ groupMetrics: function() {
+ var metrics = _.map(this.model.get('metrics'), function (metric) {
+ return metric.metric;
+ }),
+ groupedMetrics =
+ _.sortBy(
+ _.map(
+ _.groupBy(metrics, 'domain'),
+ function (metrics, domain) {
+ return {
+ domain: domain,
+ metrics: _.sortBy(metrics, 'short_name')
+ };
+ }),
+ 'domain'
+ );
+ this.model.set('groupedMetrics', groupedMetrics);
+ },
+
+
+ renderValue: function() {
+ return this.isDefaultValue() ?
+ 'Not set' :
+ this.model.get('value').metricText + ' ' + this.model.get('value').opText + ' ' + this.model.get('value').val;
+ },
+
+
+ renderInput: function() {
+ var that = this,
+ value = this.model.get('value') || {};
+ _.each(value, function(v, k) {
+
+ $j('<input>')
+ .prop('name', that.model.get('property') + '_' + k)
+ .prop('type', 'hidden')
+ .css('display', 'none')
+ .val(v)
+ .appendTo(that.$el);
+ });
+ },
+
+
+ isDefaultValue: function() {
+ var value = this.model.get('value');
+ if (!_.isObject(value)) {
+ return true;
+ }
+ return !(value.metric && value.period && value.op && value.val);
+ },
+
+
+ restoreFromQuery: function(q) {
+ var that = this,
+ value = {};
+ _.each(['metric', 'period', 'op', 'val'], function(p) {
+ var property = that.model.get('property') + '_' + p,
+ pValue = _.findWhere(q, { key: property });
+
+ if (pValue.value) {
+ value[p] = pValue.value;
+ }
+ });
+
+ if (value && value.metric && value.period && value.op && value.val) {
+ this.model.set({
+ value: value,
+ enabled: true
+ });
+ }
+ }
+
+ });
+
+
+
+ /*
+ * Export public classes
+ */
+
+ _.extend(window.SS, {
+ MetricFilterView: MetricFilterView
+ });
+
+})();
diff --git a/sonar-server/src/main/webapp/javascripts/navigator/measures-app.js b/sonar-server/src/main/webapp/javascripts/navigator/measures-app.js
index 4612850a679..388a0089dea 100644
--- a/sonar-server/src/main/webapp/javascripts/navigator/measures-app.js
+++ b/sonar-server/src/main/webapp/javascripts/navigator/measures-app.js
@@ -116,6 +116,39 @@ window.SS = typeof window.SS === 'object' ? window.SS : {};
type: window.SS.StringFilterView,
enabled: false,
optional: true
+ }),
+
+ new window.SS.Filter({
+ name: 'Metric',
+ property: 'c3',
+ type: window.SS.MetricFilterView,
+ metrics: window.SS.metrics,
+ periods: window.SS.metricPeriods,
+ operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
+ enabled: false,
+ optional: true
+ }),
+
+ new window.SS.Filter({
+ name: 'Metric',
+ property: 'c2',
+ type: window.SS.MetricFilterView,
+ metrics: window.SS.metrics,
+ periods: window.SS.metricPeriods,
+ operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
+ enabled: false,
+ optional: true
+ }),
+
+ new window.SS.Filter({
+ name: 'Metric',
+ property: 'c1',
+ type: window.SS.MetricFilterView,
+ metrics: window.SS.metrics,
+ periods: window.SS.metricPeriods,
+ operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
+ enabled: false,
+ optional: true
})
]);
diff --git a/sonar-server/src/main/webapp/stylesheets/navigator.css b/sonar-server/src/main/webapp/stylesheets/navigator.css
index 023b57618bd..c029246d1ee 100644
--- a/sonar-server/src/main/webapp/stylesheets/navigator.css
+++ b/sonar-server/src/main/webapp/stylesheets/navigator.css
@@ -121,8 +121,12 @@
display: block;
}
.navigator-filter-details-inner {
+ max-width: 300px;
padding: 5px 10px;
}
+.navigator-filter-details-inner select {
+ display: block;
+}
.navigator-filter-select-list {
min-width: 150px;
max-width: 300px;
diff --git a/sonar-server/src/main/webapp/stylesheets/navigator.less b/sonar-server/src/main/webapp/stylesheets/navigator.less
index 504733eb74b..be4b6b921d3 100644
--- a/sonar-server/src/main/webapp/stylesheets/navigator.less
+++ b/sonar-server/src/main/webapp/stylesheets/navigator.less
@@ -144,7 +144,12 @@
}
.navigator-filter-details-inner {
+ max-width: 300px;
padding: 5px @navigatorFilterPadding;
+
+ select {
+ display: block;
+ }
}
.navigator-filter-select-list {
diff --git a/sonar-server/wro.xml b/sonar-server/wro.xml
index 7ac0b8897e3..56640c1c029 100644
--- a/sonar-server/wro.xml
+++ b/sonar-server/wro.xml
@@ -38,6 +38,7 @@
<js>/javascripts/navigator/filters/range-filters.js</js>
<js>/javascripts/navigator/filters/checkbox-filters.js</js>
<js>/javascripts/navigator/filters/string-filters.js</js>
+ <js>/javascripts/navigator/filters/metric-filters.js</js>
<js>/javascripts/navigator/filters/favorite-filters.js</js>
<js>/javascripts/navigator/filters/more-criteria-filters.js</js>
<js>/javascripts/navigator/issues-app.js</js>