Add display cURL on the web debug queries shower

This commit is contained in:
Damien Alexandre 2013-12-09 10:09:36 +01:00
parent a227a3f076
commit c97a4abceb

View file

@ -41,7 +41,7 @@
</p>
{% else %}
<ul class="alt">
{% for query in collector.queries %}
{% for key, query in collector.queries %}
<li class="{{ cycle(['odd', 'even'], loop.index) }}">
<strong>Path</strong>: {{ query.path }}<br />
<strong>Method</strong>: {{ query.method }}
@ -51,8 +51,41 @@
<small>
<strong>Time</strong>: {{ '%0.2f'|format(query.executionMS * 1000) }} ms
</small>
<a href="#elastica_curl_query_{{ key }}" onclick="return curl_version(this);" style="text-decoration: none;" title="Get the cURL repeatable query">
<img alt="+" src="{{ asset('bundles/framework/images/blue_picto_more.gif') }}" style="display: inline; width: 12px; height: 12px; vertical-align: bottom;" />
<img alt="-" src="{{ asset('bundles/framework/images/blue_picto_less.gif') }}" style="display: none; width: 12px; height: 12px; vertical-align: bottom;" />
<small>Display cURL query</small>
</a>
<div style="display: none;" id="elastica_curl_query_{{ key }}">
<code>curl -X{{ query.method }} 'http://localhost:9200/{{ query.path }}' -d '{{ query.data|json_encode }}'</code>
</div>
</li>
{% endfor %}
</ul>
<script type="text/javascript">//<![CDATA[
function curl_version(link) {
"use strict";
var sections = link.children;
if (sections[0].style.display != 'none') {
sections[0].style.display = 'none';
sections[1].style.display = 'inline';
document.getElementById(link.hash.replace("#", "")).style.display = 'block';
} else {
sections[0].style.display = 'inline';
sections[1].style.display = 'none';
//sections[3].style.display = 'none';
document.getElementById(link.hash.replace("#", "")).style.display = 'none';
}
return false;
}
</script>
{% endif %}
{% endblock %}