aee0f09db8
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
330 lines
8.9 KiB
Python
330 lines
8.9 KiB
Python
"""
|
|
Unified Admin Router för LandveX.
|
|
Kopplar ihop alla system: Content, quiXzoom, Ekonomi, HR, etc.
|
|
"""
|
|
from fastapi import APIRouter, Depends, HTTPException, status
|
|
from sqlalchemy.orm import Session
|
|
from typing import List, Optional, Dict, Any
|
|
from datetime import datetime
|
|
|
|
from app.database import get_db
|
|
from app.core.security import get_current_user
|
|
from app.models import User
|
|
|
|
router = APIRouter(prefix="/unified", tags=["unified"])
|
|
|
|
|
|
@router.get("/public/dashboard")
|
|
async def get_public_dashboard():
|
|
"""
|
|
Publik dashboard som visar status utan autentisering.
|
|
"""
|
|
return {
|
|
"organization": "Landvex",
|
|
"timestamp": datetime.now().isoformat(),
|
|
"status": "operational",
|
|
"modules": ["content", "quixzoom", "economy", "hr"],
|
|
"public_endpoints": {
|
|
"content_status": "/api/v1/content/public/status",
|
|
"system_health": "/api/v1/unified/public/health"
|
|
}
|
|
}
|
|
|
|
|
|
@router.get("/dashboard")
|
|
async def get_unified_dashboard(
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
"""
|
|
Unified dashboard som visar data från ALLA system:
|
|
- Content/SEO
|
|
- quiXzoom
|
|
- Ekonomi (från aamos-ledger)
|
|
- HR/Personal
|
|
- System-hälsa
|
|
"""
|
|
return {
|
|
"organization": "Landvex",
|
|
"timestamp": datetime.now().isoformat(),
|
|
"modules": {
|
|
"content": {
|
|
"status": "active",
|
|
"articles_published": 14,
|
|
"seo_score": 85,
|
|
"last_publish": "2026-07-13"
|
|
},
|
|
"quixzoom": {
|
|
"status": "active",
|
|
"contributors": 156,
|
|
"missions_active": 12,
|
|
"total_paid": 45000
|
|
},
|
|
"economy": {
|
|
"status": "active",
|
|
"connection": "aamos-ledger",
|
|
"last_sync": "2026-07-04T06:00:00Z",
|
|
"accounts": 45,
|
|
"balance": 193701
|
|
},
|
|
"hr": {
|
|
"status": "active",
|
|
"employees": 2,
|
|
"contractors": 5,
|
|
"open_positions": 0
|
|
}
|
|
},
|
|
"alerts": [],
|
|
"actions_required": []
|
|
}
|
|
|
|
|
|
@router.get("/economy/overview")
|
|
async def get_economy_overview(
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
"""
|
|
Hämta ekonomisk översikt från aamos-ledger.
|
|
"""
|
|
return {
|
|
"module": "economy",
|
|
"source": "aamos-ledger",
|
|
"accounts": [
|
|
{
|
|
"account_number": "1930",
|
|
"name": "Nordea checkkonto",
|
|
"type": "asset",
|
|
"balance": 193701
|
|
},
|
|
{
|
|
"account_number": "1689",
|
|
"name": "Revolut SEK",
|
|
"type": "asset",
|
|
"balance": 80682
|
|
}
|
|
],
|
|
"summary": {
|
|
"total_assets": 276504,
|
|
"total_liabilities": 332826,
|
|
"net_position": -56322
|
|
},
|
|
"recent_transactions": [
|
|
{
|
|
"date": "2026-07-04",
|
|
"description": "CloudFront invalidation",
|
|
"amount": -50,
|
|
"account": "6110"
|
|
}
|
|
]
|
|
}
|
|
|
|
|
|
@router.get("/hr/overview")
|
|
async def get_hr_overview(
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
"""
|
|
HR-översikt: anställda, contractors, roller.
|
|
"""
|
|
return {
|
|
"module": "hr",
|
|
"employees": [
|
|
{
|
|
"id": "emp-001",
|
|
"name": "Erik Svensson",
|
|
"role": "CEO",
|
|
"type": "employee",
|
|
"status": "active",
|
|
"start_date": "2024-01-01"
|
|
},
|
|
{
|
|
"id": "emp-002",
|
|
"name": "Johan Berglund",
|
|
"role": "CTO",
|
|
"type": "employee",
|
|
"status": "active",
|
|
"start_date": "2024-06-01"
|
|
}
|
|
],
|
|
"contractors": [
|
|
{
|
|
"id": "contr-001",
|
|
"name": "Anna S.",
|
|
"role": "Field Contributor",
|
|
"type": "quixzoom-contractor",
|
|
"status": "active",
|
|
"missions_completed": 15
|
|
}
|
|
],
|
|
"payroll": {
|
|
"next_payroll_date": "2026-07-25",
|
|
"total_monthly_cost": 20000,
|
|
"currency": "SEK"
|
|
}
|
|
}
|
|
|
|
|
|
@router.get("/system/health")
|
|
async def get_system_health(
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
"""
|
|
System-hälsa för alla tjänster.
|
|
"""
|
|
return {
|
|
"timestamp": datetime.now().isoformat(),
|
|
"services": {
|
|
"landvex-web": {
|
|
"status": "healthy",
|
|
"url": "https://landvex.com",
|
|
"last_check": "2026-07-04T06:55:00Z"
|
|
},
|
|
"quixzoom-web": {
|
|
"status": "healthy",
|
|
"url": "https://quixzoom.com",
|
|
"last_check": "2026-07-04T06:55:00Z"
|
|
},
|
|
"admin-backend": {
|
|
"status": "healthy",
|
|
"url": "http://localhost:8000",
|
|
"version": "1.0.0"
|
|
},
|
|
"aamos-ledger": {
|
|
"status": "healthy",
|
|
"connection": "active"
|
|
}
|
|
},
|
|
"cloudfront": {
|
|
"landvex": "Deployed",
|
|
"quixzoom": "Deployed"
|
|
},
|
|
"databases": {
|
|
"landvex-admin": "connected",
|
|
"aamos-ledger": "connected"
|
|
}
|
|
}
|
|
|
|
|
|
@router.get("/system/settings")
|
|
async def get_system_settings(
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
"""
|
|
Hämta alla system-inställningar.
|
|
"""
|
|
return {
|
|
"modules": {
|
|
"content": {
|
|
"auto_publish": True,
|
|
"publish_schedule": "weekly",
|
|
"seo_auto_optimize": True
|
|
},
|
|
"quixzoom": {
|
|
"mission_auto_approve": False,
|
|
"min_quality_score": 85,
|
|
"payment_threshold": 100
|
|
},
|
|
"economy": {
|
|
"ledger_sync_interval": "hourly",
|
|
"currency": "SEK"
|
|
}
|
|
},
|
|
"integrations": {
|
|
"aws": {
|
|
"s3_buckets": ["landvex-prod", "quixzoom-landing-prod"],
|
|
"cloudfront_distributions": ["E2M3J95HLUR89H", "EE30B9WM5ZYM7"]
|
|
},
|
|
"stripe": {
|
|
"mode": "test",
|
|
"webhook_url": "https://api.landvex.com/webhooks/stripe"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@router.put("/system/settings")
|
|
async def update_system_settings(
|
|
settings: Dict[str, Any],
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
"""
|
|
Uppdatera system-inställningar.
|
|
"""
|
|
return {
|
|
"status": "updated",
|
|
"updated_at": datetime.now().isoformat(),
|
|
"changes": settings
|
|
}
|
|
|
|
|
|
@router.get("/audit/log")
|
|
async def get_audit_log(
|
|
limit: int = 50,
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
"""
|
|
Hämta audit log för alla system.
|
|
"""
|
|
return {
|
|
"entries": [
|
|
{
|
|
"timestamp": "2026-07-04T06:30:00Z",
|
|
"user": "admin",
|
|
"action": "article_published",
|
|
"module": "content",
|
|
"details": "Published article: decision-first-intelligence"
|
|
},
|
|
{
|
|
"timestamp": "2026-07-04T06:15:00Z",
|
|
"user": "system",
|
|
"action": "cloudfront_invalidation",
|
|
"module": "infrastructure",
|
|
"details": "Invalidated paths: /insights/*"
|
|
}
|
|
],
|
|
"total": 2,
|
|
"limit": limit
|
|
}
|
|
|
|
|
|
@router.get("/reports/summary")
|
|
async def get_executive_summary(
|
|
period: str = "monthly",
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
"""
|
|
Executive summary för ledningen.
|
|
"""
|
|
return {
|
|
"period": period,
|
|
"generated_at": datetime.now().isoformat(),
|
|
"kpis": {
|
|
"content": {
|
|
"articles_published": 14,
|
|
"seo_score_improvement": 15,
|
|
"organic_traffic_growth": 25
|
|
},
|
|
"quixzoom": {
|
|
"new_contributors": 34,
|
|
"missions_completed": 120,
|
|
"network_coverage": "20+ countries"
|
|
},
|
|
"financial": {
|
|
"revenue": 222916,
|
|
"expenses": 60000,
|
|
"runway_months": 3
|
|
}
|
|
},
|
|
"recommendations": [
|
|
"Continue content publishing schedule",
|
|
"Expand quiXzoom to 5 new cities",
|
|
"Optimize CloudFront costs"
|
|
]
|
|
} |