/* The subscribe method takes a window element id and object id.
Any log events for that particular object id are sent to that window element. */
-function subscribeToEventLog (elementId) {
+function subscribeToEventLog () {
// if websockets are not supported by browser, do not subscribe for events
websocketsSupported = ('WebSocket' in window);
if (websocketsSupported == false) {
object_uuid = parsedData.object_uuid;
// if there are any listeners for this object uuid or "all", trigger the event
- matches = ".arv-log-event-listener[data-object-uuid=\"" + object_uuid + "\"],.arv-log-event-listener[data-object-uuids~=\"" + object_uuid + "\"],.arv-log-event-listener[data-object-uuid=\"all\"]";
+ matches = ".arv-log-event-listener[data-object-uuid=\"" + object_uuid + "\"],.arv-log-event-listener[data-object-uuids~=\"" + object_uuid + "\"],.arv-log-event-listener[data-object-uuid=\"all\"],.arv-log-event-listener[data-object-kind=\"" + parsedData.object_kind + "\"]";
$(matches).trigger('arv-log-event', event.data);
}
+
+$(document).on('ajax:complete ready', function() {
+ var a = $('.arv-log-event-listener');
+ if (a.length > 0) {
+ subscribeToEventLog();
+ }
+});
run_pipeline_button_state();
});
-$(document).on('ajax:complete ready', function() {
- var a = $('.arv-log-event-listener');
- if (a.length > 0) {
- $('.arv-log-event-listener').each(function() {
- subscribeToEventLog(this.id);
- });
- }
-});
-
$(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(event, eventData){
- parsedData = JSON.parse(eventData);
+ var parsedData = JSON.parse(eventData);
- propertyText = undefined
+ var propertyText = undefined
- properties = parsedData.properties;
+ var properties = parsedData.properties;
if (properties !== null) {
propertyText = properties.text;
}
@objects = @objects.filter(@filters).limit(@limit).offset(@offset).all
respond_to do |f|
f.json { render json: @objects }
- f.html { render }
+ f.html {
+ if params['tab_pane']
+ comparable = self.respond_to? :compare
+ render(partial: 'show_' + params['tab_pane'].downcase,
+ locals: { comparable: comparable, objects: @objects })
+ else
+ render
+ end
+ }
f.js { render }
end
end
return render_not_found("object not found")
end
respond_to do |f|
+ puts f
f.json { render json: @object.attributes.merge(href: url_for(@object)) }
f.html {
- if request.method == 'GET'
- render
+ if params['tab_pane']
+ comparable = self.respond_to? :compare
+ render(partial: 'show_' + params['tab_pane'].downcase,
+ locals: { comparable: comparable, objects: @objects })
else
- redirect_to params[:return_to] || @object
+ if request.method == 'GET'
+ render
+ else
+ redirect_to params[:return_to] || @object
+ end
end
}
f.js { render }
end
def current_user
+ return Thread.current[:user] if Thread.current[:user]
+
if Thread.current[:arvados_api_token]
- Thread.current[:user] ||= User.current
+ if session[:user]
+ if session[:user][:is_active] != true
+ Thread.current[:user] = User.current
+ else
+ Thread.current[:user] = User.new(session[:user])
+ end
+ else
+ Thread.current[:user] = User.current
+ end
else
logger.error "No API token in Thread"
return nil
# call to verify its authenticity.
if verify_api_token
session[:arvados_api_token] = params[:api_token]
+ u = User.current
+ session[:user] = {
+ email: u.email,
+ first_name: u.first_name,
+ last_name: u.last_name,
+ is_active: u.is_active,
+ is_admin: u.is_admin,
+ prefs: u.prefs
+ }
if !request.format.json? and request.method == 'GET'
# Repeat this request with api_token in the (new) session
# cookie instead of the query string. This prevents API
}
def check_user_notifications
+ return if params['tab_pane']
+
@notification_count = 0
@notifications = []
info[:links] << link
end
@request_url = request.url
+
+ super
end
def show_file_links
@shared_folder_tree =
sorted_paths.call({'Shared with me' =>
buildtree.call(children_of, false)})
+
+ super
end
def choose
@group_uuids = @groups.collect &:uuid
@links_from = Link.where link_class: 'permission', tail_uuid: @group_uuids
@links_to = Link.where link_class: 'permission', head_uuid: @group_uuids
+ super
end
def show
class JobsController < ApplicationController
def generate_provenance(jobs)
+ return if params['tab_pane'] != "Provenance"
+
nodes = []
collections = []
jobs.each do |j|
generate_provenance(@objects)
else
@limit = 20
- super
end
+ super
end
def cancel
def show
generate_provenance([@object])
+ super
end
def index_pane_list
include PipelineInstancesHelper
def graph(pipelines)
- count = {}
+ return nil, nil if params['tab_pane'] != "Graph"
+
+ count = {}
provenance = {}
pips = {}
n = 1
pips[uuid] = 0 unless pips[uuid] != nil
pips[uuid] |= n
end
-
+
n = n << 1
end
end
provenance, pips = graph(@pipelines)
+ if provenance
+ @prov_svg = ProvenanceHelper::create_provenance_graph provenance, "provenance_svg", {
+ :request => request,
+ :all_script_parameters => true,
+ :combine_jobs => :script_and_version,
+ :script_version_nodes => true,
+ :pips => pips }
+ end
- @prov_svg = ProvenanceHelper::create_provenance_graph provenance, "provenance_svg", {
- :request => request,
- :all_script_parameters => true,
- :combine_jobs => :script_and_version,
- :script_version_nodes => true,
- :pips => pips }
super
end
@prov_svg = ProvenanceHelper::create_provenance_graph provenance, "provenance_svg", {
:request => request,
- :all_script_parameters => true,
+ :all_script_parameters => true,
:combine_jobs => :script_and_version,
:script_version_nodes => true,
:pips => pips }
panes
end
- def compare_pane_list
+ def compare_pane_list
%w(Compare Graph)
- end
+ end
def index
@limit = 20
end
def index
redirect_to root_url if session[:arvados_api_token]
+ super
end
end
resource_class.to_s.underscore
end
+ def self.class_kind(resource_class)
+ resource_class.to_s.underscore
+ end
+
protected
def profile_checkpoint label=nil
return if !@@profiling_enabled
+<% content_for :js do %>
+ function ajaxRefreshTabPane(pane) {
+ $.ajax('<%= url_for @object %>?tab_pane='+pane, {dataType: 'html', type: 'GET'}).
+ done(function(data, status, jqxhr) {
+ $('#' + pane + ' > div > div').html(data);
+ $(document).trigger('ajax:complete')
+ });
+ }
+
+ $(window).on('load', smart_scroll_fixup);
+
+ $(document).on('shown.bs.tab', 'ul.nav-tabs > li > a', smart_scroll_fixup);
+ $(document).on('shown.bs.tab', function(e) {
+ ajaxRefreshTabPane(e.target.id.slice(0, -4));
+ });
+
+ $(document).on('arv-log-event', function() {
+ ajaxRefreshTabPane($('.tab-pane.active')[0].id);
+ });
+<% end %>
+
<% content_for :tab_panes do %>
<% comparable = controller.respond_to? :compare %>
-<% pane_list ||= %w(recent) %>
-<% panes = Hash[pane_list.map { |pane|
- [pane, render(partial: 'show_' + pane.downcase,
- locals: { comparable: comparable, objects: @objects })]
- }.compact] %>
<ul class="nav nav-tabs">
- <% panes.each_with_index do |(pane, content), i| %>
+ <% pane_list.each_with_index do |pane, i| %>
<li class="<%= 'active' if i==0 %>"><a href="#<%= pane %>" data-toggle="tab" id="<%= pane %>-tab"> <%= pane.gsub('_', ' ') %></a></li>
<% end %>
</ul>
<div class="tab-content">
-<% panes.each_with_index do |(pane, content), i| %>
- <div id="<%= pane %>" class="tab-pane fade <%= 'in active' if i==0 %>">
+<% pane_list.each_with_index do |pane, i| %>
+ <div id="<%= pane %>"
+ class="tab-pane fade <%= 'in active' if i==0 %> arv-log-event-listener"
+<% if controller.action_name == "index" %>
+ data-object-kind="arvados#<%= ArvadosApiClient.class_kind controller.model_class %>"
+<% else %>
+ data-object-uuid="<%= @object.uuid %>"
+<% end %>
+>
+
+<% content_for :js do %>
+ <% if i != 0 %>
+ $(document).on('ready', function() {
+ ajaxRefreshTabPane('<%= pane %>');
+ });
+ <% end %>
+<% end %>
+
<div class="smart-scroll" style="margin-top:0.5em;">
- <%= content %>
+ <div class="pane-content">
+ <% if i == 0 %>
+ <%= render(partial: 'show_' + pane.downcase,
+ locals: { comparable: comparable, objects: @objects }) %>
+ <% else %>
+ <%= image_tag 'ajax-loader.gif' %>
+ <% end %>
+ </div>
</div>
</div>
<% end %>
</div>
<% end %>
-
-<% content_for :js do %>
- $(window).on('load', smart_scroll_fixup);
- $(document).on('shown.bs.tab', 'ul.nav-tabs > li > a', smart_scroll_fixup);
-<% end %>
</table>
<% if @object.state == 'RunningOnServer' || @object.state == 'RunningOnClient' %>
-<% content_for :js do %>
-setInterval(function(){$('a.refresh').click()}, 15000);
-<% end %>
<% content_for :tab_line_buttons do %>
<%= form_tag @object, :method => :put do |f| %>