{% extends "base.html" %}
{% set active_page = 'task_list' %}
{% block page_nav %}
    <h2>Session List</h2>
{% endblock %}
{% block body %}
    <div class="row">
        {% for session_id in sessions %}
            {% set tasks = sessions[session_id]['tasks'] %}
            <h3>{{ sessions[session_id]['name'] }}</h3>
            <table class="table">
                <thead>
                <tr>
                    <th>Task ID</th>
                    <th>Start Time</th>
                    <th>End Time</th>
                    <th>Graph Size</th>
                    <th>State</th>
                </tr>
                </thead>
                <tbody>
                {%- for task_id in tasks %}
                    {% set task_desc = tasks[task_id] %}
                    <tr>
                        {% if task_desc['state'] == 'preparing'%}
                            <td>{{ task_id }}</td>
                        {% else %}
                            <td><a href="/session/{{ session_id }}/graph/{{ task_id }}">{{ task_id }}</a></td>
                        {% endif %}
                        {% if task_desc['start_time'] is defined %}
                            <td>{{ task_desc['start_time'] | format_ts }}</td>
                        {% else %}
                            <td>N/A</td>
                        {% endif %}
                        {% if task_desc['end_time'] is defined %}
                            <td>{{ task_desc['end_time'] | format_ts }}</td>
                        {% else %}
                            <td>N/A</td>
                        {% endif %}
                        <td>{{ task_desc['graph_size'] if 'graph_size' in task_desc else 'N/A' }}</td>
                        <td>{{ task_desc['state'] if 'state' in task_desc else 'N/A'}}</td>
                    </tr>
                {% endfor -%}
                </tbody>
            </table>
        {% endfor %}
    </div>
{% endblock %}
