Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion BrainPortal/app/controllers/data_providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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] || ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions BrainPortal/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
get 'dp_transfers'
get 'new_personal'
post 'create_personal'
post 'check_all'
end
end

Expand Down
38 changes: 0 additions & 38 deletions BrainPortal/public/javascripts/cbrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<span class='loading_message'>???</span>";
}
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:
Expand Down