feat: improve setup wizard UX, add cluster sync error handling, and conditional demo data seeding
Add SEED_DEMO_DATA environment variable to control demo data population, enhance setup wizard with welcome screen and theme toggle, add smooth animations for wizard transitions, improve dashboard endpoint to return structured objects for last_syncs and faulty_nodes instead of raw models, implement comprehensive error handling in cluster sync with failed status tracking and audit logging, fix Proxmox provider
This commit is contained in:
+25
-13
@@ -45,29 +45,42 @@ SERVICES = [
|
||||
|
||||
|
||||
def seed_demo_data(db: Session) -> None:
|
||||
settings = get_settings()
|
||||
if not db.get(SystemSetting, "setup"):
|
||||
db.add(SystemSetting(key="setup", value={"complete": False}))
|
||||
db.commit()
|
||||
|
||||
roles = {
|
||||
"Super Admin": ["*"],
|
||||
"Network Admin": ["networks:*", "ipam:*", "clusters:read"],
|
||||
"Security Admin": ["policies:*", "firewall:*", "security-groups:*"],
|
||||
"Tenant Admin": ["tenants:read", "projects:*"],
|
||||
"Auditor": ["audit:read", "clusters:read", "policies:read"],
|
||||
"Read Only User": ["*:read"],
|
||||
}
|
||||
for name, permissions in roles.items():
|
||||
if not db.scalar(select(Role).where(Role.name == name)):
|
||||
db.add(Role(name=name, permissions=permissions))
|
||||
|
||||
for name, proto, ports in SERVICES:
|
||||
if not db.scalar(select(ServiceCatalogItem).where(ServiceCatalogItem.name == name)):
|
||||
db.add(ServiceCatalogItem(name=name, protocol=proto, ports=ports, editable=True))
|
||||
|
||||
db.commit()
|
||||
|
||||
if not settings.seed_demo_data:
|
||||
return
|
||||
|
||||
if db.scalar(select(User).where(User.email == "admin@nexafabric.local")):
|
||||
return
|
||||
|
||||
super_admin = Role(name="Super Admin", permissions=["*"])
|
||||
roles = [
|
||||
super_admin,
|
||||
Role(name="Network Admin", permissions=["networks:*", "ipam:*", "clusters:read"]),
|
||||
Role(name="Security Admin", permissions=["policies:*", "firewall:*", "security-groups:*"]),
|
||||
Role(name="Tenant Admin", permissions=["tenants:read", "projects:*"]),
|
||||
Role(name="Auditor", permissions=["audit:read", "clusters:read", "policies:read"]),
|
||||
Role(name="Read Only User", permissions=["*:read"]),
|
||||
]
|
||||
super_admin = db.scalar(select(Role).where(Role.name == "Super Admin"))
|
||||
user = User(
|
||||
email="admin@nexafabric.local",
|
||||
display_name="NexaFabric Administrator",
|
||||
password_hash=hash_password(get_settings().demo_admin_password),
|
||||
password_hash=hash_password(settings.demo_admin_password),
|
||||
roles=[super_admin],
|
||||
)
|
||||
db.add_all(roles + [user])
|
||||
db.add(user)
|
||||
|
||||
tenants = [
|
||||
Tenant(name="Platform", description="Shared infrastructure and platform services"),
|
||||
@@ -181,6 +194,5 @@ def seed_demo_data(db: Session) -> None:
|
||||
]
|
||||
)
|
||||
|
||||
db.add_all([ServiceCatalogItem(name=name, protocol=proto, ports=ports, editable=True) for name, proto, ports in SERVICES])
|
||||
db.add(AuditLog(user_id=user.id, action="seed.created", object_type="system", result="success"))
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user