Commit 4249a644b6ce06140814ad42d0e3b31a698f94da
Committed by
Diego Camarinha
1 parent
f60d91b1
Exists in
master
and in
23 other branches
Failing to implement ajax to autoreload results
Showing
5 changed files
with
64 additions
and
35 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -6,4 +6,9 @@ class MezuroPluginProfileController < ProfileController | @@ -6,4 +6,9 @@ class MezuroPluginProfileController < ProfileController | ||
6 | render :partial => 'content_viewer/module_result', :locals => { :module_result => project_content.module_result(module_name) } | 6 | render :partial => 'content_viewer/module_result', :locals => { :module_result => project_content.module_result(module_name) } |
7 | end | 7 | end |
8 | 8 | ||
9 | + def autoreload | ||
10 | + page_content = profile.articles.find(params[:id]) | ||
11 | + project_name = params[:project_name] | ||
12 | + render :partial => 'content_viewer/autoreload', :locals => { :project_result => page_content.project_result(project_name) } | ||
13 | + end | ||
9 | end | 14 | end |
plugins/mezuro/lib/mezuro_plugin.rb
@@ -17,7 +17,7 @@ class MezuroPlugin < Noosfero::Plugin | @@ -17,7 +17,7 @@ class MezuroPlugin < Noosfero::Plugin | ||
17 | end | 17 | end |
18 | 18 | ||
19 | def js_files | 19 | def js_files |
20 | - ['javascripts/results.js', 'javascripts/toogle.js'] | 20 | + ['javascripts/results.js', 'javascripts/toogle.js', 'javascripts/autoreload.js'] |
21 | end | 21 | end |
22 | 22 | ||
23 | end | 23 | end |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +function autoreloads($) { | ||
2 | + $('#autoreload').onload(show_autoreload); | ||
3 | +} | ||
4 | + | ||
5 | +function show_autoreload(){ | ||
6 | + var profile = jQuery('#autoreload').attr('data-profile'); | ||
7 | + var project = jQuery('#autoreload').attr('data-project-id'); | ||
8 | + var project_name = jQuery('#autoreload').attr('data-project-name'); | ||
9 | + var endpoint = '/profile/' + profile + '/plugins/mezuro/autoreload/' + project; | ||
10 | + show_loading_message(project_name); | ||
11 | + jQuery.get(endpoint, {project_name: project_name}, show_page_with_results); | ||
12 | + return false; | ||
13 | +} | ||
14 | + | ||
15 | +function show_loading_message(project_name) { | ||
16 | + jQuery('#autoreload').html("Loading results for " + project_name + "..."); | ||
17 | +} | ||
18 | + | ||
19 | +function show_page_with_results(content){ | ||
20 | + jQuery('#autoreload').html(content); | ||
21 | +} |
@@ -0,0 +1,29 @@ | @@ -0,0 +1,29 @@ | ||
1 | + <h3><%= _('LAST RESULT') %></h3> | ||
2 | + <% @project_result = @page.project_result %> | ||
3 | + | ||
4 | + <table id="project_result_info"> | ||
5 | + <tr> | ||
6 | + <td><%= _('Date') %></td> | ||
7 | + <td><%= @project_result.date %></td> | ||
8 | + </tr> | ||
9 | + <tr> | ||
10 | + <td><%= _('Load time') %></td> | ||
11 | + <td><%= @project_result.formatted_load_time %></td> | ||
12 | + </tr> | ||
13 | + <tr> | ||
14 | + <td><%= _('Analysis time') %></td> | ||
15 | + <td><%= @project_result.formatted_analysis_time %></td> | ||
16 | + </tr> | ||
17 | + </table> | ||
18 | + | ||
19 | + <h5><%= _('Source tree') %></h5> | ||
20 | + | ||
21 | + <%= render :partial => 'source_tree', :locals => { :source_tree => @project_result.source_tree } %> | ||
22 | + | ||
23 | + <div id='module-result' data-profile="<%= @page.profile.identifier %>" data-project-id='<%= @page.id %>'> | ||
24 | + <%= render :partial => 'module_result', :locals => { :module_result => @page.module_result(@project.name) } %> | ||
25 | + </div> | ||
26 | + | ||
27 | + <script type="text/javascript"> | ||
28 | + jQuery(results); | ||
29 | + </script> |
plugins/mezuro/views/content_viewer/show_project.rhtml
@@ -40,40 +40,14 @@ | @@ -40,40 +40,14 @@ | ||
40 | <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> | 40 | <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> |
41 | <% end %></ul> | 41 | <% end %></ul> |
42 | </p> | 42 | </p> |
43 | -<% elsif @project.state.end_with? 'ING' %> | ||
44 | - <p> | ||
45 | - <%= _("Kalibro Service is #{@project.state.downcase} the source code.") %> | ||
46 | - <br/> | ||
47 | - <%= _('Reload the page manually in a few moments.') %> | ||
48 | - </p> | ||
49 | -<% elsif @project.state == 'READY' %> | ||
50 | - <h3><%= _('LAST RESULT') %></h3> | ||
51 | - <% @project_result = @page.project_result %> | ||
52 | - | ||
53 | - <table id="project_result_info"> | ||
54 | - <tr> | ||
55 | - <td><%= _('Date') %></td> | ||
56 | - <td><%= @project_result.date %></td> | ||
57 | - </tr> | ||
58 | - <tr> | ||
59 | - <td><%= _('Load time') %></td> | ||
60 | - <td><%= @project_result.formatted_load_time %></td> | ||
61 | - </tr> | ||
62 | - <tr> | ||
63 | - <td><%= _('Analysis time') %></td> | ||
64 | - <td><%= @project_result.formatted_analysis_time %></td> | ||
65 | - </tr> | ||
66 | - </table> | ||
67 | - | ||
68 | - <h5><%= _('Source tree') %></h5> | ||
69 | - | ||
70 | - <%= render :partial => 'source_tree', :locals => { :source_tree => @project_result.source_tree } %> | ||
71 | - | ||
72 | - <div id='module-result' data-profile="<%= @page.profile.identifier %>" data-project-id='<%= @page.id %>'> | ||
73 | - <%= render :partial => 'module_result', :locals => { :module_result => @page.module_result(@project.name) } %> | 43 | +<% elsif @page.project.state=='READY' %> |
44 | + <div id='autoreload' data-profile="<%= @page.profile.identifier %>" data-project-id='<%= @page.id %>' data-project-name='<%= @project.name %>'> | ||
45 | + <%= render :partial => 'autoreload', :locals => { :autoreload => @page } %> | ||
46 | + </div> | ||
47 | +<% else %> | ||
48 | + <div id='autoreload' data-profile="<%= @page.profile.identifier %>" data-project-id='<%= @page.id %>' data-project-name="<%= @project.name %>"> | ||
74 | </div> | 49 | </div> |
75 | - | ||
76 | <script type="text/javascript"> | 50 | <script type="text/javascript"> |
77 | - jQuery(results); | 51 | + jQuery(autoreloads); |
78 | </script> | 52 | </script> |
79 | -<% end %> | ||
80 | \ No newline at end of file | 53 | \ No newline at end of file |
54 | +<% end %> |