diff --git a/plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb b/plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
index b333ad1..e54aaa4 100644
--- a/plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
+++ b/plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
@@ -2,7 +2,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
append_view_path File.join(File.dirname(__FILE__) + '/../../views')
- def new_repository
+ def new
@project_content = profile.articles.find(params[:id])
@repository_types = Kalibro::Repository.repository_types
@@ -18,26 +18,39 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
end
end
- def create_repository
+ def create
project_content = profile.articles.find(params[:id])
- project_content_name = project_content.name
repository = Kalibro::Repository.new( params[:repository] )
repository.save(project_content.project_id)
if( repository.errors.empty? )
- redirect_to "/#{profile.identifier}/#{project_content_name.downcase.gsub(/\s/, '-')}"
+ redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}"
else
redirect_to_error_page repository.errors[0].message
end
end
- def show_repository
+ def show
project_content = profile.articles.find(params[:id])
@project_name = project_content.name
@repository = project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_s }.first
@configuration_name = Kalibro::Configuration.find(@repository.configuration_id).name
+ @processing = processing(@repository.id)
end
+
+ def destroy
+ project_content = profile.articles.find(params[:id])
+ repository = project_content.repositories.select{ |repository| repository.id == params[:repository_id].to_s }.first
+ repository.destroy
+ if( repository.errors.empty? )
+ redirect_to "/#{profile.identifier}/#{project_content.name.downcase.gsub(/\s/, '-')}"
+ else
+ redirect_to_error_page repository.errors[0].message
+ end
+ end
+
+ private
def processing(repository_id)
begin
diff --git a/plugins/mezuro/lib/kalibro/repository.rb b/plugins/mezuro/lib/kalibro/repository.rb
index ff38895..6746736 100644
--- a/plugins/mezuro/lib/kalibro/repository.rb
+++ b/plugins/mezuro/lib/kalibro/repository.rb
@@ -25,6 +25,7 @@ class Kalibro::Repository < Kalibro::Model
def save(project_id)
begin
self.id = self.class.request(:save_repository, {:repository => self.to_hash, :project_id => project_id})[:repository_id]
+ process_repository
true
rescue Exception => exception
add_error exception
diff --git a/plugins/mezuro/public/javascripts/processing.js b/plugins/mezuro/public/javascripts/processing.js
new file mode 100644
index 0000000..8950174
--- /dev/null
+++ b/plugins/mezuro/public/javascripts/processing.js
@@ -0,0 +1,135 @@
+var processingTree = false;
+var metricName;
+jQuery(function (){
+ jQuery('.source-tree-link').live("click", reloadModule);
+ jQuery('[show-metric-history]').live("click", display_metric_history);
+ jQuery('[show-grade-history]').live("click", display_grade_history);
+ jQuery('#project_date_submit').live("click", reloadProjectWithDate);
+ showLoadingProcess(true);
+ showProcessing();
+});
+
+function showProcessing() {
+ callAction('processing', 'processing_state', {}, showProcessingFor);
+}
+
+function display_metric_history() {
+ var module_name = jQuery(this).attr('data-module-name');
+ var metric_name = jQuery(this).attr('show-metric-history');
+ toggle_mezuro("." + metric_name);
+ metricName = metric_name;
+ callAction('module', 'module_metrics_history', {module_id: module_id, module_result_id: module_result_id}, show_metrics);
+ return false;
+}
+
+function display_grade_history() {
+ var module_name = jQuery(this).attr('data-module-name');
+ toggle_mezuro("#historical-grade");
+ callAction('module', 'module_grade_history', {module_name: module_name}, show_grades);
+ return false;
+}
+
+function show_metrics(content) {
+ jQuery('#historical-' + metricName).html(content);
+}
+
+function show_grades(content) {
+ jQuery('#historical-grade').html(content);
+}
+
+function toggle_mezuro(element){
+ jQuery(element).toggle();
+ return false;
+}
+
+function reloadModule(){
+ var results_root_id = jQuery(this).attr('results_root_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);
+ return false;
+}
+
+function reloadProjectWithDate(date){
+ reloadProject(date + "T00:00:00+00:00");
+ return false;
+}
+
+function reloadProject(date){
+ showLoadingProcess(true);
+
+ callAction('processing', 'processing', {date: date}, showProjectResult);
+ callAction('module_result', 'project_tree', {date: date}, showProjectTree);
+ callAction('module_result', 'module_result', {date: date}, showModuleResult);
+}
+
+function showProcessingFor(state){
+ if (state == 'ERROR') {
+ jQuery('#project-state').html('
ERROR
');
+ callAction('processing', 'processing_error', {}, showProcessing);
+ }
+ else if (state == 'READY') {
+ jQuery('#msg-time').html('');
+ jQuery('#processing-state').html('READY
');
+ callAction('processing', 'processing', {}, showProcessing);
+ callAction('module_result','project_tree', {}, showProjectTree);
+ var module_result_id = jQuery("#processing").attr('results_root_id');
+ callAction('module_result', 'module_result', {module_result_id: module_result_id}, showModuleResult);
+ }
+ 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);
+ }
+}
+
+function showProjectContentAfter(seconds){
+ if (seconds > 0){
+ setTimeout(function() { showProjectContentAfter(seconds - 10);}, 10000);
+ } else {
+ showProjectContent();
+ }
+}
+
+function showProjectResult(content) {
+ jQuery('#processing').html(content);
+}
+
+function showProjectTree(content){
+ processingTree = false;
+ jQuery('#project-tree').html(content);
+ return false;
+}
+
+function showModuleResult(content){
+ if (processingTree != true){
+ jQuery('#module-result').html(content);
+ }
+ return false;
+}
+
+function callAction(controller, action, params, callback){
+ var profile = projectContentData('profile');
+ var content = projectContentData('content');
+ var endpoint = '/profile/' + profile + '/plugin/mezuro/' + controller + '/' + action + '/' + content;
+ jQuery.get(endpoint, params, callback);
+}
+
+function projectContentData(data){
+ return jQuery('#processing').attr('data-' + data);
+}
+
+function showLoadingProcess(firstLoad){
+ if(firstLoad)
+ showProjectResult("
");
+
+ showProjectTree("
");
+ showModuleResult("
");
+}
+
+function sourceNodeToggle(id){
+ var suffixes = ['_hidden', '_plus', '_minus'];
+ for (var i in suffixes)
+ jQuery('#' + id + suffixes[i]).toggle();
+}
diff --git a/plugins/mezuro/public/javascripts/project_content.js b/plugins/mezuro/public/javascripts/project_content.js
deleted file mode 100644
index a889498..0000000
--- a/plugins/mezuro/public/javascripts/project_content.js
+++ /dev/null
@@ -1,135 +0,0 @@
-var processingTree = false;
-var metricName;
-jQuery(function (){
- jQuery('.source-tree-link').live("click", reloadModule);
- jQuery('[show-metric-history]').live("click", display_metric_history);
- jQuery('[show-grade-history]').live("click", display_grade_history);
- jQuery('#project_date_submit').live("click", reloadProjectWithDate);
- showLoadingProcess(true);
- showProjectContent();
-});
-
-function showProjectContent() {
- callAction('project', 'project_state', {}, showProjectContentFor);
-}
-
-function display_metric_history() {
- var module_name = jQuery(this).attr('data-module-name');
- var metric_name = jQuery(this).attr('show-metric-history');
- toggle_mezuro("." + metric_name);
- metricName = metric_name;
- callAction('module', 'module_metrics_history', {module_id: module_id, module_result_id: module_result_id}, show_metrics);
- return false;
-}
-
-function display_grade_history() {
- var module_name = jQuery(this).attr('data-module-name');
- toggle_mezuro("#historical-grade");
- callAction('module', 'module_grade_history', {module_name: module_name}, show_grades);
- return false;
-}
-
-function show_metrics(content) {
- jQuery('#historical-' + metricName).html(content);
-}
-
-function show_grades(content) {
- jQuery('#historical-grade').html(content);
-}
-
-function toggle_mezuro(element){
- jQuery(element).toggle();
- return false;
-}
-
-function reloadModule(){
- var module_name = jQuery(this).attr('data-module-name');
- showLoadingProcess(false);
- processingTree = true;
- callAction('project', 'project_tree', {module_name: module_name }, showProjectTree);
- callAction('module', 'module_result', {module_name: module_name}, showModuleResult);
- return false;
-}
-
-function reloadProjectWithDate(date){
- reloadProject(date + "T00:00:00+00:00");
- return false;
-}
-
-function reloadProject(date){
- showLoadingProcess(true);
-
- callAction('project', 'project_result', {date: date}, showProjectResult);
- callAction('project', 'project_tree', {date: date}, showProjectTree);
- callAction('module', 'module_result', {date: date}, showModuleResult);
-}
-
-function showProjectContentFor(state){
- if (state == 'ERROR') {
- jQuery('#project-state').html('ERROR
');
- callAction('project', 'project_error', {}, showProjectResult);
- }
- else if (state == 'READY') {
- jQuery('#msg-time').html('');
- jQuery('#project-state').html('READY
');
- callAction('project', 'project_result', {}, showProjectResult);
- callAction('project','project_tree', {}, showProjectTree);
- var project_name = jQuery("#project-result").attr('data-project-name');
- callAction('module', 'module_result', {module_name: project_name}, showModuleResult);
- }
- else if (state.endsWith("ING")) {
- jQuery('#project-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);
- }
-}
-
-function showProjectContentAfter(seconds){
- if (seconds > 0){
- setTimeout(function() { showProjectContentAfter(seconds - 10);}, 10000);
- } else {
- showProjectContent();
- }
-}
-
-function showProjectResult(content) {
- jQuery('#project-result').html(content);
-}
-
-function showProjectTree(content){
- processingTree = false;
- jQuery('#project-tree').html(content);
- return false;
-}
-
-function showModuleResult(content){
- if (processingTree != true){
- jQuery('#module-result').html(content);
- }
- return false;
-}
-
-function callAction(controller, action, params, callback){
- var profile = projectContentData('profile');
- var content = projectContentData('content');
- var endpoint = '/profile/' + profile + '/plugin/mezuro/' + controller + '/' + action + '/' + content;
- jQuery.get(endpoint, params, callback);
-}
-
-function projectContentData(data){
- return jQuery('#project-result').attr('data-' + data);
-}
-
-function showLoadingProcess(firstLoad){
- if(firstLoad)
- showProjectResult("
");
-
- showProjectTree("
");
- showModuleResult("
");
-}
-
-function sourceNodeToggle(id){
- var suffixes = ['_hidden', '_plus', '_minus'];
- for (var i in suffixes)
- jQuery('#' + id + suffixes[i]).toggle();
-}
diff --git a/plugins/mezuro/views/content_viewer/show_project.rhtml b/plugins/mezuro/views/content_viewer/show_project.rhtml
index 8201a9f..ea6d998 100644
--- a/plugins/mezuro/views/content_viewer/show_project.rhtml
+++ b/plugins/mezuro/views/content_viewer/show_project.rhtml
@@ -18,21 +18,29 @@
<%= @project.description %> |
-
- <%= _('Repositories') %>
+
+ <%= _('Repositories') %>
+
<% @page.repositories.each do |repository| %>
- <%= repository.name %>
- <%= link_to repository.name, :controller => "mezuro_plugin_repository",
+
+ <%= link_to repository.name, :controller => "mezuro_plugin_repository",
:profile => @page.profile.identifier,
- :action => "show_repository",
+ :action => "show",
:id => @page.id,
- :repository_id => repository.id %>
+ :repository_id => repository.id %> |
+ <%= link_to "#{image_tag ('/plugins/mezuro/images/minus.png')}", :controller => "mezuro_plugin_repository",
+ :profile => @page.profile.identifier,
+ :action => "destroy",
+ :id => @page.id,
+ :repository_id => repository.id %> |
+
<% end %>
+
<%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Repository", :controller => "mezuro_plugin_repository",
:profile => @page.profile.identifier,
- :action => "new_repository",
+ :action => "new",
:id => @page.id %>
<% end %>
diff --git a/plugins/mezuro/views/mezuro_plugin_repository/show_repository.html.erb b/plugins/mezuro/views/mezuro_plugin_repository/show_repository.html.erb
index 8d3d022..b833711 100644
--- a/plugins/mezuro/views/mezuro_plugin_repository/show_repository.html.erb
+++ b/plugins/mezuro/views/mezuro_plugin_repository/show_repository.html.erb
@@ -1,24 +1,48 @@
-
- <%= "Project Name: " + @project_name %>
-
-
- <%= "Name: " + @repository.name %>
-
-
- <%= "Description: " + @repository.description %>
-
-
- <%= "License: " + @repository.license %>
-
-
- <%= "Process Period: " + @repository.process_period %>
-
-
- <%= "Type: " + @repository.type %>
-
-
- <%= "Address: " + @repository.address %>
-
-
- <%= "Configuration: " + @configuration_name %>
-
+
+<%= @project_name %>
+
+
+
+ <%= _('Name') %> |
+ <%= @repository.name %> |
+
+
+ <%= _('Description') %> |
+ <%= @repository.description %> |
+
+
+ <%= _('License') %> |
+ <%= @repository.license %> |
+
+
+ <%= _('Process Period') %> |
+ <%= MezuroPlugin::Helpers::ContentViewerHelper.get_periodicity_option(@repository.process_period) %> |
+
+
+ <%= _('Type') %> |
+ <%= @repository.type %> |
+
+
+ <%= _('Address') %> |
+ <%= @repository.address %> |
+
+
+ <%= _('Configuration') %> |
+ <%= @configuration_name %> |
+
+
+ <%= _('Status')%> |
+
+ <%= @processing.state %>
+
+ |
+
+
+
+
+
+
+
+
+
--
libgit2 0.21.2