aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-07-20 14:10:33 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-07-20 14:10:54 +0200
commitec184554fcba165e64cfa1ed2b9b20b25938f6d4 (patch)
tree959d7e4765c831ed261303ceb81b5606247a4d58 /sonar-server/src
parent2c89cde5852c1920c187ce87505ac9e96b9b7910 (diff)
downloadsonarqube-ec184554fcba165e64cfa1ed2b9b20b25938f6d4.tar.gz
sonarqube-ec184554fcba165e64cfa1ed2b9b20b25938f6d4.zip
SONAR-2628 improve administration console
Diffstat (limited to 'sonar-server/src')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb11
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb7
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb26
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/_edit_form.html.erb14
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/index.html.erb35
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/new.html.erb20
-rw-r--r--sonar-server/src/main/webapp/stylesheets/style.css6
10 files changed, 76 insertions, 57 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb
index 947da59ca2f..f2a9c564f21 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/manual_measures_controller.rb
@@ -21,7 +21,7 @@ class ManualMeasuresController < ApplicationController
SECTION=Navigation::SECTION_RESOURCE
before_filter :load_resource
- verify :method => :post, :only => [:save, :delete], :redirect_to => { :action => :index }
+ verify :method => :post, :only => [:save, :delete], :redirect_to => {:action => :index}
def index
load_measures()
@@ -47,7 +47,11 @@ class ManualMeasuresController < ApplicationController
measure.value = params[:val]
measure.description = params[:desc]
measure.save!
- redirect_to :action => 'index', :resource => params[:resource], :metric => params[:metric]
+ if (params[:redirect_to_new]=='true')
+ redirect_to :action => 'new', :resource => params[:resource]
+ else
+ redirect_to :action => 'index', :resource => params[:resource], :metric => params[:metric]
+ end
end
def delete
@@ -62,9 +66,10 @@ class ManualMeasuresController < ApplicationController
@resource=Project.by_key(params[:resource])
return redirect_to home_path unless @resource
return access_denied unless has_role?(:admin, @resource)
+ @snapshot=@resource.last_snapshot
end
def load_measures
- @measures=ManualMeasure.find(:all, :conditions => ['resource_id=?', @resource.id]).select{|m| m.metric.enabled}.sort_by{|m| m.metric.domain}
+ @measures=ManualMeasure.find(:all, :conditions => ['resource_id=?', @resource.id]).select { |m| m.metric.enabled }
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb
index 7273e229d7d..5907c95a9ab 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/manual_measure.rb
@@ -51,4 +51,11 @@ class ManualMeasure < ActiveRecord::Base
def validate_metric
errors.add_to_base("Not a valid metric") unless metric && metric.enabled?
end
+
+ def pending?(snapshot=nil)
+ if snapshot.nil?
+ snapshot=resource.last_snapshot
+ end
+ snapshot && updated_at && snapshot.created_at<updated_at
+ end
end \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb
index 69d17e09b5e..a0c8fcd78d9 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_list.html.erb
@@ -1,5 +1,5 @@
<tr>
- <td class="first">
+ <td class="keyCell">
<%= message('filters.add_column') -%>:
</td>
<td>
@@ -32,7 +32,7 @@
</td>
</tr>
<tr>
- <td class="first"><%= message('filters.default_sorted_column') -%>:</td>
+ <td class="keyCell"><%= message('filters.default_sorted_column') -%>:</td>
<td>
<form id="sorted_column_form" action="<%= url_for :action => 'set_sorted_column' -%>" method="post">
<select name="id">
@@ -52,7 +52,7 @@
</td>
</tr>
<tr>
- <td class="first"><%= message('page_size') -%>:</td>
+ <td class="keyCell"><%= message('page_size') -%>:</td>
<td>
<form id="page_size_form" action="<%= url_for :action => 'set_page_size' -%>" method="post">
<input type="hidden" name="id" value="<%= @filter.id -%>"></input>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb
index 748def5b202..7b6eea93a2e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/_customize_treemap.html.erb
@@ -5,14 +5,14 @@
%>
<form class="admin" action="<%= url_for :action => 'set_columns', :id => @filter.id -%>" method="POST">
<tr>
- <td class="first"><%= message('size') -%>:</td>
+ <td class="keyCell"><%= message('size') -%>:</td>
<td>
<%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.size_metrics({:exclude_user_managed => true}), size_metric.key),
:id => 'size_metric' %>
</td>
</tr>
<tr>
- <td class="first"><%= message('color') -%>:</td>
+ <td class="keyCell"><%= message('color') -%>:</td>
<td>
<%= select_tag 'columns[]', options_grouped_by_domain(Sonar::TreemapBuilder.color_metrics, color_metric.key),
:id => 'color_metric' %>
@@ -20,7 +20,7 @@
</td>
</tr>
<tr>
- <td class="first"> </td>
+ <td class="keyCell"> </td>
<td>
<input type="submit" value="<%= message('change_verb') -%>">
</td>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb
index 654cbca200b..eabbdbf682b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/filters/new.html.erb
@@ -23,7 +23,7 @@ table#columns td {
<table class="form">
<tbody>
<tr>
- <td class="first"><%= message('name') -%>:</td>
+ <td class="keyCell"><%= message('name') -%>:</td>
<td>
<input type="text" name="name" id="name" value="<%= @filter.name -%>" class="spaced"></input>
<% if is_admin? %>
@@ -36,7 +36,7 @@ table#columns td {
</tbody>
<tbody id="simple-form">
<tr>
- <td class="first"><%= message('path') -%>:</td>
+ <td class="keyCell"><%= message('path') -%>:</td>
<td>
<b><span id="path_name"><%= @filter.resource ? @filter.resource.path_name : params[:path_name] -%></span></b>
<input type="hidden" name="path_id" id="path_id" value="<%= @filter.resource ? @filter.resource.id : params[:path_id] -%>"></input>
@@ -45,7 +45,7 @@ table#columns td {
</td>
</tr>
<tr>
- <td class="first"><%= message('filters.search_for') -%>:</td>
+ <td class="keyCell"><%= message('filters.search_for') -%>:</td>
<td>
<% qualifiers=(@filter.criterion('qualifier') ? @filter.criterion('qualifier').text_values : []) %>
@@ -74,19 +74,19 @@ table#columns td {
</td>
</tr>
<tr>
- <td class="first"><%= message('criteria') -%>:</td>
+ <td class="keyCell"><%= message('criteria') -%>:</td>
<td>
<%= render :partial => 'filters/criterion', :locals => {:id => '0', :criterion => (@filter.measure_criteria.size>0 ? @filter.measure_criteria[0] : nil)} %>
</td>
</tr>
<tr>
- <td class="first"><%= message('and').downcase -%>: </td>
+ <td class="keyCell"><%= message('and').downcase -%>: </td>
<td>
<%= render :partial => 'filters/criterion', :locals => {:id => '1', :criterion => (@filter.measure_criteria.size>1 ? @filter.measure_criteria[1] : nil) } %>
</td>
</tr>
<tr>
- <td class="first"><%= message('and').downcase -%>: </td>
+ <td class="keyCell"><%= message('and').downcase -%>: </td>
<td>
<%= render :partial => 'filters/criterion', :locals => {:id => '2', :criterion => (@filter.measure_criteria.size>2 ? @filter.measure_criteria[2] : nil) } %>
</td>
@@ -100,7 +100,7 @@ table#columns td {
</tbody>
<tbody id="advanced-search" style="<%= 'display: none' unless @filter.advanced_search? -%>">
<tr>
- <td class="first"><%= message('filters.default_period') -%>:</td>
+ <td class="keyCell"><%= message('filters.default_period') -%>:</td>
<td>
<select id="period_index" name="period_index">
<option value=""><%= message('none') -%></option>
@@ -111,7 +111,7 @@ table#columns td {
</td>
</tr>
<tr>
- <td class="first"><%= message('language') -%>:</td>
+ <td class="keyCell"><%= message('language') -%>:</td>
<td>
<% languages=(@filter.criterion('language') ? @filter.criterion('language').text_values : []) %>
<% controller.java_facade.getLanguages().each do |language| %>
@@ -121,13 +121,13 @@ table#columns td {
</td>
</tr>
<tr>
- <td class="first"><%= image_tag 'star.png' %> <label for="favourites"><%= message('filters.favourite_only') -%>:</label></td>
+ <td class="keyCell"><%= image_tag 'star.png' %> <label for="favourites"><%= message('filters.favourite_only') -%>:</label></td>
<td>
<input type="checkbox" name="favourites" id="favourites" <%= 'checked' if @filter.favourites -%>></input>
</td>
</tr>
<tr>
- <td class="first"><label for="key_regexp"><%= message('filters.resource_key_like') -%>:</label></td>
+ <td class="keyCell"><label for="key_regexp"><%= message('filters.resource_key_like') -%>:</label></td>
<td>
<% key_regexp_criterion=@filter.criterion('key') %>
<input type="text" name="key_regexp" id="key_regexp" value="<%= key_regexp_criterion.text_value if key_regexp_criterion -%>"></input>
@@ -135,7 +135,7 @@ table#columns td {
</td>
</tr>
<tr>
- <td class="first"><label for="name_regexp"><%= message('filters.resource_name_like') -%>:</label></td>
+ <td class="keyCell"><label for="name_regexp"><%= message('filters.resource_name_like') -%>:</label></td>
<td>
<% name_regexp_criterion=@filter.criterion('name') %>
<input type="text" name="name_regexp" id="name_regexp" value="<%= name_regexp_criterion.text_value if name_regexp_criterion -%>"></input>
@@ -143,7 +143,7 @@ table#columns td {
</td>
</tr>
<tr>
- <td class="first"><label for="date"><%= message('build_date') -%>:</label></td>
+ <td class="keyCell"><label for="date"><%= message('build_date') -%>:</label></td>
<td>
<% date_criterion = @filter.criterion('date') %>
<select id="date_operator" name="date_operator">
@@ -188,7 +188,7 @@ $('name').focus();
<div class="admin">
<table class="form" id="view-form">
<tr>
- <td class="first"><%= message('filters.display_as') -%>:</td>
+ <td class="keyCell"><%= message('filters.display_as') -%>:</td>
<td>
<form action="<%= url_for :action => :set_view, :id => @filter.id -%>" method="POST">
<input type="radio" name="view" value="list" <%= 'checked' if @filter.default_view==::Filter::VIEW_LIST -%> id="view-list" onClick="$('view-loading').show();submit();"></input> <label for="view-list"><%= message('table') -%></label>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
index 8a6e7b55b5c..3b55930adde 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
@@ -50,7 +50,7 @@
<% end %>
<% if has_role?(:admin, @project) %>
<li class="h2"><%= message('sidebar.project_system') -%></li>
- <li class="<%= 'selected' if request.request_uri.include?('/manual_measures/') -%>"><a href="<%= ApplicationController.root_context -%>/manual_measures?resource=<%= @project.id -%>"><%= message('manual_measures.page') -%></a></li>
+ <li class="<%= 'selected' if request.request_uri.include?('/manual_measures') -%>"><a href="<%= ApplicationController.root_context -%>/manual_measures?resource=<%= @project.id -%>"><%= message('manual_measures.page') -%></a></li>
<% if (@project.project? || @project.module?) %>
<li class="<%= 'selected' if request.request_uri.include?('/project/settings') -%>"><a href="<%= ApplicationController.root_context -%>/project/settings/<%= @project.id -%>"><%= message('project_settings.page') -%></a></li>
<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/_edit_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/_edit_form.html.erb
deleted file mode 100644
index 24eb195c0f2..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/_edit_form.html.erb
+++ /dev/null
@@ -1,14 +0,0 @@
-<tr class="admin ">
- <td class="thin nowrap"><%= measure.metric.domain -%></td>
- <td class="thin nowrap"><%= measure.metric.short_name -%></td>
- <td class="thin nowrap" align="right">
- <input type="text" name="val" value="<%= h(measure.value) -%>" id="value_input" size="8"/>
- </td>
- <td colspan="3">
- <textarea name="desc" rows="3" class="width100"><%= measure.description -%></textarea>
- </td>
- <td class="thin nowrap">
- <input type="submit" value="Save"/>
- <a href="<%= url_for :controller => 'manual_measures', :action => 'index', :metric => measure.metric.key, :resource => @resource.key -%>">Cancel</a>
- </td>
-</tr>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/index.html.erb
index 5f5ba47e5b5..ea9e0d94e7b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/index.html.erb
@@ -2,6 +2,13 @@
#manualMeasures td {
vertical-align: top;
}
+
+ #manualMeasures td.pendingMeasure {
+ background-color: orange;
+ width: 4px;
+ padding: 0;
+ cursor: help;
+ }
</style>
<div class="line-block marginbottom10">
<ul class="operations">
@@ -12,42 +19,48 @@
</ul>
</div>
-<table class="width100 data" id="manualMeasures">
+<table class="width100 data sortable" id="manualMeasures">
<thead>
<tr>
- <th class="thin nowrap">Domain</th>
+ <th style="padding: 0; margin: 0; width: 4px" class="nosort"></th>
+ <th class="thin nowrap sortfirstasc">Domain</th>
<th class="thin nowrap">Metric</th>
<th class="thin nowrap" style="text-align: right">Value</th>
<th>Description</th>
<th style="text-align: right">Author</th>
<th style="text-align: right">Date</th>
- <th class="thin nowrap">Operations</th>
+ <th class="thin nowrap nosort">Operations</th>
</tr>
</thead>
<tbody>
<% if @measures.empty? %>
- <td colspan="7" class="even">No measures</td>
+ <td colspan="8" class="even">No measures</td>
<% end %>
<%
@measures.each do |measure|
%>
<a name="<%= measure.metric.key -%>"></a>
- <tr class="<%= cycle('even', 'odd') -%>">
+ <tr>
+ <% if measure.pending?(@snapshot) %>
+ <td class="pendingMeasure" title="Pending. New value will be available during next project analysis."></td>
+ <% else %>
+ <td></td>
+ <% end %>
<td class="thin nowrap"><%= measure.metric.domain -%></td>
<td class="thin nowrap"><%= measure.metric.short_name -%></td>
<td class="thin nowrap" align="right"><%= measure.value -%></td>
<td id="desc"><%= measure.description -%></td>
- <td align="right"><%= measure.username -%>
+ <td align="right"><%= measure.username -%>
</td>
<td align="right">
- <%= l(measure.updated_at) -%>
+ <%= l(measure.updated_at) -%>
</td>
<td class="thin nowrap">
- <a href="<%= url_for :controller => 'manual_measures', :action => 'new', :metric => measure.metric.key, :resource => @resource.key -%>">Edit</a>
- <%= link_to 'Delete', {:action => 'delete', :metric => measure.metric.key, :resource => @resource.id}, {:method => 'POST', :confirm => "This measure will be deleted during next project analysis", :class => 'action'} -%>
+ <a href="<%= url_for :controller => 'manual_measures', :action => 'new', :metric => measure.metric.key, :resource => @resource.key -%>">Edit</a>
+ <%= link_to 'Delete', {:action => 'delete', :metric => measure.metric.key, :resource => @resource.id}, {:method => 'POST', :confirm => "This measure will be deleted during next project analysis", :class => 'action'} -%>
</td>
</tr>
-
<% end %>
</tbody>
-</table> \ No newline at end of file
+</table>
+<script>TableKit.Sortable.init('manualMeasures');</script>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/new.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/new.html.erb
index 8e917aead2a..4dc0ef8e3bb 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/new.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/manual_measures/new.html.erb
@@ -3,6 +3,10 @@
document.location = '<%= ApplicationController.root_context-%>/manual_measures/new?resource=<%= @resource.key -%>&metric=' + $('metricSelect').getValue();
return false;
}
+ function saveAndAddNew() {
+ $('redirect_to_new').setValue('true');
+ return true;
+ }
</script>
<form action="<%= url_for :action => (@measure ? 'save' : 'new') -%>" method="POST" id="createForm">
@@ -10,7 +14,7 @@
<table class="width100 form">
<tbody>
<tr>
- <td class="first">
+ <td class="keyCell">
Metric:
</td>
<td>
@@ -20,15 +24,17 @@
<option value="<%= metric.key -%>" <%= 'selected' if @metric && @metric.id==metric.id -%>><%= metric.short_name -%></option>
<% end %>
</select>
+ <%= link_to 'Manage metrics', :controller => 'metrics', :action => 'index' -%>
- <% if @metric %>
+ <% if @metric && @metric.description %>
+ <br/>
<span class="note"><%= @metric.description -%></span>
<% end %>
</td>
</tr>
<% if @measure %>
<tr>
- <td class="first">
+ <td class="keyCell">
Value:
</td>
<td>
@@ -36,7 +42,7 @@
</td>
</tr>
<tr>
- <td class="first">
+ <td class="keyCell">
Description:
</td>
<td>
@@ -45,7 +51,7 @@
</tr>
<% unless @measure.new_record?() %>
<tr>
- <td class="first">
+ <td class="keyCell">
Last change:
</td>
<td>
@@ -55,11 +61,13 @@
<% end %>
<% end %>
<tr>
- <td class="first">
+ <td class="keyCell">
</td>
<td>
<% if @measure %>
+ <input type="hidden" name="redirect_to_new" value="false" id="redirect_to_new"/>
<input type="submit" value="Save"/>
+ <input type="submit" value="Save & Add new" onclick="saveAndAddNew()"/>
<% end %>
<%= link_to 'Cancel', :action => 'index', :resource => @resource.key -%>
</td>
diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css
index 70738451f96..49d3332679c 100644
--- a/sonar-server/src/main/webapp/stylesheets/style.css
+++ b/sonar-server/src/main/webapp/stylesheets/style.css
@@ -639,11 +639,11 @@ table.form td {
padding: 2px 5px;
vertical-align: top;
}
-table.form td.first {
- min-width: 120px;
+table.form td.keyCell {
+ width: 140px;
text-align: right;
font-weight: bold;
- vertical-align: middle;
+ vertical-align: top;
}
table.form td img {
vertical-align: bottom;