|
4 | 4 |
|
5 | 5 | {% block toolbar %}
|
6 | 6 | {% if collector.messages|length > 0 %}
|
| 7 | + {% set status_color = collector.exceptionsCount ? 'red' %} |
7 | 8 | {% set icon %}
|
8 | 9 | {{ include('@WebProfiler/Icon/messenger.svg') }}
|
9 | 10 | <span class="sf-toolbar-value">{{ collector.messages|length }}</span>
|
10 | 11 | {% endset %}
|
11 | 12 |
|
12 |
| - {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: 'messenger' }) }} |
| 13 | + {% set text %} |
| 14 | + {% for bus in collector.buses %} |
| 15 | + {% set exceptionsCount = collector.exceptionsCount(bus) %} |
| 16 | + <div class="sf-toolbar-info-piece"> |
| 17 | + <b>{{ bus }}</b> |
| 18 | + <span |
| 19 | + title="{{ exceptionsCount }} message(s) with exceptions" |
| 20 | + class="sf-toolbar-status sf-toolbar-status-{{ exceptionsCount ? 'red' }}" |
| 21 | + > |
| 22 | + {{ collector.messages(bus)|length }} |
| 23 | + </span> |
| 24 | + </div> |
| 25 | + {% endfor %} |
| 26 | + {% endset %} |
| 27 | + |
| 28 | + {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: 'messenger', status: status_color }) }} |
13 | 29 | {% endif %}
|
14 | 30 | {% endblock %}
|
15 | 31 |
|
16 | 32 | {% block menu %}
|
17 |
| -<span class="label"> |
| 33 | +<span class="label {{ collector.exceptionsCount ? 'label-status-error' }}"> |
18 | 34 | <span class="icon">{{ include('@WebProfiler/Icon/messenger.svg') }}</span>
|
19 | 35 | <strong>Messages</strong>
|
20 | 36 |
|
|
24 | 40 | </span>
|
25 | 41 | {% endblock %}
|
26 | 42 |
|
| 43 | +{% block head %} |
| 44 | + {{ parent() }} |
| 45 | + <style> |
| 46 | + .message-item thead th { position: relative; cursor: pointer; user-select: none; padding-right: 35px; } |
| 47 | + .message-item tbody tr td:first-child { width: 115px; } |
| 48 | +
|
| 49 | + .message-item .label { float: right; padding: 1px 5px; opacity: .75; margin-left: 5px; } |
| 50 | + .message-item .toggle-button { position: absolute; right: 6px; top: 6px; opacity: .5; pointer-events: none } |
| 51 | + .message-item .icon svg { height: 24px; width: 24px; } |
| 52 | +
|
| 53 | + .message-item .sf-toggle-off .icon-close, .sf-toggle-on .icon-open { display: none; } |
| 54 | + .message-item .sf-toggle-off .icon-open, .sf-toggle-on .icon-close { display: block; } |
| 55 | +
|
| 56 | + .message-bus .badge.status-some-errors { line-height: 16px; border-bottom: 2px solid #B0413E; } |
| 57 | +
|
| 58 | + .message-item .sf-toggle-content.sf-toggle-visible { display: table-row-group; } |
| 59 | + </style> |
| 60 | +{% endblock %} |
| 61 | + |
27 | 62 | {% block panel %}
|
| 63 | + {% import _self as helper %} |
| 64 | + |
28 | 65 | <h2>Messages</h2>
|
29 | 66 |
|
30 | 67 | {% if collector.messages is empty %}
|
31 | 68 | <div class="empty">
|
32 | 69 | <p>No messages have been collected.</p>
|
33 | 70 | </div>
|
34 | 71 | {% else %}
|
35 |
| - <table> |
36 |
| - <thead> |
37 |
| - <tr> |
38 |
| - <th>Bus</th> |
39 |
| - <th>Message</th> |
40 |
| - <th>Result</th> |
41 |
| - </tr> |
42 |
| - </thead> |
43 |
| - <tbody> |
44 |
| - {% for message in collector.messages %} |
45 |
| - <tr> |
46 |
| - <td>{{ message.bus }}</td> |
47 |
| - <td> |
48 |
| - {% if message.result.object is defined %} |
49 |
| - {{ profiler_dump(message.message.object, maxDepth=2) }} |
50 |
| - {% else %} |
51 |
| - {{ message.message.type }} |
52 |
| - {% endif %} |
53 |
| - </td> |
54 |
| - <td> |
55 |
| - {% if message.result.object is defined %} |
56 |
| - {{ profiler_dump(message.result.object, maxDepth=2) }} |
57 |
| - {% elseif message.result.type is defined %} |
58 |
| - {{ message.result.type }} |
59 |
| - {% if message.result.value is defined %} |
60 |
| - {{ message.result.value }} |
61 |
| - {% endif %} |
62 |
| - {% endif %} |
63 |
| - {% if message.exception.type is defined %} |
64 |
| - {{ message.exception.type }} |
65 |
| - {% endif %} |
66 |
| - </td> |
67 |
| - </tr> |
68 |
| - {% endfor %} |
69 |
| - </tbody> |
70 |
| - </table> |
| 72 | + |
| 73 | + <div class="sf-tabs message-bus"> |
| 74 | + <div class="tab"> |
| 75 | + {% set messages = collector.messages %} |
| 76 | + {% set exceptionsCount = collector.exceptionsCount %} |
| 77 | + <h3 class="tab-title">All<span class="badge {{ exceptionsCount ? exceptionsCount == messages|length ? 'status-error' : 'status-some-errors' }}">{{ messages|length }}</span></h3> |
| 78 | + |
| 79 | + <div class="tab-content"> |
| 80 | + <p class="text-muted">Ordered list of dispatched messages across all your buses</p> |
| 81 | + {{ helper.render_bus_messages(messages, true) }} |
| 82 | + </div> |
| 83 | + </div> |
| 84 | + |
| 85 | + {% for bus in collector.buses %} |
| 86 | + <div class="tab message-bus"> |
| 87 | + {% set messages = collector.messages(bus) %} |
| 88 | + {% set exceptionsCount = collector.exceptionsCount(bus) %} |
| 89 | + <h3 class="tab-title">{{ bus }}<span class="badge {{ exceptionsCount ? exceptionsCount == messages|length ? 'status-error' : 'status-some-errors' }}">{{ messages|length }}</span></h3> |
| 90 | + |
| 91 | + <div class="tab-content"> |
| 92 | + <p class="text-muted">Ordered list of messages dispatched on the <code>{{ bus }}</code> bus</p> |
| 93 | + {{ helper.render_bus_messages(messages) }} |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + {% endfor %} |
71 | 97 | {% endif %}
|
| 98 | + |
72 | 99 | {% endblock %}
|
| 100 | + |
| 101 | +{% macro render_bus_messages(messages, showBus = false) %} |
| 102 | + {% set discr = random() %} |
| 103 | + {% for i, dispatchCall in messages %} |
| 104 | + <table class="message-item"> |
| 105 | + <thead> |
| 106 | + <tr> |
| 107 | + <th colspan="2" class="sf-toggle" |
| 108 | + data-toggle-selector="#message-item-{{ discr }}-{{ i }}-details" |
| 109 | + data-toggle-initial="{{ loop.first ? 'display' }}" |
| 110 | + > |
| 111 | + <span class="dump-inline">{{ profiler_dump(dispatchCall.message.type) }}</span> |
| 112 | + {% if showBus %} |
| 113 | + <span class="label">{{ dispatchCall.bus }}</span> |
| 114 | + {% endif %} |
| 115 | + {% if dispatchCall.exception is defined %} |
| 116 | + <span class="label status-error">exception</span> |
| 117 | + {% endif %} |
| 118 | + <a class="toggle-button"> |
| 119 | + <span class="icon icon-close">{{ include('@Twig/images/icon-minus-square.svg') }}</span> |
| 120 | + <span class="icon icon-open">{{ include('@Twig/images/icon-plus-square.svg') }}</span> |
| 121 | + </a> |
| 122 | + </th> |
| 123 | + </tr> |
| 124 | + </thead> |
| 125 | + <tbody id="message-item-{{ discr }}-{{ i }}-details" class="sf-toggle-content"> |
| 126 | + {% if showBus %} |
| 127 | + <tr> |
| 128 | + <td class="text-bold">Bus</td> |
| 129 | + <td>{{ dispatchCall.bus }}</td> |
| 130 | + </tr> |
| 131 | + {% endif %} |
| 132 | + <tr> |
| 133 | + <td class="text-bold">Message</td> |
| 134 | + <td>{{ profiler_dump(dispatchCall.message.value, maxDepth=2) }}</td> |
| 135 | + </tr> |
| 136 | + <tr> |
| 137 | + <td class="text-bold">Envelope items</td> |
| 138 | + <td> |
| 139 | + {% for item in dispatchCall.envelopeItems %} |
| 140 | + {{ profiler_dump(item) }} |
| 141 | + {% else %} |
| 142 | + <span class="text-muted">No items</span> |
| 143 | + {% endfor %} |
| 144 | + </td> |
| 145 | + </tr> |
| 146 | + <tr> |
| 147 | + <td class="text-bold">Result</td> |
| 148 | + <td> |
| 149 | + {% if dispatchCall.result is defined %} |
| 150 | + {{ profiler_dump(dispatchCall.result.seek('value'), maxDepth=2) }} |
| 151 | + {% elseif dispatchCall.exception is defined %} |
| 152 | + <span class="text-danger">No result as an exception occurred</span> |
| 153 | + {% endif %} |
| 154 | + </td> |
| 155 | + </tr> |
| 156 | + {% if dispatchCall.exception is defined %} |
| 157 | + <tr> |
| 158 | + <td class="text-bold">Exception</td> |
| 159 | + <td> |
| 160 | + {{ profiler_dump(dispatchCall.exception.value, maxDepth=1) }} |
| 161 | + </td> |
| 162 | + </tr> |
| 163 | + {% endif %} |
| 164 | + </tbody> |
| 165 | + </table> |
| 166 | + {% endfor %} |
| 167 | +{% endmacro %} |
0 commit comments