From 2c7b72059f8390d56f7031206772dc3d4e4ad5da Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 6 Oct 2014 15:03:37 -0400 Subject: [PATCH] 3381: Merge job_status_label and job_progress into a single job_progress partial. This partial renders a progress bar if the job is running, otherwise renders a label with the job state. The progress bar now shows only 'done' tasks and renders the progress bar in orange if any tasks have failed. Move "done, failure, running, todo" from panel body to panel heading on running_component partial. Dashboard now uses job_progress partial with "scaleby" to indicate pipeline progress more precisely. --- .../assets/stylesheets/application.css.scss | 4 +- .../views/application/_job_progress.html.erb | 88 ++++++++++--------- .../application/_job_status_label.html.erb | 10 --- .../_pipeline_status_label.html.erb | 2 +- .../app/views/jobs/_show_recent.html.erb | 6 -- .../_running_component.html.erb | 56 ++++++------ .../pipeline_instances/_show_recent.html.erb | 2 +- .../views/projects/_show_dashboard.html.erb | 46 +++------- .../app/views/users/_tables.html.erb | 4 - 9 files changed, 90 insertions(+), 128 deletions(-) delete mode 100644 apps/workbench/app/views/application/_job_status_label.html.erb diff --git a/apps/workbench/app/assets/stylesheets/application.css.scss b/apps/workbench/app/assets/stylesheets/application.css.scss index eeb054551a..fc7e462b88 100644 --- a/apps/workbench/app/assets/stylesheets/application.css.scss +++ b/apps/workbench/app/assets/stylesheets/application.css.scss @@ -257,7 +257,9 @@ span.editable-textile { min-width: 1em; padding: 0px 2px 0px 0px; } - +.task-summary-status { + font-size: 80%; +} #page-wrapper > div > h2 { margin-top: 0px; } diff --git a/apps/workbench/app/views/application/_job_progress.html.erb b/apps/workbench/app/views/application/_job_progress.html.erb index 49ba39d450..efe1819ebd 100644 --- a/apps/workbench/app/views/application/_job_progress.html.erb +++ b/apps/workbench/app/views/application/_job_progress.html.erb @@ -1,43 +1,51 @@ -<% - failed = j[:tasks_summary][:failed] || 0 rescue 0 - done = j[:tasks_summary][:done] || 0 rescue 0 - running = j[:tasks_summary][:running] || 0 rescue 0 - todo = j[:tasks_summary][:todo] || 0 rescue 0 - - if j[:success] == false and done + running + failed == 0 - # The job failed but no tasks were ever started (i.e. crunch-dispatch - # was unable to start the job). Display a full 100% failed progress bar. - failed_percent = 100 - success_percent = 0 - running_percent = 0 - elsif done + running + failed + todo == 0 - # No tasks were ever created for this job; - # render an empty progress bar. - failed_percent = 0 - success_percent = 0 - running_percent = 0 - else - percent_total_tasks = 100.0 / (done + running + failed + todo) - if defined? scaleby - percent_total_tasks *= scaleby - end - failed_percent = failed * percent_total_tasks - success_percent = done * percent_total_tasks - running_percent = running * percent_total_tasks - end -%> - -<% if not defined? scaleby %> -
-<% end %> +<% if (j.andand[:state] == "Running" or defined? scaleby) and (not defined? show_progress_bar or show_progress_bar) %> + <% + failed = j[:tasks_summary][:failed] || 0 rescue 0 + done = j[:tasks_summary][:done] || 0 rescue 0 + running = j[:tasks_summary][:running] || 0 rescue 0 + todo = j[:tasks_summary][:todo] || 0 rescue 0 + + if done + running + failed + todo == 0 + # No tasks were ever created for this job; + # render an empty progress bar. + done_percent = 0 + else + percent_total_tasks = 100.0 / (done + running + failed + todo) + if defined? scaleby + percent_total_tasks *= scaleby + end + done_percent = (done+failed) * percent_total_tasks + end + %> + + <% if not defined? scaleby %> +
+ <% end %> + + + + + <% if not defined? scaleby %> +
+ <% end %> + +<% else %> + +<% to_label = { + "Cancelled" => "danger", + "Complete" => "success", + "Running" => "info", + "Failed" => "danger", + "Queued" => "default", + nil => "default" + } %> - - - - - - + + <%= if defined? title + title + else + if j.andand[:state] then j[:state].downcase else "Not ready" end + end + %> -<% if not defined? scaleby %> -
<% end %> diff --git a/apps/workbench/app/views/application/_job_status_label.html.erb b/apps/workbench/app/views/application/_job_status_label.html.erb deleted file mode 100644 index 17073fe98c..0000000000 --- a/apps/workbench/app/views/application/_job_status_label.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% to_label = { - "Cancelled" => "danger", - "Complete" => "success", - "Running" => "info", - "Failed" => "danger", - "Queued" => "default", - nil => "default" - } %> - - <%= if defined? title then title else j[:state].downcase end %> diff --git a/apps/workbench/app/views/application/_pipeline_status_label.html.erb b/apps/workbench/app/views/application/_pipeline_status_label.html.erb index 9e5b71047b..88722726dc 100644 --- a/apps/workbench/app/views/application/_pipeline_status_label.html.erb +++ b/apps/workbench/app/views/application/_pipeline_status_label.html.erb @@ -1,5 +1,5 @@ <% if p.state == 'Complete' %> - finished + complete <% elsif p.state == 'Failed' %> failed <% elsif p.state == 'RunningOnServer' || p.state == 'RunningOnClient' %> diff --git a/apps/workbench/app/views/jobs/_show_recent.html.erb b/apps/workbench/app/views/jobs/_show_recent.html.erb index c823fc5900..d12ebb649b 100644 --- a/apps/workbench/app/views/jobs/_show_recent.html.erb +++ b/apps/workbench/app/views/jobs/_show_recent.html.erb @@ -15,8 +15,6 @@ status - - progress uuid @@ -36,9 +34,6 @@ - - <%= render partial: 'job_status_label', locals: {:j => j} %> -
<%= render partial: 'job_progress', locals: {:j => j} %> @@ -123,4 +118,3 @@ - diff --git a/apps/workbench/app/views/pipeline_instances/_running_component.html.erb b/apps/workbench/app/views/pipeline_instances/_running_component.html.erb index 038efece35..3cdac9b975 100644 --- a/apps/workbench/app/views/pipeline_instances/_running_component.html.erb +++ b/apps/workbench/app/views/pipeline_instances/_running_component.html.erb @@ -2,7 +2,8 @@
-
+
+ <%# column offset 3 %> - <% if current_job %> -
- <%= render(partial: 'job_status_label', locals: { j: current_job }) %> -
+ <%# column offset 3 %> +
+ <%= pj[:progress_bar] %> +
+ <% if current_job %> + <%# column offset 5 %>
<% if current_job[:started_at] %> <% walltime = ((if current_job[:finished_at] then current_job[:finished_at] else Time.now() end) - current_job[:started_at]) %> @@ -32,7 +35,8 @@
<% if current_job[:state].in? ["Complete", "Failed", "Cancelled"] %> -
+ <%# column offset 8 %> +
<% if pj[:output_uuid] %> <%= link_to_if_arvados_object pj[:output_uuid], friendly_name: true %> <% elsif current_job[:output] %> @@ -41,18 +45,29 @@ No output. <% end %>
- <% elsif current_job[:state] == "Running" %> -
- <%= pj[:progress_bar] %> -
-
+ <% elsif current_job[:state].in? ["Queued", "Running"] %> + <%# column offset 8 %> +
+ <% if current_job[:state].in? ["Running"] %> + + <%= current_job[:tasks_summary][:done] %> task<%= if current_job[:tasks_summary][:done] > 1 then 's' else '' end %> done, + <%= current_job[:tasks_summary][:failed] %> failed, + <%= current_job[:tasks_summary][:running] %> running, + <%= current_job[:tasks_summary][:todo] %> pending + + <% end %> +
+ <%# column offset 11 %> +
<%= form_tag "/jobs/#{current_job[:uuid]}/cancel", style: "display:inline; padding-left: 1em" do |f| %> <%= hidden_field_tag :return_to, url_for(@object) %> <%= button_tag "Cancel", {class: 'btn btn-xs btn-danger', id: "cancel-job-button"} %>
<% end %> + <% elsif current_job[:state] == "Queued" %> -
+ <%# column offset 8 %> +
<% queuetime = Time.now - current_job[:created_at] %> Queued for <%= render_runtime(queuetime, true) %>. <% begin %> @@ -67,10 +82,6 @@ <% end %>
<% end %> - <% else %> -
- Not ready -
<% end %>
@@ -154,19 +165,6 @@

script_parameters:

<%= JSON.pretty_generate(current_component[:script_parameters]) rescue nil %>
- <% if current_component[:tasks_summary] %> -
- - <% [:done, :running, :failed, :todo].each do |d| %> - - - - - - <% end %> -
<%= 'tasks:' if d == :done %><%= d.to_s %><%= current_component[:tasks_summary][d] %>
-
- <% end %>
diff --git a/apps/workbench/app/views/pipeline_instances/_show_recent.html.erb b/apps/workbench/app/views/pipeline_instances/_show_recent.html.erb index 08b24f13cb..f918e24e9d 100644 --- a/apps/workbench/app/views/pipeline_instances/_show_recent.html.erb +++ b/apps/workbench/app/views/pipeline_instances/_show_recent.html.erb @@ -56,7 +56,7 @@ <% ob.components.each do |cname, c| %> <% if c.is_a?(Hash) and c[:job] %> - <%= render partial: "job_status_label", locals: {:j => c[:job], :title => cname.to_s } %> + <%= render partial: "job_progress", locals: {:j => c[:job], :title => cname.to_s, :show_progress_bar => false } %> <% else %> <%= cname.to_s %> <% end %> diff --git a/apps/workbench/app/views/projects/_show_dashboard.html.erb b/apps/workbench/app/views/projects/_show_dashboard.html.erb index 9ddd1d59d8..e384e421f5 100644 --- a/apps/workbench/app/views/projects/_show_dashboard.html.erb +++ b/apps/workbench/app/views/projects/_show_dashboard.html.erb @@ -32,55 +32,29 @@
- <% running = [] %> - <% failed = [] %> - <% completed = [] %> - <% queued = [] %> <% p.components.each do |k, v| %> - <% if v.is_a? Hash and v[:job] %> - <% if v[:job][:state] == "Running" %> - <% running << k %> - <% elsif v[:job][:state] == "Failed" or v[:job][:state] == "Cancelled" %> - <% failed << k %> - <% elsif v[:job][:state] == "Complete" %> - <% completed << k %> - <% elsif v[:job][:state] == "Queued" %> - <% queued << k %> - <% end %> - <% end %> + <%= render partial: 'job_progress', locals: {:j => v[:job], :scaleby => (1.0/p.components.size)} %> <% end %> - <% completed_pct = (completed.size * 100) / p.components.size %> - <% failed_pct = (failed.size * 100) / p.components.size %> - <% running_pct = (running.size * 100) / p.components.size %> - <% queued_pct = (queued.size * 100) / p.components.size %> - -
- -
-
- -
-
- -
-
- -
+ <% + running = p.components.select { |k, c| c.andand[:job].andand[:state] == "Running" } + queued = p.components.select { |k, c| c.andand[:job].andand[:state] == "Queued" } + %> +
Started at <%= render_localized_date(p[:started_at] || p[:created_at], "noseconds") %>. <% pipeline_time = Time.now - (p[:started_at] || p[:created_at]) %> Active for <%= render_runtime(pipeline_time, false) %>.
- <% running.each do |k| %> - <%= k %> + <% running.each do |k,v| %> + <%= render partial: 'job_progress', locals: {:j => v[:job], :show_progress_bar => false, :title => k} %> <% end %> - <% queued.each do |k| %> - <%= k %> + <% queued.each do |k,v| %> + <%= render partial: 'job_progress', locals: {:j => v[:job], :show_progress_bar => false, :title => k} %> <% end %>
diff --git a/apps/workbench/app/views/users/_tables.html.erb b/apps/workbench/app/views/users/_tables.html.erb index acde5ce8fd..45ca939281 100644 --- a/apps/workbench/app/views/users/_tables.html.erb +++ b/apps/workbench/app/views/users/_tables.html.erb @@ -22,7 +22,6 @@ Log Created at Status - Progress <%# Preload collections, logs, and pipeline instance objects %> @@ -96,9 +95,6 @@ - - <%= render partial: 'job_status_label', locals: {:j => j} %> -
<%= render partial: 'job_progress', locals: {:j => j} %> -- 2.30.2