settings oragnized, DB management system fixes

This commit is contained in:
serversdwn
2025-12-16 20:23:55 +00:00
parent 7c89d203d7
commit 7d17d355a7
3 changed files with 150 additions and 114 deletions

View File

@@ -0,0 +1,10 @@
{
"filename": "snapshot_20251216_201738.db",
"created_at": "20251216_201738",
"created_at_iso": "2025-12-16T20:17:38.638982",
"description": "Auto-backup before restore",
"size_bytes": 57344,
"size_mb": 0.05,
"original_db_size_bytes": 57344,
"type": "manual"
}

View File

@@ -0,0 +1,9 @@
{
"filename": "snapshot_uploaded_20251216_201732.db",
"created_at": "20251216_201732",
"created_at_iso": "2025-12-16T20:17:32.574205",
"description": "Uploaded: snapshot_20251216_200259.db",
"size_bytes": 77824,
"size_mb": 0.07,
"type": "uploaded"
}

View File

@@ -22,6 +22,12 @@
</svg> </svg>
Roster Management Roster Management
</button> </button>
<button class="settings-tab" data-tab="database" onclick="showTab('database')">
<svg class="w-4 h-4 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"></path>
</svg>
Database
</button>
<button class="settings-tab" data-tab="advanced" onclick="showTab('advanced')"> <button class="settings-tab" data-tab="advanced" onclick="showTab('advanced')">
<svg class="w-4 h-4 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-4 h-4 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path>
@@ -214,30 +220,24 @@
<p class="text-gray-600 dark:text-gray-400 mt-2">No roster units found</p> <p class="text-gray-600 dark:text-gray-400 mt-2">No roster units found</p>
</div> </div>
</div> </div>
</div>
</div>
<!-- Advanced Tab --> <!-- CSV Import - Replace Mode -->
<div id="advanced-tab" class="tab-content hidden"> <div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6 border-2 border-yellow-200 dark:border-yellow-800">
<div class="space-y-6"> <div class="bg-yellow-50 dark:bg-yellow-900/20 border-l-4 border-yellow-500 p-4 mb-4">
<!-- Warning Banner -->
<div class="bg-yellow-50 dark:bg-yellow-900/20 border-l-4 border-yellow-500 p-4">
<div class="flex"> <div class="flex">
<svg class="w-5 h-5 text-yellow-500 mr-2 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-5 h-5 text-yellow-500 mr-2 flex-shrink-0" 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"></path> <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"></path>
</svg> </svg>
<div> <div>
<p class="font-semibold text-yellow-800 dark:text-yellow-300">Advanced Settings</p> <p class="font-semibold text-yellow-800 dark:text-yellow-300">Replace Mode Warning</p>
<p class="text-sm text-yellow-700 dark:text-yellow-400 mt-1">These settings can affect system behavior. Change with caution.</p> <p class="text-sm text-yellow-700 dark:text-yellow-400 mt-1">This will DELETE all existing roster units before importing.</p>
</div> </div>
</div> </div>
</div> </div>
<!-- CSV Import - Replace Mode -->
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6 border-2 border-yellow-200 dark:border-yellow-800">
<h2 class="text-xl font-semibold text-yellow-800 dark:text-yellow-300 mb-2">CSV Import - Replace Mode</h2> <h2 class="text-xl font-semibold text-yellow-800 dark:text-yellow-300 mb-2">CSV Import - Replace Mode</h2>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4"> <p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
This will DELETE all existing roster units before importing. Use this to completely replace your roster with a CSV file. All existing roster data will be deleted first.
</p> </p>
<form id="importReplaceForm" class="space-y-4"> <form id="importReplaceForm" class="space-y-4">
@@ -257,6 +257,116 @@
</button> </button>
</form> </form>
</div> </div>
</div>
</div>
<!-- Database Tab -->
<div id="database-tab" class="tab-content hidden">
<div class="space-y-6">
<!-- Database Statistics -->
<div class="border-2 border-blue-300 dark:border-blue-800 rounded-lg p-6 bg-white dark:bg-slate-800">
<h3 class="font-semibold text-blue-600 dark:text-blue-400 text-lg mb-3">Database Statistics</h3>
<div id="dbStatsLoading" class="text-center py-4">
<div class="inline-block animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"></div>
</div>
<div id="dbStatsContent" class="hidden">
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
<div>
<p class="text-gray-500 dark:text-gray-400">Database Size</p>
<p id="dbSize" class="text-lg font-semibold text-gray-900 dark:text-white">-</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Total Rows</p>
<p id="dbRows" class="text-lg font-semibold text-gray-900 dark:text-white">-</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Last Modified</p>
<p id="dbModified" class="text-lg font-semibold text-gray-900 dark:text-white">-</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Snapshots</p>
<p id="dbSnapshotCount" class="text-lg font-semibold text-gray-900 dark:text-white">-</p>
</div>
</div>
</div>
<button onclick="loadDatabaseStats()" class="mt-4 px-4 py-2 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors text-sm">
Refresh Stats
</button>
</div>
<!-- Create Snapshot -->
<div class="border border-green-200 dark:border-green-800 rounded-lg p-6 bg-white dark:bg-slate-800">
<div class="flex justify-between items-start">
<div class="flex-1">
<h3 class="font-semibold text-green-600 dark:text-green-400">Create Database Snapshot</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
Create a full backup of the current database state
</p>
</div>
<button onclick="createSnapshot()" class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors whitespace-nowrap">
Create Snapshot
</button>
</div>
</div>
<!-- Snapshots List -->
<div class="border border-gray-200 dark:border-gray-700 rounded-lg p-6 bg-white dark:bg-slate-800">
<div class="flex justify-between items-center mb-4">
<h3 class="font-semibold text-gray-900 dark:text-white">Available Snapshots</h3>
<button onclick="loadSnapshots()" class="px-3 py-1 text-sm text-seismo-orange hover:bg-orange-50 dark:hover:bg-orange-900/20 rounded transition-colors">
Refresh
</button>
</div>
<div id="snapshotsLoading" class="text-center py-4">
<div class="inline-block animate-spin rounded-full h-6 w-6 border-b-2 border-seismo-orange"></div>
</div>
<div id="snapshotsList" class="hidden space-y-2">
<!-- Snapshots will be inserted here -->
</div>
<div id="snapshotsEmpty" class="hidden text-center py-8 text-gray-500 dark:text-gray-400">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"></path>
</svg>
<p class="mt-2">No snapshots found</p>
<p class="text-sm">Create your first snapshot above</p>
</div>
</div>
<!-- Upload Snapshot -->
<div class="border border-purple-200 dark:border-purple-800 rounded-lg p-6 bg-white dark:bg-slate-800">
<h3 class="font-semibold text-purple-600 dark:text-purple-400 mb-2">Upload Snapshot</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
Upload a database snapshot file from another server
</p>
<form id="uploadSnapshotForm" class="space-y-3">
<input type="file" accept=".db" id="snapshotFileInput" class="block w-full text-sm text-gray-900 dark:text-white border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer bg-gray-50 dark:bg-slate-700">
<button type="submit" class="px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors">
Upload Snapshot
</button>
</form>
<div id="uploadResult" class="hidden mt-3"></div>
</div>
</div>
</div>
<!-- Advanced Tab -->
<div id="advanced-tab" class="tab-content hidden">
<div class="space-y-6">
<!-- Warning Banner -->
<div class="bg-yellow-50 dark:bg-yellow-900/20 border-l-4 border-yellow-500 p-4">
<div class="flex">
<svg class="w-5 h-5 text-yellow-500 mr-2 flex-shrink-0" 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"></path>
</svg>
<div>
<p class="font-semibold text-yellow-800 dark:text-yellow-300">Advanced Settings</p>
<p class="text-sm text-yellow-700 dark:text-yellow-400 mt-1">These settings can affect system behavior. Change with caution.</p>
</div>
</div>
</div>
<!-- Status Thresholds --> <!-- Status Thresholds -->
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6"> <div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6">
@@ -401,99 +511,6 @@
</button> </button>
</div> </div>
</div> </div>
<!-- DATABASE MANAGEMENT SECTION -->
<div class="mt-8 mb-4">
<h2 class="text-2xl font-bold text-gray-900 dark:text-white">Database Management</h2>
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">Create snapshots, restore backups, and manage database files</p>
</div>
<!-- Database Statistics -->
<div class="border-2 border-blue-300 dark:border-blue-800 rounded-lg p-6 bg-white dark:bg-slate-800">
<h3 class="font-semibold text-blue-600 dark:text-blue-400 text-lg mb-3">Database Statistics</h3>
<div id="dbStatsLoading" class="text-center py-4">
<div class="inline-block animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"></div>
</div>
<div id="dbStatsContent" class="hidden">
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 text-sm">
<div>
<p class="text-gray-500 dark:text-gray-400">Database Size</p>
<p id="dbSize" class="text-lg font-semibold text-gray-900 dark:text-white">-</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Total Rows</p>
<p id="dbRows" class="text-lg font-semibold text-gray-900 dark:text-white">-</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Last Modified</p>
<p id="dbModified" class="text-lg font-semibold text-gray-900 dark:text-white">-</p>
</div>
<div>
<p class="text-gray-500 dark:text-gray-400">Snapshots</p>
<p id="dbSnapshotCount" class="text-lg font-semibold text-gray-900 dark:text-white">-</p>
</div>
</div>
</div>
<button onclick="loadDatabaseStats()" class="mt-4 px-4 py-2 text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-colors text-sm">
Refresh Stats
</button>
</div>
<!-- Create Snapshot -->
<div class="border border-green-200 dark:border-green-800 rounded-lg p-6 bg-white dark:bg-slate-800">
<div class="flex justify-between items-start">
<div class="flex-1">
<h3 class="font-semibold text-green-600 dark:text-green-400">Create Database Snapshot</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
Create a full backup of the current database state
</p>
</div>
<button onclick="createSnapshot()" class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg transition-colors whitespace-nowrap">
Create Snapshot
</button>
</div>
</div>
<!-- Snapshots List -->
<div class="border border-gray-200 dark:border-gray-700 rounded-lg p-6 bg-white dark:bg-slate-800">
<div class="flex justify-between items-center mb-4">
<h3 class="font-semibold text-gray-900 dark:text-white">Available Snapshots</h3>
<button onclick="loadSnapshots()" class="px-3 py-1 text-sm text-seismo-orange hover:bg-orange-50 dark:hover:bg-orange-900/20 rounded transition-colors">
Refresh
</button>
</div>
<div id="snapshotsLoading" class="text-center py-4">
<div class="inline-block animate-spin rounded-full h-6 w-6 border-b-2 border-seismo-orange"></div>
</div>
<div id="snapshotsList" class="hidden space-y-2">
<!-- Snapshots will be inserted here -->
</div>
<div id="snapshotsEmpty" class="hidden text-center py-8 text-gray-500 dark:text-gray-400">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4"></path>
</svg>
<p class="mt-2">No snapshots found</p>
<p class="text-sm">Create your first snapshot above</p>
</div>
</div>
<!-- Upload Snapshot -->
<div class="border border-purple-200 dark:border-purple-800 rounded-lg p-6 bg-white dark:bg-slate-800">
<h3 class="font-semibold text-purple-600 dark:text-purple-400 mb-2">Upload Snapshot</h3>
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
Upload a database snapshot file from another server
</p>
<form id="uploadSnapshotForm" class="space-y-3">
<input type="file" accept=".db" id="snapshotFileInput" class="block w-full text-sm text-gray-900 dark:text-white border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer bg-gray-50 dark:bg-slate-700">
<button type="submit" class="px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors">
Upload Snapshot
</button>
</form>
<div id="uploadResult" class="hidden mt-3"></div>
</div>
</div> </div>
</div> </div>
@@ -1346,11 +1363,11 @@ document.getElementById('uploadSnapshotForm').addEventListener('submit', async f
} }
}); });
// Load database stats and snapshots when danger zone tab is shown // Load database stats and snapshots when database tab is shown
const originalShowTab = showTab; const originalShowTab = showTab;
showTab = function(tabName) { showTab = function(tabName) {
originalShowTab(tabName); originalShowTab(tabName);
if (tabName === 'danger') { if (tabName === 'database') {
loadDatabaseStats(); loadDatabaseStats();
loadSnapshots(); loadSnapshots();
} }