Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added admin features #64

Merged
merged 11 commits into from
Dec 26, 2019
Prev Previous commit
Next Next commit
Better handle console data
  • Loading branch information
antoniomika committed Dec 25, 2019
commit 5027801f1128f7d7556ce80e759b17fc2311ba2f
28 changes: 8 additions & 20 deletions templates/console.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ define "console" }}
{{ template "header" .}}
<div class="row">
<div class="col">
<div class="col-md-6">
<table id="request-table" class="table table-hover">
<thead class="thead-dark">
<tr>
Expand All @@ -16,7 +16,7 @@
</table>
</div>

<div class="col">
<div class="col-md-6">
<div class="row">
<h2 id="request-info-h2">Request Info</h2>
<div class="container">
Expand Down Expand Up @@ -73,32 +73,20 @@

var requestData = $(this).data("request-data");

$("#requestHeaders").html(`
<pre><code>${JSON.stringify(requestData.requestHeaders, null, 4)}</code></pre>
`);
$("#requestHeaders").html($("<pre/>").addClass("pre-scrollable").text(JSON.stringify(requestData.requestHeaders, null, 4))[0].outerHTML);

if ("Content-Type" in requestData.requestHeaders && requestData.requestHeaders["Content-Type"][0] == "application/json") {
$("#requestBody").html(`
<pre><code>${JSON.stringify(JSON.parse(atob(requestData.requestBody)), null, 4)}</code></pre>
`);
$("#requestBody").html($("<pre/>").addClass("pre-scrollable").text(JSON.stringify(JSON.parse(atob(requestData.requestBody)), null, 4))[0].outerHTML);
} else {
$("#requestBody").html(`
<pre><code>${atob(requestData.requestBody)}</code></pre>
`);
$("#requestBody").html($("<pre/>").addClass("pre-scrollable").text(atob(requestData.requestBody))[0].outerHTML);
}

$("#responseHeaders").html(`
<pre><code>${JSON.stringify(requestData.responseHeaders, null, 4)}</code></pre>
`);
$("#responseHeaders").html($("<pre/>").addClass("pre-scrollable").text(JSON.stringify(requestData.responseHeaders, null, 4))[0].outerHTML);

if ("Content-Type" in requestData.responseHeaders && requestData.responseHeaders["Content-Type"][0] == "application/json") {
$("#responseBody").html(`
<pre><code>${JSON.stringify(JSON.parse(atob(requestData.responseBody)), null, 4)}</code></pre>
`);
$("#responseBody").html($("<pre/>").addClass("pre-scrollable").text(JSON.stringify(JSON.parse(atob(requestData.responseBody)), null, 4))[0].outerHTML);
} else {
$("#responseBody").html(`
<pre><code>${atob(requestData.responseBody)}</code></pre>
`);
$("#responseBody").html($("<pre/>").addClass("pre-scrollable").text(atob(requestData.responseBody))[0].outerHTML);
}

$("#request-info-h2").text(`
Expand Down