{% extends "../body.html" %}
{% load static %}
{% load util %}
{% block content %}
<script src="{% static 'js/jobs/manage.js' %}"></script>
<div class="table-responsive aw-data">
    <table class="table table-striped aw-text-responsive" id="aw-api-data-table">
        <tr>
            <th>Job{% include "../button/icon/sort.html" %}</th>
            <th class="aw-responsive-lg">Inventory{% include "../button/icon/sort.html" %}</th>
            <th class="aw-responsive-lg">Playbook{% include "../button/icon/sort.html" %}</th>
            <th class="aw-responsive-lg">Comment{% include "../button/icon/sort.html" %}</th>
            <th>Schedule{% include "../button/icon/sort.html" %}</th>
            <th>Last run{% include "../button/icon/sort.html" %}</th>
            <th class="aw-responsive-med">Next run{% include "../button/icon/sort.html" %}</th>
            <th>Actions</th>
        </tr>
        <tr>
            <td colspan="100%">
                {% include "../button/refresh.html" %}
                <a href="/ui/jobs/manage/job">
                    <button class="btn btn-success aw-btn-action" title="Add">
                        {% include "../button/icon/add.html" %}
                    </button>
                </a>
            </td>
        </tr>
        <tr id="aw-api-data-tmpl-row" hidden="hidden">
            <td></td>
            <td class="aw-responsive-lg"></td>
            <td class="aw-responsive-lg"></td>
            <td class="aw-responsive-lg"></td>
            <td></td>
            <td></td>
            <td class="aw-responsive-med"></td>
            <td></td>
        </tr>
        <tr id="aw-api-data-tmpl-row2" hidden="hidden">
            <td colspan="100%">
                <h2><b>Last executions</b></h2><br>
                ${EXECS}
                <div>
                    <button type="submit" title="Collapse" class="btn btn-info aw-btn-action aw-btn-collapse" aw-collapse="aw-spoiler-${ID}">
                        {% include "../button/icon/collapse.html" %}
                    </button>
                </div>
            </td>
        </tr>
    </table>
    <div id="aw-api-data-tmpl-actions" hidden="hidden">
        <!-- todo: allow to choose global- or user-credentials on job-execution -->
        <button class="btn btn-primary aw-btn-action aw-api-click" title="Run" aw-api-endpoint="job" aw-api-item="${ID}" aw-api-method="post">
            {% include "../button/icon/run.html" %}
        </button>
        <a href="/ui/jobs/log?filter=${ID}">
            <button class="btn btn-info aw-btn-action" title="Logs">
                <i class="fa-solid fa-scroll fa-2x aw-btn-action-icon"></i>
            </button>
        </a>
        <button class="btn btn-danger aw-btn-action aw-api-click" title="Stop" aw-api-endpoint="job"
                aw-api-item="${ID}/${EXEC_ID_1}" aw-api-method="delete">
            {% include "../button/icon/stop.html" %}
        </button>
        <a href="/ui/jobs/manage/job/${ID}">
            <button class="btn btn-warning aw-btn-action" title="Edit">
                {% include "../button/icon/edit.html" %}
            </button>
        </a>
        <a href="/ui/jobs/manage/job/clone/${ID}">
            <button class="btn btn-success aw-btn-action" title="Clone">
                {% include "../button/icon/copy.html" %}
            </button>
        </a>
        <button class="btn btn-danger aw-btn-action aw-api-click" title="Delete" aw-api-endpoint="job" aw-api-item="${ID}" aw-api-method="delete">
            {% include "../button/icon/delete.html" %}
        </button>
        <button class="btn btn-info aw-btn-action aw-btn-expand-child" title="Expand" aw-expand="aw-spoiler-${ID}">
            {% include "../button/icon/expand.html" %}
        </button>
    </div>
</div>
{% endblock %}