Add remote browser pages and website sync

Enable managed remote browser custom pages with login autofill and add website sync workflows so external admin surfaces can be handled inside SmartUp.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
liumangmang
2026-05-15 15:43:58 +08:00
parent a13a0070a5
commit 7adc7c00ab
43 changed files with 6615 additions and 641 deletions
+8
View File
@@ -16,7 +16,15 @@ class CustomPage(Base):
sort_order: Mapped[int] = mapped_column(Integer, default=0)
enabled: Mapped[bool] = mapped_column(Boolean, default=True)
use_proxy: Mapped[bool] = mapped_column(Boolean, default=False)
access_mode: Mapped[str] = mapped_column(String(32), default="direct", nullable=False)
description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
login_username: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
login_password: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
login_username_selector: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
login_password_selector: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
login_submit_selector: Mapped[Optional[str]] = mapped_column(String(512), nullable=True)
login_autofill_enabled: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
login_autofill_backfilled_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.now(timezone.utc))
updated_at: Mapped[datetime] = mapped_column(
DateTime,
+1 -1
View File
@@ -14,7 +14,7 @@ class WebhookConfig(Base):
url: Mapped[str] = mapped_column(String(1024), nullable=False)
secret: Mapped[str] = mapped_column(String(512), default="")
enabled: Mapped[bool] = mapped_column(Boolean, default=True)
# JSON array: ["upstream_rate_changed","upstream_unhealthy","upstream_recovered"]
# JSON array: ["upstream_rate_changed","website_rate_changed","upstream_unhealthy","upstream_recovered"]
events_json: Mapped[str] = mapped_column(Text, default='["upstream_rate_changed"]')
created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.now(timezone.utc))
updated_at: Mapped[datetime] = mapped_column(
+68
View File
@@ -0,0 +1,68 @@
from datetime import datetime, timezone
from typing import Optional
from sqlalchemy import Boolean, DateTime, ForeignKey, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.database import Base
class Website(Base):
__tablename__ = "websites"
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
name: Mapped[str] = mapped_column(String(255), nullable=False)
site_type: Mapped[str] = mapped_column(String(32), default="sub2api")
base_url: Mapped[str] = mapped_column(String(512), nullable=False)
api_prefix: Mapped[str] = mapped_column(String(128), default="/api/v1/admin")
auth_type: Mapped[str] = mapped_column(String(32), default="api_key")
auth_config_json: Mapped[str] = mapped_column(Text, default="{}")
groups_endpoint: Mapped[str] = mapped_column(String(256), default="/groups")
group_update_endpoint: Mapped[str] = mapped_column(String(256), default="/groups/{id}")
enabled: Mapped[bool] = mapped_column(Boolean, default=True)
auto_sync_enabled: Mapped[bool] = mapped_column(Boolean, default=True)
timeout_seconds: Mapped[int] = mapped_column(Integer, default=30)
last_status: Mapped[str] = mapped_column(String(32), default="unknown")
last_checked_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
last_error: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.now(timezone.utc))
updated_at: Mapped[datetime] = mapped_column(
DateTime, default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc)
)
class WebsiteGroupBinding(Base):
__tablename__ = "website_group_bindings"
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
website_id: Mapped[int] = mapped_column(Integer, ForeignKey("websites.id", ondelete="CASCADE"), index=True)
target_group_id: Mapped[str] = mapped_column(String(255), nullable=False)
target_group_name: Mapped[str] = mapped_column(String(255), default="")
source_groups_json: Mapped[str] = mapped_column(Text, default="[]")
percent: Mapped[str] = mapped_column(String(32), default="0")
algorithm: Mapped[str] = mapped_column(String(64), default="max_plus_percent")
enabled: Mapped[bool] = mapped_column(Boolean, default=True)
created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.now(timezone.utc))
updated_at: Mapped[datetime] = mapped_column(
DateTime, default=lambda: datetime.now(timezone.utc), onupdate=lambda: datetime.now(timezone.utc)
)
class WebsiteSyncLog(Base):
__tablename__ = "website_sync_logs"
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
website_id: Mapped[int] = mapped_column(Integer, ForeignKey("websites.id", ondelete="CASCADE"), index=True)
binding_id: Mapped[Optional[int]] = mapped_column(
Integer, ForeignKey("website_group_bindings.id", ondelete="SET NULL"), nullable=True, index=True
)
target_group_id: Mapped[str] = mapped_column(String(255), default="")
target_group_name: Mapped[str] = mapped_column(String(255), default="")
algorithm: Mapped[str] = mapped_column(String(64), default="")
percent: Mapped[str] = mapped_column(String(32), default="0")
source_rates_json: Mapped[str] = mapped_column(Text, default="[]")
old_rate: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
new_rate: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
status: Mapped[str] = mapped_column(String(16), nullable=False)
message: Mapped[str] = mapped_column(Text, default="")
created_at: Mapped[datetime] = mapped_column(DateTime, default=lambda: datetime.now(timezone.utc), index=True)