252 lines
12 KiB
Plaintext
252 lines
12 KiB
Plaintext
@page "/admin/server"
|
|
@model Server.IndexModel
|
|
@{
|
|
ViewData["Title"] = "Server";
|
|
}
|
|
|
|
<div class="space-y-6">
|
|
<!-- Header -->
|
|
<div class="flex items-center justify-between">
|
|
<div>
|
|
<h1 class="text-3xl font-bold text-white">Server Management</h1>
|
|
<p class="text-gray-400 mt-1">Broadcast messages and manage server state</p>
|
|
</div>
|
|
</div>
|
|
|
|
@if (!string.IsNullOrEmpty(Model.Message))
|
|
{
|
|
<div class="p-4 rounded-lg @(Model.IsError ? "bg-red-900/50 border border-red-700 text-red-300" : "bg-green-900/50 border border-green-700 text-green-300")">
|
|
@Model.Message
|
|
</div>
|
|
}
|
|
|
|
<!-- Stats -->
|
|
<div class="grid grid-cols-2 md:grid-cols-5 gap-4">
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-green-400">@Model.ActiveConnections</p>
|
|
<p class="text-sm text-gray-400">Online Players</p>
|
|
</div>
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-purple-400">@Model.ActiveDungeons</p>
|
|
<p class="text-sm text-gray-400">Active Dungeons</p>
|
|
</div>
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-white">@Model.TotalAccounts</p>
|
|
<p class="text-sm text-gray-400">Total Accounts</p>
|
|
</div>
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-indigo-400">@Model.TotalCharacters</p>
|
|
<p class="text-sm text-gray-400">Total Characters</p>
|
|
</div>
|
|
<div class="card p-4">
|
|
<p class="text-2xl font-bold text-yellow-400">@Model.TrackedAssets</p>
|
|
<p class="text-sm text-gray-400">Tracked Assets</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
|
|
<!-- Broadcast Message -->
|
|
<div class="card p-6">
|
|
<h2 class="text-lg font-semibold text-white mb-4">Broadcast Message</h2>
|
|
<p class="text-sm text-gray-400 mb-4">Send a system message to all connected players.</p>
|
|
|
|
<form method="post" asp-page-handler="Broadcast" class="space-y-4">
|
|
@Html.AntiForgeryToken()
|
|
|
|
<div>
|
|
<label class="label">Message Type</label>
|
|
<select name="messageType" class="input">
|
|
<option value="system">System (Gray)</option>
|
|
<option value="announcement">Announcement (Yellow)</option>
|
|
<option value="alert">Alert (Red)</option>
|
|
<option value="info">Info (Blue)</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="label">Message</label>
|
|
<textarea name="message" class="input" rows="3" required placeholder="Enter your message..."></textarea>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary w-full">
|
|
<svg class="w-4 h-4 mr-2 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5.882V19.24a1.76 1.76 0 01-3.417.592l-2.147-6.15M18 13a3 3 0 100-6M5.436 13.683A4.001 4.001 0 017 6h1.832c4.1 0 7.625-1.234 9.168-3v14c-1.543-1.766-5.067-3-9.168-3H7a3.988 3.988 0 01-1.564-.317z"/>
|
|
</svg>
|
|
Send Broadcast
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Quick Actions -->
|
|
<div class="card p-6">
|
|
<h2 class="text-lg font-semibold text-white mb-4">Quick Actions</h2>
|
|
|
|
<div class="space-y-3">
|
|
<form method="post" asp-page-handler="RefreshAssets">
|
|
@Html.AntiForgeryToken()
|
|
<button type="submit" class="btn btn-secondary w-full flex items-center justify-center gap-2">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
|
|
</svg>
|
|
Signal Asset Refresh to Clients
|
|
</button>
|
|
</form>
|
|
|
|
<form method="post" asp-page-handler="MaintenanceWarning">
|
|
@Html.AntiForgeryToken()
|
|
<button type="submit" class="btn bg-yellow-700 hover:bg-yellow-600 text-white w-full flex items-center justify-center gap-2">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
|
|
</svg>
|
|
Send Maintenance Warning (5 min)
|
|
</button>
|
|
</form>
|
|
|
|
<form method="post" asp-page-handler="ServerRestart">
|
|
@Html.AntiForgeryToken()
|
|
<button type="submit" class="btn bg-red-700 hover:bg-red-600 text-white w-full flex items-center justify-center gap-2" onclick="return confirm('Send server restart warning to all players?')">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
|
|
</svg>
|
|
Send Server Restart Warning
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Cache Management -->
|
|
<div class="card p-6">
|
|
<h2 class="text-lg font-semibold text-white mb-4">Cache Management</h2>
|
|
<p class="text-sm text-gray-400 mb-4">Refresh server caches without restarting. Use after adding/modifying game data.</p>
|
|
|
|
<div class="grid grid-cols-2 md:grid-cols-4 gap-3" id="cacheButtons">
|
|
<button type="button" onclick="refreshCache('recipes')" class="btn btn-secondary flex flex-col items-center gap-1 py-3">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
|
|
</svg>
|
|
<span class="text-xs">Recipes</span>
|
|
</button>
|
|
|
|
<button type="button" onclick="refreshCache('mobs')" class="btn btn-secondary flex flex-col items-center gap-1 py-3">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h.01M15 10h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
</svg>
|
|
<span class="text-xs">Mobs</span>
|
|
</button>
|
|
|
|
<button type="button" onclick="refreshCache('loot')" class="btn btn-secondary flex flex-col items-center gap-1 py-3">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"/>
|
|
</svg>
|
|
<span class="text-xs">Loot Tables</span>
|
|
</button>
|
|
|
|
<button type="button" onclick="refreshCache('all')" class="btn bg-purple-700 hover:bg-purple-600 text-white flex flex-col items-center gap-1 py-3">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
|
|
</svg>
|
|
<span class="text-xs">Refresh All</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div id="cacheStatus" class="mt-4 hidden">
|
|
<div class="p-3 rounded-lg bg-gray-800 border border-gray-700">
|
|
<span id="cacheStatusText" class="text-gray-300"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Recent Broadcasts -->
|
|
<div class="card p-6">
|
|
<h2 class="text-lg font-semibold text-white mb-4">Recent Broadcasts</h2>
|
|
|
|
@if (Model.RecentBroadcasts.Any())
|
|
{
|
|
<div class="space-y-2">
|
|
@foreach (var broadcast in Model.RecentBroadcasts)
|
|
{
|
|
var typeColor = broadcast.Type switch
|
|
{
|
|
"announcement" => "border-yellow-600 bg-yellow-900/20",
|
|
"alert" => "border-red-600 bg-red-900/20",
|
|
"info" => "border-blue-600 bg-blue-900/20",
|
|
_ => "border-gray-600 bg-gray-800"
|
|
};
|
|
<div class="@typeColor border rounded-lg p-3">
|
|
<div class="flex items-center justify-between mb-1">
|
|
<span class="text-xs text-gray-400 uppercase">@broadcast.Type</span>
|
|
<span class="text-xs text-gray-500">@broadcast.SentAt.ToString("HH:mm:ss")</span>
|
|
</div>
|
|
<p class="text-white">@broadcast.Message</p>
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<p class="text-gray-500 text-center py-4">No recent broadcasts.</p>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
@section Scripts {
|
|
<script>
|
|
async function refreshCache(type) {
|
|
const statusDiv = document.getElementById('cacheStatus');
|
|
const statusText = document.getElementById('cacheStatusText');
|
|
const buttons = document.querySelectorAll('#cacheButtons button');
|
|
|
|
// Disable all buttons
|
|
buttons.forEach(btn => btn.disabled = true);
|
|
|
|
// Show loading
|
|
statusDiv.classList.remove('hidden');
|
|
statusText.innerHTML = '<span class="animate-pulse">Refreshing ' + type + ' cache...</span>';
|
|
statusDiv.querySelector('div').className = 'p-3 rounded-lg bg-blue-900/50 border border-blue-700';
|
|
|
|
try {
|
|
const token = document.querySelector('input[name="__RequestVerificationToken"]')?.value || '';
|
|
const response = await fetch('/admin/api?handler=RefreshCache&type=' + type, {
|
|
method: 'POST',
|
|
credentials: 'same-origin',
|
|
headers: {
|
|
'RequestVerificationToken': token
|
|
}
|
|
});
|
|
|
|
let data;
|
|
const text = await response.text();
|
|
try {
|
|
data = JSON.parse(text);
|
|
} catch (e) {
|
|
throw new Error('Invalid response from server: ' + text.substring(0, 100));
|
|
}
|
|
|
|
if (response.ok && data.success) {
|
|
statusText.innerHTML = '✓ Cache refreshed: ' + (data.refreshed || []).join(', ');
|
|
statusDiv.querySelector('div').className = 'p-3 rounded-lg bg-green-900/50 border border-green-700';
|
|
|
|
if (data.errors && data.errors.length > 0) {
|
|
statusText.innerHTML += '<br><span class="text-yellow-400">Warnings: ' + data.errors.join(', ') + '</span>';
|
|
}
|
|
} else {
|
|
statusText.innerHTML = '✗ Error: ' + (data.error || 'Unknown error');
|
|
statusDiv.querySelector('div').className = 'p-3 rounded-lg bg-red-900/50 border border-red-700';
|
|
}
|
|
} catch (err) {
|
|
statusText.innerHTML = '✗ Error: ' + err.message;
|
|
statusDiv.querySelector('div').className = 'p-3 rounded-lg bg-red-900/50 border border-red-700';
|
|
} finally {
|
|
// Re-enable buttons
|
|
buttons.forEach(btn => btn.disabled = false);
|
|
|
|
// Hide status after 5 seconds
|
|
setTimeout(() => {
|
|
statusDiv.classList.add('hidden');
|
|
}, 5000);
|
|
}
|
|
}
|
|
</script>
|
|
}
|