{% extends 'base.html' %}

{% block title %}Eagle Eye - Job Status{% endblock %}

{% block head %}
{% endblock %}

{% block content %}
    <div style="margin: 0 auto; width: fit-content;">
        <h2>Job: {{ job_name }}</h2>
        <h4>State: {{ job_state.state.name }}</h4>

        <form id="progress-job" action="/progress-job/{{ job_id }}" method="post">
            <input type="submit" value="Progress"/>
        </form>
        <form id="regress-job" action="/regress-job/{{ job_id }}" method="post">
            <input type="submit" value="Regress"/>
        </form>

        <br>
        <br>

        <h6>State Change Log</h6>
        <table>
            <tr>
                <th>State</th>
                <th>Timestamp</th>
            </tr>
            {% for change in state_log %}
                <tr>
                    <td>
                        {% if change.state.name == "PRE_PROCESSED" %}
                            <a href="/job-status/{{ job_id }}/pre-process">{{ change.state.name }}</a>
                        {% elif change.state.name == "COMPLETED" %}
                            <a href="/job-status/{{ job_id }}/results">{{ change.state.name }}</a>
                        {% else %}
                            {{ change.state.name }}
                        {% endif %}
                    </td>
                    <td>{{ change.timestamp }}</td>
                </tr>
            {% endfor %}
        </table>
    </div>
{% endblock %}
