<%# Copyright (C) The Arvados Authors. All rights reserved.

SPDX-License-Identifier: AGPL-3.0 %>

<% log_ids = @object.job_log_ids
   job_ids = @object.job_ids
   still_logging, done_logging = log_ids.keys.partition { |k| log_ids[k].nil? }
%>

<% unless done_logging.empty? %>
  <table class="topalign table table-condensed table-fixedlayout">
    <colgroup>
      <col width="40%" />
      <col width="60%" />
    </colgroup>
    <thead>
      <tr>
        <th>finished component</th>
        <th>job log</th>
      </tr>
    </thead>
    <tbody>
      <% done_logging.each do |cname| %>
      <tr>
        <td><%= cname %></td>
        <td><%= link_to("Log for #{cname}",
                job_path(job_ids[cname], anchor: "Log"))
                %></td>
      </tr>
      <% end %>
    </tbody>
  </table>
<% end %>

<% unless still_logging.empty? %>
  <h4>Logs in progress</h4>

  <pre id="event_log_div"
       class="arv-log-event-listener arv-log-event-handler-append-logs arv-log-event-subscribe-to-pipeline-job-uuids arv-job-log-window"
       data-object-uuids="<%= @object.stderr_log_object_uuids.join(' ') %>"
       ><%= @object.stderr_log_lines.join("\n") %></pre>

  <%# Applying a long throttle suppresses the auto-refresh of this
      partial that would normally be triggered by arv-log-event. %>
  <div class="arv-log-refresh-control"
       data-load-throttle="86486400000" <%# 1001 nights %>
       ></div>
<% end %>