enabled="true" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="false"/>
- <manual_measures id="1" metric_id="2" resource_id="30" value="3.14" text_value="pi" created_at="[null]" updated_at="[null]" description="this is pi" url="http://pi"/>
- <manual_measures id="2" metric_id="2" resource_id="40" value="6" text_value="six" created_at="[null]" updated_at="[null]" description="this is six" url="http://six"/>
+ <manual_measures id="1" metric_id="2" resource_id="30" value="3.14" text_value="pi" created_at="[null]" updated_at="[null]" description="this is pi" url="http://pi" user_login="me"/>
+ <manual_measures id="2" metric_id="2" resource_id="40" value="6" text_value="six" created_at="[null]" updated_at="[null]" description="this is six" url="http://six" user_login="me"/>
</dataset>
\ No newline at end of file
filters.color=Color
global_roles.page=Global roles
manual_metrics.page=Manual metrics
+manual_measures.page=Manual measures
my_profile.page=My profile
project_roles.page=Project roles
project_settings.page=Settings
@Column(name = "updated_at", updatable = true, nullable = true)
private Date updatedAt;
+ @Column(name = "user_login", updatable = true, nullable = true, length = 40)
+ private String userLogin;
+
public Long getId() {
return id;
}
public Date getUpdatedAt() {
return updatedAt;
}
+
+ public String getUserLogin() {
+ return userLogin;
+ }
}
- complete the Derby DDL file used for unit tests : sonar-testing-harness/src/main/resources/org/sonar/test/persistence/sonar-test.ddl
*/
- public static final int LAST_VERSION = 213;
+ public static final int LAST_VERSION = 214;
public final static String TABLE_NAME = "schema_migrations";
measure=ManualMeasure.find(:first, :conditions => ['resource_id=? and metric_id=?', resource.id, metric.id])
if measure.nil?
- measure=ManualMeasure.new(:resource => resource, :user => current_user, :metric_id => metric.id)
+ measure=ManualMeasure.new(:resource => resource, :user_login => current_user.login, :metric_id => metric.id)
end
measure.value = value
hash[:created_at]=format_datetime(manual_measure.created_at)
hash[:updated_at]=format_datetime(manual_measure.updated_at) if manual_measure.updated_at
if manual_measure.user
- hash[:login]=manual_measure.user.login
+ hash[:login]=manual_measure.user_login
hash[:username]=manual_measure.user.name
end
hash
load_measures()
end
+ def new
+ load_measures()
+ end
+
def edit
load_measures()
@metric=Metric.by_key(params[:metric])
render :action => 'index'
end
+ def create
+
+ end
+
def save
metric=Metric.by_key(params[:metric])
measure=ManualMeasure.find(:first, :conditions => ['resource_id=? and metric_id=?', @resource.id, metric.id])
if measure.nil?
- measure=ManualMeasure.new(:resource => @resource, :user => current_user, :metric_id => metric.id)
+ measure=ManualMeasure.new(:resource => @resource, :user_login => current_user.login, :metric_id => metric.id)
end
# TODO use measure.text_value if string metric
measure.value = params[:val]
#
class ManualMeasure < ActiveRecord::Base
belongs_to :resource, :class_name => 'Project'
- belongs_to :user
validates_uniqueness_of :metric_id, :scope => :resource_id
validates_length_of :text_value, :maximum => 4000, :allow_nil => true, :allow_blank => true
validates_length_of :url, :maximum => 4000, :allow_nil => true, :allow_blank => true
validates_length_of :description, :maximum => 4000, :allow_nil => true, :allow_blank => true
validate :validate_metric
-
+
def metric
@metric ||=
- begin
- Metric.by_id(metric_id)
- end
+ begin
+ Metric.by_id(metric_id)
+ end
+ end
+
+ def user
+ @user ||=
+ begin
+ user_login ? User.find(:first, :conditions => ['login=?', user_login]) : nil
+ end
end
def metric=(m)
<% controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language).each do |page| %>
<li class="<%= 'selected' if request.request_uri.include?("page=#{page.getId()}") -%>"><a href="<%= ApplicationController.root_context -%>/plugins/resource/<%= @project.id-%>?page=<%= page.getId() -%>"><%= message(page.getId() + '.page', :default => page.getTitle()) %></a></li>
<% end %>
- <% if has_role?(:admin, @project) && @project.set? %>
+ <% 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>
<% 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 %>
<td class="thin nowrap" align="right">
<input type="text" name="val" value="<%= h(measure.value) -%>" id="value_input" size="8"/>
</td>
- <td>
- <textarea name="desc" rows="3"><%= measure.description -%></textarea>
+ <td colspan="3">
+ <textarea name="desc" rows="3" class="width100"><%= measure.description -%></textarea>
</td>
<td class="thin nowrap">
<input type="submit" value="Save"/>
<td class="thin nowrap"><%= measure.metric.short_name -%></td>
<td class="thin nowrap" align="right"><%= measure.value -%></td>
<td id="desc"><%= measure.description -%></td>
- <% unless @edited_measure %>
<td align="right">
- <%= measure.user.name if measure.user -%>
- <span class="note">(<%= l(measure.updated_at) -%>)</span>
+ <% unless @edited_measure %>
+ <%= measure.user.name if measure.user -%>
+ <% end %>
+ </td>
+ <td align="right">
+ <% unless @edited_measure %>
+ <%= l(measure.updated_at) -%>
+ <% end %>
</td>
- <% end %>
<td class="thin nowrap">
<% unless @edited_measure %>
<a href="<%= url_for :controller => 'manual_measures', :action => 'edit', :metric => measure.metric.key, :resource => @resource.key -%>">Edit</a>
-<h1>Manual Measures</h1>
<style type="text/css">
#manualMeasures td {
vertical-align: top;
}
-
- #manualMeasures textarea {
- width: 100%;
- -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
- -moz-box-sizing: border-box; /* Firefox, other Gecko */
- box-sizing: border-box; /* Opera/IE 8+ */
- }
</style>
-<form action="<%= url_for :action => 'save'-%>" method="POST" id="edit-form">
+<div class="line-block marginbottom10">
+ <ul class="operations">
+ <li>
+ <%= image_tag 'add.png' -%>
+ <a href="<%= ApplicationController.root_context-%>/manual_measures/new?resource=<%= @resource.id -%>" id="addMeasureLink">Add measure</a>
+ </li>
+ <li class="last">
+ <a href="<%= ApplicationController.root_context-%>/metrics/index" id="adminMetricsLink">Manage metrics</a>
+ </li>
+ </ul>
+</div>
+
+<form action="<%= url_for :action => 'save' -%>" method="POST" id="editForm">
<input type="hidden" name="resource" value="<%= @resource.id -%>"/>
+
<% if @metric %>
<input type="hidden" name="metric" value="<%= @metric.key -%>"/>
<% end %>
<table class="width100 data" id="manualMeasures">
<thead>
<tr>
- <th>Domain</th>
- <th>Metric</th>
- <th style="text-align: right">Value</th>
+ <th class="thin nowrap">Domain</th>
+ <th class="thin nowrap">Metric</th>
+ <th class="thin nowrap" style="text-align: right">Value</th>
<th>Description</th>
- <% unless @edited_measure %>
- <th style="text-align: right">Author</th>
- <% end %>
- <th>Operations</th>
+ <th style="text-align: right"><% unless @edited_measure %>Author<% end %></th>
+ <th style="text-align: right"><% unless @edited_measure %>Date<% end %></th>
+ <th class="thin nowrap">Operations</th>
</tr>
</thead>
<tbody>
+ <% if @measures.empty? %>
+ <td colspan="7" class="even">No measures</td>
+ <% end %>
<%
@measures.each do |measure|
%>
--- /dev/null
+<div class="line-block marginbottom10">
+ <ul class="operations">
+ <li class="last">
+ <a href="<%= ApplicationController.root_context -%>/metrics/index" id="adminMetricsLink">Manage metrics</a>
+ </li>
+ </ul>
+</div>
+
+<form action="<%= url_for :action => 'create' -%>" method="POST" id="createForm">
+ <input type="hidden" name="resource" value="<%= @resource.id -%>"/>
+ <table class="width100 data" id="manualMeasures">
+ <thead>
+ <tr>
+ <th class="thin nowrap">Metric</th>
+ <th class="thin nowrap" style="text-align: right">Value</th>
+ <th>Description</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr class="admin">
+ <td>
+ <select name="metric">
+ <option>ncloc</option>
+ </select>
+ </td>
+ <td>
+ <input type="text" name="val" size="8"/>
+ </td>
+ <td>
+ <textarea name="desc" rows="3" class="width100"></textarea>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+</form>
t.column 'resource_id', :integer, :null => true
t.column 'value', :decimal, :null => true, :precision => 30, :scale => 20
t.column 'text_value', :string, :null => true, :limit => 4000
- t.column 'user_id', :integer, :null => true
+ t.column 'user_login', :string, :null => true, :limit => 40
t.column 'description', :string, :null => true, :limit => 4000
t.column 'url', :string, :null => true, :limit => 4000
t.timestamps
--- /dev/null
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+
+#
+# Sonar 2.10
+#
+class AddIndexOnManualMeasures < ActiveRecord::Migration
+
+ def self.up
+ add_index('manual_measures', 'resource_id', :name => 'manual_measures_resource_id')
+ end
+
+end
}
ul.operations {
float: right;
+ height: 20px;
list-style-type: none;
margin: 0;
background-color: #ECECEC;
.width100 {
width: 100%;
}
+textarea.width100 {
+ width: 100%;
+ -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
+ -moz-box-sizing: border-box; /* Firefox, other Gecko */
+ box-sizing: border-box; /* Opera/IE 8+ */
+}
ul.horizontal {
list-style-type: none;
}