{% extends 'main_header.html' %}
{% block body %}

    <div class="page-title-bar">
        {% import 'block_enable_auto_refresh.html' as block_enable_refresh %}
        {{ block_enable_refresh.enable_auto_refresh() }}
    </div>

    <div class="container u-full-width">
        {% import 'block_time_window_selector.html' as block_time_window %}
        {{ block_time_window.time_window_selector(details, 2) }}

        <table class="table-entries u-full-width context-menu synergy-datatable" id="dashboard_table">
            <thead>
            <tr class="table-entries-header">
                <th scope="col">
                    <input type="checkbox" name="select_all" onclick="toggleAllCheckboxes(this)"/>
                </th>
                <th scope="col">Process Name</th>
                <th scope="col">Timeperiod</th>
                <th scope="col">State</th>
                <th scope="col"></th> <!-- View Uow -->
                <th scope="col"></th> <!-- Uow Log -->
                <th scope="col"></th> <!-- Timeline -->
                <th scope="col"></th> <!-- Workflow -->
            </tr>
            </thead>
            <tbody>

            {%- for primary_key, job_entry in details.managed.items() -%}
                <tr class="{{ job_entry.state }}">
                    {% set value = "{ process_name: '" + job_entry.process_name + "', timeperiod: '" + job_entry.timeperiod + "' }" %}
                    <td><input type="checkbox" name="batch_processing" value="{{ value }}"/></td>
                    <td>{{ job_entry.process_name }}</td>
                    <td>{{ job_entry.timeperiod }}</td>
                    <td>{{ job_entry.state }}</td>
                    <td>
                        {% set url = 'action=scheduler/managed/uow' + '&process_name=' + job_entry.process_name + '&timeperiod=' + job_entry.timeperiod %}
                        <form class="table-form" method="GET"
                              onsubmit="openViewerWindow('/scheduler/viewer/object/?{{ url }}', 'View Uow'); return false;">
                            <button type="submit" class="action_button btn-center" title="ViewUow">
                                <i class="fa fa-file-code-o"></i>
                                <span>View Uow</span></button>
                        </form>
                    </td>
                    <td>
                        {% set url = 'action=scheduler/managed/uow/log' + '&process_name=' + job_entry.process_name + '&timeperiod=' + job_entry.timeperiod %}
                        <form class="table-form" method="GET"
                              onsubmit="openViewerWindow('/scheduler/viewer/object/?{{ url }}', 'Uow Log'); return false;">
                            <button type="submit" class="action_button btn-center" title="UowLog">
                                <i class="fa fa-file-text-o"></i>
                                <span>Uow Log</span></button>
                        </form>
                    </td>
                    <td>
                        {% set url = 'action=scheduler/managed/timeline' + '&process_name=' + job_entry.process_name + '&timeperiod=' + job_entry.timeperiod %}
                        <form class="table-form" method="GET"
                              onsubmit="openViewerWindow('/scheduler/viewer/object/?{{ url }}', 'Job Timeline'); return false;">
                            <button type="submit" class="action_button btn-center" title="Timeline">
                                <i class="fa fa-history"></i>
                                <span>Timeline</span></button>
                        </form>
                    </td>
                    <td>
                        {% set url = 'action=flow/flow/details' + '&process_name=' + job_entry.process_name + '&timeperiod=' + job_entry.timeperiod + '&unit_of_work_type=type_managed' %}
                        <form class="table-form" method="GET"
                              onsubmit="openViewerWindow('/flow/viewer/?{{ url }}', 'Workflow'); return false;">
                            <button type="submit" class="action_button btn-center" title="Workflow">
                                <i class="fa fa-random"></i>
                                <span>Workflow</span></button>
                        </form>
                    </td>
                </tr>
            {%- endfor -%}

            </tbody>
        </table>
    </div>
    {% import 'block_context_menu.html' as context_menu %}
    {{ context_menu.job_menu() }}

{% endblock %}
