3381: Merge job_status_label and job_progress into a single job_progress
authorPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 6 Oct 2014 19:03:37 +0000 (15:03 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 6 Oct 2014 19:03:37 +0000 (15:03 -0400)
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.

apps/workbench/app/assets/stylesheets/application.css.scss
apps/workbench/app/views/application/_job_progress.html.erb
apps/workbench/app/views/application/_job_status_label.html.erb [deleted file]
apps/workbench/app/views/application/_pipeline_status_label.html.erb
apps/workbench/app/views/jobs/_show_recent.html.erb
apps/workbench/app/views/pipeline_instances/_running_component.html.erb
apps/workbench/app/views/pipeline_instances/_show_recent.html.erb
apps/workbench/app/views/projects/_show_dashboard.html.erb
apps/workbench/app/views/users/_tables.html.erb

index eeb054551ae41a812c86bd7a36ff2c400f7d161c..fc7e462b88c5a4c6a797b05a26530c54506207c4 100644 (file)
@@ -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;
 }
index 49ba39d45069124660399b83417efcf14d5efd99..efe1819ebd6d5cf73512046b2fcefcbb084a44b1 100644 (file)
@@ -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 %>
-  <div class="progress">
-<% 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 %>
+    <div class="progress" style="margin-bottom: 0px">
+  <% end %>
+
+  <span class="progress-bar <%= if failed == 0 then 'progress-bar-success' else 'progress-bar-warning' end %>" style="width: <%= done_percent %>%;">
+  </span>
+
+  <% if not defined? scaleby %>
+  </div>
+  <% end %>
+
+<% else %>
+
+<% to_label = {
+     "Cancelled" => "danger",
+     "Complete" => "success",
+     "Running" => "info",
+     "Failed" => "danger",
+     "Queued" => "default",
+     nil => "default"
+   } %>
 
-<span class="progress-bar progress-bar-success" style="width: <%= success_percent %>%;">
-</span>
-<span class="progress-bar progress-bar-danger" style="width: <%= failed_percent %>%;">
-</span>
-<span class="progress-bar" style="width: <%= running_percent %>%;">
-</span>
+  <span class="label label-<%= to_label[j.andand[:state]] %>">
+    <%= if defined? title
+          title
+        else
+          if j.andand[:state] then j[:state].downcase else "Not ready" end
+        end
+        %></span>
 
-<% if not defined? scaleby %>
-</div>
 <% 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 (file)
index 17073fe..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<% to_label = {
-     "Cancelled" => "danger",
-     "Complete" => "success",
-     "Running" => "info",
-     "Failed" => "danger",
-     "Queued" => "default",
-     nil => "default"
-   } %>
-
-  <span class="label label-<%= to_label[j[:state]] %>"><%= if defined? title then title else j[:state].downcase end %></span>
index 9e5b71047b3147daf54fe9478429d26555d03e8a..88722726dc61169f3468cc00b2b2d72af6bfac17 100644 (file)
@@ -1,5 +1,5 @@
 <% if p.state == 'Complete' %>
-  <span class="label label-success">finished</span>
+  <span class="label label-success">complete</span>
 <% elsif p.state == 'Failed' %>
   <span class="label label-danger">failed</span>
 <% elsif p.state == 'RunningOnServer' || p.state == 'RunningOnClient' %>
index c823fc590017d5d8ac304445f3d0c01d3065ec74..d12ebb649bee1ef64deb99795588d1760d258be6 100644 (file)
@@ -15,8 +15,6 @@
       <th>
       </th><th>
        status
-      </th><th>
-       progress
       </th><th>
        uuid
       </th><th>
@@ -36,9 +34,6 @@
       <td>
         <i class="icon-plus-sign expand-collapse-row" data-id="<%= j.uuid %>" style="cursor: pointer"></i>
       </td>
-      <td>
-        <%= render partial: 'job_status_label', locals: {:j => j} %>
-      </td>
       <td>
         <div class="inline-progress-container">
           <%= render partial: 'job_progress', locals: {:j => j} %>
 
   </tbody>
 </table>
-
index 038efece35e06fb00dc5431d95e58a287c78e72d..3cdac9b9757c7e0e063c42fbaac904183bc1d530 100644 (file)
@@ -2,7 +2,8 @@
   <div class="panel panel-default">
     <div class="panel-heading">
       <div class="container-fluid">
-        <div class="row">
+        <div class="row-fluid">
+          <%# column offset 3 %>
           <div class="col-md-3">
             <h4 class="panel-title">
               <a data-toggle="collapse" href="#collapse<%= i %>" style="white-space: nowrap;">
             </h4>
           </div>
 
-          <% if current_job %>
-            <div class="col-md-1">
-              <%= render(partial: 'job_status_label', locals: { j: current_job }) %>
-            </div>
+          <%# column offset 3 %>
+          <div class="col-md-2 pipeline-instance-spacing">
+            <%= pj[:progress_bar] %>
+          </div>
 
+          <% if current_job %>
+            <%# column offset 5 %>
             <div class="col-md-3">
               <% 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 @@
             </div>
 
             <% if current_job[:state].in? ["Complete", "Failed", "Cancelled"] %>
-              <div class="col-md-5 text-overflow-ellipsis">
+              <%# column offset 8 %>
+              <div class="col-md-4 text-overflow-ellipsis">
                 <% if pj[:output_uuid] %>
                   <%= link_to_if_arvados_object pj[:output_uuid], friendly_name: true %>
                 <% elsif current_job[:output] %>
                   No output.
                 <% end %>
               </div>
-            <% elsif current_job[:state] == "Running" %>
-              <div class="col-md-3 pipeline-instance-spacing">
-                <%= pj[:progress_bar] %>
-              </div>
-              <div class="col-md-1 pipeline-instance-spacing">
+            <% elsif current_job[:state].in? ["Queued", "Running"] %>
+              <%# column offset 8 %>
+            <div class="col-md-3">
+              <% if current_job[:state].in? ["Running"] %>
+                <span class="task-summary-status">
+                <%= current_job[:tasks_summary][:done] %>&nbsp;task<%= if current_job[:tasks_summary][:done] > 1 then 's' else '' end %> done,
+                <%= current_job[:tasks_summary][:failed] %>&nbsp;failed,
+                <%= current_job[:tasks_summary][:running] %>&nbsp;running,
+                <%= current_job[:tasks_summary][:todo] %>&nbsp;pending
+                </span>
+              <% end %>
+            </div>
+            <%# column offset 11 %>
+            <div class="col-md-1 pipeline-instance-spacing">
                 <%= 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"} %>
             </div>
             <% end %>
+
           <% elsif current_job[:state] == "Queued" %>
-            <div class="col-md-5">
+            <%# column offset 8 %>
+            <div class="col-md-4">
               <% queuetime = Time.now - current_job[:created_at] %>
               Queued for <%= render_runtime(queuetime, true) %>.
               <% begin %>
           <% end %>
             </div>
           <% end %>
-        <% else %>
-          <div class="col-md-3 col-md-offset-3">
-            <span class="label label-default">Not ready</span>
-          </div>
 <% end %>
 </div>
 </div>
             <p>script_parameters:</p>
             <pre><%= JSON.pretty_generate(current_component[:script_parameters]) rescue nil %></pre>
           </div>
-          <% if current_component[:tasks_summary] %>
-          <div class="col-md-3">
-            <table>
-              <% [:done, :running, :failed, :todo].each do |d| %>
-              <tr>
-                <td style="padding-right: 1em"><%= 'tasks:' if d == :done %></td>
-                <td style="padding-right: 1em"><%= d.to_s %></td>
-                <td><%= current_component[:tasks_summary][d] %></td>
-              </tr>
-              <% end %>
-            </table>
-          </div>
-          <% end %>
         </div>
     </div>
   </div>
index 08b24f13cb03faa1dcb17c1c1830f90aa5706c64..f918e24e9dbab740b8a6300cfdcbe3a94ad0c2fc 100644 (file)
@@ -56,7 +56,7 @@
       <td style="border-top: 0; opacity: 0.5;" colspan="6">
         <% 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 %>
             <span class="label label-default"><%= cname.to_s %></span>
           <% end %>
index 9ddd1d59d84c070f5d8ede4ff596954897f49b83..e384e421f5ccf2c8c848df0b962a960405781039 100644 (file)
 
                 <div class="pull-right" style="width: 40%">
                   <div class="progress" style="margin-bottom: 0px">
-                    <% 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 %>
-
-                    <div class="progress-bar progress-bar-success" style="width: <%= completed_pct %>%">
-                      <span class="sr-only"></span>
-                    </div>
-                    <div class="progress-bar progress-bar-danger" style="width: <%= failed_pct %>%">
-                      <span class="sr-only"></span>
-                    </div>
-                    <div class="progress-bar progress-bar-primary" style="width: <%= running_pct %>%">
-                      <span class="sr-only"></span>
-                    </div>
-                    <div class="progress-bar progress-bar-default" style="width: <%= queued_pct %>%">
-                      <span class="sr-only"></span>
-                    </div>
                   </div>
                 </div>
               </div>
 
+              <%
+                running = p.components.select { |k, c| c.andand[:job].andand[:state] == "Running" }
+                queued = p.components.select { |k, c| c.andand[:job].andand[:state] == "Queued" }
+                %>
+
               <div class="clearfix">
                 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) %>.
 
                 <div class="pull-right">
-                  <% running.each do |k| %>
-                    <span class="label label-primary"><%= k %></span>
+                  <% running.each do |k,v| %>
+                    <%= render partial: 'job_progress', locals: {:j => v[:job], :show_progress_bar => false, :title => k} %>
                   <% end %>
-                  <% queued.each do |k| %>
-                    <span class="label label-default"><%= k %></span>
+                  <% queued.each do |k,v| %>
+                    <%= render partial: 'job_progress', locals: {:j => v[:job], :show_progress_bar => false, :title => k} %>
                   <% end %>
                 </div>
               </div>
index acde5ce8fdd88ee376abfdb294ec1fb225390951..45ca939281431a2aaee8301a80d489d77771e2a0 100644 (file)
@@ -22,7 +22,6 @@
           <th>Log</th>
           <th>Created at</th>
           <th>Status</th>
-          <th>Progress</th>
         </tr>
 
         <%# Preload collections, logs, and pipeline instance objects %>
@@ -96,9 +95,6 @@
   </small>
 </td>
 
-<td>
-  <%= render partial: 'job_status_label', locals: {:j => j} %>
-</td>
 <td>
   <div class="inline-progress-container">
   <%= render partial: 'job_progress', locals: {:j => j} %>