Fix the Servers page failing when no servers are configured
An empty server list was sent as null, so the page threw on .length and showed only the loading placeholder. The API now always returns a list, the page tolerates null, and tests cover the empty config and the token. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f01c6213f
commit
4afbf2d266
4 files changed
+78
-3
No files matched your search
+2
-2
@@ -450,9 +450,9 @@ views.servers = async () => {
|
||||
S.headerAction = ['Add server', () => serverDialog()];
|
||||
const t = ov.totals;
|
||||
const totals = h('div', {class:'grid'}, stat('Connected now', t.active), stat('Connections since start', t.total), stat('Turned away', t.rejected), stat('Unknown address', t.unknown_host), stat('Running for', uptime(t.uptime_secs)));
|
||||
if (!ov.servers.length) return h('div', {}, totals, emptyState('servers', 'No servers yet', 'Add a server to start routing players. Each one needs an address players type and a backend to send them to.',
|
||||
if (!(ov.servers || []).length) return h('div', {}, totals, emptyState('servers', 'No servers yet', 'Add a server to start routing players. Each one needs an address players type and a backend to send them to.',
|
||||
h('button', {class:'btn', onclick:() => serverDialog()}, 'Add server')));
|
||||
const rows = ov.servers.map(s => {
|
||||
const rows = (ov.servers || []).map(s => {
|
||||
const hl = s.health, st = s.stats || {};
|
||||
const status = !hl ? badge('Checking') : hl.up ? badge('Online', 'success') : badge('Offline', 'danger');
|
||||
const backend = h('td', {}, s.addresses.map(a => h('div', {class:'mono'}, a)),
|
||||
|
||||
Reference in new issue
Block a user