diff --git a/index.js b/index.js index f2d0d98..c98131c 100644 --- a/index.js +++ b/index.js @@ -95,8 +95,9 @@ function submitResume(req, res) { } function submitTerminate(req, res) { - res.end('Terminating....'); - process.exit(); + res.end('Terminating....', function() { + setTimeout(process.exit, 2 * 1000); + }); } function submitConfigEdit(req, res) { @@ -179,6 +180,14 @@ function renderConfigAskDelete(req, res) { }); } +function renderAskTerminate(req, res) { + res.render('ask.terminate.html', { + gateway_name: config.globals.gateway_name, + title: 'Konfirmasi Terminasi' + }); +} + + function renderRuntimeInfo(req, res) { var template = "runtime-info.html"; @@ -318,6 +327,7 @@ function createServer() { app.get('/pause', loggedIn, submitPause); app.get('/resume', loggedIn, submitResume); app.get('/terminate', loggedIn, submitTerminate); + app.get('/ask-terminate', loggedIn, renderAskTerminate); app.get('/runtime-info', loggedIn, renderRuntimeInfo); diff --git a/views/ask.terminate.html b/views/ask.terminate.html new file mode 100644 index 0000000..9e5d29c --- /dev/null +++ b/views/ask.terminate.html @@ -0,0 +1,15 @@ +{% extends "layout-with-topbar.html" %} + +{% block content %} + +Yakin ingin terminasi gateway? + +<br/><br/> + +<a class="btn btn-danger" href="/terminate" role="button"> + Terminasi</a> + +<a class="btn btn-default" href="/dashboard" role="button"> + Batal</a> + +{% endblock %} diff --git a/views/dashboard.html b/views/dashboard.html new file mode 100644 index 0000000..aa4ea6f --- /dev/null +++ b/views/dashboard.html @@ -0,0 +1,51 @@ +{% extends "layout-with-topbar.html" %} + +{% block content %} + +<div id="paused-or-running" class="panel panel-default"> + + <div class="panel-heading"> + <h3>Pause and Resume</h3> + </div> + + <div class="panel-body"> + {% if config.globals.pause %} + + + <p> System paused. Click the button to resume it.</p> + + <p> + <a href="/resume" class="btn btn-primary">Resume</a> + </p> + + + {% else %} + + <p> System is running. Click the button to pause it</p> + + <div class="pull-right"> + <a href="/pause" class="btn btn-primary">Pause</a> + </div> + + {% endif %} + </div> + +</div> + +<div id="terminate" class="panel panel-default"> + + <div class="panel-heading"> + <h3>Process Termination</h3> + </div> + + <div class="panel-body"> + <p>Click the button to terminate (or restart) the gateway.</p> + + <div class="pull-right"> + <a href="/ask-terminate" class="btn btn-danger">Terminate / Restart</a> + </div> + </div> + +</div> + +{% endblock %} diff --git a/views/runtime-info.html b/views/runtime-info.html new file mode 100644 index 0000000..f4b8a48 --- /dev/null +++ b/views/runtime-info.html @@ -0,0 +1,31 @@ +{% extends "layout-with-topbar.html" %} + +{% block content %} + +<p> + Process uptime: {{ uptime }} seconds +</p> + +<h2 id="matrix">The Matrix</h2> +<pre>{{ matrix }}</pre> + +<h2 id="pendings">Pending Transactions</h2> +<pre>{{ pendings }}</pre> + + +<h2 id="config">Config</h2> +<pre>{{ config }}</pre> + +<h2 id="memory">Memory Usage</h2> +<pre>{{ memory_usage }}</pre> + +<h2 id="nodejs_versions">Node.js Versions</h2> +<pre>{{ nodejs_versions }}</pre> + +<h2 id="os_info">OS</h2> +<pre>{{ os_info }}</pre> + +<h2 id="net_iface">Network Interfaces</h2> +<pre>{{ net_ifaces }}</pre> + +{% endblock %}