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
app/controllers/repositories_controller.rb
... | ... | @@ -13,7 +13,6 @@ class RepositoriesController < ApplicationController |
13 | 13 | def show |
14 | 14 | @configuration = KalibroEntities::Entities::Configuration.find(@repository.configuration_id) #FIXME: As soon as the Configuration model gets created refactor this! |
15 | 15 | @processing = @repository.last_processing |
16 | - set_root_module_result if @processing.ready? | |
17 | 16 | end |
18 | 17 | |
19 | 18 | # GET projects/1/repositories/new |
... | ... | @@ -64,15 +63,6 @@ class RepositoriesController < ApplicationController |
64 | 63 | end |
65 | 64 | |
66 | 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 | 66 | # Duplicated code on create and update actions extracted here |
77 | 67 | def failed_action(format, destiny_action) |
78 | 68 | @project_id = params[:project_id] | ... | ... |
... | ... | @@ -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 | 22 | \ No newline at end of file | ... | ... |
... | ... | @@ -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 | 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 | -<% 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 | 0 | \ No newline at end of file |
app/views/repositories/show.html.erb
... | ... | @@ -36,38 +36,26 @@ |
36 | 36 | <% end %> |
37 | 37 | |
38 | 38 | <hr/> |
39 | -<h2>Modules Tree</h2> | |
40 | -<div id="module_tree"></div> | |
41 | -<hr/> | |
42 | - | |
43 | 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 | 55 | <% end %> |
59 | 56 | |
60 | -<hr/> | |
61 | - | |
62 | -<div id="container"></div> | |
63 | - | |
64 | 57 | <%= link_to 'Back', project_path(@repository.project_id), class: 'btn btn-default' %> |
65 | 58 | <% if project_owner? @repository.project_id %> |
66 | 59 | <%= link_to 'Destroy', project_repository_path(@repository.project_id, @repository.id), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' %> |
67 | 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 | 3 | As a regular user |
4 | 4 | I should see it's informations |
5 | 5 | |
6 | - @kalibro_restart | |
6 | + @kalibro_restart @javascript | |
7 | 7 | Scenario: With a ready processing |
8 | 8 | Given I am a regular user |
9 | 9 | And I am signed in |
... | ... | @@ -26,7 +26,7 @@ Feature: Show Repository |
26 | 26 | And I should see "Weight" |
27 | 27 | And I should see "Threshold" |
28 | 28 | |
29 | - @kalibro_restart | |
29 | + @kalibro_restart @javascript | |
30 | 30 | Scenario: Just after start to process |
31 | 31 | Given I am a regular user |
32 | 32 | And I am signed in |
... | ... | @@ -45,7 +45,7 @@ Feature: Show Repository |
45 | 45 | And I should not see Weight |
46 | 46 | And I should not see Threshold |
47 | 47 | |
48 | - @kalibro_restart | |
48 | + @kalibro_restart @javascript | |
49 | 49 | Scenario: Should show modules directories root when the process has been finished |
50 | 50 | Given I am a regular user |
51 | 51 | And I am signed in | ... | ... |
spec/controllers/repositories_controller_spec.rb
... | ... | @@ -86,7 +86,6 @@ describe RepositoriesController do |
86 | 86 | before :each do |
87 | 87 | processing = FactoryGirl.build(:processing) |
88 | 88 | |
89 | - processing.expects(:root_module_result).returns(FactoryGirl.build(:module_result)) | |
90 | 89 | repository.expects(:last_processing).returns(processing) |
91 | 90 | KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) |
92 | 91 | Repository.expects(:find).with(repository.id).returns(repository) |
... | ... | @@ -101,14 +100,12 @@ describe RepositoriesController do |
101 | 100 | |
102 | 101 | before :each do |
103 | 102 | processing = FactoryGirl.build(:processing) |
104 | - module_result = FactoryGirl.build(:module_result) | |
105 | 103 | |
106 | - ModuleResult.expects(:find).with(module_result.id) | |
107 | 104 | repository.expects(:last_processing).returns(processing) |
108 | 105 | KalibroEntities::Entities::Configuration.expects(:find).with(repository.id).returns(FactoryGirl.build(:configuration)) |
109 | 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 | 109 | end |
113 | 110 | |
114 | 111 | it { should render_template(:show) } | ... | ... |