updateweb
This commit is contained in:
249
website/public/test-data-sync.html
Normal file
249
website/public/test-data-sync.html
Normal file
@@ -0,0 +1,249 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Backend-Frontend Data Sync Test</title>
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"
|
||||
/>
|
||||
<style>
|
||||
body {
|
||||
padding: 40px;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
.test-card {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 30px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.status-badge {
|
||||
display: inline-block;
|
||||
padding: 8px 16px;
|
||||
border-radius: 20px;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
}
|
||||
.status-success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
.status-info {
|
||||
background: #d1ecf1;
|
||||
color: #0c5460;
|
||||
}
|
||||
.preview-box {
|
||||
background: #f8f9fa;
|
||||
border: 2px solid #dee2e6;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
margin-top: 15px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.step {
|
||||
padding: 15px;
|
||||
margin: 10px 0;
|
||||
border-left: 4px solid #667eea;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1 class="mb-4">
|
||||
<i class="bi bi-arrow-repeat"></i> Backend-Frontend Sync Test
|
||||
</h1>
|
||||
|
||||
<div class="test-card">
|
||||
<h3>
|
||||
<i class="bi bi-check-circle-fill text-success"></i>
|
||||
Data Communication Status
|
||||
</h3>
|
||||
<p class="text-muted mb-3">
|
||||
Testing the connection between admin panel edits and frontend display
|
||||
</p>
|
||||
|
||||
<div class="step">
|
||||
<strong>Step 1:</strong> Open Admin Panel →
|
||||
<a
|
||||
href="/admin/pages.html"
|
||||
target="_blank"
|
||||
class="btn btn-sm btn-primary"
|
||||
>
|
||||
<i class="bi bi-gear"></i> Open Pages Admin
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<strong>Step 2:</strong> Click Edit on any page (About, Contact, or
|
||||
Privacy)
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<strong>Step 3:</strong> Make a small change (e.g., update phone
|
||||
number, add text)
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<strong>Step 4:</strong> Click "Save Page" in the admin modal
|
||||
</div>
|
||||
|
||||
<div class="step">
|
||||
<strong>Step 5:</strong> Return to this test page and click the
|
||||
buttons below to verify
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="test-card">
|
||||
<h3><i class="bi bi-eye"></i> Live Page Previews</h3>
|
||||
<p class="text-muted">
|
||||
View current content from database (click to refresh)
|
||||
</p>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<button
|
||||
class="btn btn-outline-primary w-100"
|
||||
onclick="testPage('about')"
|
||||
>
|
||||
<i class="bi bi-file-text"></i> Test About Page
|
||||
</button>
|
||||
<a href="/about.html" target="_blank" class="btn btn-link w-100"
|
||||
>View Live →</a
|
||||
>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<button
|
||||
class="btn btn-outline-primary w-100"
|
||||
onclick="testPage('contact')"
|
||||
>
|
||||
<i class="bi bi-envelope"></i> Test Contact Page
|
||||
</button>
|
||||
<a href="/contact.html" target="_blank" class="btn btn-link w-100"
|
||||
>View Live →</a
|
||||
>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<button
|
||||
class="btn btn-outline-primary w-100"
|
||||
onclick="testPage('privacy')"
|
||||
>
|
||||
<i class="bi bi-shield-check"></i> Test Privacy Page
|
||||
</button>
|
||||
<a href="/privacy.html" target="_blank" class="btn btn-link w-100"
|
||||
>View Live →</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="previewContainer" style="display: none">
|
||||
<hr class="my-4" />
|
||||
<h4 id="previewTitle">Content Preview</h4>
|
||||
<span class="status-badge status-success mb-3">
|
||||
<i class="bi bi-check-circle"></i> Loaded from Database
|
||||
</span>
|
||||
<div class="preview-box" id="previewContent"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="test-card">
|
||||
<h3><i class="bi bi-clipboard-data"></i> Test Results</h3>
|
||||
<div id="testResults">
|
||||
<p class="text-muted">
|
||||
<i class="bi bi-info-circle"></i>
|
||||
Click a test button above to check if data is syncing correctly
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="test-card">
|
||||
<h3><i class="bi bi-lightbulb"></i> What Should Happen</h3>
|
||||
<ul>
|
||||
<li>
|
||||
<strong>Edit in Admin</strong>: Changes saved to database
|
||||
immediately
|
||||
</li>
|
||||
<li>
|
||||
<strong>View on Frontend</strong>: Refresh page shows updated
|
||||
content
|
||||
</li>
|
||||
<li>
|
||||
<strong>No Cache Issues</strong>: Changes appear within seconds
|
||||
</li>
|
||||
<li>
|
||||
<strong>All Sections Updated</strong>: Headers, paragraphs, lists
|
||||
all reflect edits
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="alert alert-info mt-3">
|
||||
<i class="bi bi-info-circle-fill"></i>
|
||||
<strong>Pro Tip:</strong> Keep this test page and the frontend page
|
||||
open side-by-side. Edit in admin, save, then refresh the frontend page
|
||||
to see changes instantly.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function testPage(slug) {
|
||||
const previewContainer = document.getElementById("previewContainer");
|
||||
const previewTitle = document.getElementById("previewTitle");
|
||||
const previewContent = document.getElementById("previewContent");
|
||||
const testResults = document.getElementById("testResults");
|
||||
|
||||
previewContainer.style.display = "block";
|
||||
previewTitle.textContent = `Loading ${slug} page...`;
|
||||
previewContent.innerHTML =
|
||||
'<div class="text-center"><div class="spinner-border" role="status"></div></div>';
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/pages/${slug}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success && data.page) {
|
||||
previewTitle.textContent = `${data.page.title} - Content Preview`;
|
||||
previewContent.innerHTML = data.page.content;
|
||||
|
||||
testResults.innerHTML = `
|
||||
<div class="alert alert-success">
|
||||
<h5><i class="bi bi-check-circle-fill"></i> ✓ Communication Working!</h5>
|
||||
<p><strong>Page:</strong> ${data.page.title}</p>
|
||||
<p><strong>Slug:</strong> ${data.page.slug}</p>
|
||||
<p><strong>Content Length:</strong> ${data.page.content.length} characters</p>
|
||||
<p class="mb-0"><strong>Status:</strong> Data successfully loaded from database</p>
|
||||
<hr>
|
||||
<small class="text-muted">
|
||||
<i class="bi bi-info-circle"></i>
|
||||
Any edits you make in the admin panel will be reflected here after saving and refreshing.
|
||||
</small>
|
||||
</div>
|
||||
`;
|
||||
} else {
|
||||
throw new Error("Page not found");
|
||||
}
|
||||
} catch (error) {
|
||||
previewContent.innerHTML = `
|
||||
<div class="alert alert-danger">
|
||||
<i class="bi bi-x-circle-fill"></i> Error loading content: ${error.message}
|
||||
</div>
|
||||
`;
|
||||
testResults.innerHTML = `
|
||||
<div class="alert alert-danger">
|
||||
<h5><i class="bi bi-x-circle-fill"></i> ✗ Communication Error</h5>
|
||||
<p>${error.message}</p>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user