Commit e09e911d02eccef12625b5e9739b9eff4990c333
1 parent
7b402ed6
Exists in
colab
and in
4 other branches
Metric results assyncronous loaded
Signed-off By: Diego Araújo <diegoamc90@gmail.com>
Showing
9 changed files
with
52 additions
and
63 deletions
Show diff stats
app/assets/javascripts/module/tree.js.coffee
1 | class Module.Tree | 1 | class Module.Tree |
2 | @load: (loading_html, module_id) -> | 2 | @load: (loading_html, module_id) -> |
3 | $('div#module_tree').html(loading_html) | 3 | $('div#module_tree').html(loading_html) |
4 | + $('div#metric_results').html(loading_html) | ||
4 | $.post '/modules/'+module_id+'/tree' | 5 | $.post '/modules/'+module_id+'/tree' |
5 | \ No newline at end of file | 6 | \ No newline at end of file |
app/controllers/repositories_controller.rb
@@ -13,7 +13,6 @@ class RepositoriesController < ApplicationController | @@ -13,7 +13,6 @@ class RepositoriesController < ApplicationController | ||
13 | def show | 13 | def show |
14 | @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! | 14 | @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! |
15 | @processing = @repository.last_processing | 15 | @processing = @repository.last_processing |
16 | - set_root_module_result if @processing.ready? | ||
17 | end | 16 | end |
18 | 17 | ||
19 | # GET projects/1/repositories/new | 18 | # GET projects/1/repositories/new |
@@ -64,15 +63,6 @@ class RepositoriesController < ApplicationController | @@ -64,15 +63,6 @@ class RepositoriesController < ApplicationController | ||
64 | end | 63 | end |
65 | 64 | ||
66 | private | 65 | private |
67 | - # Reducing show action cyclomatic complexity | ||
68 | - def set_root_module_result | ||
69 | - if params[:module_result_id].nil? | ||
70 | - @root_module_result = @processing.root_module_result | ||
71 | - else | ||
72 | - @root_module_result = ModuleResult.find(params[:module_result_id].to_i) | ||
73 | - end | ||
74 | - end | ||
75 | - | ||
76 | # Duplicated code on create and update actions extracted here | 66 | # Duplicated code on create and update actions extracted here |
77 | def failed_action(format, destiny_action) | 67 | def failed_action(format, destiny_action) |
78 | @project_id = params[:project_id] | 68 | @project_id = params[:project_id] |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +<% metric_configuration_snapshot = metric_result.metric_configuration_snapshot %> | ||
2 | +<% unless metric_configuration_snapshot.range_snapshot.nil? %> | ||
3 | + <% range_snapshot = find_range_snapshot(metric_result) | ||
4 | + metric_name = metric_configuration_snapshot.metric.name | ||
5 | + %> | ||
6 | + <tr> | ||
7 | + <td><%= link_to metric_name, "#metric_#{module_result.id}", | ||
8 | + onclick: "new Module.Graphic('container#{metric_result.id}', '#{metric_name}', '#{module_result.id}')", | ||
9 | + id: "metric_#{module_result.id}", | ||
10 | + remote: true %> | ||
11 | + </td> | ||
12 | + <td><%= format_grade(metric_result.value) %></td> | ||
13 | + <td><%= metric_configuration_snapshot.weight %></td> | ||
14 | + <td><span style="color: #<%= range_snapshot.color %>"><%= range_snapshot.label %></span></td> | ||
15 | + </tr> | ||
16 | + <tr id="container<%= metric_result.id %>" style="display: none"> | ||
17 | + <td colspan="4"> | ||
18 | + <div id="container<%= metric_result.id %>" class="graphic_container"><%= image_tag 'loader.gif' %> Loading data. Please, wait.</div> | ||
19 | + </td> | ||
20 | + </tr> | ||
21 | +<% end %> | ||
0 | \ No newline at end of file | 22 | \ No newline at end of file |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<table class="table table-hover"> | ||
2 | + <thead> | ||
3 | + <th>Metric</th> | ||
4 | + <th>Value</th> | ||
5 | + <th>Weight</th> | ||
6 | + <th>Threshold</th> | ||
7 | + </thead> | ||
8 | + | ||
9 | + <tbody> | ||
10 | + <%= render partial: 'metric_result', collection: @root_module_result.metric_results, locals: {module_result: @root_module_result} %> | ||
11 | + </tbody> | ||
12 | +</table> | ||
0 | \ No newline at end of file | 13 | \ No newline at end of file |
app/views/modules/load_module_tree.js.erb
app/views/repositories/_metric_result.html.erb
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | -<% metric_configuration_snapshot = metric_result.metric_configuration_snapshot %> | ||
2 | -<% unless metric_configuration_snapshot.range_snapshot.nil? %> | ||
3 | - <% range_snapshot = find_range_snapshot(metric_result) | ||
4 | - metric_name = metric_configuration_snapshot.metric.name | ||
5 | - %> | ||
6 | - <tr> | ||
7 | - <td><%= link_to metric_name, "#metric_#{module_result.id}", | ||
8 | - onclick: "new Module.Graphic('container#{metric_result.id}', '#{metric_name}', '#{module_result.id}')", | ||
9 | - id: "metric_#{module_result.id}", | ||
10 | - remote: true %> | ||
11 | - </td> | ||
12 | - <td><%= format_grade(metric_result.value) %></td> | ||
13 | - <td><%= metric_configuration_snapshot.weight %></td> | ||
14 | - <td><span style="color: #<%= range_snapshot.color %>"><%= range_snapshot.label %></span></td> | ||
15 | - </tr> | ||
16 | - <tr id="container<%= metric_result.id %>" style="display: none"> | ||
17 | - <td colspan="4"> | ||
18 | - <div id="container<%= metric_result.id %>" class="graphic_container"><%= image_tag 'loader.gif' %> Loading data. Please, wait.</div> | ||
19 | - </td> | ||
20 | - </tr> | ||
21 | -<% end %> | ||
22 | \ No newline at end of file | 0 | \ No newline at end of file |
app/views/repositories/show.html.erb
@@ -36,38 +36,26 @@ | @@ -36,38 +36,26 @@ | ||
36 | <% end %> | 36 | <% end %> |
37 | 37 | ||
38 | <hr/> | 38 | <hr/> |
39 | -<h2>Modules Tree</h2> | ||
40 | -<div id="module_tree"></div> | ||
41 | -<hr/> | ||
42 | - | ||
43 | <% if @processing.ready? %> | 39 | <% if @processing.ready? %> |
44 | - <h2>Metric Results</h2> | ||
45 | - <table class="table table-hover"> | ||
46 | - <thead> | ||
47 | - <th>Metric</th> | ||
48 | - <th>Value</th> | ||
49 | - <th>Weight</th> | ||
50 | - <th>Threshold</th> | ||
51 | - </thead> | 40 | + <h2>Modules Tree</h2> |
41 | + <div id="module_tree"></div> | ||
52 | 42 | ||
53 | - <tbody> | ||
54 | - <%= render partial: 'metric_result', collection: @root_module_result.metric_results, locals: {module_result: @root_module_result} %> | ||
55 | - </tbody> | 43 | + <hr/> |
56 | 44 | ||
57 | - </table> | 45 | + <h2>Metric Results</h2> |
46 | + <div id="metric_results"></div> | ||
47 | + | ||
48 | + <hr/> | ||
49 | + | ||
50 | + <script type="text/javascript"> | ||
51 | + $(document).ready(function () { | ||
52 | + Module.Tree.load("<%= escape_javascript(image_tag 'loader.gif') %> Loading data. Please, wait.", <%= @processing.results_root_id %>); | ||
53 | + }); | ||
54 | + </script> | ||
58 | <% end %> | 55 | <% end %> |
59 | 56 | ||
60 | -<hr/> | ||
61 | - | ||
62 | -<div id="container"></div> | ||
63 | - | ||
64 | <%= link_to 'Back', project_path(@repository.project_id), class: 'btn btn-default' %> | 57 | <%= link_to 'Back', project_path(@repository.project_id), class: 'btn btn-default' %> |
65 | <% if project_owner? @repository.project_id %> | 58 | <% if project_owner? @repository.project_id %> |
66 | <%= link_to 'Destroy', project_repository_path(@repository.project_id, @repository.id), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %> | 59 | <%= link_to 'Destroy', project_repository_path(@repository.project_id, @repository.id), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %> |
67 | <% end %> | 60 | <% end %> |
68 | 61 | ||
69 | -<script type="text/javascript"> | ||
70 | - $(document).ready(function () { | ||
71 | - Module.Tree.load("<%= escape_javascript(image_tag 'loader.gif') %> Loading data. Please, wait.", <%= @processing.results_root_id %>); | ||
72 | - }); | ||
73 | -</script> |
features/repository/show.feature
@@ -3,7 +3,7 @@ Feature: Show Repository | @@ -3,7 +3,7 @@ Feature: Show Repository | ||
3 | As a regular user | 3 | As a regular user |
4 | I should see it's informations | 4 | I should see it's informations |
5 | 5 | ||
6 | - @kalibro_restart | 6 | + @kalibro_restart @javascript |
7 | Scenario: With a ready processing | 7 | Scenario: With a ready processing |
8 | Given I am a regular user | 8 | Given I am a regular user |
9 | And I am signed in | 9 | And I am signed in |
@@ -26,7 +26,7 @@ Feature: Show Repository | @@ -26,7 +26,7 @@ Feature: Show Repository | ||
26 | And I should see "Weight" | 26 | And I should see "Weight" |
27 | And I should see "Threshold" | 27 | And I should see "Threshold" |
28 | 28 | ||
29 | - @kalibro_restart | 29 | + @kalibro_restart @javascript |
30 | Scenario: Just after start to process | 30 | Scenario: Just after start to process |
31 | Given I am a regular user | 31 | Given I am a regular user |
32 | And I am signed in | 32 | And I am signed in |
@@ -45,7 +45,7 @@ Feature: Show Repository | @@ -45,7 +45,7 @@ Feature: Show Repository | ||
45 | And I should not see Weight | 45 | And I should not see Weight |
46 | And I should not see Threshold | 46 | And I should not see Threshold |
47 | 47 | ||
48 | - @kalibro_restart | 48 | + @kalibro_restart @javascript |
49 | Scenario: Should show modules directories root when the process has been finished | 49 | Scenario: Should show modules directories root when the process has been finished |
50 | Given I am a regular user | 50 | Given I am a regular user |
51 | And I am signed in | 51 | And I am signed in |
spec/controllers/repositories_controller_spec.rb
@@ -86,7 +86,6 @@ describe RepositoriesController do | @@ -86,7 +86,6 @@ describe RepositoriesController do | ||
86 | before :each do | 86 | before :each do |
87 | processing = FactoryGirl.build(:processing) | 87 | processing = FactoryGirl.build(:processing) |
88 | 88 | ||
89 | - processing.expects(:root_module_result).returns(FactoryGirl.build(:module_result)) | ||
90 | repository.expects(:last_processing).returns(processing) | 89 | repository.expects(:last_processing).returns(processing) |
91 | KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | 90 | KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) |
92 | Repository.expects(:find).with(repository.id).returns(repository) | 91 | Repository.expects(:find).with(repository.id).returns(repository) |
@@ -101,14 +100,12 @@ describe RepositoriesController do | @@ -101,14 +100,12 @@ describe RepositoriesController do | ||
101 | 100 | ||
102 | before :each do | 101 | before :each do |
103 | processing = FactoryGirl.build(:processing) | 102 | processing = FactoryGirl.build(:processing) |
104 | - module_result = FactoryGirl.build(:module_result) | ||
105 | 103 | ||
106 | - ModuleResult.expects(:find).with(module_result.id) | ||
107 | repository.expects(:last_processing).returns(processing) | 104 | repository.expects(:last_processing).returns(processing) |
108 | KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) | 105 | KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) |
109 | Repository.expects(:find).with(repository.id).returns(repository) | 106 | Repository.expects(:find).with(repository.id).returns(repository) |
110 | 107 | ||
111 | - get :show, id: repository.id.to_s, project_id: project.id.to_s, module_result_id: module_result.id | 108 | + get :show, id: repository.id.to_s, project_id: project.id.to_s |
112 | end | 109 | end |
113 | 110 | ||
114 | it { should render_template(:show) } | 111 | it { should render_template(:show) } |