# the browser can't.
f.json { render opts.merge(json: {success: false, errors: @errors}) }
f.html { render({action: 'error'}.merge(opts)) }
+ f.all { render({action: 'error', formats: 'text'}.merge(opts)) }
end
end
end
def index
+ @objects = nil if !defined?(@objects)
find_objects_for_index if !@objects
render_index
end
end
def choose
+ @objects = nil if !defined?(@objects)
params[:limit] ||= 40
respond_to do |f|
if params[:partial]
def is_starred
links = Link.where(tail_uuid: current_user.uuid,
head_uuid: @object.uuid,
- link_class: 'star')
+ link_class: 'star').with_count("none")
return links.andand.any?
end
def accept_uuid_as_id_param
- if params[:id] and params[:id].match /\D/
+ if params[:id] and params[:id].match(/\D/)
params[:uuid] = params.delete :id
end
end
def missing_required_profile?
missing_required = false
- profile_config = Rails.configuration.user_profile_form_fields
- if current_user && profile_config
+ profile_config = Rails.configuration.Workbench.UserProfileFormFields
+ if current_user && !profile_config.empty?
current_user_profile = current_user.prefs[:profile]
- profile_config.kind_of?(Array) && profile_config.andand.each do |entry|
- if entry['required']
+ profile_config.each do |k, entry|
+ if entry['Required']
if !current_user_profile ||
- !current_user_profile[entry['key'].to_sym] ||
- current_user_profile[entry['key'].to_sym].empty?
+ !current_user_profile[k] ||
+ current_user_profile[k].empty?
missing_required = true
break
end
end
def select_theme
- return Rails.configuration.arvados_theme
+ return Rails.configuration.Workbench.Theme
end
@@notification_tests = []
@@notification_tests.push lambda { |controller, current_user|
- return nil if Rails.configuration.shell_in_a_box_url
- AuthorizedKey.limit(1).where(authorized_user_uuid: current_user.uuid).each do
+ return nil if Rails.configuration.Services.WebShell.ExternalURL != URI("")
+ AuthorizedKey.limit(1).with_count('none').where(authorized_user_uuid: current_user.uuid).each do
return nil
end
return lambda { |view|
}
@@notification_tests.push lambda { |controller, current_user|
- Collection.limit(1).where(created_by: current_user.uuid).each do
+ Collection.limit(1).with_count('none').where(created_by: current_user.uuid).each do
return nil
end
return lambda { |view|
@@notification_tests.push lambda { |controller, current_user|
if PipelineInstance.api_exists?(:index)
- PipelineInstance.limit(1).where(created_by: current_user.uuid).each do
+ PipelineInstance.limit(1).with_count('none').where(created_by: current_user.uuid).each do
return nil
end
else
helper_method :user_notifications
def user_notifications
- return [] if @errors or not current_user.andand.is_active or not Rails.configuration.show_user_notifications
+ @errors = nil if !defined?(@errors)
+ return [] if @errors or not current_user.andand.is_active or not Rails.configuration.Workbench.ShowUserNotifications
@notifications ||= @@notification_tests.map do |t|
t.call(self, current_user)
end.compact
helper_method :recent_jobs_and_pipelines
def recent_jobs_and_pipelines
(Job.limit(10) |
- PipelineInstance.limit(10)).
+ PipelineInstance.limit(10).with_count("none")).
sort_by do |x|
(x.finished_at || x.started_at rescue nil) || x.modified_at || x.created_at
end.reverse
helper_method :running_pipelines
def running_pipelines
- pi = PipelineInstance.order(["started_at asc", "created_at asc"]).filter([["state", "in", ["RunningOnServer", "RunningOnClient"]]])
+ pi = PipelineInstance.order(["started_at asc", "created_at asc"]).with_count("none").filter([["state", "in", ["RunningOnServer", "RunningOnClient"]]])
jobs = {}
pi.each do |pl|
pl.components.each do |k,v|
end
if jobs.keys.any?
- Job.filter([["uuid", "in", jobs.keys]]).each do |j|
+ Job.filter([["uuid", "in", jobs.keys]]).with_count("none").each do |j|
jobs[j[:uuid]] = j
end
procs = {}
if PipelineInstance.api_exists?(:index)
cols = %w(uuid owner_uuid created_at modified_at pipeline_template_uuid name state started_at finished_at)
- pipelines = PipelineInstance.select(cols).limit(lim).order(["created_at desc"])
+ pipelines = PipelineInstance.select(cols).limit(lim).order(["created_at desc"]).with_count("none")
pipelines.results.each { |pi| procs[pi] = pi.created_at }
end
- crs = ContainerRequest.limit(lim).order(["created_at desc"]).filter([["requesting_container_uuid", "=", nil]])
+ crs = ContainerRequest.limit(lim).with_count("none").order(["created_at desc"]).filter([["requesting_container_uuid", "=", nil]])
crs.results.each { |c| procs[c] = c.created_at }
Hash[procs.sort_by {|key, value| value}].keys.reverse.first(lim)
helper_method :recent_collections
def recent_collections lim
- c = Collection.limit(lim).order(["modified_at desc"]).results
+ c = Collection.limit(lim).with_count("none").order(["modified_at desc"]).results
own = {}
- Group.filter([["uuid", "in", c.map(&:owner_uuid)]]).each do |g|
+ Group.filter([["uuid", "in", c.map(&:owner_uuid)]]).with_count("none").each do |g|
own[g[:uuid]] = g
end
{collections: c, owners: own}
helper_method :my_starred_projects
def my_starred_projects user
- return if @starred_projects
- links = Link.filter([['tail_uuid', '=', user.uuid],
+ return if defined?(@starred_projects) && @starred_projects
+ links = Link.filter([['owner_uuid', 'in', ["#{Rails.configuration.ClusterID}-j7d0g-fffffffffffffff", user.uuid]],
['link_class', '=', 'star'],
- ['head_uuid', 'is_a', 'arvados#group']]).select(%w(head_uuid))
+ ['head_uuid', 'is_a', 'arvados#group']]).with_count("none").select(%w(head_uuid))
uuids = links.collect { |x| x.head_uuid }
- starred_projects = Group.filter([['uuid', 'in', uuids]]).order('name')
+ starred_projects = Group.filter([['uuid', 'in', uuids]]).order('name').with_count("none")
@starred_projects = starred_projects.results
end
# That is: get toplevel projects under home, get subprojects of
# these projects, and so on until we hit the limit.
def my_wanted_projects(user, page_size=100)
- return @my_wanted_projects if @my_wanted_projects
+ return @my_wanted_projects if defined?(@my_wanted_projects) && @my_wanted_projects
from_top = []
uuids = [user.uuid]
end
def build_my_wanted_projects_tree(user, page_size=100)
- return @my_wanted_projects_tree if @my_wanted_projects_tree
+ return @my_wanted_projects_tree if defined?(@my_wanted_projects_tree) && @my_wanted_projects_tree
parent_of = {user.uuid => 'me'}
my_wanted_projects(user, page_size).each do |ob|
children_of[parent_of[ob.uuid]] ||= []
children_of[parent_of[ob.uuid]] << ob
end
- buildtree = lambda do |children_of, root_uuid=false|
+ buildtree = lambda do |chldrn_of, root_uuid=false|
tree = {}
- children_of[root_uuid].andand.each do |ob|
- tree[ob] = buildtree.call(children_of, ob.uuid)
+ chldrn_of[root_uuid].andand.each do |ob|
+ tree[ob] = buildtree.call(chldrn_of, ob.uuid)
end
tree
end
end
# TODO: make sure we get every page of results from API server
- Link.filter([['head_uuid', 'in', uuids]]).each do |link|
+ Link.filter([['head_uuid', 'in', uuids]]).with_count("none").each do |link|
@all_links_for[link.head_uuid] << link
end
@all_links_for
end
# TODO: make sure we get every page of results from API server
- Collection.where(uuid: uuids).each do |collection|
+ Collection.where(uuid: uuids).with_count("none").each do |collection|
@all_collections_for[collection.uuid] << collection
end
@all_collections_for
end
# TODO: make sure we get every page of results from API server
- Collection.where(uuid: uuids).each do |collection|
+ Collection.where(uuid: uuids).with_count("none").each do |collection|
@all_log_collections_for[collection.uuid] << collection
end
@all_log_collections_for
@all_pdhs_for[x] = []
end
- Collection.select(%w(portable_data_hash)).where(portable_data_hash: pdhs).distinct().each do |collection|
+ Collection.select(%w(portable_data_hash)).where(portable_data_hash: pdhs).distinct().with_count("none").each do |collection|
@all_pdhs_for[collection.portable_data_hash] << collection
end
@all_pdhs_for
end
unless link_uuids.empty?
- Link.select([:head_uuid]).where(uuid: link_uuids).each do |link|
+ Link.select([:head_uuid]).where(uuid: link_uuids).with_count("none").each do |link|
if ArvadosBase::resource_class_for_uuid(link.head_uuid) == Collection
coll_ids << link.head_uuid
end
end
unless pdhs.empty?
- Collection.where(portable_data_hash: pdhs.uniq).
+ Collection.where(portable_data_hash: pdhs.uniq).with_count("none").
select([:uuid, :portable_data_hash]).each do |coll|
unless source_paths[coll.portable_data_hash].empty?
uuids << coll.uuid