Add agent fields to game management

- DB: renamed console_url to agent_link, added agent_login, agent_password, games_link, agent_guide to platforms table
- api/platforms.php: create/update now handles all 5 agent fields (admin-only)
- admin/index.php: game form has new Agent Info section (purple, admin-only styling); game list cards show all agent fields inline; JS saveGame/editGame/resetGameForm updated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 17:39:48 +00:00
parent 497071e1b7
commit 0aec13daf4
2 changed files with 93 additions and 37 deletions
+66 -18
View File
@@ -793,9 +793,31 @@ tr:hover td{background:rgba(255,255,255,.015)}
<label class="gm-edit-label">Player URL * <span style="font-weight:400;color:var(--text2)">shown to players — opens the game</span></label>
<input class="fi-sm" id="gf-player-url" type="url" placeholder="https://game.example.com/play" style="width:100%;padding:10px 12px">
</div>
<div style="margin-bottom:10px">
<label class="gm-edit-label">Console / Admin URL <span style="font-weight:400;color:var(--text2)">only visible to admins</span></label>
<input class="fi-sm" id="gf-console-url" type="url" placeholder="https://admin.game.example.com" style="width:100%;padding:10px 12px">
<!-- Agent Fields — admin only -->
<div style="background:rgba(155,93,229,0.06);border:1px solid rgba(155,93,229,0.2);border-radius:8px;padding:12px 14px;margin-bottom:10px">
<div style="font-size:12px;font-weight:700;color:var(--purple);letter-spacing:1px;text-transform:uppercase;margin-bottom:10px">🔐 Agent Info — Admin Only</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:10px">
<div>
<label class="gm-edit-label">Agent Login</label>
<input class="fi-sm" id="gf-agent-login" type="text" placeholder="Username or email" style="width:100%;padding:10px 12px">
</div>
<div>
<label class="gm-edit-label">Agent Password</label>
<input class="fi-sm" id="gf-agent-password" type="text" placeholder="Password" style="width:100%;padding:10px 12px">
</div>
</div>
<div style="margin-bottom:10px">
<label class="gm-edit-label">Agent Link <span style="font-weight:400;color:var(--text2)">admin/console URL</span></label>
<input class="fi-sm" id="gf-agent-link" type="url" placeholder="https://admin.game.example.com" style="width:100%;padding:10px 12px">
</div>
<div style="margin-bottom:10px">
<label class="gm-edit-label">Games Link <span style="font-weight:400;color:var(--text2)">game listing or lobby URL</span></label>
<input class="fi-sm" id="gf-games-link" type="url" placeholder="https://game.example.com/lobby" style="width:100%;padding:10px 12px">
</div>
<div>
<label class="gm-edit-label">Agent Guide <span style="font-weight:400;color:var(--text2)">notes, instructions, tips</span></label>
<textarea class="fi-sm" id="gf-agent-guide" rows="3" placeholder="Step-by-step agent instructions, notes, or tips..." style="width:100%;padding:10px 12px;resize:vertical;font-family:inherit;font-size:14px"></textarea>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;margin-bottom:14px">
<div>
@@ -2701,11 +2723,25 @@ async function loadGames() {
<span class="game-url-val">${escHtmlA(g.player_url)}</span>
<a href="${escHtmlA(g.player_url)}" target="_blank" class="game-url-link">↗</a>
</div>
${g.console_url ? `<div class="game-url-row">
<span class="game-url-label" style="color:var(--gold)">CONSOLE</span>
<span class="game-url-val">${escHtmlA(g.console_url)}</span>
<a href="${escHtmlA(g.console_url)}" target="_blank" class="game-url-link" style="color:var(--gold)">↗</a>
${g.agent_link ? `<div class="game-url-row">
<span class="game-url-label" style="color:var(--gold)">AGENT LINK</span>
<span class="game-url-val">${escHtmlA(g.agent_link)}</span>
<a href="${escHtmlA(g.agent_link)}" target="_blank" class="game-url-link" style="color:var(--gold)">↗</a>
</div>` : ''}
${g.games_link ? `<div class="game-url-row">
<span class="game-url-label" style="color:var(--cyan)">GAMES LINK</span>
<span class="game-url-val">${escHtmlA(g.games_link)}</span>
<a href="${escHtmlA(g.games_link)}" target="_blank" class="game-url-link" style="color:var(--cyan)">↗</a>
</div>` : ''}
${g.agent_login ? `<div class="game-url-row">
<span class="game-url-label" style="color:var(--purple)">LOGIN</span>
<span class="game-url-val">${escHtmlA(g.agent_login)}</span>
</div>` : ''}
${g.agent_password ? `<div class="game-url-row">
<span class="game-url-label" style="color:var(--purple)">PASSWORD</span>
<span class="game-url-val">${escHtmlA(g.agent_password)}</span>
</div>` : ''}
${g.agent_guide ? `<div style="margin-top:6px;padding:8px 10px;background:rgba(155,93,229,0.07);border-radius:6px;font-size:12px;color:var(--text2);white-space:pre-wrap;max-height:80px;overflow:auto"><span style="color:var(--purple);font-weight:700;font-size:11px;letter-spacing:1px">AGENT GUIDE </span>${escHtmlA(g.agent_guide)}</div>` : ''}
</div>
</div>
<div style="text-align:right;flex-shrink:0">
@@ -2727,9 +2763,13 @@ function editGame(id) {
document.getElementById('gf-name').value = g.name;
document.getElementById('gf-slug').value = g.slug;
document.getElementById('gf-slug').disabled = true; // slug can't change (used as FK in purchases)
document.getElementById('gf-player-url').value = g.player_url;
document.getElementById('gf-console-url').value= g.console_url || '';
document.getElementById('gf-color').value = g.color || '#f0c040';
document.getElementById('gf-player-url').value = g.player_url;
document.getElementById('gf-agent-link').value = g.agent_link || '';
document.getElementById('gf-agent-login').value = g.agent_login || '';
document.getElementById('gf-agent-password').value= g.agent_password || '';
document.getElementById('gf-games-link').value = g.games_link || '';
document.getElementById('gf-agent-guide').value = g.agent_guide || '';
document.getElementById('gf-color').value = g.color || '#f0c040';
document.getElementById('gf-color-hex').value = g.color || '#f0c040';
document.getElementById('gf-sort').value = g.sort_order;
document.getElementById('gf-active').value = g.is_active;
@@ -2742,9 +2782,13 @@ function resetGameForm() {
document.getElementById('gf-name').value = '';
document.getElementById('gf-slug').value = '';
document.getElementById('gf-slug').disabled = false;
document.getElementById('gf-player-url').value = '';
document.getElementById('gf-console-url').value = '';
document.getElementById('gf-color').value = '#f0c040';
document.getElementById('gf-player-url').value = '';
document.getElementById('gf-agent-link').value = '';
document.getElementById('gf-agent-login').value = '';
document.getElementById('gf-agent-password').value= '';
document.getElementById('gf-games-link').value = '';
document.getElementById('gf-agent-guide').value = '';
document.getElementById('gf-color').value = '#f0c040';
document.getElementById('gf-color-hex').value = '#f0c040';
document.getElementById('gf-sort').value = '99';
document.getElementById('gf-active').value = '1';
@@ -2761,11 +2805,15 @@ async function saveGame() {
const id = document.getElementById('gf-id').value;
const data = {
id: id ? parseInt(id) : undefined,
name: document.getElementById('gf-name').value.trim(),
slug: document.getElementById('gf-slug').value.trim(),
player_url: document.getElementById('gf-player-url').value.trim(),
console_url: document.getElementById('gf-console-url').value.trim(),
color: document.getElementById('gf-color-hex').value.trim() || document.getElementById('gf-color').value,
name: document.getElementById('gf-name').value.trim(),
slug: document.getElementById('gf-slug').value.trim(),
player_url: document.getElementById('gf-player-url').value.trim(),
agent_link: document.getElementById('gf-agent-link').value.trim(),
agent_login: document.getElementById('gf-agent-login').value.trim(),
agent_password: document.getElementById('gf-agent-password').value.trim(),
games_link: document.getElementById('gf-games-link').value.trim(),
agent_guide: document.getElementById('gf-agent-guide').value.trim(),
color: document.getElementById('gf-color-hex').value.trim() || document.getElementById('gf-color').value,
sort_order: parseInt(document.getElementById('gf-sort').value) || 99,
is_active: parseInt(document.getElementById('gf-active').value),
};