diff --git a/plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb b/plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb index ebf3ef0..47b8bb2 100644 --- a/plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb +++ b/plugins/mezuro/controllers/profile/mezuro_plugin_processing_controller.rb @@ -2,16 +2,13 @@ class MezuroPluginProcessingController < MezuroPluginProfileController append_view_path File.join(File.dirname(__FILE__) + '/../../views') - def render_last_state - last_state = Kalibro::Processing.last_processing_state_of(params[:repository_id].to_i) - render :text => last_state + def state + processing = processing_for_date(params[:repository_id].to_i, params[:date]) + render :text => processing.state end def processing - date = params[:date] - repository_id = params[:repository_id].to_i - processing_class = Kalibro::Processing - @processing = date.nil? ? processing_class.processing_of(repository_id) : processing_class.processing_with_date_of(repository_id, date) + @processing = processing_for_date(params[:repository_id].to_i, params[:date]) if @processing.state == 'ERROR' render :partial => 'processing_error' else @@ -19,4 +16,15 @@ class MezuroPluginProcessingController < MezuroPluginProfileController end end + private + + def processing_for_date(repository_id, date = nil) + processing_class = Kalibro::Processing + if date.nil? + processing_class.processing_of(repository_id) + else + processing_class.processing_with_date_of(repository_id, date) + end + end + end diff --git a/plugins/mezuro/public/javascripts/processing.js b/plugins/mezuro/public/javascripts/processing.js index 2ca380a..a69b227 100644 --- a/plugins/mezuro/public/javascripts/processing.js +++ b/plugins/mezuro/public/javascripts/processing.js @@ -4,18 +4,19 @@ jQuery(function (){ jQuery('.source-tree-link').live("click", reloadModule); jQuery('[show-metric-history]').live("click", display_metric_history); //TODO review for project history jQuery('[show-grade-history]').live("click", display_grade_history); //TODO review for project history - jQuery('#project_date_submit').live("click", reloadProjectWithDate); //TODO review for project history + jQuery('#project_date_submit').live("click", reloadProcessingWithDate); //TODO review for project history showLoadingProcess(true); showProcessing(); }); function showProcessing() { - callAction('processing', 'processing', {}, showProcessingFor); + repository_id = processingData('repository-id'); + callAction('processing', 'state', {repository_id: repository_id}, showProcessingFor); } //TODO review for project history function display_metric_history() { - var module_name = jQuery(this).attr('data-module-name'); + var module_result_id = jQuery(this).attr('data-module-id'); var metric_name = jQuery(this).attr('show-metric-history'); toggle_mezuro("." + metric_name); metricName = metric_name; @@ -25,7 +26,7 @@ function display_metric_history() { //TODO review for project history function display_grade_history() { - var module_name = jQuery(this).attr('data-module-name'); + var module_name = jQuery(this).attr('data-module-id'); toggle_mezuro("#historical-grade"); callAction('module_result', 'module_result_history', {module_result_id: module_result_id}, show_grades); return false; @@ -48,62 +49,69 @@ function toggle_mezuro(element){ //TODO Waiting for ModuleResultController refactoring function reloadModule(){ - var results_root_id = jQuery(this).attr('results_root_id'); + var module_result_id = jQuery(this).attr('module_result_id'); showLoadingProcess(false); processingTree = true; // callAction('module_result', 'project_tree', {results_root_id: results_root_id }, showProjectTree); - callAction('module_result', 'module_result', {results_root_id: results_root_id}, showModuleResult); + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); return false; } //TODO review for project history -function reloadProjectWithDate(date){ - reloadProject(date + "T00:00:00+00:00"); +function reloadProcessingWithDate(date){ + reloadProcessing(date + "T00:00:00+00:00"); return false; } //TODO review for project history -function reloadProject(date){ +function reloadProcessing(date){ + repository_id = processingData('repository-id'); showLoadingProcess(true); - - callAction('processing', 'processing', {date: date}, showProjectResult); -// callAction('module_result', 'project_tree', {date: date}, showProjectTree); - callAction('module_result', 'module_result', {date: date}, showModuleResult); + + callAction('processing', 'processing', {date: date, repository_id: repository_id}, function(content){ + showReadyProcessing(content); + var module_result_id = jQuery("#module_result_root_id").attr('module_result_root_id'); //TODO Waiting for ModuleResultController refactoring + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); //TODO Waiting for ModuleResultController refactoring + } + ); } function showProcessingFor(state){ + repository_id = processingData('repository-id'); if (state == 'ERROR') { jQuery('#project-state').html('
ERROR
'); - callAction('processing', 'processing_error', {}, showProcessing); + callAction('processing', 'processing', {repository_id: repository_id}, showReadyProcessing); } else if (state == 'READY') { jQuery('#msg-time').html(''); jQuery('#processing-state').html('
READY
'); - callAction('processing', 'processing', {}, showProcessing); -// callAction('processing','project_tree', {}, showProjectTree); - //var module_result_id = jQuery("#processing").attr('results_root_id'); //TODO Waiting for ModuleResultController refactoring - callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); //TODO Waiting for ModuleResultController refactoring - } + callAction('processing', 'processing', {repository_id: repository_id}, function(content){ + showReadyProcessing(content); + var module_result_id = jQuery("#module_result_root_id").attr('module_result_root_id'); //TODO Waiting for ModuleResultController refactoring + callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult); //TODO Waiting for ModuleResultController refactoring + } + ); + } else if (state.endsWith("ING")) { jQuery('#processing-state').html('
'+ state +'
'); jQuery('#msg-time').html("The project analysis may take long.
You'll receive an e-mail when it's ready!"); - showProjectContentAfter(20); - } + showProcessingAfter(20); + } } -function showProjectContentAfter(seconds){ +function showProcessingAfter(seconds){ if (seconds > 0){ - setTimeout(function() { showProjectContentAfter(seconds - 10);}, 10000); + setTimeout(function() { showProcessingAfter(seconds - 10);}, 10000); } else { - showProjectContent(); + showProcessing(); } } -function showProjectResult(content) { +function showReadyProcessing(content) { jQuery('#processing').html(content); } -//function showProjectTree(content){ +//function showProjectTree(content){ // processingTree = false; // jQuery('#project-tree').html(content); // return false; @@ -118,21 +126,19 @@ function showModuleResult(content){ } function callAction(controller, action, params, callback){ - var profile = projectContentData('profile'); - var content = projectContentData('content'); + var profile = processingData('profile'); + var content = processingData('content'); var endpoint = '/profile/' + profile + '/plugin/mezuro/' + controller + '/' + action + '/' + content; jQuery.get(endpoint, params, callback); } -function projectContentData(data){ +function processingData(data){ return jQuery('#processing').attr('data-' + data); } function showLoadingProcess(firstLoad){ - if(firstLoad) - showProjectResult(""); - - showProjectTree(""); + if(firstLoad) + showReadyProcessing(""); showModuleResult(""); } diff --git a/plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml b/plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml index 69f0d4d..9e0003e 100644 --- a/plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml +++ b/plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml @@ -32,3 +32,5 @@ }); + + \ No newline at end of file -- libgit2 0.21.2