Commit 15de08565e0daab1f6aa8dbb79555d93c24ad5a3
Committed by
Carlos Morais
1 parent
1c31fda6
Exists in
master
and in
29 other branches
[Mezuro] Ajax autoloading results
Showing
5 changed files
with
19 additions
and
20 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
| @@ -20,12 +20,6 @@ class MezuroPluginProfileController < ProfileController | @@ -20,12 +20,6 @@ class MezuroPluginProfileController < ProfileController | ||
| 20 | render :partial => 'content_viewer/project_error', :locals => { :project => project } | 20 | render :partial => 'content_viewer/project_error', :locals => { :project => project } |
| 21 | end | 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 | def project_state | 23 | def project_state |
| 30 | content = profile.articles.find(params[:id]) | 24 | content = profile.articles.find(params[:id]) |
| 31 | project = content.project | 25 | project = content.project |
plugins/mezuro/public/javascripts/dynamic.js
| @@ -9,16 +9,30 @@ function endpoint(action){ | @@ -9,16 +9,30 @@ function endpoint(action){ | ||
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | function select_project_partial(state){ | 11 | function select_project_partial(state){ |
| 12 | - var action; | 12 | + var action, callback = show_project_content; |
| 13 | if (state == 'ERROR') | 13 | if (state == 'ERROR') |
| 14 | action = 'project_error'; | 14 | action = 'project_error'; |
| 15 | else if (state == 'READY') | 15 | else if (state == 'READY') |
| 16 | action = 'project_result'; | 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 | function show_project_content(content){ | 36 | function show_project_content(content){ |
| 23 | jQuery('#project-content').html(content); | 37 | jQuery('#project-content').html(content); |
| 24 | jQuery('.module-result-link').click(show_module_result); | 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,14 +56,6 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase | ||
| 56 | assert_select('h3', 'ERROR') | 56 | assert_select('h3', 'ERROR') |
| 57 | end | 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 | should 'get error state if project has error' do | 59 | should 'get error state if project has error' do |
| 68 | create_project_content | 60 | create_project_content |
| 69 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) | 61 | Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) |
plugins/mezuro/views/content_viewer/_project_processing.rhtml
plugins/mezuro/views/content_viewer/show_project.rhtml
| @@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
| 30 | <br /> | 30 | <br /> |
| 31 | 31 | ||
| 32 | <div id="project-content" data-profile="<%= @page.profile.identifier %>" data-content='<%= @page.id %>'> | 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 | </div> | 34 | </div> |
| 35 | 35 | ||
| 36 | <script type="text/javascript"> | 36 | <script type="text/javascript"> |