Merge branch 'master' into 3219-further-docker-improvements
[arvados.git] / apps / workbench / app / views / application / _job_progress.html.erb
1 <%
2    failed = j[:tasks_summary][:failed] || 0 rescue 0
3    done = j[:tasks_summary][:done] || 0 rescue 0
4    running = j[:tasks_summary][:running] || 0 rescue 0
5    todo = j[:tasks_summary][:todo] || 0 rescue 0
6
7    if j[:success] == false and done + running + failed == 0
8      # The job failed but no tasks were ever started (i.e. crunch-dispatch
9      # was unable to start the job). Display a full 100% failed progress bar.
10      failed_percent = 100
11      success_percent = 0
12      running_percent = 0
13    elsif done + running + failed + todo == 0
14      # No tasks were ever created for this job;
15      # render an empty progress bar.
16      failed_percent = 0
17      success_percent = 0
18      running_percent = 0
19    else
20      percent_total_tasks = 100.0 / (done + running + failed + todo)
21      if defined? scaleby
22        percent_total_tasks *= scaleby
23      end
24      failed_percent = (failed * percent_total_tasks).ceil
25      success_percent = (done * percent_total_tasks).ceil
26      running_percent = (running * percent_total_tasks).ceil
27    end
28 %>
29
30 <% if not defined? scaleby %>
31   <div class="progress">
32 <% end %>
33
34 <span class="progress-bar progress-bar-success" style="width: <%= success_percent %>%;">
35 </span>
36 <span class="progress-bar progress-bar-danger" style="width: <%= failed_percent %>%;">
37 </span>
38 <span class="progress-bar" style="width: <%= running_percent %>%;">
39 </span>
40
41 <% if not defined? scaleby %>
42 </div>
43 <% end %>