Browse Source

Add error handling to listing page

pm2
Luke Childs 8 years ago
parent
commit
f81bd4d0c2
  1. 12
      viewModels/listing.js
  2. 56
      views/listing.html

12
viewModels/listing.js

@ -14,8 +14,12 @@ module.exports = (req, res) => {
query.running = true;
}
tor.listNodes(query).then(nodes => res.render('listing.html', {
title: title,
nodes: nodes
}));
tor.listNodes(query)
.then(nodes => res.render('listing.html', {
title: title,
nodes: nodes
}))
.catch(error => res.render('listing.html', {
error: error
}));
}

56
views/listing.html

@ -1,29 +1,35 @@
{% extends 'index.html' %}
{% block main %}
<h2>{{ title }}</h2>
<table>
<thead>
<tr>
<th>Nickname</th>
<th>Bandwidth</th>
<th>Uptime</th>
<th>Country</th>
<th>Flags</th>
<th>Type</th>
</tr>
</thead>
<tbody>
{% for node in nodes %}
<tr>
<td><a href="/node/{{ node.fingerprint if node.fingerprint else node.hashed_fingerprint }}">{{ node.nickname }}</a></td>
<td>{{ node | bandwidth }}</td>
<td>{{ node | uptime }}</td>
<td>{{ node.country_name }}</td>
<td>{{ node.flags | join(', ') }}</td>
<td>{{ node.type | title }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if error %}
<h2>{{ error.statusMessage }}</h2>
{% else %}
<h2>{{ title }}</h2>
<table>
<thead>
<tr>
<th>Nickname</th>
<th>Bandwidth</th>
<th>Uptime</th>
<th>Country</th>
<th>Flags</th>
<th>Type</th>
</tr>
</thead>
<tbody>
{% for node in nodes %}
<tr>
<td><a href="/node/{{ node.fingerprint if node.fingerprint else node.hashed_fingerprint }}">{{ node.nickname }}</a></td>
<td>{{ node | bandwidth }}</td>
<td>{{ node | uptime }}</td>
<td>{{ node.country_name }}</td>
<td>{{ node.flags | join(', ') }}</td>
<td>{{ node.type | title }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock %}

Loading…
Cancel
Save