Add audited admin player item and title management

This commit is contained in:
dingo
2026-09-08 07:20:18 -04:00
parent ed55cd23ab
commit ece92fa65c
15 changed files with 512 additions and 8 deletions
+6 -1
View File
@@ -2,6 +2,7 @@ import './portal.css';
import { permanentTitles, progressionSummary } from './progression';
import { statsBreakdown, equipmentDetails } from './character-stats';
import { showCatalog, hasCatalogDraft } from './content-editor';
import { playerContent } from './player-content';
import { $, api, APIError, badge, cell, date, el, gameURL, icons, icon, table, type Command, type RecordCharacter, type World } from './portal-shared';
type Data = { worlds: World[]; characters: RecordCharacter[]; commands: Command[]; provisioningEnabled: boolean; characterLimit: number; auditLimit: number };
@@ -11,6 +12,7 @@ let tab = 'worlds';
let busy = false;
let draft: Draft;
const labels: Record<string, string> = { 'create-world': 'New world', 'close-admissions': 'Close arrivals', 'open-admissions': 'Open arrivals', 'awaken-boss': 'Awaken Harbinger', 'end-world': 'End world permanently', rename: 'Rename character', heal: 'Restore health', unstuck: 'Return to sanctuary', retire: 'Retire character permanently', 'revoke-sessions': 'Revoke account sessions' };
Object.assign(labels, { 'grant-item':'Add item', 'remove-item':'Remove item', 'grant-title':'Add / restore title', 'revoke-title':'Remove title' });
function notify(message: string) { $('control-message').textContent = message; $('control-message').hidden = false; }
function openCommand(op: string, worldId = '', target = '', value = '') {
draft = { id: crypto.randomUUID(), worldId, op, target, value };
@@ -43,6 +45,9 @@ function actions(world: string, options: string[], target = '', value = '', disa
function detail(r: RecordCharacter) {
$('detail-name').textContent = r.name;
const parent = $('character-detail'); parent.replaceChildren();
parent.append(playerContent(r,['alive','eligible'].includes(r.state)&&!!data.worlds.find(w=>w.id===r.worldId)?.available,()=>{
$<HTMLDialogElement>('character-dialog').close();notify('Player change queued. The audit log records its result.');void refresh();
}));
const list = el('dl', '', 'details'); const v = r.character.view;
const pairs: [string, string][] = [['Character ID', r.id], ['Account ID', r.account], ['World', r.worldId], ['State', r.state], ['Health', `${v.entity.hp} / ${v.entity.maxHp}`], ['Position', `${Math.round(v.entity.position.x)}, ${Math.round(v.entity.position.y)}, ${Math.round(v.entity.position.z)}`], ['Played today', `${Math.floor(r.character.dailySeconds / 60)} min`], ['Born', date(r.character.bornAt)], ['Died', r.character.diedAt ? date(r.character.diedAt) : '-'], ['Cause', r.character.deathReason || '-']];
for (const [key,value] of pairs) list.append(el('dt', key), el('dd', value)); parent.append(list);
@@ -81,7 +86,7 @@ function render() {
} else {
const { node, body } = table(['Requested', 'Action', 'World / target', 'Status', 'Reason / result']);
for (const c of data.commands.filter(c => matches([c.id,c.actor,c.op,c.target,c.reason,c.result], c.worldId === '_provision' ? c.target : c.worldId,c.status))) {
const row = body.insertRow(); cell(row, date(c.createdAt)); const op = el('div', labels[c.op] || c.op); op.title = `Request ${c.id}\nActor ${c.actor}`; cell(row, op); const target = el('div', c.worldId === '_provision' ? c.target : c.worldId); if (c.target && c.worldId !== '_provision') target.append(el('small', c.target, 'muted block')); cell(row, target); cell(row, badge(c.status)); const reason = el('div', c.reason); if (c.result) reason.append(el('small', c.result, 'muted block')); cell(row, reason); count++;
const row = body.insertRow(); cell(row, date(c.createdAt)); const op = el('div', labels[c.op] || c.op); op.title = `Request ${c.id}\nActor ${c.actor}`; if (['grant-item','remove-item','grant-title','revoke-title'].includes(c.op)) op.append(el('small',c.value,'muted block')); cell(row, op); const target = el('div', c.worldId === '_provision' ? c.target : c.worldId); if (c.target && c.worldId !== '_provision') target.append(el('small', c.target, 'muted block')); cell(row, target); cell(row, badge(c.status)); const reason = el('div', c.reason); if (c.result) reason.append(el('small', c.result, 'muted block')); cell(row, reason); count++;
}
parent.append(node); $('table-note').textContent = `Latest ${data.auditLimit} actions. Completed provisioning means committed to Git; world availability confirms startup.`;
}