Commit 15de08565e0daab1f6aa8dbb79555d93c24ad5a3

Authored by Alessandro Palmeira + Carlos Morais
Committed by Carlos Morais
1 parent 1c31fda6

[Mezuro] Ajax autoloading results

plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... ... @@ -20,12 +20,6 @@ class MezuroPluginProfileController < ProfileController
20 20 render :partial => 'content_viewer/project_error', :locals => { :project => project }
21 21 end
22 22  
23   - def project_processing
24   - content = profile.articles.find(params[:id])
25   - project = content.project
26   - render :partial => 'content_viewer/project_processing', :locals => { :project => project }
27   - end
28   -
29 23 def project_state
30 24 content = profile.articles.find(params[:id])
31 25 project = content.project
... ...
plugins/mezuro/public/javascripts/dynamic.js
... ... @@ -9,16 +9,30 @@ function endpoint(action){
9 9 }
10 10  
11 11 function select_project_partial(state){
12   - var action;
  12 + var action, callback = show_project_content;
13 13 if (state == 'ERROR')
14 14 action = 'project_error';
15 15 else if (state == 'READY')
16 16 action = 'project_result';
17   - else
18   - action = 'project_processing';
19   - jQuery.get(endpoint(action), {}, show_project_content);
  17 + else {
  18 +// wait(10);
  19 + action = 'project_state';
  20 + callback = select_project_partial;
  21 + }
  22 + jQuery.get(endpoint(action), {}, callback);
20 23 }
21 24  
  25 +//function wait(seconds){
  26 +// var remaining = seconds;
  27 +// while(remaining > 0){
  28 +// setTimeout(function() {
  29 +// jQuery('#project-content').html("Processing. Trying again in " + remaining + " seconds");
  30 +// }, 1000);
  31 +// remaining--;
  32 +// }
  33 +// jQuery('#project-content').html("Trying now...");
  34 +//}
  35 +
22 36 function show_project_content(content){
23 37 jQuery('#project-content').html(content);
24 38 jQuery('.module-result-link').click(show_module_result);
... ...
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
... ... @@ -56,14 +56,6 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase
56 56 assert_select('h3', 'ERROR')
57 57 end
58 58  
59   - should 'get project processing' do
60   - create_project_content
61   - Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
62   - get :project_processing, :profile => @profile.identifier, :id => @content.id
63   - assert_response 200
64   - assert_select('h3', 'Service is processing Qt-Calculator...')
65   - end
66   -
67 59 should 'get error state if project has error' do
68 60 create_project_content
69 61 Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project)
... ...
plugins/mezuro/views/content_viewer/_project_processing.rhtml
... ... @@ -1 +0,0 @@
1   -<h3><%= _('Service is processing ') + project.name + '...' %></h3>
2 0 \ No newline at end of file
plugins/mezuro/views/content_viewer/show_project.rhtml
... ... @@ -30,7 +30,7 @@
30 30 <br />
31 31  
32 32 <div id="project-content" data-profile="<%= @page.profile.identifier %>" data-content='<%= @page.id %>'>
33   - <%= _('Loading project content...') %>
  33 + <h3><%= _('Processing ') + @project.name + '...' %></h3>
34 34 </div>
35 35  
36 36 <script type="text/javascript">
... ...