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,7 +18,9 @@ class MezuroPluginProfileController < ProfileController | ||
18 | def project_result | 18 | def project_result |
19 | content = profile.articles.find(params[:id]) | 19 | content = profile.articles.find(params[:id]) |
20 | project_result = content.project_result | 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 | end | 24 | end |
23 | 25 | ||
24 | def module_result | 26 | def module_result |
plugins/mezuro/lib/kalibro/entities/project_result.rb
@@ -14,6 +14,22 @@ class Kalibro::Entities::ProjectResult < Kalibro::Entities::Entity | @@ -14,6 +14,22 @@ class Kalibro::Entities::ProjectResult < Kalibro::Entities::Entity | ||
14 | format_milliseconds(@load_time) | 14 | format_milliseconds(@load_time) |
15 | end | 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 | def formatted_analysis_time | 33 | def formatted_analysis_time |
18 | format_milliseconds(@analysis_time) | 34 | format_milliseconds(@analysis_time) |
19 | end | 35 | end |
@@ -31,4 +47,4 @@ class Kalibro::Entities::ProjectResult < Kalibro::Entities::Entity | @@ -31,4 +47,4 @@ class Kalibro::Entities::ProjectResult < Kalibro::Entities::Entity | ||
31 | ('%2d' % amount).sub(/\s/, '0') | 47 | ('%2d' % amount).sub(/\s/, '0') |
32 | end | 48 | end |
33 | 49 | ||
34 | -end | ||
35 | \ No newline at end of file | 50 | \ No newline at end of file |
51 | +end |
plugins/mezuro/public/javascripts/project_content.js
@@ -24,8 +24,16 @@ function showProjectContentAfter(seconds){ | @@ -24,8 +24,16 @@ function showProjectContentAfter(seconds){ | ||
24 | } | 24 | } |
25 | 25 | ||
26 | function setProjectContent(content){ | 26 | function setProjectContent(content){ |
27 | + var module_name = jQuery(this).attr('data-module-name'); | ||
27 | jQuery('#project-content').html(content); | 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 | function showModuleResult(){ | 39 | function showModuleResult(){ |
@@ -35,6 +43,10 @@ function showModuleResult(){ | @@ -35,6 +43,10 @@ function showModuleResult(){ | ||
35 | return false; | 43 | return false; |
36 | } | 44 | } |
37 | 45 | ||
46 | +function setProjectResult(content){ | ||
47 | + jQuery('#project_results').html(content); | ||
48 | +} | ||
49 | + | ||
38 | function setModuleResult(content){ | 50 | function setModuleResult(content){ |
39 | jQuery('#module-result').html(content); | 51 | jQuery('#module-result').html(content); |
40 | } | 52 | } |
@@ -54,4 +66,4 @@ function sourceNodeToggle(id){ | @@ -54,4 +66,4 @@ function sourceNodeToggle(id){ | ||
54 | var suffixes = ['_hidden', '_plus', '_minus']; | 66 | var suffixes = ['_hidden', '_plus', '_minus']; |
55 | for (var i in suffixes) | 67 | for (var i in suffixes) |
56 | jQuery('#' + id + suffixes[i]).toggle(); | 68 | jQuery('#' + id + suffixes[i]).toggle(); |
57 | -} | ||
58 | \ No newline at end of file | 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 | <table> | 3 | <table> |
4 | <tr> | 4 | <tr> |
@@ -16,7 +16,4 @@ | @@ -16,7 +16,4 @@ | ||
16 | </table> | 16 | </table> |
17 | 17 | ||
18 | <h4><%= _('Source tree') %></h4> | 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,9 +4,9 @@ | ||
4 | <table> | 4 | <table> |
5 | <tr> | 5 | <tr> |
6 | <td width="10%"> | 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 | id="<%= module_name %>_plus" onclick="sourceNodeToggle('<%= module_name %>')"/> | 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 | id="<%= module_name %>_minus" onclick="sourceNodeToggle('<%= module_name %>')"/> | 10 | id="<%= module_name %>_minus" onclick="sourceNodeToggle('<%= module_name %>')"/> |
11 | </td> | 11 | </td> |
12 | <td> | 12 | <td> |
@@ -15,7 +15,7 @@ | @@ -15,7 +15,7 @@ | ||
15 | </a> | 15 | </a> |
16 | </td> | 16 | </td> |
17 | </tr> | 17 | </tr> |
18 | - <tr id="<%= module_name %>_hidden" style="display: none"> | 18 | + <tr id="<%= module_name %>_hidden"> |
19 | <td></td> | 19 | <td></td> |
20 | <td style="text-align: left"> | 20 | <td style="text-align: left"> |
21 | <% source_tree.children.each do |child| %> | 21 | <% source_tree.children.each do |child| %> |
plugins/mezuro/views/content_viewer/show_project.rhtml
@@ -32,4 +32,6 @@ | @@ -32,4 +32,6 @@ | ||
32 | 32 | ||
33 | <div id="project-content" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>"> | 33 | <div id="project-content" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>"> |
34 | <h3><%= _('Processing ') + @project.name + '...' %></h3> | 34 | <h3><%= _('Processing ') + @project.name + '...' %></h3> |
35 | -</div> | ||
36 | \ No newline at end of file | 35 | \ No newline at end of file |
36 | +</div> | ||
37 | +<div id='module-result'> | ||
38 | +</div> |