diff --git a/BrainPortal/app/controllers/data_providers_controller.rb b/BrainPortal/app/controllers/data_providers_controller.rb index b39726684..1d21d62cf 100644 --- a/BrainPortal/app/controllers/data_providers_controller.rb +++ b/BrainPortal/app/controllers/data_providers_controller.rb @@ -33,7 +33,7 @@ class DataProvidersController < ApplicationController before_action :login_required before_action :manager_role_required, :only => [:new, :create] - before_action :admin_role_required, :only => [:new, :create, :report, :repair] + before_action :admin_role_required, :only => [:new, :create, :report, :repair, :check_all] def index #:nodoc: @scope = scope_from_session @@ -242,6 +242,21 @@ def is_alive end end + # Refresh is_alive status for all the providers (in or out of the current scope) + def check_all + + dp_ids = DataProvider.find_all_accessible_by_user(current_user).pluck(:id) + + bac = BackgroundActivity::VerifyDataProvider.setup!(current_user.id, dp_ids) + + flash[:notice] = "Data Providers statuses are being updated in background." + + respond_to do |format| + format.html { redirect_to :action => :index } + format.json { render :json => { :message => flash[:notice], :background_activity_id => bac.id }} + end + end + # Returns a report about the +dataprovider+ disk usage by users. def disk_usage dataprovider_id = params[:id] || "" diff --git a/BrainPortal/app/views/data_providers/_data_providers_table.html.erb b/BrainPortal/app/views/data_providers/_data_providers_table.html.erb index 0164e6953..c3f18d4dc 100644 --- a/BrainPortal/app/views/data_providers/_data_providers_table.html.erb +++ b/BrainPortal/app/views/data_providers/_data_providers_table.html.erb @@ -36,7 +36,7 @@ <%= link_to "Create Personal Data Provider", new_personal_data_providers_path, :class => "button menu_button" %> <% if check_role(:admin_user) %> - <%= link_to "Check All", nil, {:class => "button check_all_dp",} %> + <%= link_to "Check All", check_all_data_providers_path, method: :post, :class => "button menu_button" %> <% end %> <%= link_to "User Access Report", diff --git a/BrainPortal/config/routes.rb b/BrainPortal/config/routes.rb index d1b720fe7..231746fae 100644 --- a/BrainPortal/config/routes.rb +++ b/BrainPortal/config/routes.rb @@ -132,6 +132,7 @@ get 'dp_transfers' get 'new_personal' post 'create_personal' + post 'check_all' end end diff --git a/BrainPortal/public/javascripts/cbrain.js b/BrainPortal/public/javascripts/cbrain.js index 60ab31bc1..167ded509 100644 --- a/BrainPortal/public/javascripts/cbrain.js +++ b/BrainPortal/public/javascripts/cbrain.js @@ -1043,44 +1043,6 @@ $(document).delegate(".ajax_onclick_show_element", "click", ajax_onclick_show); $(document).delegate(".ajax_onclick_hide_element", "click", ajax_onclick_hide); - // For checking the alive status of all DataProviders - // The sequential_loading function is called recursively - // with the id of each DataProvider that is online - // The url and DataProvider id are stored in the button - $(document).delegate(".check_all_dp", "click", function (event) { - var dp_check_btns = $("body").find(".dp_alive_btn"); - - sequential_loading(0, dp_check_btns); - - event.preventDefault(); - }); - - function sequential_loading(index, element_array) { - if (index >= element_array.length) return; - - var current_element = $(element_array[index]); - var url = current_element.data("url"); - var error_message = current_element.data("error"); - var replace_elem = $("#" + current_element.data("replace")); - - jQuery.ajax({ - dataType: 'html', - url: url, - timeout: 50000, - success: function(data) { - replace_elem.html(data); - }, - error: function(e) { - if (!error_message) { - error_message = "???"; - } - replace_elem.html(error_message); - }, - complete: function(e) { - sequential_loading(index+1, element_array); - } - }); - } // Allows to submit an interval of two dates, uses // datepicker of jquery-ui, see: