{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
    <div class="sf-toolbar-block sf-toolbar-block-leezy-pheanstalk sf-toolbar-status-normal">
        <a href="{{ path('_profiler', { 'token': token, 'panel': name }) }}">
            <div class="sf-toolbar-icon">
                {{ include('@LeezyPheanstalk/Profiler/queue.svg') }}
                <span class="sf-toolbar-value">{{ collector.jobCount }}</span>
                <span class="sf-toolbar-label">Jobs</span>
            </div>
        </a>
        <div class="sf-toolbar-info">
            <div class="sf-toolbar-status">
                <b>Pheanstalks</b>
                <span>{{ collector.pheanstalks|length }}</span>
            </div>
            <div class="sf-toolbar-status">
                <b>Tubes</b>
                <span>{{ collector.tubes|length }}</span>
            </div>
            <div class="sf-toolbar-status">
                <b>Jobs</b>
                <span>{{ collector.jobCount }}</span>
            </div>
        </div>
    </div>
{% endblock %}

{% block menu %}
    <span class="label">
        <span class="icon">{{ include('@LeezyPheanstalk/Profiler/queue.svg') }}</span>
        <strong>Pheanstalk</strong>
        <span class="count">
            <span>{{ collector.pheanstalks|length }}</span>
            <span>{{ collector.jobCount }} Jb</span>
        </span>
    </span>
{% endblock %}

{% block panel %}
    <h2>Pheanstalks</h2>
    {% set data = collector.pheanstalks %}
    {{ block('table_pheanstalk') }}

    <h2>Tubes</h2>
    {% set data = collector.tubes %}
    {{ block('table_tube') }}

    <h2>Jobs</h2>
    {% set data = collector.jobs %}
    {{ block('table_jobs') }}
{% endblock %}

{% block table_pheanstalk %}
    <table>
        {% for row in data %}
            <tr>
                <th colspan="2" style="text-align: center;vertical-align: middle;padding: 5px 0">
                    {{ row.name }} {% if row.default %}(default){% endif %}
                </th>
            </tr>
            <tbody>
                <tr>
                    <th>default</th>
                    <td>{{ row.default ? 'yes' : 'no' }}</td>
                </tr>
                {% for stat, data in row.stats %}
                <tr>
                    <th style="width: 150px">{{ stat }}</th>
                    <td>{{ data }}</td>
                </tr>
                {% endfor %}
            </tbody>
        {% endfor %}
    </table>
{% endblock %}

{% block table_tube %}
    <table>
        {% for row in data %}
            <tr>
                <th colspan="2" style="text-align: center;vertical-align: middle;padding: 5px 0">
                    {{ row.name }} tube on '{{ row.pheanstalk }}' pheanstalk
                </th>
            </tr>
            <tbody>
                <tr>
                    <th style="width: 150px">pheanstalk</th>
                    <td>{{ row.pheanstalk }}</td>
                </tr>
                {% for stat, data in row.stats %}
                    <tr>
                        <th style="width: 150px">{{ stat }}</th>
                        <td>{{ data }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        {% endfor %}
    </table>
{% endblock %}

{% block table_jobs %}
    {% for tube, types in data %}
        <table>
            <th colspan="2" style="text-align: center;vertical-align: middle;padding: 5px 0">
                {{ tube }}
            </th>
            {% for job_type, job in types %}
                <tr>
                    <th rowspan="2">Next {{ job_type }}</th>
                    <td>Job ID: {{ job.id }}</td>
                </tr>
                <tr>
                    <td>
                        <div style="float:left;width:100%;word-spacing:normal;word-wrap:break-word;max-width:720px;">
                            Data: {{ job.data }}
                        </div>
                    </td>
                </tr>
            {% endfor %}
        </table>
    {% endfor %}
{% endblock %}
