Files
jump-host/nodejs/views/audit.ejs
T
wmantly 0ef451e15d Match page width to sso-manager-node; gate Audit nav to admins
- Dashboard, Sessions, and Audit pages now wrap their content in
  <div class="container mt-4">, matching sso-manager-node/proxy's width
  instead of rendering full-bleed inside the fluid shell.
- Audit's nav entry now carries groups: ['admin'] (utils/ui.js), reusing
  the existing synthetic-admin-group nav-gating convention -- the API
  route was already server-side admin-gated, this closes the last gap by
  hiding the nav link/page for non-admins too.
- app-base.js (byte-identical across the 3 apps): added
  app.util.revealItem() and the --sw-content-offset sticky-positioning
  variable, carried over from the same round of changes in
  sso-manager-node/proxy. Not yet called anywhere in this app -- no
  sticky/reveal use case here yet -- but keeps the shared file in sync.
2026-07-29 22:20:56 -04:00

65 lines
3.0 KiB
Plaintext

<%- include('top') %>
<script type="text/javascript">app.auth.forceLogin();</script>
<div class="container mt-4">
<div class="card shadow-sm">
<div class="card-header"><i class="fa-solid fa-clipboard-list me-1"></i> Audit log</div>
<div class="card-body pb-0">
<form class="row g-2 mb-2" onsubmit="applyFilters(); return false;">
<div class="col-auto"><input class="form-control form-control-sm" id="f-uid" placeholder="user"></div>
<div class="col-auto"><input class="form-control form-control-sm" id="f-target" placeholder="target"></div>
<div class="col-auto">
<select class="form-select form-select-sm" id="f-status">
<option value="">any result</option>
<option value="success">success</option>
<option value="fail">fail</option>
</select>
</div>
<div class="col-auto"><button class="btn btn-sm btn-primary">Filter</button></div>
</form>
</div>
<div class="table-responsive">
<table class="table table-striped table-sm mb-0">
<thead><tr><th>Time</th><th>User</th><th>Method</th><th>Mode</th><th>Target</th><th>Chan</th><th>Client</th><th>Result</th><th class="text-end">Bytes</th></tr></thead>
<tbody id="audit-body"></tbody>
</table>
</div>
<div class="card-footer d-flex justify-content-between align-items-center">
<button class="btn btn-sm btn-outline-secondary" id="prev" onclick="changePage(-1)">&larr; prev</button>
<span class="text-muted small" id="page-info"></span>
<button class="btn btn-sm btn-outline-secondary" id="next" onclick="changePage(1)">next &rarr;</button>
</div>
</div>
</div>
<script type="text/javascript">
var page = 0;
function filters(){ return {page: page, uid: $('#f-uid').val(), target: $('#f-target').val(), status: $('#f-status').val()}; }
function applyFilters(){ page = 0; load(); }
function changePage(d){ page = Math.max(0, page + d); load(); }
function load(){
app.jump.audit(filters(), function(error, data){
var $b = $('#audit-body').empty();
if(error || !data || !data.results.length){ $b.append('<tr><td colspan="9" class="text-muted">No events.</td></tr>'); }
else data.results.forEach(function(e){
$b.append('<tr class="' + (e.success ? '' : 'table-danger') + '">' +
'<td>' + app.jump.fmtTime(e.ts) + '</td>' +
'<td>' + app.jump.esc(e.uid) + '</td>' +
'<td>' + app.jump.esc(e.authMethod) + '</td>' +
'<td>' + app.jump.esc(e.mode) + '</td>' +
'<td>' + app.jump.esc(e.targetSlug || e.targetAddr || '—') + '</td>' +
'<td>' + app.jump.esc(e.channel || '—') + '</td>' +
'<td>' + app.jump.esc(e.clientIp) + '</td>' +
'<td>' + app.jump.result(e) + '</td>' +
'<td class="text-end">' + ((e.bytesIn + e.bytesOut) || 0) + '</td></tr>');
});
var total = data ? data.total : 0, size = data ? data.pageSize : 50;
$('#page-info').text(total + ' events · page ' + (page + 1));
$('#prev').prop('disabled', page === 0);
$('#next').prop('disabled', (page + 1) * size >= total);
});
}
$(document).ready(load);
</script>
<%- include('bottom') %>