<%- def job(job_info, job_executions) -%>
    <%- layout_base(title: "Job #{job_info.name}") do -%>
        <h3 class="section_title">
            Job
            <b><%= job_info.name %></b>
            <%- if @identity.is_admin -%>
                <form method="post" action="/job/<%= job_info.name %>/run">
                    <input type="submit" value="Execute" class="button" />
                </form>
            <%- end -%>
        </h3>

        <div class="table">
            <div class="table-header">
                <div>Execution</div>
                <div>Started</div>
                <div>Duration</div>
            </div>

            <%- job_executions.each do |job_execution| -%>
                <%-
                    duration_text = ""
                    if !job_execution.end_date.nil?
                        duration_span = job_execution.end_date.not_nil! - job_execution.start_date
                        duration_text = "#{duration_span.minutes > 9 ? "" : "0"}#{duration_span.minutes}:#{duration_span.seconds > 9 ? "" : "0"}#{duration_span.seconds}"
                    end
                -%>
                <div class="table-row">
                    <div>
                        <a href="/job/<%= job_info.name %>/execution/<%= job_execution.id %>">
                            #<%= job_execution.id %></a><div class="status_dot is-<%= job_execution.finished ? (job_execution.exit_code == 0 ? "finished" : "failed") : "running" %>"></div>
                    </div>
                    <div>
                        <span class="execution_date"><%= job_execution.start_date %></span>
                        <span class="execution_date is-ago">(<%= time_ago(job_execution.start_date) %>)</span>
                    </div>
                    <div>
                        <span class="execution_date"><%= duration_text %></span>
                    </div>
                </div>
            <%- end -%>
        </div>

    <%- end -%>
<%- end -%>