Files
Church-Music/legacy-site/frontend/public/clear-cache.html

225 lines
6.2 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Clear App Cache - Church Music Database</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
background: #f5f5f5;
}
.container {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
h1 {
color: #7c3aed;
margin-bottom: 10px;
}
.subtitle {
color: #666;
margin-bottom: 30px;
}
button {
background: #7c3aed;
color: white;
border: none;
padding: 15px 30px;
font-size: 16px;
border-radius: 8px;
cursor: pointer;
margin: 10px 5px;
}
button:hover {
background: #6d28d9;
}
button.danger {
background: #dc2626;
}
button.danger:hover {
background: #b91c1c;
}
.info {
background: #eff6ff;
border-left: 4px solid #3b82f6;
padding: 15px;
margin: 20px 0;
}
.success {
background: #f0fdf4;
border-left: 4px solid #22c55e;
padding: 15px;
margin: 20px 0;
}
.warning {
background: #fefce8;
border-left: 4px solid #eab308;
padding: 15px;
margin: 20px 0;
}
#output {
margin-top: 20px;
padding: 15px;
background: #f9fafb;
border-radius: 5px;
white-space: pre-wrap;
font-family: monospace;
font-size: 12px;
}
</style>
</head>
<body>
<div class="container">
<h1>🔧 Church Music Database - Cache Manager</h1>
<p class="subtitle">Clear cached data and fix persistent issues</p>
<div class="info">
<strong> What does this do?</strong><br />
This tool helps fix issues where deleted worship lists keep reappearing
by clearing your browser's local cache.
</div>
<div class="warning">
<strong>⚠️ Before you start:</strong><br />
Make sure any unsaved changes are backed up. This will clear all locally
cached data.
</div>
<button onclick="viewCache()">📊 View Current Cache</button>
<button onclick="clearPlansCache()">🗑️ Clear Worship Lists Cache</button>
<button onclick="clearAllCache()" class="danger">
🧹 Clear All App Data
</button>
<button onclick="location.href='/'">← Back to App</button>
<div id="output"></div>
</div>
<script>
const STORAGE_KEYS = {
SONGS: "hop_songs",
PROFILES: "hop_profiles",
PLANS: "hop_plans",
PLAN_SONGS: "hop_plan_songs",
SETTINGS: "hop_settings",
};
function log(message, type = "info") {
const output = document.getElementById("output");
const timestamp = new Date().toLocaleTimeString();
output.innerHTML += `[${timestamp}] ${message}\n`;
output.scrollTop = output.scrollHeight;
}
function viewCache() {
const output = document.getElementById("output");
output.innerHTML = "";
log("=== CURRENT CACHE CONTENTS ===\n", "info");
Object.entries(STORAGE_KEYS).forEach(([name, key]) => {
const data = localStorage.getItem(key);
if (data) {
try {
const parsed = JSON.parse(data);
const count = Array.isArray(parsed) ? parsed.length : 1;
log(`${name}: ${count} items`);
if (name === "PLANS" && Array.isArray(parsed)) {
parsed.forEach((plan) => {
log(
` - ID: ${plan.id}, Date: ${plan.date}, Notes: ${
plan.notes?.substring(0, 30) || "None"
}`
);
});
}
} catch (e) {
log(`${name}: Invalid JSON data`);
}
} else {
log(`${name}: No data`);
}
});
log("\n=== END CACHE CONTENTS ===");
}
function clearPlansCache() {
if (
!confirm(
"Clear worship lists cache? This will remove all locally cached worship lists."
)
) {
return;
}
const output = document.getElementById("output");
output.innerHTML = "";
log("Clearing worship lists cache...", "info");
const plansData = localStorage.getItem(STORAGE_KEYS.PLANS);
const planSongsData = localStorage.getItem(STORAGE_KEYS.PLAN_SONGS);
if (plansData) {
const plans = JSON.parse(plansData);
log(`Found ${plans.length} cached worship lists`);
}
localStorage.removeItem(STORAGE_KEYS.PLANS);
localStorage.removeItem(STORAGE_KEYS.PLAN_SONGS);
log("✅ Worship lists cache cleared!", "success");
log("Please refresh the app to reload from the server.");
}
function clearAllCache() {
if (
!confirm(
"Clear ALL app data? This will remove all cached songs, profiles, and worship lists. The app will reload fresh from the server."
)
) {
return;
}
if (!confirm("Are you REALLY sure? This cannot be undone!")) {
return;
}
const output = document.getElementById("output");
output.innerHTML = "";
log("Clearing all app data...", "info");
Object.entries(STORAGE_KEYS).forEach(([name, key]) => {
const data = localStorage.getItem(key);
if (data) {
try {
const parsed = JSON.parse(data);
const count = Array.isArray(parsed) ? parsed.length : 1;
log(`Clearing ${name}: ${count} items`);
} catch (e) {
log(`Clearing ${name}`);
}
localStorage.removeItem(key);
}
});
log("\n✅ All app data cleared!", "success");
log("Redirecting to app in 3 seconds...");
setTimeout(() => {
window.location.href = "/";
}, 3000);
}
</script>
</body>
</html>