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

Taffy API Response Dump #440

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dashboard/asset.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<cfcontent type="image/gif" file="#expandPath('./loading.gif')#" reset="true" /><cfabort />
</cfcase>

<cfcase value="jquery.dump.min.js">
<cfcontent type="text/javascript" file="#expandPath('./jquery.dump.min.js')#" reset="true" /><cfabort />
</cfcase>

<cfdefaultcase>
<cfheader statuscode="404" statustext="Not Found" />
<cfcontent reset="true" /><cfabort />
Expand Down
4 changes: 3 additions & 1 deletion dashboard/dash.css

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion dashboard/dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ $(function(){
submit.removeAttr('disabled');
reset.show();
headers = parseHeaders(headers);
resource.data("jsondata", "");

if (headers['content-type'].indexOf('application/json') > -1 || headers['content-type'].indexOf('text/json') > -1 || headers['content-type'].indexOf('application/vnd.api+json') > -1){
//indentation!
if (body.length){
resource.data("jsondata", JSON.parse(body));
body = JSON.stringify(JSON.parse(body), null, 3);
// only do syntax highlighting if hljs is defined
if (typeof hljs === 'undefined') {
Expand Down Expand Up @@ -166,13 +168,30 @@ $(function(){
headerRow.append('<div class="row"><div class="col-md-5 headerName">' + sortable[h] + ':</div><div class="col-md-7 headerVal">' + headers[sortable[h]] + '</div></div>');
}

response.find('.responseTime').html('Request took ' + timeSpent + 'ms');
// only display dump button if jQuery dump is available
var renderBtn = "";
if (typeof $.dump === "undefined") {
/* nothing */
} else if (resource.data("jsondata")){
renderBtn = "<span class=\"dumpBtn label label-default\" style=\"cursor:pointer;\">CLICK TO DUMP</span> ";
}

response.find('.responseTime').html(renderBtn + 'Request took ' + timeSpent + 'ms');
response.find('.responseStatus').html(status);
response.find('.responseBody').html(body);
});

});

$("body").on("click", ".dumpBtn", function(e){
var data = $(this).closest(".resource").data("jsondata") || 0;
if (data){
$.dump(data, false, true, true);
} else {
alert("Unable to dump API response");
}
});

$(".resetRequest").click(function(){
var reset = $(this)
,resource = reset.closest('.resource')
Expand Down
3 changes: 2 additions & 1 deletion dashboard/dashboard.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<head>
<title>Taffy Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="https://fav.farm/🍬" />
<style>
<cfinclude template="dash.css" />
<cfinclude template="highlight-github.min.css" />
</style>
<link id="favicon" rel="shortcut icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAACHDwAAjA8AAP1SAACBQAAAfXkAAOmLAAA85QAAGcxzPIV3AAAB+1BMVEUAAAAAEACPyWiKxWJ0v0L///8iiBT//3b//3UsmgVdjD1hty1LZzk5pg6225L///cOIASFx1d4t012wERknj2AxFJppEF7vk1fkD9kpDo/TjV/vlJQejRpujoANQB3qlMEBAVyt0QnPRtnoUEAAQBamzEtOihwp0xsoUmHxV2Dv1sAAADF46693KYpmAJXsyBQsBkAaQB/v1ff7tLs9OPR6L2Ww3dAeBwAhgCk1H3I46vJ46zF4qa32Zapzovb6s3M3b2Ao2iUzWrN5bHT57maxnlulFVzv0HH5avK4q5vs0IAjwCw247O5bKn0YN9xk/T4rbG36lTmyZxvELN4bC916FMhiio14fR5LeGsGd2vEnP3rGhx4UrXQ+q1ouk0IPW2be50Jtejz8nkQCu15Dl8djk8NmnzYyWwnmky4mu0ZOlyYlzn1VdnDORuHW1z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HQAMTkyQF1xVQAAABd0RVh0VGh1bWI6OkltYWdlOjpXaWR0aAAxOTLTrCEIAAAAGXRFWHRUaHVtYjo6TWltZXR5cGUAaW1hZ2UvcG5nP7JWTgAAABd0RVh0VGh1bWI6Ok1UaW1lADE2NDc1NTUzMDYHNLqKAAAAD3RFWHRUaHVtYjo6U2l6ZQAwQkKUoj7sAAAAVnRFWHRUaHVtYjo6VVJJAGZpbGU6Ly8vbW50bG9nL2Zhdmljb25zLzIwMjItMDMtMTcvMDNkZmIyNWFhY2ZlYTZjMWFiYzZmY2M3OGRiYTc0YTcuaWNvLnBuZzW4WyQAAAAASUVORK5CYII=">
</head>
<body>
<script>
Expand Down Expand Up @@ -525,6 +525,7 @@
<cfinclude template="bootstrap.min.js" />
<cfinclude template="highlight.min.js" />
<cfinclude template="dash.js" />
<cfinclude template="jquery.dump.min.js" />

$(function(){
hljs.initHighlighting();
Expand Down
2 changes: 2 additions & 0 deletions dashboard/jquery.dump.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading