diff --git a/views/browser.pug b/views/rpc-browser.pug similarity index 100% rename from views/browser.pug rename to views/rpc-browser.pug diff --git a/views/rpc-terminal.pug b/views/rpc-terminal.pug new file mode 100644 index 0000000..fe53646 --- /dev/null +++ b/views/rpc-terminal.pug @@ -0,0 +1,68 @@ +extends layout + +block headContent + title RPC Terminal + +block content + div.row + div.col + h1.h3 RPC Terminal + + div.col + if (!config.demoSite && (!config.credentials.rpc || !config.credentials.rpc.rpc)) + span(style="float: right;") + a.btn.btn-secondary(href="/disconnect") Disconnect from node + + hr + + :markdown-it + Use this interactive terminal to send RPC commands to your node. Results will be shown inline. To browse all available RPC commands you can use the [RPC Browser](/rpc-browser). + + div.card.shadow-sm.mb-3 + div.card-body + form(id="terminal-form") + div.form-group + label(for="input-cmd") Command + input.form-control(type="text", id="input-cmd", name="cmd") + + input.btn.btn-primary.btn-block(type="submit", value="Send") + + hr + + div(id="terminal-output") + +block endOfBody + script. + var csrfToken = $('meta[name=csrf-token]').attr('content'); + + $(document).ready(function() { + $("#terminal-form").submit(function(e) { + e.preventDefault(); + + var cmd = $("#input-cmd").val() + + var postData = {}; + postData.cmd = cmd; + postData._csrf = csrfToken; + + $.post( + "/rpc-terminal", + postData, + function(response, textStatus, jqXHR) { + var t = new Date().getTime(); + + $("#terminal-output").prepend("
" + cmd + "
" + response + "
"); + console.log(response); + + $("#output-" + t + " pre code").each(function(i, block) { + hljs.highlightBlock(block); + }); + + return false; + }) + .done(function(data) { + }); + + return false; + }); + }); \ No newline at end of file diff --git a/views/terminal.pug b/views/terminal.pug index fe53646..e65e5c4 100644 --- a/views/terminal.pug +++ b/views/terminal.pug @@ -1,17 +1,12 @@ extends layout block headContent - title RPC Terminal + title Terminal block content div.row div.col - h1.h3 RPC Terminal - - div.col - if (!config.demoSite && (!config.credentials.rpc || !config.credentials.rpc.rpc)) - span(style="float: right;") - a.btn.btn-secondary(href="/disconnect") Disconnect from node + h1.h3 Terminal hr @@ -46,7 +41,7 @@ block endOfBody postData._csrf = csrfToken; $.post( - "/rpc-terminal", + "/terminal", postData, function(response, textStatus, jqXHR) { var t = new Date().getTime();