feat: Add documentation and Sites status dashboard page
This commit is contained in:
@@ -145,6 +145,45 @@ router.get('/token', function(req, res, next) {
|
||||
res.render('token', {...values});
|
||||
});
|
||||
|
||||
router.get('/sites', async function(req, res, next) {
|
||||
const net = require('net');
|
||||
const url = require('url');
|
||||
|
||||
const myId = process.env.LDAP_SERVER_ID || 'Standalone';
|
||||
const hostsStr = process.env.LDAP_REPLICATION_HOSTS || '';
|
||||
const hosts = hostsStr.split(' ').filter(h => h);
|
||||
|
||||
const sites = await Promise.all(hosts.map(hostUrl => {
|
||||
return new Promise((resolve) => {
|
||||
try {
|
||||
const u = new url.URL(hostUrl);
|
||||
const port = u.port || (u.protocol === 'ldaps:' ? 636 : 389);
|
||||
const hostname = u.hostname;
|
||||
const socket = new net.Socket();
|
||||
socket.setTimeout(2000);
|
||||
|
||||
socket.on('connect', () => {
|
||||
socket.destroy();
|
||||
resolve({ url: hostUrl, status: 'Online' });
|
||||
});
|
||||
socket.on('timeout', () => {
|
||||
socket.destroy();
|
||||
resolve({ url: hostUrl, status: 'Offline (Timeout)' });
|
||||
});
|
||||
socket.on('error', (err) => {
|
||||
socket.destroy();
|
||||
resolve({ url: hostUrl, status: 'Offline (' + err.code + ')' });
|
||||
});
|
||||
socket.connect(port, hostname);
|
||||
} catch (e) {
|
||||
resolve({ url: hostUrl, status: 'Invalid URL' });
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
res.render('sites', { ...values, myId, sites });
|
||||
});
|
||||
|
||||
|
||||
router.get('/login/resetpassword/:token', async function(req, res, next){
|
||||
let token = await PasswordResetToken.get(req.params.token);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<%- include('header') %>
|
||||
|
||||
<div class="container-fluid" style="margin-top: 80px;">
|
||||
<div class="row">
|
||||
<div class="col-md-8 offset-md-2">
|
||||
<div class="card shadow-lg mb-4">
|
||||
<div class="card-header">
|
||||
<i class="fa-solid fa-network-wired"></i> Sites & Replication
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="mb-4">
|
||||
This page shows the status of Multi-Master LDAP replication peers.
|
||||
<br/>Your Server ID: <strong><%= myId %></strong>
|
||||
</p>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Site LDAP URL</th>
|
||||
<th>Replication Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if (sites.length === 0) { %>
|
||||
<tr>
|
||||
<td colspan="2" class="text-center text-muted">No replication peers configured in environment (LDAP_REPLICATION_HOSTS is empty).</td>
|
||||
</tr>
|
||||
<% } else { %>
|
||||
<% sites.forEach(function(site) { %>
|
||||
<tr>
|
||||
<td class="align-middle"><strong><%= site.url %></strong></td>
|
||||
<td class="align-middle">
|
||||
<% if (site.status === 'Online') { %>
|
||||
<span class="badge bg-success"><i class="fa-solid fa-circle-check"></i> Online</span>
|
||||
<% } else { %>
|
||||
<span class="badge bg-danger"><i class="fa-solid fa-circle-xmark"></i> <%= site.status %></span>
|
||||
<% } %>
|
||||
</td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
<% } %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%- include('footer') %>
|
||||
@@ -56,6 +56,12 @@
|
||||
Invites
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item group-required group-required-app_sso_admin">
|
||||
<a class="nav-link" href="/sites">
|
||||
<i class="fa-solid fa-network-wired"></i>
|
||||
Sites
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item group-required group-required-app_sso_admin">
|
||||
<a class="nav-link" href="/dashboard">
|
||||
<i class="fa-solid fa-gauge-high"></i>
|
||||
|
||||
Reference in New Issue
Block a user