[ARVADOS] created: 6a2406f04875497a7bfad72fc8bcd73b792fefae
git at public.curoverse.com
git at public.curoverse.com
Fri Jul 18 02:44:17 EDT 2014
at 6a2406f04875497a7bfad72fc8bcd73b792fefae (commit)
commit 6a2406f04875497a7bfad72fc8bcd73b792fefae
Author: Tom Clegg <tom at curoverse.com>
Date: Fri Jul 18 02:43:17 2014 -0400
3170: On pipeline instance page, refresh the tab panes rather than the entire page.
diff --git a/apps/workbench/app/assets/javascripts/pipeline_instances.js b/apps/workbench/app/assets/javascripts/pipeline_instances.js
index f206213..350b361 100644
--- a/apps/workbench/app/assets/javascripts/pipeline_instances.js
+++ b/apps/workbench/app/assets/javascripts/pipeline_instances.js
@@ -86,3 +86,9 @@ var showhide_compare = function() {
};
$('[data-object-uuid*=-d1hrv-] input[name="uuids[]"]').on('click', showhide_compare);
showhide_compare();
+
+setInterval(function(){
+ if ($('[data-pipeline-state=RunningOnServer],[data-pipeline-state=RunningOnClient]').length > 0) {
+ $('#Components.tab-pane,#Graph.tab-pane').trigger('arv:pane:reload');
+ }
+}, 15000);
diff --git a/apps/workbench/app/assets/javascripts/tab_panes.js b/apps/workbench/app/assets/javascripts/tab_panes.js
index 55cf7d8..9586e4c 100644
--- a/apps/workbench/app/assets/javascripts/tab_panes.js
+++ b/apps/workbench/app/assets/javascripts/tab_panes.js
@@ -10,7 +10,20 @@ $(document).on('shown.bs.tab', '[data-toggle="tab"]', function(e) {
});
});
-$(document).on('arv-log-event', function() {
- $('[data-pane-content-url]').removeClass('loaded');
- $('.tab-pane.active').trigger('shown.bs.tab');
+$(document).on('arv:pane:reload', '.tab-pane', function() {
+ // Unload a single pane. Reload it if it's active.
+ $(this).removeClass('loaded');
+ if ($(this).hasClass('active')) {
+ $('[href=#' + $(this).attr('id') + ']').trigger('shown.bs.tab');
+ } else {
+ // When the user selects this tab, show a spinner instead of
+ // old content while loading.
+ $('> div > div', this).
+ html('<div class="spinner spinner-32px spinner-h-center"></div>');
+ }
+});
+
+$(document).on('arv-log-event arv:pane:reload:all', function() {
+ // Reload all panes (except ones that haven't even loaded yet).
+ $('.tab-pane.loaded').trigger('arv:pane:reload');
});
diff --git a/apps/workbench/app/views/application/_content.html.erb b/apps/workbench/app/views/application/_content.html.erb
index 22db2e7..1609a66 100644
--- a/apps/workbench/app/views/application/_content.html.erb
+++ b/apps/workbench/app/views/application/_content.html.erb
@@ -44,8 +44,8 @@
<% if i == 0 %>
<%= render(partial: 'show_' + pane.downcase,
locals: { comparable: comparable, objects: @objects }) %>
- <% else %>
- <div class="spinner spinner-32px spinner-h-center"></div>
+ <% else %>
+ <div class="spinner spinner-32px spinner-h-center"></div>
<% end %>
</div>
</div>
diff --git a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
index fb15cd7..3850019 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
@@ -3,7 +3,7 @@
<% pipeline_job_uuids = [] %>
<div class="pull-right">
- Current state: <span class="badge badge-info"><%= @object.state.sub('OnServer', '') %></span>
+ Current state: <span class="badge badge-info" data-pipeline-state="<%= @object.state %>"><%= @object.state.sub('OnServer', '') %></span>
</div>
<table class="table pipeline-components-table">
diff --git a/apps/workbench/app/views/pipeline_instances/show.html.erb b/apps/workbench/app/views/pipeline_instances/show.html.erb
index 28972a4..b30db3b 100644
--- a/apps/workbench/app/views/pipeline_instances/show.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/show.html.erb
@@ -46,10 +46,4 @@
<% end %>
<% end %>
-<% if @object.state.in? %w(RunningOnServer RunningOnClient) %>
- <% content_for :js do %>
- setInterval(function(){$('a.refresh').click()}, 15000);
- <% end %>
-<% end %>
-
<%= render partial: 'content', layout: 'content_layout', locals: {pane_list: controller.show_pane_list }%>
commit d188143b2acd99dc594231360eeaf3e178794ff8
Author: Tom Clegg <tom at curoverse.com>
Date: Fri Jul 18 02:08:43 2014 -0400
3170: Root out evil runtime-generated javascript. Simplify tab loading.
diff --git a/apps/workbench/app/assets/javascripts/sizing.js b/apps/workbench/app/assets/javascripts/sizing.js
index 71761db..2341628 100644
--- a/apps/workbench/app/assets/javascripts/sizing.js
+++ b/apps/workbench/app/assets/javascripts/sizing.js
@@ -28,3 +28,4 @@ function smart_scroll_fixup(s) {
}
$(window).on('load ready resize scroll ajax:complete', smart_scroll_fixup);
+$(document).on('shown.bs.tab', 'ul.nav-tabs > li > a', smart_scroll_fixup);
diff --git a/apps/workbench/app/assets/javascripts/tab_panes.js b/apps/workbench/app/assets/javascripts/tab_panes.js
new file mode 100644
index 0000000..55cf7d8
--- /dev/null
+++ b/apps/workbench/app/assets/javascripts/tab_panes.js
@@ -0,0 +1,16 @@
+$(document).on('shown.bs.tab', '[data-toggle="tab"]', function(e) {
+ var content_url = $(e.target).attr('data-pane-content-url');
+ var $pane = $($(e.target).attr('href'));
+ if ($pane.hasClass('loaded'))
+ return;
+ $.ajax(content_url, {dataType: 'html', type: 'GET', context: $pane}).
+ done(function(data, status, jqxhr) {
+ $('> div > div', this).html(data);
+ $(this).addClass('loaded');
+ });
+});
+
+$(document).on('arv-log-event', function() {
+ $('[data-pane-content-url]').removeClass('loaded');
+ $('.tab-pane.active').trigger('shown.bs.tab');
+});
diff --git a/apps/workbench/app/views/application/_content.html.erb b/apps/workbench/app/views/application/_content.html.erb
index c9522de..22db2e7 100644
--- a/apps/workbench/app/views/application/_content.html.erb
+++ b/apps/workbench/app/views/application/_content.html.erb
@@ -19,48 +19,19 @@
<% end %>
<% end %>
-<% content_for :js do %>
- tab_pane_valid_state = {};
-
- function ajaxRefreshTabPane(pane) {
- if (!tab_pane_valid_state[pane]) {
- tab_pane_valid_state[pane] = true;
- $.ajax('<%=j url_for() %>?<%= raw(controller.request.query_string) %>&tab_pane='+pane, {dataType: 'html', type: 'GET'}).
- done(function(data, status, jqxhr) {
- $('#' + pane + ' > div > div').html(data);
- ajaxRefreshTabPane(pane);
- });
- }
- }
-
- $(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() {
- <% pane_list.each do |pane| %>
- tab_pane_valid_state['<%=j pane %>'] = false;
- <% end %>
- ajaxRefreshTabPane($('.tab-pane.active')[0].id);
- });
-<% end %>
-
<% content_for :tab_panes do %>
<% comparable = controller.respond_to? :compare %>
<ul class="nav nav-tabs">
<% 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>
+ <li class="<%= 'active' if i==0 %>"><a href="#<%= pane %>" data-toggle="tab" id="<%= pane %>-tab" data-pane-content-url="<%= url_for(tab_pane: pane) %>"> <%= pane.gsub('_', ' ') %></a></li>
<% end %>
</ul>
<div class="tab-content">
<% pane_list.each_with_index do |pane, i| %>
<div id="<%= pane %>"
- class="tab-pane fade <%= 'in active' if i==0 %> arv-log-event-listener"
+ class="tab-pane fade <%= 'in active loaded' if i==0 %> arv-log-event-listener"
<% if controller.action_name == "index" %>
data-object-kind="arvados#<%= ArvadosApiClient.class_kind controller.model_class %>"
<% else %>
@@ -68,17 +39,6 @@
<% end %>
>
-<% content_for :js do %>
- <% if i == 0 %>
- tab_pane_valid_state['<%=j pane %>'] = true;
- <% else %>
- tab_pane_valid_state['<%=j pane %>'] = false;
- $(document).on('ready', function() {
- ajaxRefreshTabPane('<%=j pane %>');
- });
- <% end %>
-<% end %>
-
<div id="<%= pane %>-scroll" style="margin-top:0.5em;">
<div class="pane-content">
<% if i == 0 %>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list