Commit a947b109de8cc69ab8d4731de9540eb3b9c915a8
Committed by
Diego Camarinha
1 parent
ed170105
Exists in
staging
and in
42 other branches
[Mezuro] remodel project show
Showing
5 changed files
with
65 additions
and
92 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
| @@ -19,18 +19,28 @@ class MezuroPluginProfileController < ProfileController | @@ -19,18 +19,28 @@ class MezuroPluginProfileController < ProfileController | ||
| 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 | project = content.project | 21 | project = content.project |
| 22 | - if params[:module_name].nil? | ||
| 23 | - source_tree = project_result.source_tree | ||
| 24 | - else | ||
| 25 | - source_tree = project_result.get_node(params[:module_name]) | ||
| 26 | - end | ||
| 27 | - render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result, :source_tree => source_tree, :project => project } | 22 | + render :partial => 'content_viewer/project_result', :locals => { :project_result => project_result } |
| 28 | end | 23 | end |
| 29 | 24 | ||
| 30 | def module_result | 25 | def module_result |
| 31 | content = profile.articles.find(params[:id]) | 26 | content = profile.articles.find(params[:id]) |
| 32 | - module_result = content.module_result(params[:module_name]) | 27 | + if params[:module_name].nil? or params[:module_name] == content.project.name |
| 28 | + module_result = content.module_result(content.project.name) | ||
| 29 | + else | ||
| 30 | + module_result = content.module_result(params[:module_name]) | ||
| 31 | + end | ||
| 33 | render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} | 32 | render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} |
| 34 | end | 33 | end |
| 35 | 34 | ||
| 35 | + def project_tree | ||
| 36 | + content = profile.articles.find(params[:id]) | ||
| 37 | + project_result = content.project_result | ||
| 38 | + if params[:module_name].nil? or params[:module_name] == content.project.name | ||
| 39 | + source_tree = project_result.source_tree | ||
| 40 | + else | ||
| 41 | + source_tree = project_result.get_node(params[:module_name]) | ||
| 42 | + end | ||
| 43 | + render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name} | ||
| 44 | + end | ||
| 45 | + | ||
| 36 | end | 46 | end |
plugins/mezuro/public/javascripts/project_content.js
| 1 | -jQuery(showProjectContent); | 1 | +jQuery(function (){ |
| 2 | + jQuery('.source-tree-link').live("click", reloadModule); | ||
| 3 | + showProjectContent(); | ||
| 4 | +}); | ||
| 2 | 5 | ||
| 3 | function showProjectContent() { | 6 | function showProjectContent() { |
| 4 | callAction('project_state', {}, showProjectContentFor); | 7 | callAction('project_state', {}, showProjectContentFor); |
| 5 | } | 8 | } |
| 6 | 9 | ||
| 10 | +function reloadModule(){ | ||
| 11 | + var module_name = jQuery(this).attr('data-module-name'); | ||
| 12 | + callAction('project_tree', {module_name: module_name }, showProjectTree); | ||
| 13 | + callAction('module_result', {module_name: module_name}, showModuleResult); | ||
| 14 | + return false; | ||
| 15 | +} | ||
| 16 | + | ||
| 7 | function showProjectContentFor(state){ | 17 | function showProjectContentFor(state){ |
| 8 | if (state == 'ERROR') | 18 | if (state == 'ERROR') |
| 9 | - callAction('project_error', {}, setProjectContent); | ||
| 10 | - else if (state == 'READY') | ||
| 11 | - callAction('project_result', {}, setProjectContent); | 19 | + callAction('project_error', {}, showProjectResult); |
| 20 | + else if (state == 'READY') { | ||
| 21 | + callAction('project_result', {}, showProjectResult); | ||
| 22 | + callAction('project_tree', {}, showProjectTree); | ||
| 23 | + callAction('module_result', {}, showModuleResult); | ||
| 24 | + } | ||
| 12 | else if (state.endsWith("ING")) | 25 | else if (state.endsWith("ING")) |
| 13 | showProjectContentAfter(20); | 26 | showProjectContentAfter(20); |
| 14 | } | 27 | } |
| @@ -23,31 +36,15 @@ function showProjectContentAfter(seconds){ | @@ -23,31 +36,15 @@ function showProjectContentAfter(seconds){ | ||
| 23 | } | 36 | } |
| 24 | } | 37 | } |
| 25 | 38 | ||
| 26 | -function setProjectContent(content){ | ||
| 27 | - var module_name = jQuery(this).attr('data-module-name'); | ||
| 28 | - jQuery('#project-content').html(content); | ||
| 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; | ||
| 37 | -} | ||
| 38 | - | ||
| 39 | -function showModuleResult(){ | ||
| 40 | - var module_name = jQuery(this).attr('data-module-name'); | ||
| 41 | - setModuleResult("Loading results for " + module_name + "..."); | ||
| 42 | - callAction('module_result', {module_name: module_name}, setModuleResult); | ||
| 43 | - return false; | 39 | +function showProjectResult(content) { |
| 40 | + jQuery('#project-result').html(content); | ||
| 44 | } | 41 | } |
| 45 | 42 | ||
| 46 | -function setProjectResult(content){ | ||
| 47 | - jQuery('#project_results').html(content); | 43 | +function showProjectTree(content){ |
| 44 | + jQuery('#project-tree').html(content); | ||
| 48 | } | 45 | } |
| 49 | 46 | ||
| 50 | -function setModuleResult(content){ | 47 | +function showModuleResult(content){ |
| 51 | jQuery('#module-result').html(content); | 48 | jQuery('#module-result').html(content); |
| 52 | } | 49 | } |
| 53 | 50 | ||
| @@ -59,11 +56,5 @@ function callAction(action, params, callback){ | @@ -59,11 +56,5 @@ function callAction(action, params, callback){ | ||
| 59 | } | 56 | } |
| 60 | 57 | ||
| 61 | function projectContentData(data){ | 58 | function projectContentData(data){ |
| 62 | - return jQuery('#project-content').attr('data-' + data); | ||
| 63 | -} | ||
| 64 | - | ||
| 65 | -function sourceNodeToggle(id){ | ||
| 66 | - var suffixes = ['_hidden', '_plus', '_minus']; | ||
| 67 | - for (var i in suffixes) | ||
| 68 | - jQuery('#' + id + suffixes[i]).toggle(); | 59 | + return jQuery('#project-result').attr('data-' + data); |
| 69 | } | 60 | } |
plugins/mezuro/views/content_viewer/_project_result.rhtml
| @@ -14,21 +14,3 @@ | @@ -14,21 +14,3 @@ | ||
| 14 | <td><%= project_result.formatted_analysis_time %></td> | 14 | <td><%= project_result.formatted_analysis_time %></td> |
| 15 | </tr> | 15 | </tr> |
| 16 | </table> | 16 | </table> |
| 17 | -<h4><%= _('Source tree') %></h4> | ||
| 18 | - | ||
| 19 | -<% if !source_tree.nil? && project.name != source_tree.module.name %> | ||
| 20 | - <a href="#" class="module-result-link" data-module-name="<%= project_result.source_tree %>"> | ||
| 21 | - <%= project.name %> | ||
| 22 | - </a> | ||
| 23 | - <% split_link = source_tree.module.ancestor_names %> | ||
| 24 | - <% split_link.each do |link| %> | ||
| 25 | - <% if split_link.length - 1 != split_link.index(link) %> | ||
| 26 | - <a href="#" class="module-result-link" data-module-name="<%= link %>"> | ||
| 27 | - <%= link.split(".").last %> | ||
| 28 | - </a> | ||
| 29 | - <% end %> | ||
| 30 | - <% end %> | ||
| 31 | - <%= render :partial => 'content_viewer/source_tree', :locals => { :source_tree => source_tree } %> | ||
| 32 | -<% else %> | ||
| 33 | - <%= render :partial => 'content_viewer/source_tree', :locals => { :source_tree => project_result.source_tree } %> | ||
| 34 | -<% end %> |
plugins/mezuro/views/content_viewer/_source_tree.rhtml
| 1 | +<h4><%= _('Source tree') %></h4> | ||
| 1 | <% module_name = source_tree.module.name %> | 2 | <% module_name = source_tree.module.name %> |
| 2 | <% module_label = "#{module_name} (#{source_tree.module.granularity})" %> | 3 | <% module_label = "#{module_name} (#{source_tree.module.granularity})" %> |
| 3 | 4 | ||
| 5 | +<% if module_name != project_name %> | ||
| 6 | + <a href="#" class="source-tree-link" data-module-name="<%= project_name %>"> | ||
| 7 | + <%= project_name %> | ||
| 8 | + </a> | ||
| 9 | +<% end %> | ||
| 10 | + | ||
| 11 | + <% split_link = source_tree.module.ancestor_names %> | ||
| 12 | + <% split_link.each do |link| %> | ||
| 13 | + <a href="#" class="source-tree-link" data-module-name="<%= link %>"> | ||
| 14 | + <%= link.split(".").last %> | ||
| 15 | + </a> | ||
| 16 | +<% end %> | ||
| 17 | + | ||
| 4 | <% if source_tree.children %> | 18 | <% if source_tree.children %> |
| 5 | <table> | 19 | <table> |
| 6 | - <tr> | ||
| 7 | - <td width="10%"> | ||
| 8 | - <img alt="+" src="/plugins/mezuro/images/plus.png" class="link" style="display: none" | ||
| 9 | - id="<%= module_name %>_plus" onclick="sourceNodeToggle('<%= module_name %>')"/> | ||
| 10 | - <img alt="-" src="/plugins/mezuro/images/minus.png" class="link" | ||
| 11 | - id="<%= module_name %>_minus" onclick="sourceNodeToggle('<%= module_name %>')"/> | ||
| 12 | - </td> | ||
| 13 | - <td> | ||
| 14 | - <a href="#" class="module-result-link" data-module-name="<%= module_name %>"> | ||
| 15 | - <%= module_label %> | ||
| 16 | - </a> | ||
| 17 | - </td> | ||
| 18 | - </tr> | ||
| 19 | - <tr id="<%= module_name %>_hidden"> | ||
| 20 | - <td></td> | ||
| 21 | - <td style="text-align: left"> | ||
| 22 | - <% source_tree.children.each do |child| %> | ||
| 23 | - <%= render :partial => 'content_viewer/source_tree', :locals => { :source_tree => child } %> | ||
| 24 | - <% end %> | ||
| 25 | - </td> | ||
| 26 | - </tr> | ||
| 27 | - </table> | ||
| 28 | -<% else %> | ||
| 29 | - <table> | ||
| 30 | - <tr> | ||
| 31 | - <td width="1"></td> | ||
| 32 | - <td> | ||
| 33 | - <a href="#" class="module-result-link" data-module-name="<%= module_name %>"> | ||
| 34 | - <%= module_label %> | ||
| 35 | - </a> | ||
| 36 | - </td> | ||
| 37 | - </tr> | 20 | + <% source_tree.children.each do |child| %> |
| 21 | + <tr> | ||
| 22 | + <td> | ||
| 23 | + <a href='#' class="source-tree-link" data-module-name="<%= child.module.name %>"> | ||
| 24 | + <%= "#{child.module.name} (#{child.module.granularity})" %> | ||
| 25 | + </td> | ||
| 26 | + </tr> | ||
| 27 | + <% end %> | ||
| 38 | </table> | 28 | </table> |
| 39 | <% end %> | 29 | <% end %> |
plugins/mezuro/views/content_viewer/show_project.rhtml
| @@ -30,8 +30,8 @@ | @@ -30,8 +30,8 @@ | ||
| 30 | 30 | ||
| 31 | <br /> | 31 | <br /> |
| 32 | 32 | ||
| 33 | -<div id="project-content" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>"> | 33 | +<div id="project-result" data-profile="<%= @page.profile.identifier %>" data-content="<%= @page.id %>"> |
| 34 | <h3><%= _('Processing ') + @project.name + '...' %></h3> | 34 | <h3><%= _('Processing ') + @project.name + '...' %></h3> |
| 35 | </div> | 35 | </div> |
| 36 | -<div id='module-result'> | ||
| 37 | -</div> | 36 | +<div id="project-tree"></div> |
| 37 | +<div id="module-result"></div> |