Commit 5844c8d4d76abf25409ee1ae2253e2928c9957bf
1 parent
2e0277e25c
Exists in
master
dashboard jadi runtime-info
Showing 3 changed files with 16 additions and 39 deletions Side-by-side Diff
index.js
... | ... | @@ -171,8 +171,8 @@ function renderConfigAskDelete(req, res) { |
171 | 171 | }); |
172 | 172 | } |
173 | 173 | |
174 | -function renderDashboardIndex(req, res) { | |
175 | - var template = "dashboard.index.html"; | |
174 | +function renderRuntimeInfo(req, res) { | |
175 | + var template = "runtime-info.html"; | |
176 | 176 | |
177 | 177 | var os_info = { |
178 | 178 | uptime: os.uptime(), |
... | ... | @@ -185,13 +185,21 @@ function renderDashboardIndex(req, res) { |
185 | 185 | totalmem: os.totalmem(), |
186 | 186 | } |
187 | 187 | |
188 | + var pendings; | |
189 | + try { | |
190 | + pendings = JSON.stringify(aaa.getPendingList(), null, 2); | |
191 | + } | |
192 | + catch(err) { | |
193 | + pendings = "{}"; | |
194 | + } | |
195 | + | |
188 | 196 | res.render(template, { |
189 | 197 | gateway_name: config.globals.gateway_name, |
190 | - title: 'Dashboard', | |
198 | + title: 'Runtime Info', | |
191 | 199 | matrix: JSON.stringify(matrix, null, 2), |
192 | 200 | config: JSON.stringify(config, null, 2), |
193 | 201 | nodejs_versions: JSON.stringify(process.versions, null, 2), |
194 | - pendings: JSON.stringify(aaa.getPendingList(), null, 2), | |
202 | + pendings: pendings, | |
195 | 203 | memory_usage: JSON.stringify(process.memoryUsage(), null, 2), |
196 | 204 | uptime: process.uptime(), |
197 | 205 | os_info: JSON.stringify(os_info, null, 2), |
... | ... | @@ -268,10 +276,10 @@ function createServer() { |
268 | 276 | done(null, user); |
269 | 277 | }); |
270 | 278 | |
271 | - app.get('/', loggedIn, function(req, res) { res.redirect('/dashboard'); }); | |
279 | + app.get('/', loggedIn, function(req, res) { res.redirect('/runtime-info'); }); | |
272 | 280 | app.get('/config', loggedIn, renderConfigIndex); |
273 | 281 | app.get('/login', renderLoginPage); |
274 | - app.post('/login', passport.authenticate('local', { successRedirect: '/dashboard', failureRedirect: '/login' })); | |
282 | + app.post('/login', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login' })); | |
275 | 283 | app.get('/logout', function(req, res){ |
276 | 284 | req.logout(); |
277 | 285 | res.redirect('/login'); |
... | ... | @@ -302,7 +310,7 @@ function createServer() { |
302 | 310 | app.get('/resume', loggedIn, submitResume); |
303 | 311 | app.get('/terminate', loggedIn, submitTerminate); |
304 | 312 | |
305 | - app.get('/dashboard', loggedIn, renderDashboardIndex); | |
313 | + app.get('/runtime-info', loggedIn, renderRuntimeInfo); | |
306 | 314 | |
307 | 315 | var server = app.listen(config.expresso.listen_port, function () { |
308 | 316 | var host = server.address().address; |
views/dashboard.index.html
... | ... | @@ -1,31 +0,0 @@ |
1 | -{% extends "layout-with-topbar.html" %} | |
2 | - | |
3 | -{% block content %} | |
4 | - | |
5 | -<p> | |
6 | - Process uptime: {{ uptime }} seconds | |
7 | -</p> | |
8 | - | |
9 | -<h2 id="matrix">The Matrix</h2> | |
10 | -<pre>{{ matrix }}</pre> | |
11 | - | |
12 | -<h2 id="pendings">Pending Transactions</h2> | |
13 | -<pre>{{ pendings }}</pre> | |
14 | - | |
15 | - | |
16 | -<h2 id="config">Config</h2> | |
17 | -<pre>{{ config }}</pre> | |
18 | - | |
19 | -<h2 id="memory">Memory Usage</h2> | |
20 | -<pre>{{ memory_usage }}</pre> | |
21 | - | |
22 | -<h2 id="nodejs_versions">Node.js Versions</h2> | |
23 | -<pre>{{ nodejs_versions }}</pre> | |
24 | - | |
25 | -<h2 id="os_info">OS</h2> | |
26 | -<pre>{{ os_info }}</pre> | |
27 | - | |
28 | -<h2 id="net_iface">Network Interfaces</h2> | |
29 | -<pre>{{ net_ifaces }}</pre> | |
30 | - | |
31 | -{% endblock %} |
views/layout-with-topbar.html
... | ... | @@ -40,8 +40,8 @@ |
40 | 40 | <div id="navbar" class="collapse navbar-collapse"> |
41 | 41 | <ul class="nav navbar-nav"> |
42 | 42 | <li><a href="/">Home</a></li> |
43 | - <li><a href="/dashboard">Dashboard</a></li> | |
44 | 43 | <li><a href="/config">Config</a></li> |
44 | + <li><a href="/runtime-info">Runtime</a></li> | |
45 | 45 | <li><a href="/logout">Logout</a></li> |
46 | 46 | </ul> |
47 | 47 | </div><!--/.nav-collapse --> |