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

{% block summary %}
    <div class="status">
        <div class="container">
            <h2>Profile Search</h2>
        </div>
    </div>
{% endblock %}

{% block panel %}
    <h2>{{ tokens ? tokens|length : 'No' }} results found</h2>

    {% if tokens %}
        <table id="search-results">
            <thead>
                <tr>
                    <th scope="col" class="text-center">Status</th>
                    <th scope="col">IP</th>
                    <th scope="col">Method</th>
                    <th scope="col">URL</th>
                    <th scope="col">Time</th>
                    <th scope="col">Token</th>
                </tr>
            </thead>
            <tbody>
                {% for result in tokens %}
                    {% set css_class = result.status_code|default(0) > 399 ? 'status-error' : result.status_code|default(0) > 299 ? 'status-warning' : 'status-success' %}

                    <tr>
                        <td class="text-center">
                            <span class="label {{ css_class }}">{{ result.status_code|default('n/a') }}</span>
                        </td>
                        <td>
                            <span class="nowrap">{{ result.ip }}</span>
                            {% if request.session is not null %}
                                <a href="{{ path('_profiler_search_results', request.query.all|merge({'ip': result.ip, 'token': result.token})) }}" title="Search">
                                    <span title="Search" class="sf-icon sf-search">{{ include('@WebProfiler/Icon/search.svg') }}</span>
                                </a>
                            {% endif %}
                        </td>
                        <td>
                            {{ result.method }}
                            {% if request.session is not null %}
                                <a href="{{ path('_profiler_search_results', request.query.all|merge({'method': result.method, 'token': result.token})) }}" title="Search">
                                    <span title="Search" class="sf-icon sf-search">{{ include('@WebProfiler/Icon/search.svg') }}</span>
                                </a>
                            {% endif %}
                        </td>
                        <td class="break-long-words">
                            {{ result.url }}
                            {% if request.session is not null %}
                                <a href="{{ path('_profiler_search_results', request.query.all|merge({'url': result.url, 'token': result.token})) }}" title="Search">
                                    <span title="Search" class="sf-icon sf-search">{{ include('@WebProfiler/Icon/search.svg') }}</span>
                                </a>
                            {% endif %}
                        </td>
                        <td class="text-small">
                            <span class="nowrap">{{ result.time|date('d-M-Y') }}</span>
                            <span class="nowrap newline">{{ result.time|date('H:i:s') }}</span>
                        </td>
                        <td class="nowrap"><a href="{{ path('_profiler', { token: result.token }) }}">{{ result.token }}</a></td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    {% else %}
        <div class="empty">
            <p>The query returned no result.</p>
        </div>
    {% endif %}

{% endblock %}
