Build and Push / build (release) Successful in 1m10s
Adds link_type column to quick_links table for iframe vs new_tab behavior. Includes Alembic migration and schema updates. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
78 lines
2.6 KiB
Python
78 lines
2.6 KiB
Python
"""
|
|
Dashboard Domain Models
|
|
|
|
SQLAlchemy models for dashboard-related data.
|
|
"""
|
|
from datetime import datetime
|
|
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Text, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from src.shared.database import Base
|
|
|
|
|
|
class QuickLink(Base):
|
|
"""Quick link for dashboard jump pad"""
|
|
__tablename__ = "quick_links"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
|
|
# Link content
|
|
title = Column(String(100), nullable=False)
|
|
url = Column(String(500), nullable=False)
|
|
icon = Column(String(100), nullable=True) # Icon name or URL
|
|
description = Column(String(255), nullable=True)
|
|
|
|
# Categorization
|
|
category = Column(String(50), nullable=True) # e.g., "services", "tools", "docs"
|
|
|
|
# User association - nullable for global links
|
|
user_id = Column(String(255), nullable=True, index=True) # Authentik user ID
|
|
|
|
# Ordering and display
|
|
position = Column(Integer, default=0)
|
|
is_visible = Column(Boolean, default=True)
|
|
link_type = Column(String(20), default="iframe") # "iframe", "new_tab", etc.
|
|
|
|
# Styling
|
|
color = Column(String(20), nullable=True) # Hex color for the link card
|
|
background_color = Column(String(20), nullable=True)
|
|
|
|
# Metadata
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
def __repr__(self):
|
|
return f"<QuickLink(id={self.id}, title='{self.title}', user_id='{self.user_id}')>"
|
|
|
|
|
|
class DashboardWidget(Base):
|
|
"""Dashboard widget configuration"""
|
|
__tablename__ = "dashboard_widgets"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
|
|
# Widget identification
|
|
widget_type = Column(String(50), nullable=False) # e.g., "quick_links", "service_status", "weather"
|
|
|
|
# User association - nullable for default widgets
|
|
user_id = Column(String(255), nullable=True, index=True)
|
|
|
|
# Position and sizing
|
|
position_x = Column(Integer, default=0)
|
|
position_y = Column(Integer, default=0)
|
|
width = Column(Integer, default=1)
|
|
height = Column(Integer, default=1)
|
|
|
|
# Widget-specific configuration (JSON)
|
|
config = Column(Text, nullable=True) # JSON string for widget-specific settings
|
|
|
|
# Display
|
|
is_visible = Column(Boolean, default=True)
|
|
|
|
# Metadata
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
|
|
|
def __repr__(self):
|
|
return f"<DashboardWidget(id={self.id}, type='{self.widget_type}', user_id='{self.user_id}')>"
|