diff --git a/plugins/mezuro/public/javascripts/dynamic.js b/plugins/mezuro/public/javascripts/dynamic.js index f1efe21..7a90e48 100644 --- a/plugins/mezuro/public/javascripts/dynamic.js +++ b/plugins/mezuro/public/javascripts/dynamic.js @@ -1,38 +1,37 @@ function dynamic($) { - $('.module-result-link').click(show_module_result); + $.get(endpoint('project_state'), {}, select_project_partial); } function endpoint(action){ - var profile = jQuery('#ids').attr('data-profile'); - var project = jQuery('#ids').attr('data-content'); + var profile = jQuery('#project-content').attr('data-profile'); + var project = jQuery('#project-content').attr('data-content'); return '/profile/' + profile + '/plugins/mezuro/' + action + '/' + project; } +function select_project_partial(state){ + var action; + if (state == 'ERROR') + action = 'project_error'; + else if (state == 'READY') + action = 'project_result'; + else + action = 'project_processing'; + jQuery.get(endpoint(action), {}, show_project_content); +} + +function show_project_content(content){ + jQuery('#project-content').html(content); + jQuery('.module-result-link').click(show_module_result); + return false; +} + function show_module_result(){ var module_name = jQuery(this).attr('data-module-name'); jQuery('#module-result').html("Loading results for " + module_name + "..."); - jQuery.get(endpoint('module_result'), {module_name: module_name}, show_result_table); + jQuery.get(endpoint('module_result'), { module_name: module_name }, show_result_table); return false; } function show_result_table(content){ jQuery('#module-result').html(content); } - -function show_autoreload($){ - jQuery('#autoreload').html('Loading results for ...' + project_name); // #FIXME - jQuery.get(endpoint('project_result'), {project_name: project_name}, show_page_with_results); - return false; -} - -function show_page_with_results(content){ - var done = true; // FIXME; test the content in some way - if (done) { - jQuery('#autoreload').html(content); - } else { - var wait = 10; // FIXME; how many seconds to wait? - setTimeout(function() { - show_autoreload(jQuery); - }, wait * 1000); - } -} \ No newline at end of file diff --git a/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb b/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb index 366c318..da4b5e9 100644 --- a/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb +++ b/plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb @@ -59,10 +59,9 @@ class MezuroPluginProfileControllerTest < ActionController::TestCase should 'get project processing' do create_project_content Kalibro::Client::ProjectClient.expects(:project).with(@name).returns(@project) - @project.expects(:state).returns("LOADING") get :project_processing, :profile => @profile.identifier, :id => @content.id assert_response 200 - assert_select('h3', 'Service is loading Qt-Calculator...') + assert_select('h3', 'Service is processing Qt-Calculator...') end should 'get error state if project has error' do diff --git a/plugins/mezuro/views/content_viewer/_project_processing.rhtml b/plugins/mezuro/views/content_viewer/_project_processing.rhtml index 9abb77a..66d8231 100644 --- a/plugins/mezuro/views/content_viewer/_project_processing.rhtml +++ b/plugins/mezuro/views/content_viewer/_project_processing.rhtml @@ -1 +1 @@ -