Commit 3be6de1e810b97e4194aab7068145f47d3686abd
1 parent
1f34a5b4
Exists in
master
and in
29 other branches
[Mezuro] Refactoring project content, views and controller (profile)
Showing
11 changed files
with
312 additions
and
233 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
1 | class MezuroPluginProfileController < ProfileController | 1 | class MezuroPluginProfileController < ProfileController |
2 | 2 | ||
3 | append_view_path File.join(File.dirname(__FILE__) + '/../views') | 3 | append_view_path File.join(File.dirname(__FILE__) + '/../views') |
4 | - | 4 | + |
5 | def project_state | 5 | def project_state |
6 | - content = profile.articles.find(params[:id]) | ||
7 | - project = content.project | 6 | + @content = profile.articles.find(params[:id]) |
7 | + project = @content.project | ||
8 | state = project.error.nil? ? project.state : "ERROR" | 8 | state = project.error.nil? ? project.state : "ERROR" |
9 | render :text => state | 9 | render :text => state |
10 | end | 10 | end |
11 | 11 | ||
12 | def project_error | 12 | def project_error |
13 | - content = profile.articles.find(params[:id]) | ||
14 | - project = content.project | ||
15 | - render :partial => 'content_viewer/project_error', :locals => { :project => project } | 13 | + @content = profile.articles.find(params[:id]) |
14 | + @project = @content.project | ||
15 | + render :partial => 'content_viewer/project_error' | ||
16 | end | 16 | end |
17 | 17 | ||
18 | def project_result | 18 | def project_result |
19 | - content = profile.articles.find(params[:id]) | 19 | + @content = profile.articles.find(params[:id]) |
20 | date = params[:date] | 20 | date = params[:date] |
21 | - project_result = date.nil? ? content.project_result : content.get_date_result(date) | ||
22 | - project = content.project | ||
23 | - render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result} | 21 | + @project_result = date.nil? ? @content.project_result : @content.get_date_result(date) |
22 | + render :partial => 'content_viewer/project_result' | ||
24 | end | 23 | end |
25 | 24 | ||
26 | def module_result | 25 | def module_result |
27 | - content = profile.articles.find(params[:id]) | 26 | + @content = profile.articles.find(params[:id]) |
28 | date = params[:date] | 27 | date = params[:date] |
29 | - date.nil? ? content.project_result : content.get_date_result(date) | ||
30 | - module_result = content.module_result(params[:module_name]) | ||
31 | - render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} | 28 | + date.nil? ? @content.project_result : @content.get_date_result(date) |
29 | + @module_result = @content.module_result(params[:module_name]) | ||
30 | + render :partial => 'content_viewer/module_result' | ||
32 | end | 31 | end |
33 | 32 | ||
34 | def project_tree | 33 | def project_tree |
35 | - content = profile.articles.find(params[:id]) | 34 | + @content = profile.articles.find(params[:id]) |
36 | date = params[:date] | 35 | date = params[:date] |
37 | - project_result = date.nil? ? content.project_result : content.get_date_result(date) | ||
38 | - source_tree = project_result.node_of(params[:module_name]) | ||
39 | - render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name} | 36 | + project_result = date.nil? ? @content.project_result : @content.get_date_result(date) |
37 | + @project_name = @content.project.name | ||
38 | + @source_tree = project_result.node_of(params[:module_name]) | ||
39 | + render :partial =>'content_viewer/source_tree' | ||
40 | end | 40 | end |
41 | 41 | ||
42 | def module_metrics_history | 42 | def module_metrics_history |
43 | metric_name = params[:metric_name] | 43 | metric_name = params[:metric_name] |
44 | - content = profile.articles.find(params[:id]) | ||
45 | - module_history = content.result_history(params[:module_name]) | ||
46 | - score_history = (module_history.collect { |module_result| (module_result.metric_results.select { |metric_result| metric_result.metric.name.delete("() ") == metric_name })[0] }).collect { |metric_result| metric_result.value } | ||
47 | - render :partial => 'content_viewer/score_history', :locals => {:score_history => score_history} | 44 | + @content = profile.articles.find(params[:id]) |
45 | + module_history = @content.result_history(params[:module_name]) | ||
46 | + @score_history = filtering_metric_history(metric_name, module_history) | ||
47 | + render :partial => 'content_viewer/score_history' | ||
48 | end | 48 | end |
49 | 49 | ||
50 | def module_grade_history | 50 | def module_grade_history |
51 | - content = profile.articles.find(params[:id]) | ||
52 | - modules_results = content.result_history(params[:module_name]) | ||
53 | - score_history = modules_results.collect { |module_result| module_result.grade } | ||
54 | - render :partial => 'content_viewer/score_history', :locals => {:score_history => score_history} | 51 | + @content = profile.articles.find(params[:id]) |
52 | + modules_results = @content.result_history(params[:module_name]) | ||
53 | + @score_history = modules_results.collect { |module_result| module_result.grade } | ||
54 | + render :partial => 'content_viewer/score_history' | ||
55 | + end | ||
56 | + | ||
57 | + private | ||
58 | + | ||
59 | + def filtering_metric_history(metric_name, module_history) | ||
60 | + metric_history = module_history.collect do |module_result| | ||
61 | + module_result.metric_results.select do |metric_result| | ||
62 | + metric_result.metric.name.delete("() ") == metric_name | ||
63 | + end | ||
64 | + end | ||
65 | + metric_history[0].collect{ |metric_result| metric_result.value } | ||
55 | end | 66 | end |
56 | end | 67 | end |
plugins/mezuro/lib/mezuro_plugin/project_content.rb
1 | class MezuroPlugin::ProjectContent < Article | 1 | class MezuroPlugin::ProjectContent < Article |
2 | - validate :validate_kalibro_project_name | ||
3 | - | 2 | + validate_on_create :validate_kalibro_project_name |
3 | + validate_on_create :validate_repository_url | ||
4 | def self.short_description | 4 | def self.short_description |
5 | 'Kalibro project' | 5 | 'Kalibro project' |
6 | end | 6 | end |
@@ -20,17 +20,29 @@ class MezuroPlugin::ProjectContent < Article | @@ -20,17 +20,29 @@ class MezuroPlugin::ProjectContent < Article | ||
20 | 20 | ||
21 | 21 | ||
22 | def project | 22 | def project |
23 | - @project ||= Kalibro::Client::ProjectClient.project(name) | 23 | + begin |
24 | + @project ||= Kalibro::Client::ProjectClient.project(name) | ||
25 | + rescue Exception => error | ||
26 | + errors.add_to_base(error.message) | ||
27 | + end | ||
24 | end | 28 | end |
25 | 29 | ||
26 | def project_result | 30 | def project_result |
27 | - @project_result ||= Kalibro::Client::ProjectResultClient.last_result(name) | 31 | + begin |
32 | + @project_result ||= Kalibro::Client::ProjectResultClient.last_result(name) | ||
33 | + rescue Exception => error | ||
34 | + errors.add_to_base(error.message) | ||
35 | + end | ||
28 | end | 36 | end |
29 | 37 | ||
30 | def get_date_result(date) | 38 | def get_date_result(date) |
31 | - client = Kalibro::Client::ProjectResultClient.new | ||
32 | - @project_result ||= client.has_results_before(name, date) ? client.last_result_before(name, date) : | 39 | + begin |
40 | + client = Kalibro::Client::ProjectResultClient.new | ||
41 | + @project_result ||= client.has_results_before(name, date) ? client.last_result_before(name, date) : | ||
33 | client.first_result_after(name, date) | 42 | client.first_result_after(name, date) |
43 | + rescue Exception => error | ||
44 | + errors.add_to_base(error.message) | ||
45 | + end | ||
34 | end | 46 | end |
35 | 47 | ||
36 | def module_result(module_name) | 48 | def module_result(module_name) |
@@ -48,24 +60,47 @@ client.first_result_after(name, date) | @@ -48,24 +60,47 @@ client.first_result_after(name, date) | ||
48 | private | 60 | private |
49 | 61 | ||
50 | def validate_kalibro_project_name | 62 | def validate_kalibro_project_name |
51 | - existing = Kalibro::Client::ProjectClient.new.project_names | 63 | + begin |
64 | + existing = Kalibro::Client::ProjectClient.new.project_names | ||
65 | + rescue Exception => error | ||
66 | + errors.add_to_base(error.message) | ||
67 | + end | ||
52 | 68 | ||
53 | - if existing.include?(name) | 69 | + if existing.any?{|existing_name| existing_name.casecmp(name)==0} # existing.include?(name) + case insensitive |
54 | errors.add_to_base("Project name already exists in Kalibro") | 70 | errors.add_to_base("Project name already exists in Kalibro") |
55 | end | 71 | end |
56 | end | 72 | end |
57 | - | 73 | + |
74 | + def validate_repository_url | ||
75 | + if(repository_url.nil? || repository_url == "") | ||
76 | + errors.add_to_base("Repository URL is mandatory") | ||
77 | + end | ||
78 | + end | ||
79 | + | ||
58 | def send_project_to_service | 80 | def send_project_to_service |
59 | - Kalibro::Client::ProjectClient.save(self) | ||
60 | - Kalibro::Client::KalibroClient.process_project(name, periodicity_in_days) | 81 | + begin |
82 | + Kalibro::Client::ProjectClient.save(self) | ||
83 | + Kalibro::Client::KalibroClient.process_project(name, periodicity_in_days) | ||
84 | + rescue Exception => error | ||
85 | + errors.add_to_base(error.message) | ||
86 | + end | ||
87 | + | ||
61 | end | 88 | end |
62 | 89 | ||
63 | def remove_project_from_service | 90 | def remove_project_from_service |
64 | - Kalibro::Client::ProjectClient.remove(name) | 91 | + begin |
92 | + Kalibro::Client::ProjectClient.remove(name) | ||
93 | + rescue Exception => error | ||
94 | + errors.add_to_base(error.message) | ||
95 | + end | ||
96 | + | ||
65 | end | 97 | end |
66 | 98 | ||
67 | def module_result_client | 99 | def module_result_client |
68 | - @module_result_client ||= Kalibro::Client::ModuleResultClient.new | 100 | + begin |
101 | + @module_result_client ||= Kalibro::Client::ModuleResultClient.new | ||
102 | + rescue Exception => error | ||
103 | + errors.add_to_base(error.message) | ||
104 | + end | ||
69 | end | 105 | end |
70 | end | 106 | end |
71 | - |
plugins/mezuro/public/javascripts/project_content.js
@@ -5,6 +5,7 @@ jQuery(function (){ | @@ -5,6 +5,7 @@ jQuery(function (){ | ||
5 | jQuery('[data-show]').live("click", toggle_mezuro); | 5 | jQuery('[data-show]').live("click", toggle_mezuro); |
6 | jQuery('[show-metric-history]').live("click", display_metric_history); | 6 | jQuery('[show-metric-history]').live("click", display_metric_history); |
7 | jQuery('[show-grade-history]').live("click", display_grade_history); | 7 | jQuery('[show-grade-history]').live("click", display_grade_history); |
8 | + jQuery('#project_date_submit').live("click", reloadProjectWithDate); | ||
8 | showLoadingProcess(true); | 9 | showLoadingProcess(true); |
9 | showProjectContent(); | 10 | showProjectContent(); |
10 | }); | 11 | }); |
@@ -55,8 +56,17 @@ function reloadProjectWithDate(){ | @@ -55,8 +56,17 @@ function reloadProjectWithDate(){ | ||
55 | var month = jQuery("#project_date_month").val(); | 56 | var month = jQuery("#project_date_month").val(); |
56 | var year = jQuery("#project_date_year").val(); | 57 | var year = jQuery("#project_date_year").val(); |
57 | 58 | ||
58 | - var date = year + "-" + month + "-" + day + "T00:00:00+00:00"; | 59 | + if(day.length == 1) |
60 | + day = "0" + day; | ||
61 | + if(month.length == 1) | ||
62 | + month = "0" + month; | ||
59 | 63 | ||
64 | + var date = new Date(year + "-" + month + "-" + day + "T00:00:00+00:00"); | ||
65 | + | ||
66 | + if(isNaN(date)){ | ||
67 | + alert("Invalid date! " + date); | ||
68 | + return false; | ||
69 | + } | ||
60 | reloadProject(date); | 70 | reloadProject(date); |
61 | return false; | 71 | return false; |
62 | } | 72 | } |
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
@@ -6,6 +6,7 @@ require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" | @@ -6,6 +6,7 @@ require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" | ||
6 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" | 6 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures" |
7 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures" | 7 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures" |
8 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" | 8 | require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" |
9 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/repository_fixtures" | ||
9 | 10 | ||
10 | class MezuroPluginProfileControllerTest < ActionController::TestCase | 11 | class MezuroPluginProfileControllerTest < ActionController::TestCase |
11 | 12 | ||
@@ -17,6 +18,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -17,6 +18,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
17 | 18 | ||
18 | @project_result = ProjectResultFixtures.qt_calculator | 19 | @project_result = ProjectResultFixtures.qt_calculator |
19 | @module_result = ModuleResultFixtures.create | 20 | @module_result = ModuleResultFixtures.create |
21 | + @repository_url = RepositoryFixtures.qt_calculator.address | ||
20 | @project = @project_result.project | 22 | @project = @project_result.project |
21 | @name = @project.name | 23 | @name = @project.name |
22 | 24 | ||
@@ -66,7 +68,6 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -66,7 +68,6 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
66 | should 'get project results without date' do | 68 | should 'get project results without date' do |
67 | create_project_content | 69 | create_project_content |
68 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) | 70 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) |
69 | - Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | ||
70 | get :project_result, :profile => @profile.identifier, :id => @content.id | 71 | get :project_result, :profile => @profile.identifier, :id => @content.id |
71 | assert_response 200 | 72 | assert_response 200 |
72 | assert_select('h4', 'Last Result') | 73 | assert_select('h4', 'Last Result') |
@@ -75,7 +76,6 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -75,7 +76,6 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
75 | should 'get project results from a specific date' do | 76 | should 'get project results from a specific date' do |
76 | create_project_content | 77 | create_project_content |
77 | mock_project_result | 78 | mock_project_result |
78 | - Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | ||
79 | get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date | 79 | get :project_result, :profile => @profile.identifier, :id => @content.id, :date => @project_result.date |
80 | assert_response 200 | 80 | assert_response 200 |
81 | end | 81 | end |
@@ -90,7 +90,6 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -90,7 +90,6 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
90 | mock_module_result | 90 | mock_module_result |
91 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) | 91 | Kalibro::Client::ProjectResultClient.expects(:last_result).with(@name).returns(@project_result) |
92 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | 92 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
93 | - | ||
94 | get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @name | 93 | get :module_result, :profile => @profile.identifier, :id => @content.id, :module_name => @name |
95 | assert_response 200 | 94 | assert_response 200 |
96 | assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') | 95 | assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') |
@@ -157,6 +156,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | @@ -157,6 +156,7 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
157 | @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @name) | 156 | @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => @name) |
158 | @content.expects(:send_project_to_service).returns(nil) | 157 | @content.expects(:send_project_to_service).returns(nil) |
159 | Kalibro::Client::ProjectClient.expects(:new).returns(client) | 158 | Kalibro::Client::ProjectClient.expects(:new).returns(client) |
159 | + @content.repository_url = @repository_url | ||
160 | client.expects(:project_names).returns([]) | 160 | client.expects(:project_names).returns([]) |
161 | @content.save | 161 | @content.save |
162 | end | 162 | end |
plugins/mezuro/views/cms/mezuro_plugin/_project_content.html.erb
@@ -15,8 +15,11 @@ | @@ -15,8 +15,11 @@ | ||
15 | <%= hidden_field_tag 'id', @article.id %> | 15 | <%= hidden_field_tag 'id', @article.id %> |
16 | 16 | ||
17 | <%= required_fields_message %> | 17 | <%= required_fields_message %> |
18 | - | ||
19 | -<%= required f.text_field(:name) %> | 18 | +<% if !@project.nil? && !@article.id.nil? %> |
19 | + <%= required f.text_field(:name, :disabled => 'true') %> | ||
20 | +<% else %> | ||
21 | + <%= required f.text_field(:name) %> | ||
22 | +<% end %> | ||
20 | 23 | ||
21 | <%= f.text_field :license %><br/> | 24 | <%= f.text_field :license %><br/> |
22 | 25 | ||
@@ -31,9 +34,14 @@ | @@ -31,9 +34,14 @@ | ||
31 | 34 | ||
32 | <% @configuration_names = Kalibro::Client::ConfigurationClient.new.configuration_names.sort %> | 35 | <% @configuration_names = Kalibro::Client::ConfigurationClient.new.configuration_names.sort %> |
33 | <% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %> | 36 | <% @selected = (@project.nil? ? @configuration_names[0] : @project.configuration_name) %> |
34 | -<%= required labelled_form_field _('Configuration'), | ||
35 | - f.select(:configuration_name, @configuration_names, {:selected => @selected}) %><br/> | ||
36 | 37 | ||
38 | +<% if !@project.nil? && !@article.id.nil? %> | ||
39 | + <%= required labelled_form_field _('Configuration'), | ||
40 | + f.select(:configuration_name, @configuration_names, {:selected => @selected}, :disabled => 'true') %> | ||
41 | +<% else %> | ||
42 | + <%= required labelled_form_field _('Configuration'), | ||
43 | + f.select(:configuration_name, @configuration_names, {:selected => @selected}) %><br/> | ||
44 | +<% end %> | ||
37 | 45 | ||
38 | <% selected = (@project.nil? ? 0 : @kalibro_client.process_period(@article.title).to_i) %> | 46 | <% selected = (@project.nil? ? 0 : @kalibro_client.process_period(@article.title).to_i) %> |
39 | <%= required labelled_form_field _('Periodic Avaliation'), | 47 | <%= required labelled_form_field _('Periodic Avaliation'), |
plugins/mezuro/views/content_viewer/_module_result.rhtml
1 | -<% the_module = module_result.module %> | ||
2 | -<% module_label = "#{the_module.name} (#{the_module.granularity})" %> | 1 | +<% unless @content.errors[:base].nil? %> |
2 | + <%= @content.errors[:base] %> | ||
3 | +<% else %> | ||
4 | + <% the_module = @module_result.module %> | ||
5 | + <% module_label = "#{the_module.name} (#{the_module.granularity})" %> | ||
3 | 6 | ||
4 | -<h5><%= _('Metric results for: ') + module_label %> </h5> | 7 | + <h5><%= _('Metric results for: ') + module_label %> </h5> |
5 | 8 | ||
6 | -<hr/> | ||
7 | -<div class="zoomable-image"> | ||
8 | -<table> | ||
9 | - <thead> | ||
10 | - <tr> | ||
11 | - <th>Metric</th> | ||
12 | - <th>Value</th> | ||
13 | - <th>Weight</th> | ||
14 | - <th>Threshold</th> | ||
15 | - </tr> | ||
16 | - </thead> | ||
17 | - <tbody> | ||
18 | - <% module_result.metric_results.each do |metric_result| %> | ||
19 | - <% range = metric_result.range %> | ||
20 | - <% if !range.nil? %> | ||
21 | - <tr> | ||
22 | - <td><a href="#" data-show=".<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>"><%= metric_result.metric.name %></a></td> | ||
23 | - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | ||
24 | - <td><%= metric_result.weight %></td> | ||
25 | - <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | ||
26 | - </tr> | ||
27 | - <tr class="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" style="display: none;"> | ||
28 | - <td colspan="3"> | ||
29 | - <div id='historical-<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>'> | ||
30 | - <a href="#" show-metric-history="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>"> <p style="text-indent: 3em;"> Get Historical Values </p> </a> | ||
31 | - </div> | ||
32 | - </td> | ||
33 | - <td align="right"> | ||
34 | - <%= range.comments.nil? ? '' : range.comments %> | ||
35 | - </td> | ||
36 | - </tr> | 9 | + <hr/> |
10 | + <div class="zoomable-image"> | ||
11 | + <table> | ||
12 | + <thead> | ||
13 | + <tr> | ||
14 | + <th>Metric</th> | ||
15 | + <th>Value</th> | ||
16 | + <th>Weight</th> | ||
17 | + <th>Threshold</th> | ||
18 | + </tr> | ||
19 | + </thead> | ||
20 | + <tbody> | ||
21 | + <% @module_result.metric_results.each do |metric_result| %> | ||
22 | + <% range = metric_result.range %> | ||
23 | + <% if !range.nil? %> | ||
24 | + <tr> | ||
25 | + <td><a href="#" data-show=".<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>"><%= metric_result.metric.name %></a></td> | ||
26 | + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> | ||
27 | + <td><%= metric_result.weight %></td> | ||
28 | + <td style="background-color: #<%= range.color[2..-1] %>"><%= range.label %></td> | ||
29 | + </tr> | ||
30 | + <tr class="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" style="display: none;"> | ||
31 | + <td colspan="3"> | ||
32 | + <div id='historical-<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>'> | ||
33 | + <a href="#" show-metric-history="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>" data-module-name="<%= the_module.name %>" data-metric-name="<%= MezuroPlugin::Helpers::ContentViewerHelper.format_name(metric_result) %>"> <p style="text-indent: 3em;"> Get Historical Values </p> </a> | ||
34 | + </div> | ||
35 | + </td> | ||
36 | + <td align="right"> | ||
37 | + <%= range.comments.nil? ? '' : range.comments %> | ||
38 | + </td> | ||
39 | + </tr> | ||
40 | + <% end %> | ||
37 | <% end %> | 41 | <% end %> |
38 | - <% end %> | ||
39 | - </tbody> | ||
40 | - <tfoot> | ||
41 | - <tr> | ||
42 | - <td colspan = "3"> | ||
43 | - <div id='historical-grade'></div> | ||
44 | - </td> | ||
45 | - <td align = "right"> | ||
46 | - <a href="#" show-grade-history="<%= module_result.module.name %>" data-module-name="<%= the_module.name%>" > | ||
47 | - <strong> | ||
48 | - <%= _('Grade:') %> | ||
49 | - <%= "%.02f" % module_result.grade %> | ||
50 | - </strong> | ||
51 | - </a> | ||
52 | - </td> | ||
53 | - </tr> | ||
54 | - </tfoot> | ||
55 | -</table> | ||
56 | -</div> | 42 | + </tbody> |
43 | + <tfoot> | ||
44 | + <tr> | ||
45 | + <td colspan = "3"> | ||
46 | + <div id='historical-grade'></div> | ||
47 | + </td> | ||
48 | + <td align = "right"> | ||
49 | + <a href="#" show-grade-history="<%= @module_result.module.name %>" data-module-name="<%= the_module.name%>" > | ||
50 | + <strong> | ||
51 | + <%= _('Grade:') %> | ||
52 | + <%= "%.02f" % @module_result.grade %> | ||
53 | + </strong> | ||
54 | + </a> | ||
55 | + </td> | ||
56 | + </tr> | ||
57 | + </tfoot> | ||
58 | + </table> | ||
59 | + </div> | ||
60 | +<% end %> |
plugins/mezuro/views/content_viewer/_project_error.rhtml
1 | <h3><%= _('ERROR') %></h3> | 1 | <h3><%= _('ERROR') %></h3> |
2 | <p> | 2 | <p> |
3 | - <%= "State when error ocurred: #{project.state}" %> | 3 | + <%= "State when error ocurred: #{@project.state}" %> |
4 | <br/> | 4 | <br/> |
5 | - <% error = project.error %> | 5 | + <% error = @project.error %> |
6 | <%= error.message %> | 6 | <%= error.message %> |
7 | <ul> | 7 | <ul> |
8 | <% error.stack_trace.each do |trace| %> | 8 | <% error.stack_trace.each do |trace| %> |
plugins/mezuro/views/content_viewer/_project_result.rhtml
1 | - | ||
2 | -<% form_for :project_date, :html=>{:id=>"project_history_date"} do |f| %> | ||
3 | - <%= f.label :day, "Choose project date:" %> | 1 | +<% unless @content.errors[:base].nil? %> |
2 | + <%= @content.errors[:base] %> | ||
3 | +<% else %> | ||
4 | + <% form_for :project_date, :html=>{:id=>"project_history_date"} do |f| %> | ||
5 | + <%= f.label :day, "Choose project date:" %> | ||
4 | 6 | ||
5 | -<table> | ||
6 | - <tr> | ||
7 | - <td> | ||
8 | - Day | ||
9 | - </td> | ||
10 | - <td> | ||
11 | - Month | ||
12 | - </td> | ||
13 | - <td> | ||
14 | - Year | ||
15 | - </td> | ||
16 | - </tr> | ||
17 | - <tr> | ||
18 | - <td> | ||
19 | - <%= f.text_field :day, :size => 1, :maxlength => 2, :placeholder =>"dd" %> | ||
20 | - </td> | ||
21 | - <td> | ||
22 | - <%= f.text_field :month, :size => 1, :maxlength => 2, :placeholder =>"mm" %> | ||
23 | - </td> | ||
24 | - <td> | ||
25 | - <%= f.text_field :year, :size => 1, :maxlength => 4, :placeholder =>"yyyy" %> | ||
26 | - </td> | ||
27 | - </tr> | ||
28 | -</table> | ||
29 | - <%= f.submit "Refresh" %> | ||
30 | -<% end %> | 7 | + <table> |
8 | + <tr> | ||
9 | + <td> | ||
10 | + Day | ||
11 | + </td> | ||
12 | + <td> | ||
13 | + Month | ||
14 | + </td> | ||
15 | + <td> | ||
16 | + Year | ||
17 | + </td> | ||
18 | + </tr> | ||
19 | + <tr> | ||
20 | + <td> | ||
21 | + <%= f.text_field :day, :size => 1, :maxlength => 2, :placeholder =>"dd" %> | ||
22 | + </td> | ||
23 | + <td> | ||
24 | + <%= f.text_field :month, :size => 1, :maxlength => 2, :placeholder =>"mm" %> | ||
25 | + </td> | ||
26 | + <td> | ||
27 | + <%= f.text_field :year, :size => 1, :maxlength => 4, :placeholder =>"yyyy" %> | ||
28 | + </td> | ||
29 | + </tr> | ||
30 | + </table> | ||
31 | + <%= f.submit "Refresh" %> | ||
32 | + <% end %> | ||
31 | 33 | ||
32 | - | ||
33 | -<h4><%= _('Last Result') %></h4> | 34 | + |
35 | + <h4><%= _('Last Result') %></h4> | ||
34 | 36 | ||
35 | -<table> | ||
36 | - <tr> | ||
37 | - <td><%= _('Date') %></td> | ||
38 | - <td><%= project_result.date %></td> | ||
39 | - </tr> | ||
40 | - <tr> | ||
41 | - <td><%= _('Load time') %></td> | ||
42 | - <td><%= project_result.formatted_load_time %></td> | ||
43 | - </tr> | ||
44 | - <tr> | ||
45 | - <td><%= _('Analysis time') %></td> | ||
46 | - <td><%= project_result.formatted_analysis_time %></td> | ||
47 | - </tr> | ||
48 | -</table> | 37 | + <table> |
38 | + <tr> | ||
39 | + <td><%= _('Date') %></td> | ||
40 | + <td><%= @project_result.date %></td> | ||
41 | + </tr> | ||
42 | + <tr> | ||
43 | + <td><%= _('Load time') %></td> | ||
44 | + <td><%= @project_result.formatted_load_time %></td> | ||
45 | + </tr> | ||
46 | + <tr> | ||
47 | + <td><%= _('Analysis time') %></td> | ||
48 | + <td><%= @project_result.formatted_analysis_time %></td> | ||
49 | + </tr> | ||
50 | + </table> | ||
51 | +<% end %> |
plugins/mezuro/views/content_viewer/_score_history.rhtml
plugins/mezuro/views/content_viewer/_source_tree.rhtml
1 | -<h4><%= _('Source tree') %></h4> | ||
2 | -<% module_name = source_tree.module.name %> | ||
3 | -<% module_label = "#{module_name} (#{source_tree.module.granularity})" %> | 1 | +<% unless @content.errors[:base].nil? %> |
2 | + <%= @content.errors[:base] %> | ||
3 | +<% else %> | ||
4 | + <h4><%= _('Source tree') %></h4> | ||
5 | + <% module_name = @source_tree.module.name %> | ||
6 | + <% module_label = "#{module_name} (#{@source_tree.module.granularity})" %> | ||
4 | 7 | ||
5 | -<p><h2 class="path"> | ||
6 | - <% if module_name != project_name %> | ||
7 | - <a href="#" class="source-tree-link" data-module-name="<%= project_name %>"> | ||
8 | - <%= project_name %> | ||
9 | - </a> | ||
10 | - <% end %> | 8 | + <p><h2 class="path"> |
9 | + <% if module_name != @project_name %> | ||
10 | + <a href="#" class="source-tree-link" data-module-name="<%= @project_name %>"> | ||
11 | + <%= @project_name %> | ||
12 | + </a> | ||
13 | + <% end %> | ||
11 | 14 | ||
12 | 15 | ||
13 | - <% split_link = source_tree.module.ancestor_names %> | ||
14 | - <% split_link.each do |link| %> | ||
15 | - /<a href="#" class="source-tree-link" data-module-name="<%= link %>"> | ||
16 | - <%= link.split(".").last %> | ||
17 | - </a> | 16 | + <% split_link = @source_tree.module.ancestor_names %> |
17 | + <% split_link.each do |link| %> | ||
18 | + /<a href="#" class="source-tree-link" data-module-name="<%= link %>"> | ||
19 | + <%= link.split(".").last %> | ||
20 | + </a> | ||
21 | + <% end %> | ||
22 | + </h2></p> | ||
23 | + | ||
24 | + <% if @source_tree.children %> | ||
25 | + <table border="0" class="source-tree"> | ||
26 | + <% @source_tree.children.each do |child| %> | ||
27 | + <% if child.module.granularity=='PACKAGE' %> | ||
28 | + <tr> | ||
29 | + <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | ||
30 | + <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"><%= child.module.name %></a></td> | ||
31 | + </tr> | ||
32 | + <% else %> | ||
33 | + <tr> | ||
34 | + <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | ||
35 | + <td class="source-tree-text"> | ||
36 | + <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | ||
37 | + <%= child.module.name %> | ||
38 | + </a> | ||
39 | + </td> | ||
40 | + </tr> | ||
41 | + <% end %> | ||
42 | + <% end %> | ||
43 | + </table> | ||
18 | <% end %> | 44 | <% end %> |
19 | -</h2></p> | ||
20 | - | ||
21 | -<% if source_tree.children %> | ||
22 | - <table border="0" class="source-tree"> | ||
23 | - <% source_tree.children.each do |child| %> | ||
24 | - <% if child.module.granularity=='PACKAGE' %> | ||
25 | - <tr> | ||
26 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/folder.png')%></td> | ||
27 | - <td class="source-tree-text"><a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"><%= child.module.name %></a></td> | ||
28 | - </tr> | ||
29 | - <% else %> | ||
30 | - <tr> | ||
31 | - <td class="icon"><%= image_tag('/plugins/mezuro/images/file.png') %></td> | ||
32 | - <td class="source-tree-text"> | ||
33 | - <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | ||
34 | - <%= child.module.name %> | ||
35 | - </a> | ||
36 | - </td> | ||
37 | - </tr> | ||
38 | - <% end %> | ||
39 | - <% end %> | ||
40 | - </table> | ||
41 | <% end %> | 45 | <% end %> |
plugins/mezuro/views/content_viewer/show_project.rhtml
1 | <script src="/plugins/mezuro/javascripts/project_content.js" type="text/javascript"></script> | 1 | <script src="/plugins/mezuro/javascripts/project_content.js" type="text/javascript"></script> |
2 | 2 | ||
3 | <% @project = @page.project %> | 3 | <% @project = @page.project %> |
4 | -<% if (@project==nil) %> | ||
5 | - <h3>Warning:</h3> | ||
6 | - <p>This project doesn't exist on the Web Service. Do you want to <a href="/myprofile/<%= @page.profile.name %>/cms/destroy/<%= @page.id%>">delete</a> or <a href="/myprofile/<%= @page.profile.name %>/cms/edit/<%= @page.id%>">save it again</a>?</p> | 4 | +<% unless @page.errors[:base].nil? %> |
5 | + <%= @page.errors[:base] %> | ||
7 | <% else %> | 6 | <% else %> |
8 | 7 | ||
8 | + <% if (@project==nil) %> | ||
9 | + <h3>Warning:</h3> | ||
10 | + <p>This project doesn't exist on the Web Service. Do you want to <a href="/myprofile/<%= @page.profile.name %>/cms/destroy/<%= @page.id%>">delete</a> or <a href="/myprofile/<%= @page.profile.name %>/cms/edit/<%= @page.id%>">save it again</a>?</p> | ||
11 | + <% else %> | ||
9 | 12 | ||
10 | -<table> | ||
11 | - <tr> | ||
12 | - <td><%= _('Name') %></td> | ||
13 | - <td><%= @project.name %></td> | ||
14 | - </tr> | ||
15 | - <tr> | ||
16 | - <td><%= _('License') %></td> | ||
17 | - <td><%= @project.license %></td> | ||
18 | - </tr> | ||
19 | - <tr> | ||
20 | - <td><%= _('Description') %></td> | ||
21 | - <td><%= @project.description %></td> | ||
22 | - </tr> | ||
23 | - <tr> | ||
24 | - <td><%= _('Repository type') %></td> | ||
25 | - <td><%= @project.repository.type %></td> | ||
26 | - </tr> | ||
27 | - <tr> | ||
28 | - <td><%= _('Repository address') %></td> | ||
29 | - <td><%= @project.repository.address %></td> | ||
30 | - </tr> | ||
31 | - <tr> | ||
32 | - <td><%= _('Configuration') %></td> | ||
33 | - <td><%= @project.configuration_name %></td> | ||
34 | - </tr> | ||
35 | - <tr> | ||
36 | - <td><%= _('Periodicity') %></td> | ||
37 | - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.get_periodicity_option(@page.periodicity_in_days) %></td> | ||
38 | - </tr> | ||
39 | - <tr> | ||
40 | - <td><%= _('Status')%></td> | ||
41 | - <td> | ||
42 | - <div id="project-state"><%= @project.state %></div> | ||
43 | - <div id="msg-time"></div> | ||
44 | - </td> | ||
45 | - </tr> | ||
46 | -</table> | ||
47 | 13 | ||
48 | -<br /> | 14 | + <table> |
15 | + <tr> | ||
16 | + <td><%= _('Name') %></td> | ||
17 | + <td><%= @project.name %></td> | ||
18 | + </tr> | ||
19 | + <tr> | ||
20 | + <td><%= _('License') %></td> | ||
21 | + <td><%= @project.license %></td> | ||
22 | + </tr> | ||
23 | + <tr> | ||
24 | + <td><%= _('Description') %></td> | ||
25 | + <td><%= @project.description %></td> | ||
26 | + </tr> | ||
27 | + <tr> | ||
28 | + <td><%= _('Repository type') %></td> | ||
29 | + <td><%= @project.repository.type %></td> | ||
30 | + </tr> | ||
31 | + <tr> | ||
32 | + <td><%= _('Repository address') %></td> | ||
33 | + <td><%= @project.repository.address %></td> | ||
34 | + </tr> | ||
35 | + <tr> | ||
36 | + <td><%= _('Configuration') %></td> | ||
37 | + <td><%= @project.configuration_name %></td> | ||
38 | + </tr> | ||
39 | + <tr> | ||
40 | + <td><%= _('Periodicity') %></td> | ||
41 | + <td><%= MezuroPlugin::Helpers::ContentViewerHelper.get_periodicity_option(@page.periodicity_in_days) %></td> | ||
42 | + </tr> | ||
43 | + <tr> | ||
44 | + <td><%= _('Status')%></td> | ||
45 | + <td> | ||
46 | + <div id="project-state"><%= @project.state %></div> | ||
47 | + <div id="msg-time"></div> | ||
48 | + </td> | ||
49 | + </tr> | ||
50 | + </table> | ||
49 | 51 | ||
50 | -<div id="project-result" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>" | ||
51 | - data-project-name="<%= @project.name %>"> | ||
52 | -</div> | ||
53 | -<div id="project-tree"></div> | ||
54 | -<div id="module-result"> | ||
55 | -</div> | ||
56 | -<% end %> | 52 | + <br /> |
57 | 53 | ||
54 | + <div id="project-result" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>" | ||
55 | + data-project-name="<%= @project.name %>"> | ||
56 | + </div> | ||
57 | + <div id="project-tree"></div> | ||
58 | + <div id="module-result"> | ||
59 | + </div> | ||
60 | + <% end %> | ||
61 | +<% end %> |