[ARVADOS] created: e13874a4bb666423c5b2ddf1ebb517a10789f4c0
git at public.curoverse.com
git at public.curoverse.com
Tue Aug 19 20:58:23 EDT 2014
at e13874a4bb666423c5b2ddf1ebb517a10789f4c0 (commit)
commit e13874a4bb666423c5b2ddf1ebb517a10789f4c0
Author: Tom Clegg <tom at curoverse.com>
Date: Tue Aug 19 20:57:46 2014 -0400
3610: Move live log display into its own tab, avoid clobbering with tab reload.
* PipelineInstances#show gets a Log tab dedicated to the live log
window, rather than hiding it below the components table.
* Jobs#show uses its Log tab to show a live log window (instead of a
teaser) when the log is not yet finished/written to disk.
* In both cases, the live log window's tab pane intercepts and ignores
the arv:tab:reload event. (Previously, in addition to appending log
entries to the live window, websocket events would trigger a
"refresh all tabs" event, which would blow away the whole log viewer
anyway.)
* Behave sensibly when multiple lines of stderr arrive in a single
websocket update event.
* Stop displaying "update {pipeline-uuid}" messages that have no
additional content.
* Stop scrolling to bottom every time an ajax:complete fires
somewhere. (Previously, seeing anything above the last page of logs
was somewhere between annoying and impossible.)
* Make the log window taller.
diff --git a/apps/workbench/app/assets/javascripts/pipeline_instances.js b/apps/workbench/app/assets/javascripts/pipeline_instances.js
index 350b361..d485bc5 100644
--- a/apps/workbench/app/assets/javascripts/pipeline_instances.js
+++ b/apps/workbench/app/assets/javascripts/pipeline_instances.js
@@ -58,15 +58,40 @@ $(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(e
propertyText = properties.text;
}
if (propertyText !== undefined) {
+ propertyText = propertyText.
+ replace(/\n$/, '').
+ replace(/\n/g, '<br/>');
$(this).append(propertyText + "<br/>");
- } else {
- $(this).append(parsedData.summary + "<br/>");
+ } else if (parsedData.summary !== undefined) {
+ if (parsedData.summary.match(/^update of [-a-z0-9]{27}$/))
+ ; // Not helpful.
+ else
+ $(this).append(parsedData.summary + "<br/>");
}
if (wasatbottom)
this.scrollTop = this.scrollHeight;
-}).on('ready ajax:complete', function(){
- $('.arv-log-event-handler-append-logs').each(function() {
+}).on('arv:pane:loaded', '#Logs,#Log', function(){
+ $('.arv-log-event-handler-append-logs', this).each(function() {
this.scrollTop = this.scrollHeight;
+ $(this).closest('.tab-pane').on('arv:pane:reload', function(e) {
+ // Do not let this tab auto-refresh.
+ e.stopPropagation();
+ });
+ });
+}).on('ready ajax:complete', function(){
+ $(".arv-log-event-listener[data-object-uuids-live]").each(function() {
+ // Look at data-object-uuid attribute of elements matching
+ // given selector, so the event listener can listen for events
+ // that appeared on the page via ajax.
+ var $listener = $(this);
+ var have_uuids = '' + $listener.attr('data-object-uuids');
+ $($listener.attr('data-object-uuids-live')).each(function() {
+ var this_uuid = $(this).attr('data-object-uuid');
+ if (have_uuids.indexOf(this_uuid) == -1) {
+ have_uuids = have_uuids + ' ' + this_uuid;
+ }
+ });
+ $listener.attr('data-object-uuids', have_uuids);
});
});
diff --git a/apps/workbench/app/assets/javascripts/tab_panes.js b/apps/workbench/app/assets/javascripts/tab_panes.js
index 0b7800c..411a009 100644
--- a/apps/workbench/app/assets/javascripts/tab_panes.js
+++ b/apps/workbench/app/assets/javascripts/tab_panes.js
@@ -12,6 +12,7 @@ $(document).on('shown.bs.tab', '[data-toggle="tab"]', function(e) {
done(function(data, status, jqxhr) {
$('> div > div', this).html(data);
$(this).addClass('loaded');
+ $(this).trigger('arv:pane:loaded');
}).fail(function(jqxhr, status, error) {
var errhtml;
if (jqxhr.getResponseHeader('Content-Type').match(/\btext\/html\b/)) {
diff --git a/apps/workbench/app/assets/stylesheets/jobs.css.scss b/apps/workbench/app/assets/stylesheets/jobs.css.scss
index 14f8699..b25c04a 100644
--- a/apps/workbench/app/assets/stylesheets/jobs.css.scss
+++ b/apps/workbench/app/assets/stylesheets/jobs.css.scss
@@ -1,5 +1,5 @@
.arv-job-log-window {
- height: 20em;
+ height: 40em;
white-space: nowrap;
overflow: scroll;
background: black;
diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb
index b5c9815..f1e3634 100644
--- a/apps/workbench/app/controllers/pipeline_instances_controller.rb
+++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb
@@ -193,9 +193,9 @@ class PipelineInstancesController < ApplicationController
end
def show_pane_list
- panes = %w(Components Graph Advanced)
+ panes = %w(Components Log Graph Advanced)
if @object and @object.state.in? ['New', 'Ready']
- panes = %w(Inputs) + panes
+ panes = %w(Inputs) + panes - %w(Log)
end
if not @object.components.values.any? { |x| x[:job] rescue false }
panes -= ['Graph']
diff --git a/apps/workbench/app/helpers/jobs_helper.rb b/apps/workbench/app/helpers/jobs_helper.rb
index 44c7bf6..60268cb 100644
--- a/apps/workbench/app/helpers/jobs_helper.rb
+++ b/apps/workbench/app/helpers/jobs_helper.rb
@@ -1,2 +1,21 @@
module JobsHelper
+ def stderr_log_history(job_uuids)
+ results = []
+
+ log_history = Log.where(event_type: 'stderr',
+ object_uuid: job_uuids).order('id DESC')
+ if !log_history.results.empty?
+ reversed_results = log_history.results.reverse
+ reversed_results.each do |entry|
+ if entry.andand.properties
+ properties = entry.properties
+ text = properties[:text]
+ if text
+ results = results.concat text.split("\n")
+ end
+ end
+ end
+ end
+ return results
+ end
end
diff --git a/apps/workbench/app/helpers/pipeline_instances_helper.rb b/apps/workbench/app/helpers/pipeline_instances_helper.rb
index c15c94c..b282723 100644
--- a/apps/workbench/app/helpers/pipeline_instances_helper.rb
+++ b/apps/workbench/app/helpers/pipeline_instances_helper.rb
@@ -22,27 +22,6 @@ module PipelineInstancesHelper
pj
end
- def pipeline_log_history(job_uuids)
- results = []
-
- log_history = Log.where(event_type: 'stderr',
- object_uuid: job_uuids).order('id DESC')
- if !log_history.results.empty?
- reversed_results = log_history.results.reverse
- reversed_results.each do |entry|
- if entry.andand.properties
- properties = entry.properties
- text = properties[:text]
- if text
- results = results.concat text.split("\n")
- end
- end
- end
- end
-
- return results
- end
-
protected
def pipeline_jobs_newschool object
diff --git a/apps/workbench/app/views/jobs/_show_log.html.erb b/apps/workbench/app/views/jobs/_show_log.html.erb
index f1466aa..b523af8 100644
--- a/apps/workbench/app/views/jobs/_show_log.html.erb
+++ b/apps/workbench/app/views/jobs/_show_log.html.erb
@@ -1,3 +1,14 @@
+<% if !@object.log %>
+
+<% log_history = stderr_log_history([@object.uuid]) %>
+<div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuids="<%= @object.uuid %>">
+ <% log_history.each do |entry| %>
+ <%=entry%><br/>
+ <% end %>
+</div>
+
+<% else %>
+
<script>
(function() {
var pagesize = 1000;
@@ -103,16 +114,8 @@ $("#set-show-failed-only").on("click", function() {
<h3>Summary</h3>
<p id="log-viewer-overview">
- <% if !@object.log %>
- <% if @object.finished_at %>
- This job did not produce an diagnostic log.
- <% else %>
- This job is still running. The job log will be available when the job is complete.
- <% end %>
- <% else %>
- <% if !logcollection %>
- The collection containing the job log was not found.
- <% end %>
+ <% if !logcollection %>
+ The collection containing the job log was not found.
<% end %>
</p>
@@ -215,3 +218,5 @@ $("#set-show-failed-only").on("click", function() {
<a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>
</div>
</div>
+
+<% end %>
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 c55a725..786a8fd 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
@@ -1,24 +1,10 @@
<% if !@object.state.in? ['New', 'Ready'] %>
- <% pipeline_job_uuids = [] %>
-
<div class="pull-right">
Current state: <span class="badge badge-info" data-pipeline-state="<%= @object.state %>"><%= @object.state.sub('OnServer', '') %></span>
</div>
- <%= render_pipeline_components("running", :json, pipeline_job_uuids: pipeline_job_uuids) %>
-
- <% if @object.state.in? %w(RunningOnServer RunningOnClient Failed) %>
-
- <h4>Log messages from jobs</h4>
- <% log_history = pipeline_log_history((pipeline_job_uuids || []) + [@object.uuid]) %>
- <div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuids="<%= @object.uuid %> <%=(pipeline_job_uuids || []).join(" ")%>">
- <% log_history.each do |entry| %>
- <%=entry%><br/>
- <% end %>
- </div>
-
- <% end %>
+ <%= render_pipeline_components("running", :json) %>
<% else %>
<%# state is either New or Ready %>
diff --git a/apps/workbench/app/views/pipeline_instances/_show_components_running.html.erb b/apps/workbench/app/views/pipeline_instances/_show_components_running.html.erb
index a41fdd1..36c097e 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components_running.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components_running.html.erb
@@ -23,42 +23,39 @@
</thead>
<tbody>
<% render_pipeline_jobs.each do |pj| %>
- <% if pj[:job].andand[:uuid]
- pipeline_job_uuids << pj[:job][:uuid]
- end %>
- <tr>
- <td>
- <%= pj[:name] %>
- </td><td>
- <%= pj[:script] %>
- <br /><span class="deemphasize"><%= pj[:script_version] %></span>
- </td><td>
- <%= render(partial: 'job_status_label', locals: { j: pj[:job] }) %>
- </td><td>
- <%= pj[:progress_bar] %>
- </td>
- <% current_job = Job.find(pj[:job][:uuid]) rescue nil %>
- <td>
- <% if current_job %>
- <%= render partial: 'show_object_button', locals: {object: current_job, size: 'xs', link_text: 'Show job details'} %>
- <% end %>
- </td><td>
- <% if current_job.andand[:log] %>
- <% fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(current_job[:log])%>
- <% Collection.limit(1).where(uuid: fixup[1]).each do |c| %>
- <% c.files.first.andand do |file| %>
- <%= link_to url_for(controller: 'collections', action: 'show_file', uuid: current_job[:log], file: "#{file[0]}/#{file[1]}", disposition: 'inline', size: file[2]), class: 'btn btn-default btn-xs' do %>
- <i class="fa fa-fw fa-info"></i> Show log messages
+ <tr data-object-uuid="<%= pj[:job].andand[:uuid] %>">
+ <td>
+ <%= pj[:name] %>
+ </td><td>
+ <%= pj[:script] %>
+ <br /><span class="deemphasize"><%= pj[:script_version] %></span>
+ </td><td>
+ <%= render(partial: 'job_status_label', locals: { j: pj[:job] }) %>
+ </td><td>
+ <%= pj[:progress_bar] %>
+ </td>
+ <% current_job = Job.find(pj[:job][:uuid]) rescue nil %>
+ <td>
+ <% if current_job %>
+ <%= render partial: 'show_object_button', locals: {object: current_job, size: 'xs', link_text: 'Show job details'} %>
+ <% end %>
+ </td><td>
+ <% if current_job.andand[:log] %>
+ <% fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(current_job[:log])%>
+ <% Collection.limit(1).where(uuid: fixup[1]).each do |c| %>
+ <% c.files.first.andand do |file| %>
+ <%= link_to url_for(controller: 'collections', action: 'show_file', uuid: current_job[:log], file: "#{file[0]}/#{file[1]}", disposition: 'inline', size: file[2]), class: 'btn btn-default btn-xs' do %>
+ <i class="fa fa-fw fa-info"></i> Show log messages
+ <% end %>
<% end %>
<% end %>
<% end %>
- <% end %>
- </td><td>
- <% if current_job.andand[:output] %>
- <%= link_to_if_arvados_object current_job[:output], {thumbnail: true, link_text: raw('<i class="fa fa-fw fa-archive"></i> Show output files')}, {class: 'btn btn-default btn-xs'} %>
- <% end %>
- </td>
- </tr>
+ </td><td>
+ <% if current_job.andand[:output] %>
+ <%= link_to_if_arvados_object current_job[:output], {thumbnail: true, link_text: raw('<i class="fa fa-fw fa-archive"></i> Show output files')}, {class: 'btn btn-default btn-xs'} %>
+ <% end %>
+ </td>
+ </tr>
<% end %>
</tbody>
<tfoot>
diff --git a/apps/workbench/app/views/pipeline_instances/_show_log.html.erb b/apps/workbench/app/views/pipeline_instances/_show_log.html.erb
new file mode 100644
index 0000000..2fdb45b
--- /dev/null
+++ b/apps/workbench/app/views/pipeline_instances/_show_log.html.erb
@@ -0,0 +1,6 @@
+<% log_history = stderr_log_history([@object.uuid] + pipeline_jobs(@object).collect{|x|x[:job].andand[:uuid]}.compact) %>
+<div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuids="<%= @object.uuid %>" data-object-uuids-live="#Components tr[data-object-uuid]">
+ <% log_history.each do |entry| %>
+ <%=entry%><br/>
+ <% end %>
+</div>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list