Commit 03f1e6329886fa5a96e0237409073e5cea144b8e

Authored by João M. M. da Silva + Alessandro Palmeira
Committed by João M. M. da Silva
1 parent 2e1b1e90

[Mezuro] added basic edit and create metric configuration screens

plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -35,14 +35,36 @@ class MezuroPluginProfileController < ProfileController @@ -35,14 +35,36 @@ class MezuroPluginProfileController < ProfileController
35 def choose_metric 35 def choose_metric
36 @configuration_name = params[:configuration_name] 36 @configuration_name = params[:configuration_name]
37 @collector_name = params[:collector_name] 37 @collector_name = params[:collector_name]
38 - collector_client = Kalibro::Client::BaseToolClient.new  
39 - @collector = collector_client.base_tool(@collector_name) 38 +
  39 + @collector = Kalibro::Client::BaseToolClient.new.base_tool(@collector_name)
40 end 40 end
41 41
42 - def add_metric 42 + def new_metric_configuration
43 @metric_name = params[:metric_name] 43 @metric_name = params[:metric_name]
44 @configuration_name = params[:configuration_name] 44 @configuration_name = params[:configuration_name]
45 @collector_name = params[:collector_name] 45 @collector_name = params[:collector_name]
46 end 46 end
47 47
  48 + def edit_metric_configuration
  49 + @metric_configuration_code = params[:metric_code]
  50 + @configuration_name = params[:configuration_name]
  51 +
  52 + @metric_configuration = Kalibro::Entities::MetricConfiguration.new
  53 + @metric_configuration.code = @metric_configuration_code
  54 + @metric_configuration.aggregation_form = "MEDIAN"
  55 + @metric_configuration.weight = "1"
  56 + @metric_configuration.metric = Kalibro::Entities::NativeMetric.new
  57 + @metric_configuration.metric.name = "Nome falso"
  58 + @metric_configuration.metric.origin = "Origem Falsa"
  59 + end
  60 +
  61 + def create_metric_configuration
  62 + @configuration_name = params[:configuration_name]
  63 + redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}"
  64 + end
  65 +
  66 + def update_metric_configuration
  67 + @configuration_name = params[:configuration_name]
  68 + redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}"
  69 + end
48 end 70 end
plugins/mezuro/views/content_viewer/show_configuration.rhtml
@@ -27,10 +27,8 @@ @@ -27,10 +27,8 @@
27 <td><%= metric_configuration.metric.name %></td> 27 <td><%= metric_configuration.metric.name %></td>
28 <td><%= metric_configuration.metric.origin %></td> 28 <td><%= metric_configuration.metric.origin %></td>
29 <td><%= metric_configuration.code %></td> 29 <td><%= metric_configuration.code %></td>
30 - <td><%= link_to "Edit", :controller => "mezuro_plugin_profile", :action => "edit_metric", :params => 30 + <td><%= link_to "Edit", :controller => "mezuro_plugin_profile", :action => "edit_metric_configuration", :params =>
31 {:configuration_name => @configuration.name, :metric_code => metric_configuration.code} %></td> 31 {:configuration_name => @configuration.name, :metric_code => metric_configuration.code} %></td>
32 </tr> 32 </tr>
33 <% end %> 33 <% end %>
34 </table> 34 </table>
35 -  
36 -<% #link_to "Teste", "/profile/#{profile.identifier}/plugins/mezuro/teste" %>  
plugins/mezuro/views/mezuro_plugin_profile/add_metric.html.erb
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
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>Metric choosed <%= @metric_name %></h5>  
9 - </tr>  
10 -</table>  
plugins/mezuro/views/mezuro_plugin_profile/choose_metric.html.erb
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <% @collector.supported_metrics.each do |metric| %> 10 <% @collector.supported_metrics.each do |metric| %>
11 <tr class="metric" title="<%= metric.name %>"> 11 <tr class="metric" title="<%= metric.name %>">
12 <td> 12 <td>
13 - <%= link_to metric.name, :controller => "mezuro_plugin_profile", :action => "add_metric", :params => {:metric_name => metric.name, 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} %> 14 :collector_name => @collector_name, :configuration_name => @configuration_name} %>
15 </td> 15 </td>
16 </tr> 16 </tr>
plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb 0 → 100644
@@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
  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 + <p>
  30 + <%= f.submit "Save" %>
  31 + </p>
  32 +
  33 +<% end %>
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 %>