{% block toolbar %}
    {% set icon %}
        <a href="{{ url("webprofiler.dashboard", {profile: token}, {fragment: 'events'}) }}" title="{{ 'Events'|t }}">
            <img width="20" height="28" alt="{{ 'Events'|t }}"
                 src="data:image/png;base64,{{ collector.icon }}">
            <span class="sf-toolbar-info-piece-additional sf-toolbar-status">{{ collector.getCalledListenersCount }}</span>
        </a>
    {% endset %}

    {% set text %}
        <div class="sf-toolbar-info-piece">
            <b>{{ 'Called'|t }}</b>
            <span>{{ collector.getCalledListenersCount }}</span>
        </div>

        <div class="sf-toolbar-info-piece">
            <b>{{ 'Not called'|t }}</b>
            <span>{{ collector.getNotCalledListenersCount }}</span>
        </div>
    {% endset %}

    <div class="sf-toolbar-block">
        <div class="sf-toolbar-icon">{{ icon|default('') }}</div>
        <div class="sf-toolbar-info">{{ text|default('') }}</div>
    </div>
{% endblock %}

{% block panel %}
    <script id="events" type="text/template">

        <h2 class="panel__title">{{ 'Events'|t }}</h2>
        <div class="panel__container">

            <table class="table--duo">
                <thead>
                <th>{{ 'Called listeners'|t }}</th>
                <th>{{ 'Class'|t }}</th>
                <th>{{ 'Priority'|t }}</th>
                </thead>
                <tbody>
                <% _.each( data.called_listeners, function( events, event_name ){ %>
                    <% _.each( events, function( priority, priority_value ){ %>
                        <% _.each( priority, function( listener ){ %>
                            <tr>
                                <td><%= event_name %></td>
                                <% if( listener.clazz ) { %>
                                    <td><%= Drupal.webprofiler.helpers.classLink(listener.clazz) %></td>
                                <% } else { %>
                                    <td><%= listener.service[0] %>::<%= listener.service[1] %></td>
                                <% } %>
                                <td><%= priority_value %></td>
                            </tr>
                        <% }); %>
                    <% }); %>
                <% }); %>
                </tbody>
            </table>

            <table class="table--duo">
                <thead>
                <th>{{ 'Not called listeners'|t }}</th>
                <th>{{ 'Service'|t }}</th>
                <th>{{ 'Priority'|t }}</th>
                </thead>
                <tbody>
                <% _.each( data.not_called_listeners, function( events, event_name ){ %>
                <% _.each( events, function( priority, priority_value ){ %>
                <% _.each( priority, function( listener ){ %>
                <tr>
                    <td><%= event_name %></td>
                    <td><%= listener.service[0] %>::<%= listener.service[1] %></td>
                    <td><%= priority_value %></td>
                </tr>
                <% }); %>
                <% }); %>
                <% }); %>
                </tbody>
            </table>
        </div>

    </script>
{% endblock %}
