Initial commit - Church Music Database

This commit is contained in:
2026-01-27 18:04:50 -06:00
commit d367261867
336 changed files with 103545 additions and 0 deletions

View File

@@ -0,0 +1,248 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Settings Diagnostic</title>
<style>
body {
font-family: Arial;
padding: 20px;
background: #f5f5f5;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #333;
}
.status {
padding: 15px;
margin: 10px 0;
border-radius: 5px;
}
.good {
background: #d4edda;
color: #155724;
}
.bad {
background: #f8d7da;
color: #721c24;
}
.warning {
background: #fff3cd;
color: #856404;
}
pre {
background: #f8f9fa;
padding: 15px;
border-radius: 5px;
overflow-x: auto;
}
button {
background: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
margin: 5px;
}
button:hover {
background: #0056b3;
}
</style>
</head>
<body>
<div class="container">
<h1>🔍 Settings Diagnostic Tool</h1>
<div id="results"></div>
<h3>Quick Actions:</h3>
<button onclick="fixSettings()">
🔧 Fix Settings (Set to Backend Mode)
</button>
<button onclick="testConnection()">🌐 Test Backend Connection</button>
<button onclick="restoreData()">📦 Restore Data to Backend</button>
<button onclick="clearAll()">🗑️ Clear All Settings</button>
</div>
<script>
function check() {
const results = document.getElementById("results");
let html = "";
// Check API settings
const apiSettings = localStorage.getItem("api_settings");
if (apiSettings) {
try {
const settings = JSON.parse(apiSettings);
html +=
'<div class="status ' +
(settings.useLocalStorage ? "warning" : "good") +
'">';
html += "<strong>API Settings Found:</strong><br>";
html +=
"Local Mode: <strong>" +
(settings.useLocalStorage ? "ON (❌ Issue)" : "OFF (✓)") +
"</strong><br>";
html += "Protocol: " + settings.protocol + "<br>";
html += "Hostname: " + settings.hostname + "<br>";
html += "Port: " + settings.port + "<br>";
html += "</div>";
if (settings.useLocalStorage) {
html += '<div class="status bad">';
html +=
"⚠️ <strong>Local Mode is ON</strong> — songs save only in this browser, not to the backend. Turn it OFF with Fix Settings.";
html += "</div>";
}
} catch (e) {
html +=
'<div class="status bad">Error parsing settings: ' +
e.message +
"</div>";
}
} else {
html +=
'<div class="status bad">No API settings found. Defaults may enable Local Mode (OFFLINE). Click Fix Settings.</div>';
}
// Check localStorage data
const songs = localStorage.getItem("SONGS");
const profiles = localStorage.getItem("PROFILES");
const plans = localStorage.getItem("PLANS");
html += '<div class="status">';
html += "<strong>Local Storage (this device only):</strong><br>";
html +=
"Songs: " +
(songs ? JSON.parse(songs).length + " song(s)" : "0 song(s)") +
"<br>";
html +=
"Profiles: " +
(profiles
? JSON.parse(profiles).length + " profile(s)"
: "0 profile(s)") +
"<br>";
html +=
"Plans: " +
(plans ? JSON.parse(plans).length + " plan(s)" : "0 plan(s)") +
"<br>";
html += "</div>";
results.innerHTML = html;
}
function fixSettings() {
const isDesktop =
window.location.hostname === "localhost" ||
window.location.hostname === "127.0.0.1";
const hostname = isDesktop ? "localhost" : window.location.hostname;
const settings = {
protocol: "http",
hostname: hostname,
port: "5000",
useLocalStorage: false,
};
localStorage.setItem("api_settings", JSON.stringify(settings));
alert(
"✓ Settings fixed! Local Mode is now OFF.\nHostname: " +
hostname +
"\nPort: 5000\n\nGo back to main app and refresh."
);
check();
}
async function testConnection() {
const apiSettings = localStorage.getItem("api_settings");
if (!apiSettings) {
alert('No settings found. Click "Fix Settings" first.');
return;
}
const settings = JSON.parse(apiSettings);
const url =
settings.protocol +
"://" +
settings.hostname +
":" +
settings.port +
"/api/health";
try {
const response = await fetch(url, { method: "GET" });
const data = await response.json();
alert(
"✓ Backend connection successful!\nStatus: " +
data.status +
"\n\nYou can now save songs to backend."
);
} catch (e) {
alert(
"✗ Backend connection failed!\n\n" +
e.message +
"\n\nCheck:\n1. Backend is running\n2. Hostname/IP is correct\n3. Port 5000 is accessible"
);
}
}
async function restoreData() {
const apiSettings = localStorage.getItem("api_settings");
if (!apiSettings) {
alert('No settings found. Click "Fix Settings" first.');
return;
}
const settings = JSON.parse(apiSettings);
const base = `${settings.protocol}://${settings.hostname}:${settings.port}`;
const url = `${base}/api/admin/restore`;
try {
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
alert(
`✓ Restore complete!\nSource: ${
data.source || "data.json"
}\nProfiles: created ${data.profiles_created}, updated ${
data.profiles_updated
}\nSongs: created ${data.songs_created}, updated ${
data.songs_updated
}\n\nOpen the main app and run Full Sync.`
);
} catch (e) {
alert(
"✗ Restore failed.\n\n" +
e.message +
"\n\nEnsure backend is running and data.json exists (root or backend folder)."
);
}
}
function clearAll() {
if (
confirm("Clear ALL settings and local data? This cannot be undone!")
) {
localStorage.clear();
alert("✓ All cleared! Reload the page.");
check();
}
}
// Run check on load
check();
</script>
</body>
</html>