Skip to content

Commit

Permalink
Organizes textArea to the json expanded format
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelgfirmino authored and Florian Preusner committed Jul 22, 2016
1 parent 5f6c108 commit cc996ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
9 changes: 6 additions & 3 deletions Resources/public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,21 @@
}

#guzzle_profiler textarea {
background-color: #404040;
background-color: #222;
border: 1px solid #636363;
border-radius: 6px;
min-height: 100px;
max-height: 250px;
width: 100%;

overflow: auto;
color: #EBEBEB;
line-height: 1.2em;
font: 12px Menlo, Monaco, Consolas, monospace;
white-space: pre-wrap;
word-wrap: break-word;
width:100%;
max-height:90%;
resize: vertical;

}

#guzzle_profiler .request {
Expand Down
38 changes: 27 additions & 11 deletions Resources/views/profiler.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
</p>
{% else %}

<div id="guzzle_profiler">
<div id="guzzle_profiler">

{% set firstRequest = false %}
{% set firstRequest = false %}

{% for group in collector.logs %}
{% for group in collector.logs %}

<h2>Group {{ group.requestName }}</h2>
<h2>Group {{ group.requestName }}</h2>

{% for i, message in group.messages %}

Expand Down Expand Up @@ -50,7 +50,7 @@
<tr>
<th>Body</th>
<td>
<textarea>{{ message.request.body }}</textarea>
<textarea readonly id="requestBody">{{ message.request.body }}</textarea>
</td>
</tr>
</table>
Expand All @@ -71,7 +71,7 @@
<tr>
<th>Body</th>
<td>
<textarea>{{ message.response.body }}</textarea>
<textarea readonly id="responseBody">{{ message.response.body }}</textarea>
</td>
</tr>
</table>
Expand All @@ -80,18 +80,34 @@
</div>

<script>
$("#request_{{ i }} h3 a").click(function() {
$("#request_{{ i }} h3 a").click(function () {
$("#request_{{ i }} .content").toggle("fast");
});
var requestBody = $('#requestBody');
requestBody.val(formatJson(requestBody.val()));
var responseBody = $('#responseBody');
responseBody.val(formatJson(responseBody.val()));
function formatJson(json) {
if (json) {
try{
return JSON.stringify(JSON.parse(json), null, 2);
}catch(error){
//different formats json ex: xml
}
}
}
</script>

{% set firstRequest = true %}
{% else %}
{% set firstRequest = true %}
{% else %}

<p>No Calls</p>
{% endfor %}
{% endfor %}
{% endfor %}

</div>
</div>

{% endif %}

0 comments on commit cc996ac

Please sign in to comment.