Commit 65f1356b142ef08b108199c6c06600bdf3a2775d
Committed by
Alessandro Palmeira
Exists in
master
and in
29 other branches
Merge branch 'metrics_in_configuration' into merging_configuration
Conflicts: plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb plugins/mezuro/public/javascripts/project_content.js
Showing
21 changed files
with
370 additions
and
13 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -35,4 +35,64 @@ class MezuroPluginProfileController < ProfileController | @@ -35,4 +35,64 @@ class MezuroPluginProfileController < ProfileController | ||
35 | render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name} | 35 | render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name} |
36 | end | 36 | end |
37 | 37 | ||
38 | + def choose_base_tool | ||
39 | + @configuration_name = params[:configuration_name] | ||
40 | + @tool_names = Kalibro::Client::BaseToolClient.new | ||
41 | + end | ||
42 | + | ||
43 | + def choose_metric | ||
44 | + @configuration_name = params[:configuration_name] | ||
45 | + @collector_name = params[:collector_name] | ||
46 | + | ||
47 | + @collector = Kalibro::Client::BaseToolClient.new.base_tool(@collector_name) | ||
48 | + end | ||
49 | + | ||
50 | + def new_metric_configuration | ||
51 | + @metric_name = params[:metric_name] | ||
52 | + @configuration_name = params[:configuration_name] | ||
53 | + @collector_name = params[:collector_name] | ||
54 | + end | ||
55 | + | ||
56 | + def edit_metric_configuration | ||
57 | + @metric_configuration_code = params[:metric_code] | ||
58 | + @configuration_name = params[:configuration_name] | ||
59 | + | ||
60 | + @metric_configuration = Kalibro::Entities::MetricConfiguration.new | ||
61 | + @metric_configuration.code = @metric_configuration_code | ||
62 | + @metric_configuration.aggregation_form = "MEDIAN" | ||
63 | + @metric_configuration.weight = "1" | ||
64 | + @metric_configuration.metric = Kalibro::Entities::NativeMetric.new | ||
65 | + @metric_configuration.metric.name = "Nome falso" | ||
66 | + @metric_configuration.metric.origin = "Origem Falsa" | ||
67 | + range = Kalibro::Entities::Range.new | ||
68 | + range.beginning = "0" | ||
69 | + range.end = "100" | ||
70 | + range.label = "fake label" | ||
71 | + range.grade = "100" | ||
72 | + range.color = "FFFFFF" | ||
73 | + @metric_configuration.range = [range] | ||
74 | + end | ||
75 | + | ||
76 | + def create_metric_configuration | ||
77 | + @configuration_name = params[:configuration_name] | ||
78 | + redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" | ||
79 | + end | ||
80 | + | ||
81 | + def update_metric_configuration | ||
82 | + @configuration_name = params[:configuration_name] | ||
83 | + redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" | ||
84 | + end | ||
85 | + | ||
86 | + def new_range | ||
87 | + end | ||
88 | + | ||
89 | + def create_range | ||
90 | + @range = Kalibro::Entities::Range.new | ||
91 | + @range.beginning = params[:range][:beginning] | ||
92 | + @range.end = params[:range][:end] | ||
93 | + @range.label = params[:range][:label] | ||
94 | + @range.grade = params[:range][:grade] | ||
95 | + @range.color = params[:range][:color] | ||
96 | + @range.comments = params[:range][:comments] | ||
97 | + end | ||
38 | end | 98 | end |
plugins/mezuro/lib/kalibro/client/base_tool_client.rb
@@ -13,4 +13,4 @@ class Kalibro::Client::BaseToolClient | @@ -13,4 +13,4 @@ class Kalibro::Client::BaseToolClient | ||
13 | Kalibro::Entities::BaseTool.from_hash(hash) | 13 | Kalibro::Entities::BaseTool.from_hash(hash) |
14 | end | 14 | end |
15 | 15 | ||
16 | -end | ||
17 | \ No newline at end of file | 16 | \ No newline at end of file |
17 | +end |
plugins/mezuro/lib/kalibro/entities/configuration.rb
@@ -14,4 +14,11 @@ class Kalibro::Entities::Configuration < Kalibro::Entities::Entity | @@ -14,4 +14,11 @@ class Kalibro::Entities::Configuration < Kalibro::Entities::Entity | ||
14 | @metric_configuration = metric_configurations | 14 | @metric_configuration = metric_configurations |
15 | end | 15 | end |
16 | 16 | ||
17 | + def create_metric_configurations(metrics) | ||
18 | + @metric_configuration = [] | ||
19 | + metrics.each do |metric| | ||
20 | + @metric_configuration << create_metric_configuration(metric) | ||
21 | + end | ||
22 | + end | ||
23 | + | ||
17 | end | 24 | end |
plugins/mezuro/lib/kalibro/entities/metric.rb
@@ -2,4 +2,4 @@ class Kalibro::Entities::Metric < Kalibro::Entities::Entity | @@ -2,4 +2,4 @@ class Kalibro::Entities::Metric < Kalibro::Entities::Entity | ||
2 | 2 | ||
3 | attr_accessor :name, :scope, :description | 3 | attr_accessor :name, :scope, :description |
4 | 4 | ||
5 | -end | ||
6 | \ No newline at end of file | 5 | \ No newline at end of file |
6 | +end |
plugins/mezuro/lib/kalibro/entities/metric_configuration.rb
@@ -27,4 +27,4 @@ class Kalibro::Entities::MetricConfiguration < Kalibro::Entities::Entity | @@ -27,4 +27,4 @@ class Kalibro::Entities::MetricConfiguration < Kalibro::Entities::Entity | ||
27 | @range = ranges | 27 | @range = ranges |
28 | end | 28 | end |
29 | 29 | ||
30 | -end | ||
31 | \ No newline at end of file | 30 | \ No newline at end of file |
31 | +end |
plugins/mezuro/lib/mezuro_plugin/configuration_content.rb
@@ -8,7 +8,7 @@ class MezuroPlugin::ConfigurationContent < Article | @@ -8,7 +8,7 @@ class MezuroPlugin::ConfigurationContent < Article | ||
8 | 'Sets of thresholds to interpret metrics' | 8 | 'Sets of thresholds to interpret metrics' |
9 | end | 9 | end |
10 | 10 | ||
11 | - settings_items :description | 11 | + settings_items :description, :metrics |
12 | 12 | ||
13 | include ActionView::Helpers::TagHelper | 13 | include ActionView::Helpers::TagHelper |
14 | def to_html(options = {}) | 14 | def to_html(options = {}) |
plugins/mezuro/lib/mezuro_plugin/metric_configuration_content.rb
0 → 100644
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +class MezuroPlugin::MetricConfigurationContent < Article | ||
2 | + | ||
3 | + def self.short_description | ||
4 | + 'Kalibro Configurated Metric' | ||
5 | + end | ||
6 | + | ||
7 | + def self.description | ||
8 | + 'Sets of thresholds to interpret a metric' | ||
9 | + end | ||
10 | + | ||
11 | + settings_items :description, :code, :weight, :scope, :aggregation_form, :range | ||
12 | + | ||
13 | + include ActionView::Helpers::TagHelper | ||
14 | + def to_html(options = {}) | ||
15 | + lambda do | ||
16 | + render :file => 'content_viewer/show_configuration.rhtml' | ||
17 | + end | ||
18 | + end | ||
19 | + | ||
20 | + def metric_configuration | ||
21 | + Kalibro::Client::MetricConfigurationClient.metric_configuration(name) | ||
22 | + end | ||
23 | + | ||
24 | + after_save :send_metric_configuration_to_service | ||
25 | + after_destroy :remove_metric_configuration_from_service | ||
26 | + | ||
27 | + private | ||
28 | + | ||
29 | + def send_metric_configuration_to_service | ||
30 | + Kalibro::Client::MetricConfigurationClient.save(self) | ||
31 | + end | ||
32 | + | ||
33 | + def remove_metric_configuration_from_service | ||
34 | + Kalibro::Client::MetricConfigurationClient.remove(name) | ||
35 | + end | ||
36 | + | ||
37 | +end |
plugins/mezuro/public/javascripts/project_content.js
@@ -79,4 +79,10 @@ function showLoadingProcess(firstLoad){ | @@ -79,4 +79,10 @@ function showLoadingProcess(firstLoad){ | ||
79 | 79 | ||
80 | showProjectTree("<img src='/images/loading-small.gif'/>"); | 80 | showProjectTree("<img src='/images/loading-small.gif'/>"); |
81 | showModuleResult("<img src='/images/loading-small.gif'/>"); | 81 | showModuleResult("<img src='/images/loading-small.gif'/>"); |
82 | -} | 82 | +} |
83 | + | ||
84 | +function sourceNodeToggle(id){ | ||
85 | + var suffixes = ['_hidden', '_plus', '_minus']; | ||
86 | + for (var i in suffixes) | ||
87 | + jQuery('#' + id + suffixes[i]).toggle(); | ||
88 | +} |
plugins/mezuro/test/unit/kalibro/entities/configuration_test.rb
@@ -17,4 +17,13 @@ class ConfigurationTest < ActiveSupport::TestCase | @@ -17,4 +17,13 @@ class ConfigurationTest < ActiveSupport::TestCase | ||
17 | assert_equal @hash, @configuration.to_hash | 17 | assert_equal @hash, @configuration.to_hash |
18 | end | 18 | end |
19 | 19 | ||
20 | -end | ||
21 | \ No newline at end of file | 20 | \ No newline at end of file |
21 | + should 'create metric configuration' do | ||
22 | + configuration = Kalibro::Entities::Configuration.new | ||
23 | + configuration.create_metric_configurations(["Analizo:Metric Name"]) | ||
24 | + metric_configuration = configuration.metric_configurations[0] | ||
25 | + assert_equal metric_configuration.code, "Metric Name" | ||
26 | + assert_equal metric_configuration.metric.name, "Metric Name" | ||
27 | + assert_equal metric_configuration.metric.origin, "Analizo" | ||
28 | + end | ||
29 | + | ||
30 | +end |
plugins/mezuro/test/unit/mezuro_plugin/configuration_content_test.rb
@@ -42,7 +42,7 @@ class ConfigurationContentTest < ActiveSupport::TestCase | @@ -42,7 +42,7 @@ class ConfigurationContentTest < ActiveSupport::TestCase | ||
42 | @content.send :send_configuration_to_service | 42 | @content.send :send_configuration_to_service |
43 | end | 43 | end |
44 | 44 | ||
45 | - should 'remove project from service' do | 45 | + should 'remove configuration from service' do |
46 | Kalibro::Client::ConfigurationClient.expects(:remove).with(@content.name) | 46 | Kalibro::Client::ConfigurationClient.expects(:remove).with(@content.name) |
47 | @content.send :remove_configuration_from_service | 47 | @content.send :remove_configuration_from_service |
48 | end | 48 | end |
plugins/mezuro/views/cms/mezuro_plugin/_configuration_content.html.erb
1 | <h1> <%= _(MezuroPlugin::ConfigurationContent.short_description) %> </h1> | 1 | <h1> <%= _(MezuroPlugin::ConfigurationContent.short_description) %> </h1> |
2 | 2 | ||
3 | <% | 3 | <% |
4 | - begin | ||
5 | - @configuration = @article.title.nil? ? nil : Kalibro::Client::ConfigurationClient.new.configuration(@article.title) | ||
6 | - rescue | ||
7 | - @configuration = nil | ||
8 | - end | 4 | +begin |
5 | + @configuration = @article.title.nil? ? nil : Kalibro::Client::ConfigurationClient.new.configuration(@article.title) | ||
6 | +rescue | ||
7 | + @configuration = nil | ||
8 | +end | ||
9 | %> | 9 | %> |
10 | 10 | ||
11 | <%= error_messages_for 'kalibro_configuration' %> | 11 | <%= error_messages_for 'kalibro_configuration' %> |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
1 | -<% @configuration = @page.configuration %> | 1 | +<% @configuration_content = @page |
2 | +@configuration = Kalibro::Entities::Configuration.new | ||
3 | +@configuration.name = @configuration_content.name | ||
4 | +@configuration.description = @configuration_content.description | ||
5 | +@fake_metric_configuration = Kalibro::Entities::MetricConfiguration.new | ||
6 | +@fake_metric_configuration.metric = {:name => "fake_name", :origin => "Analizo"} | ||
7 | +@fake_metric_configuration.code = "fake_code" | ||
8 | +@configuration.metric_configurations = [@fake_metric_configuration] %> | ||
2 | 9 | ||
3 | <table id="project_info"> | 10 | <table id="project_info"> |
4 | <tr> | 11 | <tr> |
@@ -10,3 +17,26 @@ | @@ -10,3 +17,26 @@ | ||
10 | <td><%= @configuration.description %></td> | 17 | <td><%= @configuration.description %></td> |
11 | </tr> | 18 | </tr> |
12 | </table> | 19 | </table> |
20 | + | ||
21 | + | ||
22 | +<br/> | ||
23 | + | ||
24 | +<%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_profile", :action => "choose_base_tool", :params => | ||
25 | +{:configuration_name => @configuration.name} %><br/> | ||
26 | + | ||
27 | +<table> | ||
28 | +<% @configuration.metric_configurations.each do |metric_configuration| %> | ||
29 | + <tr class="titles"> | ||
30 | + <td><h5>Metric Name</h5></td> | ||
31 | + <td><h5>Collector Name</h5></td> | ||
32 | + <td><h5>Metric Code</h5></td> | ||
33 | + </tr> | ||
34 | + <tr class="metric"> | ||
35 | + <td><%= metric_configuration.metric.name %></td> | ||
36 | + <td><%= metric_configuration.metric.origin %></td> | ||
37 | + <td><%= metric_configuration.code %></td> | ||
38 | + <td><%= link_to "Edit", :controller => "mezuro_plugin_profile", :action => "edit_metric_configuration", :params => | ||
39 | + {:configuration_name => @configuration.name, :metric_code => metric_configuration.code} %></td> | ||
40 | + </tr> | ||
41 | +<% end %> | ||
42 | +</table> |
plugins/mezuro/views/mezuro_plugin_profile/_new_range.html.erb
0 → 100644
@@ -0,0 +1,55 @@ | @@ -0,0 +1,55 @@ | ||
1 | +<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %> | ||
2 | + <%= hidden_field_tag :configuration_name, @configuration_name %> | ||
3 | + <%= hidden_field_tag :metric_name, @metric_name %> | ||
4 | + <table> | ||
5 | + <tr> | ||
6 | + <td> | ||
7 | + <%= f.label :label, "Label:" %> | ||
8 | + </td> | ||
9 | + <td> | ||
10 | + <%= f.text_field :label %> | ||
11 | + </td> | ||
12 | + </tr> | ||
13 | + <tr> | ||
14 | + <td> | ||
15 | + <%= f.label :beginning, "Beginning:" %> | ||
16 | + </td> | ||
17 | + <td> | ||
18 | + <%= f.text_field :beginning %> | ||
19 | + </td> | ||
20 | + </tr> | ||
21 | + <tr> | ||
22 | + <td> | ||
23 | + <%= f.label :end, "End:" %> | ||
24 | + </td> | ||
25 | + <td> | ||
26 | + <%= f.text_field :end %> | ||
27 | + </td> | ||
28 | + </tr> | ||
29 | + <tr> | ||
30 | + <td> | ||
31 | + <%= f.label :grade, "Grade:" %> | ||
32 | + </td> | ||
33 | + <td> | ||
34 | + <%= f.text_field :grade %> | ||
35 | + </td> | ||
36 | + </tr> | ||
37 | + <tr> | ||
38 | + <td> | ||
39 | + <%= f.label :color, "Color:" %> | ||
40 | + </td> | ||
41 | + <td> | ||
42 | + <%= f.text_field :color %> | ||
43 | + </td> | ||
44 | + </tr> | ||
45 | + <tr> | ||
46 | + <td> | ||
47 | + <%= f.label :comments, "Comments:" %> | ||
48 | + </td> | ||
49 | + <td> | ||
50 | + <%= f.text_field :comments %> | ||
51 | + </td> | ||
52 | + </tr> | ||
53 | + </table> | ||
54 | + <%= f.submit "Save Range" %> | ||
55 | +<% end %> |
plugins/mezuro/views/mezuro_plugin_profile/_range.html.erb
0 → 100644
plugins/mezuro/views/mezuro_plugin_profile/choose_base_tool.html.erb
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +<h2><%= @configuration_name%> Configuration</h2> | ||
2 | + | ||
3 | +<h5>Base Tools:</h5> | ||
4 | +<table id="project_info"> | ||
5 | + <% @tool_names.base_tool_names.each do |collector_name| %> | ||
6 | + <tr> | ||
7 | + <td> | ||
8 | + <%= link_to collector_name, :controller => "mezuro_plugin_profile", :action => "choose_metric", :params => | ||
9 | + {:configuration_name => @configuration_name, :collector_name => collector_name} %> | ||
10 | + </td> | ||
11 | + </tr> | ||
12 | + <% end %> | ||
13 | +</table> |
plugins/mezuro/views/mezuro_plugin_profile/choose_metric.html.erb
0 → 100644
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +<h2><%= @configuration_name %> Configuration</h2> | ||
2 | + | ||
3 | +<table id="project_info"> | ||
4 | + <tr> | ||
5 | + <h5>Metric Collector: <%= @collector_name %></h5> | ||
6 | + </tr> | ||
7 | + <tr> | ||
8 | + <h5>Choose a metric to add:</h5> | ||
9 | + </tr> | ||
10 | + <% @collector.supported_metrics.each do |metric| %> | ||
11 | + <tr class="metric" title="<%= metric.name %>"> | ||
12 | + <td> | ||
13 | + <%= link_to metric.name, :controller => "mezuro_plugin_profile", :action => "new_metric_configuration", :params => {:metric_name => metric.name, | ||
14 | + :collector_name => @collector_name, :configuration_name => @configuration_name} %> | ||
15 | + </td> | ||
16 | + </tr> | ||
17 | + <% end %> | ||
18 | +</table> |
plugins/mezuro/views/mezuro_plugin_profile/create_range.rjs
0 → 100644
plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb
0 → 100644
@@ -0,0 +1,66 @@ | @@ -0,0 +1,66 @@ | ||
1 | +<h2><%= @configuration_name %> Configuration</h2> | ||
2 | + | ||
3 | +<% form_for @metric_configuration, :url => {:action =>"update_metric_configuration", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %> | ||
4 | + <%= hidden_field_tag :configuration_name, @configuration_name %> | ||
5 | + <p> | ||
6 | + <%= f.label :collector_name, "Collector Name:" %> | ||
7 | + <%= @metric_configuration.metric.origin %> | ||
8 | + <%= hidden_field_tag "metric[origin]", @metric_origin %> | ||
9 | + </p> | ||
10 | + <p> | ||
11 | + <%= f.label :metric_name, "Metric Name:" %> | ||
12 | + <%= @metric_configuration.metric.name %> | ||
13 | + <%= hidden_field_tag "metric[name]", @metric_name %> | ||
14 | + </p> | ||
15 | + <p> | ||
16 | + <%= f.label :code, "Code:" %> | ||
17 | + <%= @metric_configuration.code %> | ||
18 | + <%= f.hidden_field :code, :value => @metric_configuration.code %> | ||
19 | + </p> | ||
20 | + <p> | ||
21 | + <%= f.label :aggregation_form, "Aggregation Form:" %> | ||
22 | + <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | ||
23 | + ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | ||
24 | + </p> | ||
25 | + <p> | ||
26 | + <%= f.label :weight, "Weight:" %> | ||
27 | + <%= f.text_field :weight %> | ||
28 | + </p> | ||
29 | + | ||
30 | + <p> | ||
31 | + <%= f.submit "Save" %> | ||
32 | + </p> | ||
33 | +<% end %> | ||
34 | + | ||
35 | + | ||
36 | +<h5> Ranges </h5><br/> | ||
37 | + | ||
38 | +<table id="ranges"> | ||
39 | + <tr> | ||
40 | + <td> | ||
41 | + Label | ||
42 | + </td> | ||
43 | + <td> | ||
44 | + Beginning | ||
45 | + </td> | ||
46 | + <td> | ||
47 | + End | ||
48 | + </td> | ||
49 | + <td> | ||
50 | + Grade | ||
51 | + </td> | ||
52 | + <td> | ||
53 | + Color | ||
54 | + </td> | ||
55 | + </tr> | ||
56 | + <% if (@metric_configuration.ranges!=nil) | ||
57 | + @metric_configuration.ranges.each do |range| %> | ||
58 | + <%= render :partial => "range", :locals => {:range => range} %> | ||
59 | + <% end | ||
60 | + end %> | ||
61 | +</table> | ||
62 | + | ||
63 | +<br/> | ||
64 | +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_profile"} %> | ||
65 | +<div id="new_range" style="display:none"></div> | ||
66 | + |
plugins/mezuro/views/mezuro_plugin_profile/new_metric_configuration.html.erb
0 → 100644
@@ -0,0 +1,36 @@ | @@ -0,0 +1,36 @@ | ||
1 | +<h2><%= @configuration_name %> Configuration</h2> | ||
2 | + | ||
3 | +<% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %> | ||
4 | + <%= hidden_field_tag :configuration_name, @configuration_name %> | ||
5 | + <p> | ||
6 | + <%= f.label :collector_name, "Collector Name:" %> | ||
7 | + <%= @collector_name %> | ||
8 | + <%= f.hidden_field :collector_name, :value => @collector_name %> | ||
9 | + </p> | ||
10 | + <p> | ||
11 | + <%= f.label :metric_name, "Metric Name:" %> | ||
12 | + <%= @metric_name %> | ||
13 | + <%= f.hidden_field :metric_name, :value => @metric_name %> | ||
14 | + </p> | ||
15 | + <p> | ||
16 | + <%= f.label :description, "Description:" %> | ||
17 | + <%= f.text_field :description %> | ||
18 | + </p> | ||
19 | + <p> | ||
20 | + <%= f.label :code, "Code:" %> | ||
21 | + <%= f.text_field :code %> | ||
22 | + </p> | ||
23 | + <p> | ||
24 | + <%= f.label :aggregation, "Aggregation:" %> | ||
25 | + <%= f.select :aggregation, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | ||
26 | + ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | ||
27 | + </p> | ||
28 | + <p> | ||
29 | + <%= f.label :weight, "Weight:" %> | ||
30 | + <%= f.text_field :weight %> | ||
31 | + </p> | ||
32 | + <p> | ||
33 | + <%= f.submit "Add" %> | ||
34 | + </p> | ||
35 | + | ||
36 | +<% end %> |
plugins/mezuro/views/mezuro_plugin_profile/new_range.rjs
0 → 100644
plugins/mezuro/views/mezuro_plugin_profile/teste.html.erb
0 → 100644
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +<h3><%= @configuration_name %></h3> |