Commit 9aeb6dc29cde1e2c8e9cccf9787929a2d75c2d9a
Committed by
Paulo Meireles
1 parent
56378671
Exists in
master
and in
28 other branches
[Mezuro] Creating, editing and removing Configuration.
Showing
9 changed files
with
145 additions
and
101 deletions
Show diff stats
plugins/mezuro/lib/kalibro/configuration.rb
| 1 | class Kalibro::Configuration < Kalibro::Model | 1 | class Kalibro::Configuration < Kalibro::Model |
| 2 | 2 | ||
| 3 | attr_accessor :id, :name, :description | 3 | attr_accessor :id, :name, :description |
| 4 | - | 4 | + |
| 5 | + def id=(value) | ||
| 6 | + @id = value.to_i | ||
| 7 | + end | ||
| 8 | + | ||
| 5 | def self.configuration_of(repository_id) | 9 | def self.configuration_of(repository_id) |
| 6 | new request(:configuration_of, {:repository_id => repository_id})[:configuration] | 10 | new request(:configuration_of, {:repository_id => repository_id})[:configuration] |
| 7 | end | 11 | end |
| @@ -13,10 +17,4 @@ class Kalibro::Configuration < Kalibro::Model | @@ -13,10 +17,4 @@ class Kalibro::Configuration < Kalibro::Model | ||
| 13 | response.map {|configuration| new configuration} | 17 | response.map {|configuration| new configuration} |
| 14 | end | 18 | end |
| 15 | 19 | ||
| 16 | - | ||
| 17 | - def update_attributes(attributes={}) | ||
| 18 | - attributes.each { |field, value| send("#{field}=", value) if self.class.is_valid?(field) } | ||
| 19 | - save | ||
| 20 | - end | ||
| 21 | - | ||
| 22 | end | 20 | end |
plugins/mezuro/lib/mezuro_plugin/configuration_content.rb
| 1 | class MezuroPlugin::ConfigurationContent < Article | 1 | class MezuroPlugin::ConfigurationContent < Article |
| 2 | - validate_on_create :validate_kalibro_configuration_name | 2 | + validate_on_create :validate_configuration_name |
| 3 | 3 | ||
| 4 | - settings_items :kalibro_id, :description, :configuration_to_clone_name | 4 | + settings_items :configuration_id |
| 5 | 5 | ||
| 6 | - after_save :send_kalibro_configuration_to_service | ||
| 7 | - after_destroy :remove_kalibro_configuration_from_service | 6 | + before_save :send_configuration_to_service |
| 7 | + after_destroy :remove_configuration_from_service | ||
| 8 | 8 | ||
| 9 | def self.short_description | 9 | def self.short_description |
| 10 | 'Mezuro configuration' | 10 | 'Mezuro configuration' |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | def self.description | 13 | def self.description |
| 14 | - 'Sets of thresholds to interpret metrics' | 14 | + 'Set of metric configurations to interpret a Kalibro project' |
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | include ActionView::Helpers::TagHelper | 17 | include ActionView::Helpers::TagHelper |
| @@ -21,25 +21,21 @@ class MezuroPlugin::ConfigurationContent < Article | @@ -21,25 +21,21 @@ class MezuroPlugin::ConfigurationContent < Article | ||
| 21 | end | 21 | end |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | - def kalibro_configuration | 24 | + def kalibro_configuration #Can't be just "configuration", method name exists somewhere in noosfero |
| 25 | begin | 25 | begin |
| 26 | - @kalibro_configuration ||= Kalibro::Configuration.find(self.kalibro_id) | 26 | + @configuration ||= Kalibro::Configuration.find(self.configuration_id) |
| 27 | rescue Exception => exception | 27 | rescue Exception => exception |
| 28 | errors.add_to_base(exception.message) | 28 | errors.add_to_base(exception.message) |
| 29 | end | 29 | end |
| 30 | - @kalibro_configuration | 30 | + @configuration |
| 31 | end | 31 | end |
| 32 | 32 | ||
| 33 | -# def metric_configurations | ||
| 34 | -# kalibro_configuration.metric_configurations | ||
| 35 | -# end | ||
| 36 | - | ||
| 37 | - def kalibro_configuration_names_and_ids | 33 | + def configuration_names_and_ids |
| 38 | all_names_and_ids = {} | 34 | all_names_and_ids = {} |
| 39 | begin | 35 | begin |
| 40 | all_configurations = Kalibro::Configuration.all | 36 | all_configurations = Kalibro::Configuration.all |
| 41 | - if(!all_configurations.nil?) | ||
| 42 | - all_configuration.each do |configuration| | 37 | + if(!all_configurations.empty?) |
| 38 | + all_configurations.each do |configuration| | ||
| 43 | all_names_and_ids[configuration.id] = configuration.name | 39 | all_names_and_ids[configuration.id] = configuration.name |
| 44 | end | 40 | end |
| 45 | end | 41 | end |
| @@ -50,40 +46,63 @@ class MezuroPlugin::ConfigurationContent < Article | @@ -50,40 +46,63 @@ class MezuroPlugin::ConfigurationContent < Article | ||
| 50 | all_names_and_ids | 46 | all_names_and_ids |
| 51 | end | 47 | end |
| 52 | 48 | ||
| 49 | + def description=(value) | ||
| 50 | + @description=value | ||
| 51 | + end | ||
| 52 | + | ||
| 53 | + def description | ||
| 54 | + begin | ||
| 55 | + @description ||= kalibro_configuration.description | ||
| 56 | + rescue | ||
| 57 | + @description = "" | ||
| 58 | + end | ||
| 59 | + @description | ||
| 60 | + end | ||
| 61 | + | ||
| 62 | + def metric_configurations | ||
| 63 | + begin | ||
| 64 | + @metric_configurations ||= Kalibro::MetricConfiguration.metric_configurations_of(configuration_id) | ||
| 65 | + rescue Exception => error | ||
| 66 | + errors.add_to_base(error.message) | ||
| 67 | + @metric_configurations = [] | ||
| 68 | + end | ||
| 69 | + @metric_configurations | ||
| 70 | + end | ||
| 71 | + | ||
| 72 | + def metric_configurations=(value) | ||
| 73 | + @metric_configurations = value.kind_of?(Array) ? value : [value] | ||
| 74 | + @metric_configurations = @metric_configurations.map { |element| to_metric_configuration(element) } | ||
| 75 | + end | ||
| 76 | + | ||
| 53 | private | 77 | private |
| 54 | 78 | ||
| 55 | - def validate_kalibro_configuration_name | ||
| 56 | - existing = kalibro_configuration_names.map { |a| a.downcase} | 79 | + def self.to_metric_configuration value |
| 80 | + value.kind_of?(Hash) ? Kalibro::MetricConfiguration.new(value) : value | ||
| 81 | + end | ||
| 82 | + | ||
| 83 | + def validate_configuration_name | ||
| 84 | + existing = configuration_names_and_ids.values.map { |a| a.downcase} | ||
| 57 | 85 | ||
| 58 | if existing.include?(name.downcase) | 86 | if existing.include?(name.downcase) |
| 59 | errors.add_to_base("Configuration name already exists in Kalibro") | 87 | errors.add_to_base("Configuration name already exists in Kalibro") |
| 60 | end | 88 | end |
| 61 | end | 89 | end |
| 62 | 90 | ||
| 63 | - def send_kalibro_configuration_to_service | ||
| 64 | - if editing_kalibro_configuration? | ||
| 65 | - kalibro_configuration.update_attributes({:description => description}) | ||
| 66 | - else | ||
| 67 | - create_kalibro_configuration | ||
| 68 | - end | 91 | + def send_configuration_to_service |
| 92 | + attributes = {:id => configuration_id, :name => name, :description => description} | ||
| 93 | +# if cloning_configuration? | ||
| 94 | +# attributes[:metric_configuration] = configuration_to_clone.metric_configurations_hash | ||
| 95 | +# end | ||
| 96 | + created_configuration = Kalibro::Configuration.create attributes | ||
| 97 | + self.configuration_id = created_configuration.id | ||
| 69 | end | 98 | end |
| 70 | 99 | ||
| 71 | - def remove_kalibro_configuration_from_service | 100 | + def remove_configuration_from_service |
| 101 | + puts "aqui tem #{@configuration.inspect}" | ||
| 72 | kalibro_configuration.destroy unless kalibro_configuration.nil? | 102 | kalibro_configuration.destroy unless kalibro_configuration.nil? |
| 73 | end | 103 | end |
| 74 | 104 | ||
| 75 | - def create_kalibro_configuration | ||
| 76 | - attributes = {:name => name, :description => description} | ||
| 77 | - if cloning_kalibro_configuration? | ||
| 78 | - attributes[:metric_configuration] = configuration_to_clone.metric_configurations_hash | ||
| 79 | - end | ||
| 80 | - Kalibro::Configuration.create attributes | ||
| 81 | - end | ||
| 82 | - | ||
| 83 | - def editing_kalibro_configuration? | ||
| 84 | - kalibro_configuration.present? | ||
| 85 | - end | ||
| 86 | - | 105 | +=begin |
| 87 | def configuration_to_clone | 106 | def configuration_to_clone |
| 88 | @configuration_to_clone ||= find_configuration_to_clone | 107 | @configuration_to_clone ||= find_configuration_to_clone |
| 89 | end | 108 | end |
| @@ -92,8 +111,9 @@ class MezuroPlugin::ConfigurationContent < Article | @@ -92,8 +111,9 @@ class MezuroPlugin::ConfigurationContent < Article | ||
| 92 | (configuration_to_clone_name == "None") ? nil : Kalibro::Configuration.find_by_name(configuration_to_clone_name) | 111 | (configuration_to_clone_name == "None") ? nil : Kalibro::Configuration.find_by_name(configuration_to_clone_name) |
| 93 | end | 112 | end |
| 94 | 113 | ||
| 95 | - def cloning_kalibro_configuration? | 114 | + def cloning_configuration? |
| 96 | configuration_to_clone.present? | 115 | configuration_to_clone.present? |
| 97 | end | 116 | end |
| 117 | +=end | ||
| 98 | 118 | ||
| 99 | end | 119 | end |
plugins/mezuro/lib/mezuro_plugin/project_content.rb
| @@ -3,6 +3,9 @@ class MezuroPlugin::ProjectContent < Article | @@ -3,6 +3,9 @@ class MezuroPlugin::ProjectContent < Article | ||
| 3 | 3 | ||
| 4 | settings_items :project_id | 4 | settings_items :project_id |
| 5 | 5 | ||
| 6 | + before_save :send_project_to_service | ||
| 7 | + after_destroy :destroy_project_from_service | ||
| 8 | + | ||
| 6 | def self.short_description | 9 | def self.short_description |
| 7 | 'Mezuro project' | 10 | 'Mezuro project' |
| 8 | end | 11 | end |
| @@ -54,9 +57,6 @@ class MezuroPlugin::ProjectContent < Article | @@ -54,9 +57,6 @@ class MezuroPlugin::ProjectContent < Article | ||
| 54 | @repositories = @repositories.map { |element| to_repository(element) } | 57 | @repositories = @repositories.map { |element| to_repository(element) } |
| 55 | end | 58 | end |
| 56 | 59 | ||
| 57 | - before_save :send_project_to_service | ||
| 58 | - after_destroy :destroy_project_from_service | ||
| 59 | - | ||
| 60 | private | 60 | private |
| 61 | 61 | ||
| 62 | def self.to_repository value | 62 | def self.to_repository value |
plugins/mezuro/lib/mezuro_plugin/reading_group_content.rb
| @@ -3,6 +3,9 @@ class MezuroPlugin::ReadingGroupContent < Article | @@ -3,6 +3,9 @@ class MezuroPlugin::ReadingGroupContent < Article | ||
| 3 | 3 | ||
| 4 | settings_items :reading_group_id | 4 | settings_items :reading_group_id |
| 5 | 5 | ||
| 6 | + before_save :send_reading_group_to_service | ||
| 7 | + after_destroy :destroy_reading_group_from_service | ||
| 8 | + | ||
| 6 | def self.short_description | 9 | def self.short_description |
| 7 | 'Mezuro reading group' | 10 | 'Mezuro reading group' |
| 8 | end | 11 | end |
| @@ -54,9 +57,6 @@ class MezuroPlugin::ReadingGroupContent < Article | @@ -54,9 +57,6 @@ class MezuroPlugin::ReadingGroupContent < Article | ||
| 54 | @readings = @readings.map { |element| to_reading(element) } | 57 | @readings = @readings.map { |element| to_reading(element) } |
| 55 | end | 58 | end |
| 56 | 59 | ||
| 57 | - before_save :send_reading_group_to_service | ||
| 58 | - after_destroy :destroy_reading_group_from_service | ||
| 59 | - | ||
| 60 | private | 60 | private |
| 61 | 61 | ||
| 62 | def self.to_reading value | 62 | def self.to_reading value |
plugins/mezuro/test/fixtures/configuration_content_fixtures.rb
0 → 100644
| @@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
| 1 | +class ConfigurationContentFixtures | ||
| 2 | + | ||
| 3 | + def self.configuration_content | ||
| 4 | + MezuroPlugin::ConfigurationContent.new configuration_content_hash | ||
| 5 | + end | ||
| 6 | + | ||
| 7 | + def self.created_configuration_content | ||
| 8 | + MezuroPlugin::ConfigurationContent.new( { | ||
| 9 | + :name => 'Sample Configuration', | ||
| 10 | + :description => 'Kalibro configuration for Java projects.', | ||
| 11 | + :configuration_id => nil | ||
| 12 | + } ) | ||
| 13 | + end | ||
| 14 | + | ||
| 15 | + def self.configuration_content_hash | ||
| 16 | + { | ||
| 17 | + :name => 'Sample Configuration', | ||
| 18 | + :description => 'Kalibro configuration for Java projects.', | ||
| 19 | + :configuration_id => "42" | ||
| 20 | + } | ||
| 21 | + end | ||
| 22 | + | ||
| 23 | +end |
plugins/mezuro/test/fixtures/configuration_fixtures.rb
| @@ -21,16 +21,8 @@ class ConfigurationFixtures | @@ -21,16 +21,8 @@ class ConfigurationFixtures | ||
| 21 | } | 21 | } |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | - def self.configuration_content(clone_configuration) | ||
| 25 | - MezuroPlugin::ConfigurationContent.new({ | ||
| 26 | - :name => 'Sample Configuration', | ||
| 27 | - :description => 'Kalibro configuration for Java projects.', | ||
| 28 | - :configuration_to_clone_name => clone_configuration | ||
| 29 | - }) | 24 | + def self.all |
| 25 | + [configuration] | ||
| 30 | end | 26 | end |
| 31 | 27 | ||
| 32 | -def self.all | ||
| 33 | - [configuration] | ||
| 34 | -end | ||
| 35 | - | ||
| 36 | end | 28 | end |
plugins/mezuro/test/unit/mezuro_plugin/configuration_content_test.rb
| 1 | require "test_helper" | 1 | require "test_helper" |
| 2 | 2 | ||
| 3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" | 3 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures" |
| 4 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_content_fixtures" | ||
| 4 | 5 | ||
| 5 | class ConfigurationContentTest < ActiveSupport::TestCase | 6 | class ConfigurationContentTest < ActiveSupport::TestCase |
| 6 | 7 | ||
| 7 | def setup | 8 | def setup |
| 8 | @configuration = ConfigurationFixtures.configuration | 9 | @configuration = ConfigurationFixtures.configuration |
| 9 | - @content = ConfigurationFixtures.configuration_content("None") | 10 | + @content = ConfigurationContentFixtures.configuration_content |
| 11 | + @created_configuration = ConfigurationFixtures.created_configuration | ||
| 12 | + @content_hash = ConfigurationContentFixtures.configuration_content_hash | ||
| 13 | + @configuration_hash = {:name => @content_hash[:name], :description => @content_hash[:description], :id => @content_hash[:configuration_id]} | ||
| 14 | + @created_content = ConfigurationContentFixtures.created_configuration_content | ||
| 10 | end | 15 | end |
| 11 | 16 | ||
| 12 | should 'be an article' do | 17 | should 'be an article' do |
| @@ -18,7 +23,7 @@ class ConfigurationContentTest < ActiveSupport::TestCase | @@ -18,7 +23,7 @@ class ConfigurationContentTest < ActiveSupport::TestCase | ||
| 18 | end | 23 | end |
| 19 | 24 | ||
| 20 | should 'provide proper description' do | 25 | should 'provide proper description' do |
| 21 | - assert_equal 'Sets of thresholds to interpret metrics', MezuroPlugin::ConfigurationContent.description | 26 | + assert_equal 'Set of metric configurations to interpret a Kalibro project', MezuroPlugin::ConfigurationContent.description |
| 22 | end | 27 | end |
| 23 | 28 | ||
| 24 | should 'have an html view' do | 29 | should 'have an html view' do |
| @@ -26,52 +31,55 @@ class ConfigurationContentTest < ActiveSupport::TestCase | @@ -26,52 +31,55 @@ class ConfigurationContentTest < ActiveSupport::TestCase | ||
| 26 | end | 31 | end |
| 27 | 32 | ||
| 28 | should 'not save a configuration with an existing cofiguration name in kalibro' do | 33 | should 'not save a configuration with an existing cofiguration name in kalibro' do |
| 29 | - Kalibro::Configuration.expects(:all_names).returns([@content.name.upcase]) | ||
| 30 | - @content.send :validate_kalibro_configuration_name | 34 | + Kalibro::Configuration.expects(:all).returns([@configuration]) |
| 35 | + @content.send :validate_configuration_name | ||
| 31 | assert_equal "Configuration name already exists in Kalibro", @content.errors.on_base | 36 | assert_equal "Configuration name already exists in Kalibro", @content.errors.on_base |
| 32 | end | 37 | end |
| 33 | 38 | ||
| 34 | should 'get configuration from service' do | 39 | should 'get configuration from service' do |
| 35 | - Kalibro::Configuration.expects(:find_by_name).with(@content.name).returns(@configuration) | ||
| 36 | - assert_equal @configuration, @content.kalibro_configuration | 40 | + Kalibro::Configuration.expects(:find).with(@content.configuration_id).returns(@configuration) |
| 41 | + assert_equal @configuration, @content.configuration | ||
| 37 | end | 42 | end |
| 38 | 43 | ||
| 39 | should 'send configuration to service after saving' do | 44 | should 'send configuration to service after saving' do |
| 40 | - @content.expects :send_kalibro_configuration_to_service | 45 | + @content.expects :send_configuration_to_service |
| 41 | @content.stubs(:solr_save) | 46 | @content.stubs(:solr_save) |
| 42 | @content.run_callbacks :after_save | 47 | @content.run_callbacks :after_save |
| 43 | end | 48 | end |
| 44 | 49 | ||
| 45 | should 'create new configuration' do | 50 | should 'create new configuration' do |
| 46 | - Kalibro::Configuration.expects(:create).with(:name => @content.name, :description => @content.description) | ||
| 47 | - Kalibro::Configuration.expects(:find_by_name).with(@content.name) | ||
| 48 | - @content.send :send_kalibro_configuration_to_service | 51 | + Kalibro::Configuration.expects(:create).with(:name => @created_content.name, :description => @created_content.description, :id => nil).returns(@configuration) |
| 52 | + @created_content.send :send_configuration_to_service | ||
| 53 | + assert_equal @configuration.id, @created_content.configuration_id | ||
| 49 | end | 54 | end |
| 50 | - | 55 | + |
| 56 | +=begin | ||
| 51 | should 'clone configuration' do | 57 | should 'clone configuration' do |
| 52 | @content.configuration_to_clone_name = 'clone name' | 58 | @content.configuration_to_clone_name = 'clone name' |
| 53 | - Kalibro::Configuration.expects(:create).with(:name => @content.name, :description => @content.description, :metric_configuration => @configuration.metric_configurations_hash) | ||
| 54 | - Kalibro::Configuration.expects(:find_by_name).with(@content.name).returns(nil) | ||
| 55 | - Kalibro::Configuration.expects(:find_by_name).with('clone name').returns(@configuration) | ||
| 56 | - @content.send :send_kalibro_configuration_to_service | 59 | + Kalibro::Configuration.expects(:create).with(:name => @content.configuration_id, :description => @content.description, :metric_configuration => @configuration.metric_configurations_hash) |
| 60 | + Kalibro::Configuration.expects(:find).with(@content.configuration_id).returns(nil) | ||
| 61 | + Kalibro::Configuration.expects(:find).with('clone name').returns(@configuration) | ||
| 62 | + @content.send :send_configuration_to_service | ||
| 57 | end | 63 | end |
| 64 | +=end | ||
| 58 | 65 | ||
| 59 | should 'edit configuration' do | 66 | should 'edit configuration' do |
| 60 | - Kalibro::Configuration.expects(:find_by_name).with(@content.name).returns(@configuration) | ||
| 61 | - @configuration.expects(:update_attributes).with(:description => @content.description) | ||
| 62 | - @content.send :send_kalibro_configuration_to_service | 67 | + Kalibro::Configuration.expects(:new).with(@configuration_hash).returns(@configuration) |
| 68 | + @configuration.expects(:save).returns(true) | ||
| 69 | + @content.send :send_configuration_to_service | ||
| 70 | + assert_equal @configuration.id, @content.configuration_id | ||
| 63 | end | 71 | end |
| 64 | 72 | ||
| 65 | should 'send correct configuration to service but comunication fails' do | 73 | should 'send correct configuration to service but comunication fails' do |
| 66 | - Kalibro::Configuration.expects(:find_by_name).with(@content.name).returns(@configuration) | ||
| 67 | - @configuration.expects(:save).returns(false) | ||
| 68 | - @content.send :send_kalibro_configuration_to_service | 74 | + Kalibro::Configuration.expects(:new).with(@configuration_hash).returns(@created_configuration) |
| 75 | + @created_configuration.expects(:save).returns(false) | ||
| 76 | + @content.send :send_configuration_to_service | ||
| 69 | end | 77 | end |
| 70 | 78 | ||
| 71 | should 'remove configuration from service' do | 79 | should 'remove configuration from service' do |
| 72 | - Kalibro::Configuration.expects(:find_by_name).with(@content.name).returns(@configuration) | 80 | + Kalibro::Configuration.expects(:find).with(@content.configuration_id).returns(@configuration) |
| 73 | @configuration.expects(:destroy) | 81 | @configuration.expects(:destroy) |
| 74 | - @content.send :remove_kalibro_configuration_from_service | 82 | + @content.send :remove_configuration_from_service |
| 75 | end | 83 | end |
| 76 | 84 | ||
| 77 | end | 85 | end |
plugins/mezuro/views/cms/mezuro_plugin/_configuration_content.html.erb
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | <% | 3 | <% |
| 4 | kalibro_configuration = @article.title.nil? ? nil : @article.kalibro_configuration | 4 | kalibro_configuration = @article.title.nil? ? nil : @article.kalibro_configuration |
| 5 | - kalibro_configuration_names = @article.kalibro_configuration_names | 5 | + kalibro_configuration_names = @article.configuration_names_and_ids.values |
| 6 | %> | 6 | %> |
| 7 | 7 | ||
| 8 | <%= error_messages_for 'kalibro_configuration' %> | 8 | <%= error_messages_for 'kalibro_configuration' %> |
| @@ -10,19 +10,23 @@ | @@ -10,19 +10,23 @@ | ||
| 10 | <%= hidden_field_tag 'kalibro_configuration[profile_id]', profile.id %> | 10 | <%= hidden_field_tag 'kalibro_configuration[profile_id]', profile.id %> |
| 11 | <%= hidden_field_tag 'id', @article.id %> | 11 | <%= hidden_field_tag 'id', @article.id %> |
| 12 | 12 | ||
| 13 | - | ||
| 14 | -<% selected = (kalibro_configuration.nil? ? "None" : @article.configuration_to_clone_name) %> | 13 | +<% # selected = (kalibro_configuration.nil? ? "None" : @article.configuration_to_clone_name) |
| 14 | + %> | ||
| 15 | 15 | ||
| 16 | <%= required_fields_message %> | 16 | <%= required_fields_message %> |
| 17 | 17 | ||
| 18 | -<%= required labelled_form_field _('Clone Configuration'), | 18 | +<% |
| 19 | +=begin | ||
| 20 | +required labelled_form_field _('Clone Configuration'), | ||
| 19 | if !kalibro_configuration.nil? && !@article.id.nil? | 21 | if !kalibro_configuration.nil? && !@article.id.nil? |
| 20 | f.select(:configuration_to_clone_name, kalibro_configuration_names, {:selected => selected}, :disabled => 'true') | 22 | f.select(:configuration_to_clone_name, kalibro_configuration_names, {:selected => selected}, :disabled => 'true') |
| 21 | else | 23 | else |
| 22 | f.select(:configuration_to_clone_name, kalibro_configuration_names, {:selected => selected}) | 24 | f.select(:configuration_to_clone_name, kalibro_configuration_names, {:selected => selected}) |
| 23 | -end %> | 25 | +end |
| 26 | +=end | ||
| 27 | +%> | ||
| 24 | <br/> | 28 | <br/> |
| 25 | 29 | ||
| 26 | -<%= required f.text_field(:name, :disabled => !(kalibro_configuration.nil? || @article.id.nil?)) %> | 30 | +<%= required f.text_field(:name) %> |
| 27 | 31 | ||
| 28 | <%= f.text_field :description %><br/> | 32 | <%= f.text_field :description %><br/> |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
| 1 | <% @configuration_content = @page | 1 | <% @configuration_content = @page |
| 2 | @kalibro_configuration = @page.kalibro_configuration %> | 2 | @kalibro_configuration = @page.kalibro_configuration %> |
| 3 | <% owner = (not user.nil?) && user.id == @profile.id %> | 3 | <% owner = (not user.nil?) && user.id == @profile.id %> |
| 4 | - | ||
| 5 | <% unless @page.errors[:base].nil? %> | 4 | <% unless @page.errors[:base].nil? %> |
| 6 | - <% if @page.errors[:base] =~ /There is no configuration named/ %> | 5 | + <% if @page.errors[:base] =~ /Kalibro::Errors::RecordNotFound/ %> |
| 7 | <h3>Warning:</h3> | 6 | <h3>Warning:</h3> |
| 8 | <p>This Configuration doesn't exist on the Web Service.</p> | 7 | <p>This Configuration doesn't exist on the Web Service.</p> |
| 9 | <% if owner %> | 8 | <% if owner %> |
| @@ -39,27 +38,27 @@ | @@ -39,27 +38,27 @@ | ||
| 39 | <td><h5>Metric Name</h5></td> | 38 | <td><h5>Metric Name</h5></td> |
| 40 | <td><h5>Collector Name</h5></td> | 39 | <td><h5>Collector Name</h5></td> |
| 41 | <td><h5>Metric Code</h5></td> | 40 | <td><h5>Metric Code</h5></td> |
| 41 | + <td><h5>Weight</h5></td> | ||
| 42 | + <td><h5>Aggregation Form</h5></td> | ||
| 42 | <td/> | 43 | <td/> |
| 43 | </tr> | 44 | </tr> |
| 44 | - <% @kalibro_configuration.metric_configurations.each do |metric_configuration| %> | 45 | + <% @configuration_content.metric_configurations.each do |metric_configuration| %> |
| 45 | <tr class="metric"> | 46 | <tr class="metric"> |
| 46 | - <% if metric_configuration.metric.instance_of? Kalibro::NativeMetric %> | ||
| 47 | <td><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", :action => "edit_metric_configuration", | 47 | <td><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", :action => "edit_metric_configuration", |
| 48 | - :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, | 48 | + :metric_configuration_id => metric_configuration.id, :id => @configuration_content.id, |
| 49 | :profile => @page.profile.identifier %></td> | 49 | :profile => @page.profile.identifier %></td> |
| 50 | + <% if metric_configuration.metric.compound %> | ||
| 50 | <td> | 51 | <td> |
| 51 | - <%= metric_configuration.metric.origin %> | 52 | + Compound Metric |
| 52 | </td> | 53 | </td> |
| 53 | - <td><%= metric_configuration.code %></td> | ||
| 54 | <% else %> | 54 | <% else %> |
| 55 | - <td><%= link_to metric_configuration.metric.name, :controller => "mezuro_plugin_metric_configuration", | ||
| 56 | - :action => "edit_compound_metric_configuration", :metric_name => metric_configuration.metric.name, | ||
| 57 | - :id => @configuration_content.id, :profile => @page.profile.identifier %></td> | ||
| 58 | <td> | 55 | <td> |
| 59 | - Compound Metric | 56 | + <%= metric_configuration.metric.origin %> |
| 60 | </td> | 57 | </td> |
| 61 | - <td><%= metric_configuration.code %></td> | ||
| 62 | <% end %> | 58 | <% end %> |
| 59 | + <td><%= metric_configuration.code %></td> | ||
| 60 | + <td><%= metric_configuration.weight %></td> | ||
| 61 | + <td><%= metric_configuration.aggreafation_form %></td> | ||
| 63 | <% if owner %> | 62 | <% if owner %> |
| 64 | <td><%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove_metric_configuration", | 63 | <td><%= link_to "Remove", :controller => "mezuro_plugin_metric_configuration", :action => "remove_metric_configuration", |
| 65 | :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, | 64 | :metric_name => metric_configuration.metric.name, :id => @configuration_content.id, |