Commit 753516fac863250a9e9dae1c96ca292d63e88cc9
Committed by
Rafael Manzo
1 parent
c204718c
Exists in
master
and in
28 other branches
[Mezuro] adding, editing and removing draft for compound metric in configuration…
…, not working yet, but it should
Showing
3 changed files
with
108 additions
and
24 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_myprofile_controller.rb
| @@ -111,10 +111,26 @@ class MezuroPluginMyprofileController < ProfileController | @@ -111,10 +111,26 @@ class MezuroPluginMyprofileController < ProfileController | ||
| 111 | def create_compound_metric_configuration | 111 | def create_compound_metric_configuration |
| 112 | @configuration_name = params[:configuration_name] | 112 | @configuration_name = params[:configuration_name] |
| 113 | compound_metric_configuration = new_compound_metric_configuration_instance | 113 | compound_metric_configuration = new_compound_metric_configuration_instance |
| 114 | - # NOT WORKING # Kalibro::Client::MetricConfigurationClient.new.save(compound_metric_configuration, @configuration_name) | 114 | + Kalibro::Client::MetricConfigurationClient.new.save(compound_metric_configuration, @configuration_name) |
| 115 | redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" | 115 | redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" |
| 116 | end | 116 | end |
| 117 | - | 117 | + |
| 118 | + def edit_compound_metric_configuration | ||
| 119 | + metric_name = params[:metric_name] | ||
| 120 | + @configuration_name = params[:configuration_name] | ||
| 121 | + @metric_configuration = Kalibro::Client::MetricConfigurationClient.new.metric_configuration(@configuration_name, metric_name) | ||
| 122 | + @metric = @metric_configuration.metric | ||
| 123 | + end | ||
| 124 | + | ||
| 125 | + def update_compound_metric_configuration | ||
| 126 | + @configuration_name = params[:configuration_name] | ||
| 127 | + metric_name = params[:metric][:name] | ||
| 128 | + metric_configuration = Kalibro::Client::MetricConfigurationClient.new.metric_configuration(@configuration_name, metric_name) | ||
| 129 | + assign_compound_metric_configuration_instance (metric_configuration) | ||
| 130 | + Kalibro::Client::MetricConfigurationClient.new.save(metric_configuration, @configuration_name) | ||
| 131 | + redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}" | ||
| 132 | + end | ||
| 133 | + | ||
| 118 | private | 134 | private |
| 119 | 135 | ||
| 120 | def new_metric_configuration_instance | 136 | def new_metric_configuration_instance |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
| 1 | <% @configuration_content = @page | 1 | <% @configuration_content = @page |
| 2 | @configuration = Kalibro::Client::ConfigurationClient.new.configuration(@configuration_content.name) %> | 2 | @configuration = Kalibro::Client::ConfigurationClient.new.configuration(@configuration_content.name) %> |
| 3 | -<% | ||
| 4 | - # FAKE de CompoundMetric | ||
| 5 | - fake_compound_metric = Kalibro::Entities::CompoundMetric.new | ||
| 6 | - fake_compound_metric.script = "return LOC*1;" | ||
| 7 | - fake_compound_metric.name = "new LOC" | ||
| 8 | - fake_compound_metric.scope = "CLASS" | ||
| 9 | - fake_compound_metric.description = "Description" | ||
| 10 | - fake_compound_metric_configuration = Kalibro::Entities::MetricConfiguration.new | ||
| 11 | - fake_compound_metric_configuration.metric = fake_compound_metric | ||
| 12 | - fake_compound_metric_configuration.code = "code" | ||
| 13 | - @configuration.metric_configurations << fake_compound_metric_configuration | ||
| 14 | -%> | ||
| 15 | 3 | ||
| 16 | <table id="project_info"> | 4 | <table id="project_info"> |
| 17 | <tr> | 5 | <tr> |
| @@ -38,17 +26,22 @@ | @@ -38,17 +26,22 @@ | ||
| 38 | <% @configuration.metric_configurations.each do |metric_configuration| %> | 26 | <% @configuration.metric_configurations.each do |metric_configuration| %> |
| 39 | <tr class="metric"> | 27 | <tr class="metric"> |
| 40 | <td><%= metric_configuration.metric.name %></td> | 28 | <td><%= metric_configuration.metric.name %></td> |
| 41 | - | ||
| 42 | - <td> | ||
| 43 | - <% if metric_configuration.metric.instance_of? Kalibro::Entities::NativeMetric %> | 29 | + <% if metric_configuration.metric.instance_of? Kalibro::Entities::NativeMetric %> |
| 30 | + <td> | ||
| 44 | <%= metric_configuration.metric.origin %> | 31 | <%= metric_configuration.metric.origin %> |
| 45 | - <% else %> Compound Metric | ||
| 46 | - <% end %> | ||
| 47 | - </td> | ||
| 48 | - | ||
| 49 | - <td><%= metric_configuration.code %></td> | ||
| 50 | - <td><%= link_to "Edit", :controller => "mezuro_plugin_myprofile", :action => "edit_metric_configuration", :params => | ||
| 51 | - {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> | 32 | + </td> |
| 33 | + <td><%= metric_configuration.code %></td> | ||
| 34 | + <td><%= link_to "Edit", :controller => "mezuro_plugin_myprofile", :action => "edit_metric_configuration", :params => | ||
| 35 | + {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> | ||
| 36 | + <% else %> | ||
| 37 | + <td> | ||
| 38 | + Compound Metric | ||
| 39 | + </td> | ||
| 40 | + <td><%= metric_configuration.code %></td> | ||
| 41 | + <td><%= link_to "Edit", :controller => "mezuro_plugin_myprofile", :action => "edit_compound_metric_configuration", :params => | ||
| 42 | + {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> | ||
| 43 | + <% end %> | ||
| 44 | + | ||
| 52 | <td><%= link_to "Remove", :controller => "mezuro_plugin_myprofile", :action => "remove_metric_configuration", :params => | 45 | <td><%= link_to "Remove", :controller => "mezuro_plugin_myprofile", :action => "remove_metric_configuration", :params => |
| 53 | {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> | 46 | {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td> |
| 54 | </tr> | 47 | </tr> |
plugins/mezuro/views/mezuro_plugin_myprofile/edit_compound_metric_configuration.html.erb
0 → 100644
| @@ -0,0 +1,75 @@ | @@ -0,0 +1,75 @@ | ||
| 1 | +<h2><%= @configuration_name %> Configuration</h2> | ||
| 2 | + | ||
| 3 | +<% form_for :metric_configuration, :url => {:action =>"update_compound_metric_configuration", :controller => "mezuro_plugin_myprofile"}, :method => :get do |f| %> | ||
| 4 | + <%= hidden_field_tag :configuration_name, @configuration_name %> | ||
| 5 | + | ||
| 6 | + <p> | ||
| 7 | + <%= f.label :metric_name, "Metric Name:" %> | ||
| 8 | + <%= @metric.name %> | ||
| 9 | + <%= hidden_field_tag "metric[name]", @metric.name %> | ||
| 10 | + </p> | ||
| 11 | + <p> | ||
| 12 | + <%= f.label :description, "Description:" %> | ||
| 13 | + <%= @metric.description %> | ||
| 14 | + <%= text_field_tag "metric[description]", @metric.description %> | ||
| 15 | + </p> | ||
| 16 | + <p> | ||
| 17 | + <%= f.label :code, "Code:" %> | ||
| 18 | + <%= f.text_field :code %> | ||
| 19 | + </p> | ||
| 20 | + <p> | ||
| 21 | + <%= f.label :scope, "Scope:" %> | ||
| 22 | + <%= @metric.scope %> | ||
| 23 | + <%= text_field_tag "metric[scope]", @metric.scope %> | ||
| 24 | + </p> | ||
| 25 | + <p> | ||
| 26 | + <%= f.label :aggregation_form, "Aggregation Form:" %> | ||
| 27 | + <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"], | ||
| 28 | + ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %> | ||
| 29 | + </p> | ||
| 30 | + <p> | ||
| 31 | + <%= f.label :weight, "Weight:" %> | ||
| 32 | + <%= f.text_field :weight %> | ||
| 33 | + </p> | ||
| 34 | + <p> | ||
| 35 | + <%= f.label :script, "script:" %> | ||
| 36 | + <%= f.text_area :script %> | ||
| 37 | + </p> | ||
| 38 | + <p> | ||
| 39 | + <%= f.submit "Save" %> | ||
| 40 | + </p> | ||
| 41 | +<% end %> | ||
| 42 | + | ||
| 43 | + | ||
| 44 | +<h5> Ranges </h5><br/> | ||
| 45 | + | ||
| 46 | +<table id="ranges"> | ||
| 47 | + <tr> | ||
| 48 | + <td> | ||
| 49 | + Label | ||
| 50 | + </td> | ||
| 51 | + <td> | ||
| 52 | + Beginning | ||
| 53 | + </td> | ||
| 54 | + <td> | ||
| 55 | + End | ||
| 56 | + </td> | ||
| 57 | + <td> | ||
| 58 | + Grade | ||
| 59 | + </td> | ||
| 60 | + <td> | ||
| 61 | + Color | ||
| 62 | + </td> | ||
| 63 | + </tr> | ||
| 64 | + <% if (@metric_configuration.ranges!=nil) | ||
| 65 | + @metric_configuration.ranges.each do |range| %> | ||
| 66 | + <%= render :partial => "range", :locals => {:range => range, :configuration_name => @configuration_name, | ||
| 67 | + :metric_name => @metric_configuration.metric.name} %> | ||
| 68 | + <% end | ||
| 69 | + end %> | ||
| 70 | +</table> | ||
| 71 | + | ||
| 72 | +<br/> | ||
| 73 | +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_myprofile", :configuration_name => @configuration_name, :metric_name => @metric.name} %> | ||
| 74 | +<div id="range_form" style="display:none"></div> | ||
| 75 | + |