Commit 7aefdd4ad2a9600270a065991097f044f216783b
Committed by
Diego Camarinha
1 parent
c07f1fb0
Exists in
master
and in
23 other branches
stating a new display view for source tree
Showing
6 changed files
with
42 additions
and
13 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... | ... | @@ -18,7 +18,9 @@ class MezuroPluginProfileController < ProfileController |
18 | 18 | def project_result |
19 | 19 | content = profile.articles.find(params[:id]) |
20 | 20 | project_result = content.project_result |
21 | - render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result } | |
21 | + source_tree = project_result.subtree(params[:module_name]) | |
22 | + source_tree = project_result.source_tree if source_tree.nil? | |
23 | + render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result, :source_tree => source_tree } | |
22 | 24 | end |
23 | 25 | |
24 | 26 | def module_result | ... | ... |
plugins/mezuro/lib/kalibro/entities/project_result.rb
... | ... | @@ -14,6 +14,22 @@ class Kalibro::Entities::ProjectResult < Kalibro::Entities::Entity |
14 | 14 | format_milliseconds(@load_time) |
15 | 15 | end |
16 | 16 | |
17 | + def subtree(name) | |
18 | + find_subtree(@source_tree, name) | |
19 | + end | |
20 | + | |
21 | + def find_subtree(tree, name) | |
22 | + if tree.module.name == name | |
23 | + tree | |
24 | + elsif !tree.children.nil? | |
25 | + tree.children.each do |child| | |
26 | + found = find_subtree(child, name) | |
27 | + return found if !found.nil? | |
28 | + end | |
29 | + return nil | |
30 | + end | |
31 | + end | |
32 | + | |
17 | 33 | def formatted_analysis_time |
18 | 34 | format_milliseconds(@analysis_time) |
19 | 35 | end |
... | ... | @@ -31,4 +47,4 @@ class Kalibro::Entities::ProjectResult < Kalibro::Entities::Entity |
31 | 47 | ('%2d' % amount).sub(/\s/, '0') |
32 | 48 | end |
33 | 49 | |
34 | -end | |
35 | 50 | \ No newline at end of file |
51 | +end | ... | ... |
plugins/mezuro/public/javascripts/project_content.js
... | ... | @@ -24,8 +24,16 @@ function showProjectContentAfter(seconds){ |
24 | 24 | } |
25 | 25 | |
26 | 26 | function setProjectContent(content){ |
27 | + var module_name = jQuery(this).attr('data-module-name'); | |
27 | 28 | jQuery('#project-content').html(content); |
28 | - jQuery('.module-result-link').click(showModuleResult); | |
29 | + jQuery('.module-result-link').click(showProjectTree); | |
30 | + callAction('module_result', {module_name: module_name}, setModuleResult); | |
31 | +} | |
32 | + | |
33 | +function showProjectTree(){ | |
34 | + var module_name = jQuery(this).attr('data-module-name'); | |
35 | + callAction('project_result', {module_name: module_name}, setProjectContent); | |
36 | + return false; | |
29 | 37 | } |
30 | 38 | |
31 | 39 | function showModuleResult(){ |
... | ... | @@ -35,6 +43,10 @@ function showModuleResult(){ |
35 | 43 | return false; |
36 | 44 | } |
37 | 45 | |
46 | +function setProjectResult(content){ | |
47 | + jQuery('#project_results').html(content); | |
48 | +} | |
49 | + | |
38 | 50 | function setModuleResult(content){ |
39 | 51 | jQuery('#module-result').html(content); |
40 | 52 | } |
... | ... | @@ -54,4 +66,4 @@ function sourceNodeToggle(id){ |
54 | 66 | var suffixes = ['_hidden', '_plus', '_minus']; |
55 | 67 | for (var i in suffixes) |
56 | 68 | jQuery('#' + id + suffixes[i]).toggle(); |
57 | -} | |
58 | 69 | \ No newline at end of file |
70 | +} | ... | ... |
plugins/mezuro/views/content_viewer/_project_result.rhtml
1 | -<h3><%= _('LAST RESULT') %></h3> | |
1 | +<h4><%= _('Last Result') %></h4> | |
2 | 2 | |
3 | 3 | <table> |
4 | 4 | <tr> |
... | ... | @@ -16,7 +16,4 @@ |
16 | 16 | </table> |
17 | 17 | |
18 | 18 | <h4><%= _('Source tree') %></h4> |
19 | -<%= render :partial => 'content_viewer/source_tree', :locals => { :source_tree => project_result.source_tree } %> | |
20 | - | |
21 | -<div id='module-result'> | |
22 | -</div> | |
19 | +<%= render :partial => 'content_viewer/source_tree', :locals => { :source_tree => source_tree } %> | ... | ... |
plugins/mezuro/views/content_viewer/_source_tree.rhtml
... | ... | @@ -4,9 +4,9 @@ |
4 | 4 | <table> |
5 | 5 | <tr> |
6 | 6 | <td width="10%"> |
7 | - <img alt="+" src="/plugins/mezuro/images/plus.png" class="link" | |
7 | + <img alt="+" src="/plugins/mezuro/images/plus.png" class="link" style="display: none" | |
8 | 8 | id="<%= module_name %>_plus" onclick="sourceNodeToggle('<%= module_name %>')"/> |
9 | - <img alt="-" src="/plugins/mezuro/images/minus.png" class="link" style="display: none" | |
9 | + <img alt="-" src="/plugins/mezuro/images/minus.png" class="link" | |
10 | 10 | id="<%= module_name %>_minus" onclick="sourceNodeToggle('<%= module_name %>')"/> |
11 | 11 | </td> |
12 | 12 | <td> |
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | </a> |
16 | 16 | </td> |
17 | 17 | </tr> |
18 | - <tr id="<%= module_name %>_hidden" style="display: none"> | |
18 | + <tr id="<%= module_name %>_hidden"> | |
19 | 19 | <td></td> |
20 | 20 | <td style="text-align: left"> |
21 | 21 | <% source_tree.children.each do |child| %> | ... | ... |
plugins/mezuro/views/content_viewer/show_project.rhtml
... | ... | @@ -32,4 +32,6 @@ |
32 | 32 | |
33 | 33 | <div id="project-content" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>"> |
34 | 34 | <h3><%= _('Processing ') + @project.name + '...' %></h3> |
35 | -</div> | |
36 | 35 | \ No newline at end of file |
36 | +</div> | |
37 | +<div id='module-result'> | |
38 | +</div> | ... | ... |