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
|
<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"
|
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 ? {
|
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',
|
backgroundSize: 'cover',
|
||||||
backgroundPosition: 'center',
|
backgroundPosition: 'center',
|
||||||
} : undefined}
|
} : undefined}
|
||||||
|
|||||||
@@ -173,16 +173,18 @@ function NodeCard({ node }: { node: NodeProfile }) {
|
|||||||
|
|
||||||
export default function NodesPage() {
|
export default function NodesPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { user } = useAuth();
|
const { user, isAuthenticated } = useAuth();
|
||||||
const { nodes, total, isLoading, error } = useNodeList();
|
const { nodes, total, isLoading, error } = useNodeList();
|
||||||
|
|
||||||
// Check if user can add nodes (admin or orchestrator)
|
// Check if user can add nodes
|
||||||
const canAddNode = user && (
|
// For MVP: show button to all authenticated users
|
||||||
user.roles?.includes('admin') ||
|
// Later: restrict to admin/orchestrator roles
|
||||||
user.roles?.includes('orchestrator') ||
|
const canAddNode = isAuthenticated && user;
|
||||||
user.roles?.includes('is_admin') ||
|
|
||||||
user.roles?.includes('is_orchestrator')
|
// Debug: log user roles
|
||||||
);
|
if (typeof window !== 'undefined' && user) {
|
||||||
|
console.log('[NodesPage] User roles:', user.roles);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-gradient-to-b from-slate-900 via-slate-900 to-slate-950">
|
<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
|
Node Directory
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
{canAddNode && (
|
{canAddNode ? (
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push('/nodes/register')}
|
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"
|
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" />
|
<Plus className="w-5 h-5" />
|
||||||
Додати ноду
|
Додати ноду
|
||||||
</button>
|
</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>
|
</div>
|
||||||
<p className="text-white/60 text-lg">
|
<p className="text-white/60 text-lg">
|
||||||
@@ -263,7 +273,7 @@ export default function NodesPage() {
|
|||||||
<p className="text-white/50 mb-6">
|
<p className="text-white/50 mb-6">
|
||||||
Наразі немає жодної зареєстрованої ноди.
|
Наразі немає жодної зареєстрованої ноди.
|
||||||
</p>
|
</p>
|
||||||
{canAddNode && (
|
{canAddNode ? (
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push('/nodes/register')}
|
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"
|
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" />
|
<Plus className="w-5 h-5" />
|
||||||
Додати першу ноду
|
Додати першу ноду
|
||||||
</button>
|
</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>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -205,7 +205,9 @@ class NodeGuardian:
|
|||||||
r = await self.client.get(f"{swapper_url}/health", timeout=3.0)
|
r = await self.client.get(f"{swapper_url}/health", timeout=3.0)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
health_data = r.json()
|
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:
|
else:
|
||||||
metrics["swapper_healthy"] = False
|
metrics["swapper_healthy"] = False
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Reference in New Issue
Block a user