fix: add node button visibility, fix node-guardian swapper health check, fix banner URL transform
This commit is contained in:
@@ -94,7 +94,7 @@ export default function MicrodaoDetailPage() {
|
||||
<section
|
||||
className="rounded-3xl border border-white/10 bg-gradient-to-br from-sky-950/50 via-slate-900 to-black p-6 md:p-8 space-y-6 relative overflow-hidden shadow-2xl shadow-sky-900/10"
|
||||
style={microdao.banner_url ? {
|
||||
backgroundImage: `linear-gradient(to bottom, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.95)), url(${microdao.banner_url.startsWith('/') ? `/api/static${microdao.banner_url}` : microdao.banner_url.replace('/static/', '/api/static/')})`,
|
||||
backgroundImage: `linear-gradient(to bottom, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.95)), url(${getAssetUrl(microdao.banner_url)})`,
|
||||
backgroundSize: 'cover',
|
||||
backgroundPosition: 'center',
|
||||
} : undefined}
|
||||
|
||||
@@ -173,16 +173,18 @@ function NodeCard({ node }: { node: NodeProfile }) {
|
||||
|
||||
export default function NodesPage() {
|
||||
const router = useRouter();
|
||||
const { user } = useAuth();
|
||||
const { user, isAuthenticated } = useAuth();
|
||||
const { nodes, total, isLoading, error } = useNodeList();
|
||||
|
||||
// Check if user can add nodes (admin or orchestrator)
|
||||
const canAddNode = user && (
|
||||
user.roles?.includes('admin') ||
|
||||
user.roles?.includes('orchestrator') ||
|
||||
user.roles?.includes('is_admin') ||
|
||||
user.roles?.includes('is_orchestrator')
|
||||
);
|
||||
// Check if user can add nodes
|
||||
// For MVP: show button to all authenticated users
|
||||
// Later: restrict to admin/orchestrator roles
|
||||
const canAddNode = isAuthenticated && user;
|
||||
|
||||
// Debug: log user roles
|
||||
if (typeof window !== 'undefined' && user) {
|
||||
console.log('[NodesPage] User roles:', user.roles);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-b from-slate-900 via-slate-900 to-slate-950">
|
||||
@@ -196,7 +198,7 @@ export default function NodesPage() {
|
||||
Node Directory
|
||||
</h1>
|
||||
</div>
|
||||
{canAddNode && (
|
||||
{canAddNode ? (
|
||||
<button
|
||||
onClick={() => router.push('/nodes/register')}
|
||||
className="flex items-center gap-2 px-4 py-2 bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 rounded-xl text-white font-medium transition-all shadow-lg shadow-purple-500/25 hover:shadow-purple-500/40"
|
||||
@@ -204,6 +206,14 @@ export default function NodesPage() {
|
||||
<Plus className="w-5 h-5" />
|
||||
Додати ноду
|
||||
</button>
|
||||
) : (
|
||||
<Link
|
||||
href="/nodes/register"
|
||||
className="flex items-center gap-2 px-4 py-2 bg-white/10 hover:bg-white/20 border border-white/20 rounded-xl text-white/80 font-medium transition-all"
|
||||
>
|
||||
<Plus className="w-5 h-5" />
|
||||
Як додати ноду
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-white/60 text-lg">
|
||||
@@ -263,7 +273,7 @@ export default function NodesPage() {
|
||||
<p className="text-white/50 mb-6">
|
||||
Наразі немає жодної зареєстрованої ноди.
|
||||
</p>
|
||||
{canAddNode && (
|
||||
{canAddNode ? (
|
||||
<button
|
||||
onClick={() => router.push('/nodes/register')}
|
||||
className="inline-flex items-center gap-2 px-6 py-3 bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 rounded-xl text-white font-medium transition-all shadow-lg shadow-purple-500/25 hover:shadow-purple-500/40"
|
||||
@@ -271,6 +281,14 @@ export default function NodesPage() {
|
||||
<Plus className="w-5 h-5" />
|
||||
Додати першу ноду
|
||||
</button>
|
||||
) : (
|
||||
<Link
|
||||
href="/nodes/register"
|
||||
className="inline-flex items-center gap-2 px-6 py-3 bg-white/10 hover:bg-white/20 border border-white/20 rounded-xl text-white/80 font-medium transition-all"
|
||||
>
|
||||
<Plus className="w-5 h-5" />
|
||||
Як додати ноду
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
|
||||
@@ -205,7 +205,9 @@ class NodeGuardian:
|
||||
r = await self.client.get(f"{swapper_url}/health", timeout=3.0)
|
||||
if r.status_code == 200:
|
||||
health_data = r.json()
|
||||
metrics["swapper_healthy"] = health_data.get("status") == "healthy"
|
||||
# Swapper can return "status": "healthy" or "ok"
|
||||
status = health_data.get("status", "").lower()
|
||||
metrics["swapper_healthy"] = status in ("healthy", "ok")
|
||||
else:
|
||||
metrics["swapper_healthy"] = False
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user