Commit bc2113ca33e353e2f391f2ae40aaedf5086ec861
1 parent
d819ba58
Exists in
colab
and in
4 other branches
Fixed metric selection on MetricConfiguration creation
Signed off by: Daniel Paulino Alves <danpaulalves@gmail.com>
Showing
4 changed files
with
16 additions
and
12 deletions
Show diff stats
Gemfile.lock
| 1 | GIT | 1 | GIT |
| 2 | remote: https://github.com/mezuro/kalibro_client | 2 | remote: https://github.com/mezuro/kalibro_client |
| 3 | - revision: 212353618d1bc315b26dfd77793654be205397fc | 3 | + revision: f602fbb76c2dd5e1b8ad9c28934647c33f85c991 |
| 4 | specs: | 4 | specs: |
| 5 | kalibro_client (0.0.1) | 5 | kalibro_client (0.0.1) |
| 6 | activeresource (~> 4.0.0) | 6 | activeresource (~> 4.0.0) |
| @@ -157,7 +157,7 @@ GEM | @@ -157,7 +157,7 @@ GEM | ||
| 157 | metaclass (0.0.4) | 157 | metaclass (0.0.4) |
| 158 | mime-types (2.4.3) | 158 | mime-types (2.4.3) |
| 159 | mini_portile (0.6.1) | 159 | mini_portile (0.6.1) |
| 160 | - minitest (5.4.3) | 160 | + minitest (5.5.0) |
| 161 | mocha (1.1.0) | 161 | mocha (1.1.0) |
| 162 | metaclass (~> 0.0.1) | 162 | metaclass (~> 0.0.1) |
| 163 | multi_json (1.10.1) | 163 | multi_json (1.10.1) |
app/controllers/metric_configurations_controller.rb
| 1 | class MetricConfigurationsController < BaseMetricConfigurationsController | 1 | class MetricConfigurationsController < BaseMetricConfigurationsController |
| 2 | def choose_metric | 2 | def choose_metric |
| 3 | - @kalibro_configuration_id = params[:kalibro_configuration_id].to_i | 3 | + @kalibro_configuration = KalibroConfiguration.find(params[:kalibro_configuration_id].to_i) |
| 4 | @metric_configuration_id = params[:metric_configuration_id].to_i | 4 | @metric_configuration_id = params[:metric_configuration_id].to_i |
| 5 | - @metric_collectors = KalibroClient::Processor::MetricCollector.all | 5 | + @metric_collectors_names = KalibroClient::Processor::MetricCollector.all_names |
| 6 | end | 6 | end |
| 7 | 7 | ||
| 8 | def new | 8 | def new |
app/helpers/metric_configurations_helper.rb
| @@ -13,4 +13,8 @@ module MetricConfigurationsHelper | @@ -13,4 +13,8 @@ module MetricConfigurationsHelper | ||
| 13 | [ metric_configuration.code, metric_configuration.metric.name ] | 13 | [ metric_configuration.code, metric_configuration.metric.name ] |
| 14 | end | 14 | end |
| 15 | end | 15 | end |
| 16 | + | ||
| 17 | + def supported_metrics_of(metric_collector_name) | ||
| 18 | + KalibroClient::Processor::MetricCollector.find(metric_collector_name).supported_metrics | ||
| 19 | + end | ||
| 16 | end | 20 | end |
app/views/metric_configurations/choose_metric.html.erb
| @@ -2,24 +2,24 @@ | @@ -2,24 +2,24 @@ | ||
| 2 | <h1>Choose a metric from a Base Tool:</h1> | 2 | <h1>Choose a metric from a Base Tool:</h1> |
| 3 | </div> | 3 | </div> |
| 4 | 4 | ||
| 5 | -<%= form_tag kalibro_configuration_new_metric_configuration_path(@kalibro_configuration_id) do %> | 5 | +<%= form_tag kalibro_configuration_new_metric_configuration_path(@kalibro_configuration.id) do %> |
| 6 | <%= hidden_field_tag(:metric_collector_name,) %> | 6 | <%= hidden_field_tag(:metric_collector_name,) %> |
| 7 | <%= hidden_field_tag(:metric_name) %> | 7 | <%= hidden_field_tag(:metric_name) %> |
| 8 | <% end %> | 8 | <% end %> |
| 9 | 9 | ||
| 10 | <div id="base-tool-accordion"> | 10 | <div id="base-tool-accordion"> |
| 11 | - <% @metric_collectors.each do |metric_collector| %> | ||
| 12 | - <h3 class="jquery-ui-accordion"><%= metric_collector.name %></h3> | 11 | + <% @metric_collectors_names.each do |metric_collector_name| %> |
| 12 | + <h3 class="jquery-ui-accordion"><%= metric_collector_name %></h3> | ||
| 13 | <div> | 13 | <div> |
| 14 | - <% metric_collector.supported_metrics.each do |code, metric| %> | ||
| 15 | - <%= link_to metric.name, '#', onclick: "MetricCollector.choose_metric(\"#{metric.name}\", \"#{metric_collector.name}\");", remote: true %><br> | 14 | + <% supported_metrics_of(metric_collector_name).each do |metric| %> |
| 15 | + <%= link_to metric.name, '#', onclick: "MetricCollector.choose_metric(\"#{metric.name}\", \"#{metric_collector_name}\");", remote: true %><br> | ||
| 16 | <% end %> | 16 | <% end %> |
| 17 | </div> | 17 | </div> |
| 18 | <% end %> | 18 | <% end %> |
| 19 | </div><br /> | 19 | </div><br /> |
| 20 | 20 | ||
| 21 | -<%= link_to 'Back', kalibro_configuration_path(@kalibro_configuration_id), class: 'btn btn-default' %> | ||
| 22 | -<%= link_to 'Compound Metric', new_kalibro_configuration_compound_metric_configuration_path(@kalibro_configuration_id), class: 'btn btn-info', id: "link_to_compound" %> | 21 | +<%= link_to 'Back', kalibro_configuration_path(@kalibro_configuration.id), class: 'btn btn-default' %> |
| 22 | +<%= link_to 'Compound Metric', new_kalibro_configuration_compound_metric_configuration_path(@kalibro_configuration.id), class: 'btn btn-info', id: "link_to_compound" %> | ||
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | <script type="text/javascript"> | 25 | <script type="text/javascript"> |
| @@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
| 31 | }); | 31 | }); |
| 32 | }); | 32 | }); |
| 33 | 33 | ||
| 34 | - <% if MetricConfiguration.metric_configurations_of(@kalibro_configuration_id).blank? %> | 34 | + <% if @kalibro_configuration.metric_configurations.blank? %> |
| 35 | $("#link_to_compound").css("display", "none"); | 35 | $("#link_to_compound").css("display", "none"); |
| 36 | <% end %> | 36 | <% end %> |
| 37 | </script> | 37 | </script> |