Skip to content

Commit a33db13

Browse files
committed
feature #26520 Added some HTML5 features to the Symfony Profiler (javiereguiluz)
This PR was merged into the 4.1-dev branch. Discussion ---------- Added some HTML5 features to the Symfony Profiler | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Some of these changes are invisible to end-users, but others may be nice tweaks: 1) Times now display full details when you hover them: ![log-time](https://user-images.githubusercontent.com/73419/37395211-ff9acfe6-2775-11e8-9ba5-37470dc0dc38.png) 2) The "profile search" results are now better aligned: ### Before ![before](https://user-images.githubusercontent.com/73419/37395252-177e3ef4-2776-11e8-97d2-d013eb3f22fa.gif) ### After ![after](https://user-images.githubusercontent.com/73419/37395255-1ad02b62-2776-11e8-99af-93e777d0a0d1.gif) 3) The "profile search" form now validates URLs and HTTP Status numbers: ![search-filter](https://user-images.githubusercontent.com/73419/37395295-35799bb0-2776-11e8-96dc-bd979298a7b3.png) I've decided to not use the new and recommended HTML5 `datetime-local` input type for "From" and "Until" fields because support is still poor in desktop browsers. Commits ------- 547076e Added some HTML5 features to the Symfony Profiler
2 parents 3e99988 + 547076e commit a33db13

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
{% if show_level %}
204204
<span class="colored text-bold">{{ log.priorityName }}</span>
205205
{% endif %}
206-
<span class="text-muted newline">{{ log.timestamp|date('H:i:s') }}</span>
206+
<time class="text-muted newline" title="{{ log.timestamp|date('r') }}" datetime="{{ log.timestamp|date('c') }}">{{ log.timestamp|date('H:i:s') }}</time>
207207
</td>
208208

209209
{% if channel_is_defined %}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
</dd>
7878

7979
<dt>Profiled on</dt>
80-
<dd>{{ profile.time|date('r') }}</dd>
80+
<dd><time datetime="{{ profile.time|date('c') }}">{{ profile.time|date('r') }}</time></dd>
8181

8282
<dt>Token</dt>
8383
<dd>{{ profile.token }}</dd>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

3+
{% macro profile_search_filter(request, result, property) %}
4+
{%- if request.session is not null -%}
5+
<a href="{{ path('_profiler_search_results', request.query.all|merge({token: result.token})|merge({ (property): result[property] })) }}" title="Search"><span title="Search" class="sf-icon sf-search">{{ include('@WebProfiler/Icon/search.svg') }}</span></a>
6+
{%- endif -%}
7+
{% endmacro %}
8+
9+
{% import _self as helper %}
10+
311
{% block summary %}
412
<div class="status">
513
<div class="container">
@@ -32,28 +40,14 @@
3240
<span class="label {{ css_class }}">{{ result.status_code|default('n/a') }}</span>
3341
</td>
3442
<td>
35-
<span class="nowrap">{{ result.ip }}</span>
36-
{% if request.session is not null %}
37-
<a href="{{ path('_profiler_search_results', request.query.all|merge({'ip': result.ip, 'token': result.token})) }}" title="Search">
38-
<span title="Search" class="sf-icon sf-search">{{ include('@WebProfiler/Icon/search.svg') }}</span>
39-
</a>
40-
{% endif %}
43+
<span class="nowrap">{{ result.ip }} {{ helper.profile_search_filter(request, result, 'ip') }}</span>
4144
</td>
4245
<td>
43-
{{ result.method }}
44-
{% if request.session is not null %}
45-
<a href="{{ path('_profiler_search_results', request.query.all|merge({'method': result.method, 'token': result.token})) }}" title="Search">
46-
<span title="Search" class="sf-icon sf-search">{{ include('@WebProfiler/Icon/search.svg') }}</span>
47-
</a>
48-
{% endif %}
46+
<span class="nowrap">{{ result.method }} {{ helper.profile_search_filter(request, result, 'method') }}</span>
4947
</td>
5048
<td class="break-long-words">
5149
{{ result.url }}
52-
{% if request.session is not null %}
53-
<a href="{{ path('_profiler_search_results', request.query.all|merge({'url': result.url, 'token': result.token})) }}" title="Search">
54-
<span title="Search" class="sf-icon sf-search">{{ include('@WebProfiler/Icon/search.svg') }}</span>
55-
</a>
56-
{% endif %}
50+
{{ helper.profile_search_filter(request, result, 'url') }}
5751
</td>
5852
<td class="text-small">
5953
<span class="nowrap">{{ result.time|date('d-M-Y') }}</span>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/search.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
<div class="form-group">
1919
<label for="status_code">Status</label>
20-
<input type="number" name="status_code" id="status_code" value="{{ status_code }}">
20+
<input type="number" name="status_code" id="status_code" min="100" max="599" value="{{ status_code }}">
2121
</div>
2222

2323
<div class="form-group">
2424
<label for="url">URL</label>
25-
<input type="text" name="url" id="url" value="{{ url }}">
25+
<input type="url" name="url" id="url" value="{{ url }}">
2626
</div>
2727

2828
<div class="form-group">

0 commit comments

Comments
 (0)