From ce408713e3067fc278a5a8f9c2d534567f65c636 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 3 Feb 2014 00:07:24 -0800 Subject: [PATCH] Improve progress view on pipeline_instances.show page and add AJAX auto-refresh. refs #1976 refs #2004 --- .../app/controllers/application_controller.rb | 2 + .../app/helpers/pipeline_instances_helper.rb | 30 +++--- .../workbench/app/models/pipeline_instance.rb | 4 + .../app/views/layouts/application.html.erb | 5 +- .../views/pipeline_instances/show.html.erb | 93 +++++++++++++------ .../app/views/pipeline_instances/show.js.erb | 3 + 6 files changed, 94 insertions(+), 43 deletions(-) create mode 100644 apps/workbench/app/views/pipeline_instances/show.js.erb diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 8d23c71a73..21941b266e 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -59,6 +59,7 @@ class ApplicationController < ActionController::Base respond_to do |f| f.json { render json: @objects } f.html { render } + f.js { render } end end @@ -75,6 +76,7 @@ class ApplicationController < ActionController::Base redirect_to params[:return_to] || @object end } + f.js { render } end end diff --git a/apps/workbench/app/helpers/pipeline_instances_helper.rb b/apps/workbench/app/helpers/pipeline_instances_helper.rb index f314c658ce..fbce7f550b 100644 --- a/apps/workbench/app/helpers/pipeline_instances_helper.rb +++ b/apps/workbench/app/helpers/pipeline_instances_helper.rb @@ -61,23 +61,23 @@ module PipelineInstancesHelper pj[:progress] = 0.0 end end - if pj[:job] - if pj[:job][:success] - pj[:result] = 'complete' - pj[:complete] = true - pj[:progress] = 1.0 - elsif pj[:job][:finished_at] - pj[:result] = 'failed' - pj[:failed] = true - elsif pj[:job][:started_at] - pj[:result] = 'running' - else - pj[:result] = 'queued' - end + if pj[:job][:success] + pj[:result] = 'complete' + pj[:complete] = true + pj[:progress] = 1.0 + elsif pj[:job][:finished_at] + pj[:result] = 'failed' + pj[:failed] = true + elsif pj[:job][:started_at] + pj[:result] = 'running' + elsif pj[:job][:uuid] + pj[:result] = 'queued' + else + pj[:result] = 'none' end pj[:job_id] = pj[:job][:uuid] - pj[:script] = pj[:job][:script] - pj[:script_version] = pj[:job][:script_version] + pj[:script] = pj[:job][:script] || c[:script] + pj[:script_version] = pj[:job][:script_version] || c[:script_version] pj[:output] = pj[:job][:output] pj[:finished_at] = (Time.parse(pj[:job][:finished_at]) rescue nil) ret << pj diff --git a/apps/workbench/app/models/pipeline_instance.rb b/apps/workbench/app/models/pipeline_instance.rb index 81cd42bf46..f6dbf4003f 100644 --- a/apps/workbench/app/models/pipeline_instance.rb +++ b/apps/workbench/app/models/pipeline_instance.rb @@ -20,4 +20,8 @@ class PipelineInstance < ArvadosBase def attribute_editable?(attr) attr == 'name' end + + def attributes_for_display + super.reject { |k,v| k == 'components' } + end end diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb index 3d2c6faec0..9af00d5fd2 100644 --- a/apps/workbench/app/views/layouts/application.html.erb +++ b/apps/workbench/app/views/layouts/application.html.erb @@ -113,7 +113,10 @@
<%= content_for?(:breadcrumbs) ? yield(:breadcrumbs) : render(partial: 'breadcrumbs') %> - <%= yield %> + +
+ <%= yield %> +
diff --git a/apps/workbench/app/views/pipeline_instances/show.html.erb b/apps/workbench/app/views/pipeline_instances/show.html.erb index a36412eb5c..900075084d 100644 --- a/apps/workbench/app/views/pipeline_instances/show.html.erb +++ b/apps/workbench/app/views/pipeline_instances/show.html.erb @@ -1,33 +1,72 @@ - +<% content_for :css do %> +table.pipeline-components-table thead th { + text-align: bottom; +} +table.pipeline-components-table div.progress { + margin-bottom: 0; +} +<% end %> +
+ +
+ + + + + + + + + - <% @object.attributes_for_display.each do |attr, attrvalue| %> - <% if attr == 'components' and attrvalue.is_a? Hash %> - - - - <% else %> - <%= render partial: 'application/arvados_object_attr', locals: { attr: attr, attrvalue: attrvalue } %> - <% end %> + <% render_pipeline_jobs.each do |pj| %> + + + <% end %> + + +
+ component + + progress + <%= link_to '(refresh)', request.fullpath, class: 'refresh', remote: true, method: 'get' %> + + script, version + + output +
<%= attr %> - - <% render_pipeline_jobs.each do |pj| %> - <% %w(index name result job_link script script_version progress_detail progress_bar output_link).each do |key| %> - - <% end %> - - <% end %> -
- <% if key == 'script_version' %> - <%= pj[key.to_sym][0..6] rescue '' %> - <% else %> - <%= pj[key.to_sym] %> - <% end %> -
-
+ <% if pj[:job].andand[:uuid] %> + <%= link_to pj[:name], job_url(id: pj[:job][:uuid]) %> + <% else %> + <%= pj[:name] %> + <% end %> + + <%= pj[:progress_bar] %> + <% if pj[:job].andand[:cancelled_at] %> + cancelled + <% elsif pj[:failed] %> + failed + <% elsif pj[:result] == 'queued' %> + queued + <% end %> + + <%= pj[:script] %> +
<%= pj[:script_version] %> +
+ <%= link_to_if_arvados_object pj[:output] %> +
-
-<%= JSON.pretty_generate(@object.attributes) rescue nil %>
-
+ +
+ +<%= render partial: 'arvados_object' %> + +<% if @object.active %> +<% content_for :js do %> +setInterval(function(){$('a.refresh').click()}, 30000); +<% end %> +<% end %> diff --git a/apps/workbench/app/views/pipeline_instances/show.js.erb b/apps/workbench/app/views/pipeline_instances/show.js.erb new file mode 100644 index 0000000000..9460f0bc9d --- /dev/null +++ b/apps/workbench/app/views/pipeline_instances/show.js.erb @@ -0,0 +1,3 @@ +var new_content = "<%= escape_javascript(render template: 'pipeline_instances/show.html') %>"; +if ($('div.body-content').html() != new_content) + $('div.body-content').html(new_content); -- 2.30.2