Fix panel break when stopwatch component is not installed.

This commit is contained in:
Stefan 2017-12-17 16:53:26 +01:00
parent 77104a1468
commit 410b597393

View File

@ -14,10 +14,12 @@
} %} } %}
{% endif %} {% endif %}
{% set has_time_events = collector.events|length > 0 %}
{% block toolbar %} {% block toolbar %}
{% set total_time = collector.events|length ? '%.0f'|format(collector.duration) : 'n/a' %} {% set total_time = has_time_events ? '%.0f'|format(collector.duration) : 'n/a' %}
{% set initialization_time = collector.events|length ? '%.0f'|format(collector.inittime) : 'n/a' %} {% set initialization_time = collector.events|length ? '%.0f'|format(collector.inittime) : 'n/a' %}
{% set status_color = collector.events|length and collector.duration > 1000 ? 'yellow' : '' %} {% set status_color = has_time_events and collector.duration > 1000 ? 'yellow' : '' %}
{% set icon %} {% set icon %}
{{ include('@WebProfiler/Icon/time.svg') }} {{ include('@WebProfiler/Icon/time.svg') }}
@ -75,10 +77,14 @@
<span class="label">Sub-Request{{ profile.children|length > 1 ? 's' }}</span> <span class="label">Sub-Request{{ profile.children|length > 1 ? 's' }}</span>
</div> </div>
{% set subrequests_time = 0 %} {% if has_time_events %}
{% for child in profile.children %} {% set subrequests_time = 0 %}
{% set subrequests_time = subrequests_time + child.getcollector('time').events.__section__.duration %} {% for child in profile.children %}
{% endfor %} {% set subrequests_time = subrequests_time + child.getcollector('time').events.__section__.duration %}
{% endfor %}
{% else %}
{% set subrequests_time = 0 %}
{% endif %}
<div class="metric"> <div class="metric">
<span class="value">{{ subrequests_time }} <span class="unit">ms</span></span> <span class="value">{{ subrequests_time }} <span class="unit">ms</span></span>