{% extends "master.html" %}

{% block title %} - Overview{% endblock %}

{% block body %}

{% if failed_warning %}
<div class="notice">
    <div class="alert alert-error">
        <a class="close" data-dismiss="alert" href="#">×</a>
        Some messages have failed. <a href="/failed" class="failed">Click here</a> to take action.
    </div>
</div>
{% endif %}

<div class="container main">
    <div class="current-jobs section">
        <h1>Jobs in Progress</h1>

        {% for job_type in g.job_types %}
        <h2>{{ job_type }}</h2>
        <table class="table table-striped table-bordered table-condensed">
            <thead>
                <tr>
                    <th class="job-id-col">Job ID</th>
                    <th>Phase</th>
                </tr>
            </thead>
            <tbody>
                {% for job in g.jobs[job_type] %}
                <tr>
                    <td>{{ job }}</td>
                    <td>Mapping</td>
                </tr>
                {% else %}
                <tr>
                    <td colspan="2" class="no-jobs">Nothing happening here right now...</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
        {% else %}
        <table class="no-jobs table table-striped table-bordered table-condensed">
            <thead>
                <tr>
                    <th class="job-id-col">Job ID</th>
                    <th>Phase</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td colspan="2" class="no-jobs">Nothing happening here right now...</td>
                </tr>
            </tbody>
        </table>
        {% endfor %}

        <span class="explain">click a job type to view its activity</span>
    </div>

    <div class="mappers section">
        <h1>Mappers</h1>

        <div class="filters">
            <ul>
                <li><a href="#" data-filter="all">all</a></li>
                {% for job_type in g.job_types %}
                <li><a href="#" data-filter="{{ job_type }}">{{ job_type }}</a></li>
                {% endfor %}
            </ul>
        </div>

        <table class="mappers-table table table-striped table-bordered table-condensed">
            <thead>
                <tr>
                    <th class="mapper-name">Name</th>
                    <th class="working">Working on</th>
                </tr>
            </thead>
            <tbody>
                {% for mapper, status in g.mappers.iteritems() %}
                <tr>
                    <td>{{ mapper }}</td>
                    {% if status %}
                    <td>Processing job {{ status['job_id'] }}</td>
                    {% else %}
                    <td>Waiting for a new job...</td>
                    {% endif %}
                </tr>
                {% else %}
                <tr>
                    <td class="no-mappers" colspan="2">No mappers registered so far...</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>

        <span class="explain">click a mapper to view its activity</span>
    </div>
</div>
{% endblock %}
