Indent JSON on admin screen.
This commit is contained in:
parent
851d3137e5
commit
32c5c7a524
@ -1,7 +1,10 @@
|
|||||||
package webapi
|
package webapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html/template"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -33,3 +36,14 @@ func stripWss(input string) string {
|
|||||||
input = strings.ReplaceAll(input, "/ws", "")
|
input = strings.ReplaceAll(input, "/ws", "")
|
||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func indentJSON(input string) template.HTML {
|
||||||
|
var indented bytes.Buffer
|
||||||
|
err := json.Indent(&indented, []byte(input), "<br/>", " ")
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("Failed to indent JSON: %w", err)
|
||||||
|
return template.HTML(input)
|
||||||
|
}
|
||||||
|
|
||||||
|
return template.HTML(indented.String())
|
||||||
|
}
|
||||||
|
|||||||
@ -117,7 +117,6 @@ footer .code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.block__content table th {
|
.block__content table th {
|
||||||
vertical-align: top;
|
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +127,7 @@ footer .code {
|
|||||||
.ticket-table td {
|
.ticket-table td {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
padding-right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -193,7 +193,7 @@
|
|||||||
<table class="table ticket-table my-2">
|
<table class="table ticket-table my-2">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Request</th>
|
<th>Request</th>
|
||||||
<td>{{ $value.Request }}</td>
|
<td>{{ indentJSON $value.Request }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Request<br />Signature</th>
|
<th>Request<br />Signature</th>
|
||||||
@ -201,7 +201,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Response</th>
|
<th>Response</th>
|
||||||
<td>{{ $value.Response }}</td>
|
<td>{{ indentJSON $value.Response }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Response<br />Signature</th>
|
<th>Response<br />Signature</th>
|
||||||
|
|||||||
@ -182,6 +182,7 @@ func router(debugMode bool, cookieSecret []byte, dcrd rpc.DcrdConnect, wallets r
|
|||||||
"blockURL": blockURL(cfg.BlockExplorerURL),
|
"blockURL": blockURL(cfg.BlockExplorerURL),
|
||||||
"dateTime": dateTime,
|
"dateTime": dateTime,
|
||||||
"stripWss": stripWss,
|
"stripWss": stripWss,
|
||||||
|
"indentJSON": indentJSON,
|
||||||
})
|
})
|
||||||
|
|
||||||
router.LoadHTMLGlob("webapi/templates/*.html")
|
router.LoadHTMLGlob("webapi/templates/*.html")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user