fix bugs in contrib system, remove health endpoint
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// src/pages/contribute/index.astro - Updated for Phase 3
|
||||
import BaseLayout from '../../layouts/BaseLayout.astro';
|
||||
import { getSessionFromRequest, verifySession } from '../../utils/auth.js';
|
||||
import { getAuthContext, requireAuth } from '../../utils/serverAuth.js';
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
@@ -20,9 +21,9 @@ if (authRequired) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return Astro.redirect('/auth/login');
|
||||
}
|
||||
const authContext = await getAuthContext(Astro);
|
||||
const authRedirect = requireAuth(authContext, Astro.url.toString());
|
||||
if (authRedirect) return authRedirect;
|
||||
}
|
||||
---
|
||||
|
||||
@@ -148,12 +149,6 @@ if (authRequired) {
|
||||
</svg>
|
||||
Report Issue
|
||||
</a>
|
||||
<a href="/api/contribute/health" class="btn btn-secondary" target="_blank">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="margin-right: 0.5rem;">
|
||||
<path d="M22 12h-4l-3 9L9 3l-3 9H2"/>
|
||||
</svg>
|
||||
System Health
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -199,95 +194,7 @@ if (authRequired) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- System Status -->
|
||||
<div class="card" style="background-color: var(--color-bg-secondary);">
|
||||
<h3 style="margin-bottom: 1rem; color: var(--color-text);">System Status</h3>
|
||||
<div id="system-status" style="display: flex; align-items: center; gap: 1rem;">
|
||||
<div style="width: 12px; height: 12px; background-color: var(--color-text-secondary); border-radius: 50%; animation: pulse 2s infinite;"></div>
|
||||
<span style="color: var(--color-text-secondary);">Checking system health...</span>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 1rem; font-size: 0.875rem; color: var(--color-text-secondary);">
|
||||
<p style="margin: 0;">
|
||||
<strong>Features Available:</strong> Tool contributions, knowledgebase articles, media uploads
|
||||
</p>
|
||||
<p style="margin: 0.5rem 0 0 0;">
|
||||
<strong>Storage:</strong> Local + Nextcloud (if configured) |
|
||||
<strong>Authentication:</strong> {authRequired ? 'Required' : 'Disabled'} |
|
||||
<strong>Rate Limiting:</strong> Active
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<style>
|
||||
.card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.5; }
|
||||
}
|
||||
|
||||
.loading {
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
div[style*="grid-template-columns: 2fr 1fr"] {
|
||||
grid-template-columns: 1fr !important;
|
||||
gap: 1rem !important;
|
||||
}
|
||||
|
||||
div[style*="grid-template-columns: repeat(auto-fit, minmax(300px, 1fr))"] {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2rem !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
// Check system health on page load
|
||||
document.addEventListener('DOMContentLoaded', async function() {
|
||||
const statusEl = document.getElementById('system-status');
|
||||
|
||||
if (!statusEl) return;
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/contribute/health');
|
||||
const health = await response.json();
|
||||
|
||||
let statusColor = 'var(--color-success)';
|
||||
let statusText = 'All systems operational';
|
||||
|
||||
if (health.overall === 'warning') {
|
||||
statusColor = 'var(--color-warning)';
|
||||
statusText = `${health.summary.warnings} warning(s) detected`;
|
||||
} else if (health.overall === 'error') {
|
||||
statusColor = 'var(--color-error)';
|
||||
statusText = `${health.summary.errors} error(s) detected`;
|
||||
}
|
||||
|
||||
statusEl.innerHTML = `
|
||||
<div style="width: 12px; height: 12px; background-color: ${statusColor}; border-radius: 50%;"></div>
|
||||
<span style="color: var(--color-text);">${statusText}</span>
|
||||
<a href="/api/contribute/health" target="_blank" style="color: var(--color-primary); text-decoration: underline; font-size: 0.875rem;">View Details</a>
|
||||
`;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Health check failed:', error);
|
||||
statusEl.innerHTML = `
|
||||
<div style="width: 12px; height: 12px; background-color: var(--color-error); border-radius: 50%;"></div>
|
||||
<span style="color: var(--color-error);">Health check failed</span>
|
||||
`;
|
||||
}
|
||||
});
|
||||
|
||||
// Add hover effects for cards
|
||||
document.querySelectorAll('.card[onclick]').forEach((card) => {
|
||||
const cardEl = card as HTMLElement;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user