Commit 5b1b4afc9b66f0d66e4d4440da52c6f938d26232
Committed by
João M. M. da Silva
1 parent
c07f1fb0
Exists in
master
and in
28 other branches
Loading metrics from client(needs refactoring)
(tests not running in the enviroment)
Showing
8 changed files
with
39 additions
and
6 deletions
Show diff stats
plugins/mezuro/lib/kalibro/client/configuration_client.rb
| @@ -4,6 +4,7 @@ class Kalibro::Client::ConfigurationClient | @@ -4,6 +4,7 @@ class Kalibro::Client::ConfigurationClient | ||
| 4 | configuration = Kalibro::Entities::Configuration.new | 4 | configuration = Kalibro::Entities::Configuration.new |
| 5 | configuration.name = configuration_content.name | 5 | configuration.name = configuration_content.name |
| 6 | configuration.description = configuration_content.description | 6 | configuration.description = configuration_content.description |
| 7 | + configuration.metric_ids = configuration_content.metric_ids | ||
| 7 | new.save(configuration) | 8 | new.save(configuration) |
| 8 | end | 9 | end |
| 9 | 10 |
plugins/mezuro/lib/kalibro/entities/configuration.rb
| 1 | class Kalibro::Entities::Configuration < Kalibro::Entities::Entity | 1 | class Kalibro::Entities::Configuration < Kalibro::Entities::Entity |
| 2 | 2 | ||
| 3 | - attr_accessor :name, :description, :metric_configuration | 3 | + attr_accessor :name, :description, :metric_configuration, :metric_ids |
| 4 | 4 | ||
| 5 | def metric_configuration=(value) | 5 | def metric_configuration=(value) |
| 6 | @metric_configuration = to_entity_array(value, Kalibro::Entities::MetricConfiguration) | 6 | @metric_configuration = to_entity_array(value, Kalibro::Entities::MetricConfiguration) |
plugins/mezuro/lib/kalibro/entities/metric.rb
| 1 | class Kalibro::Entities::Metric < Kalibro::Entities::Entity | 1 | class Kalibro::Entities::Metric < Kalibro::Entities::Entity |
| 2 | 2 | ||
| 3 | - attr_accessor :name, :scope, :description | 3 | + attr_accessor :name, :scope, :description, :id |
| 4 | 4 | ||
| 5 | -end | ||
| 6 | \ No newline at end of file | 5 | \ No newline at end of file |
| 6 | + def initialize name, scope, description, id | ||
| 7 | + @name = name | ||
| 8 | + @scope = scope | ||
| 9 | + @description = description | ||
| 10 | + @id = id | ||
| 11 | + end | ||
| 12 | + | ||
| 13 | +end |
plugins/mezuro/lib/mezuro_plugin/configuration_content.rb
plugins/mezuro/test/unit/mezuro_plugin/configuration_content_test.rb
| @@ -23,6 +23,11 @@ class ConfigurationContentTest < ActiveSupport::TestCase | @@ -23,6 +23,11 @@ class ConfigurationContentTest < ActiveSupport::TestCase | ||
| 23 | assert_equal 'Sets of thresholds to interpret metrics', MezuroPlugin::ConfigurationContent.description | 23 | assert_equal 'Sets of thresholds to interpret metrics', MezuroPlugin::ConfigurationContent.description |
| 24 | end | 24 | end |
| 25 | 25 | ||
| 26 | + should 'accept metric_ids' do | ||
| 27 | + @content.metric_ids = [1,5] | ||
| 28 | + assert_equal @content.metric_ids, [1,5] | ||
| 29 | + end | ||
| 30 | + | ||
| 26 | should 'have an html view' do | 31 | should 'have an html view' do |
| 27 | assert_not_nil @content.to_html | 32 | assert_not_nil @content.to_html |
| 28 | end | 33 | end |
plugins/mezuro/views/cms/mezuro_plugin/_configuration_content.html.erb
| @@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
| 6 | rescue | 6 | rescue |
| 7 | @configuration = nil | 7 | @configuration = nil |
| 8 | end | 8 | end |
| 9 | + @metrics = Kalibro::Client::MetricsClient.all_metrics | ||
| 9 | %> | 10 | %> |
| 10 | 11 | ||
| 11 | <%= error_messages_for 'kalibro_configuration' %> | 12 | <%= error_messages_for 'kalibro_configuration' %> |
| @@ -18,3 +19,12 @@ | @@ -18,3 +19,12 @@ | ||
| 18 | <%= required f.text_field(:name) %> | 19 | <%= required f.text_field(:name) %> |
| 19 | 20 | ||
| 20 | <%= f.text_field :description %><br/> | 21 | <%= f.text_field :description %><br/> |
| 22 | + | ||
| 23 | +<h3> Metrics </h3> | ||
| 24 | +<% @metrics.each do |metric| %> | ||
| 25 | + <div class="metric"> | ||
| 26 | + <%= check_box_tag "article[metric_ids][]", metric.id, true, :id => "article_metric_ids_#{metric.id}" %> | ||
| 27 | + <%= label_tag "article_metric_ids_#{metric.id}", metric.name %> | ||
| 28 | + <%= metric.description %> | ||
| 29 | + </div> | ||
| 30 | +<% end %> |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
| 1 | -<% @configuration = @page.configuration %> | 1 | +<% @configuration_content = @page %> |
| 2 | 2 | ||
| 3 | <table id="project_info"> | 3 | <table id="project_info"> |
| 4 | <tr> | 4 | <tr> |
| 5 | <td><%= _('Name') %></td> | 5 | <td><%= _('Name') %></td> |
| 6 | - <td><%= @configuration.name %></td> | 6 | + <td><%= @configuration_content.name %></td> |
| 7 | </tr> | 7 | </tr> |
| 8 | <tr> | 8 | <tr> |
| 9 | <td><%= _('Description') %></td> | 9 | <td><%= _('Description') %></td> |
| 10 | - <td><%= @configuration.description %></td> | 10 | + <td><%= @configuration_content.description %></td> |
| 11 | </tr> | 11 | </tr> |
| 12 | </table> | 12 | </table> |