Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class DBRegion(Base):

id = Column(Integer, primary_key=True, index=True)
name = Column(String, unique=True, index=True)
label = Column(String)
postgres_host = Column(String)
postgres_port = Column(Integer, default=5432)
postgres_admin_user = Column(String)
Expand Down
4 changes: 2 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ async def custom_swagger_ui_html():
return get_swagger_ui_html(
openapi_url="/openapi.json",
title="API Documentation",
swagger_js_url="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.9.0/swagger-ui-bundle.js",
swagger_css_url="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.9.0/swagger-ui.css",
swagger_js_url="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.31.0/swagger-ui-bundle.js",
swagger_css_url="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5.31.0/swagger-ui.css",
oauth2_redirect_url="/oauth2-redirect",
init_oauth={
"usePkceWithAuthorizationCodeGrant": False,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""add label to regions

Revision ID: 646f3aa3b394
Revises: 0ba9c30d601d
Create Date: 2026-01-30 20:28:35.668898+00:00

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '646f3aa3b394'
down_revision: Union[str, None] = '0ba9c30d601d'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('regions', sa.Column('label', sa.String(), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('regions', 'label')
# ### end Alembic commands ###
3 changes: 3 additions & 0 deletions app/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class APITokenResponse(APITokenBase):

class RegionBase(BaseModel):
name: str
label: str
postgres_host: str
postgres_port: int = 5432
postgres_admin_user: str
Expand All @@ -88,6 +89,7 @@ class RegionCreate(RegionBase):

class RegionUpdate(BaseModel):
name: str
label: str
postgres_host: str
postgres_port: int
postgres_admin_user: str
Expand All @@ -101,6 +103,7 @@ class RegionUpdate(BaseModel):
class RegionResponse(BaseModel):
id: int
name: str
label: str
postgres_host: str
litellm_api_url: str
is_active: bool
Expand Down
29 changes: 27 additions & 2 deletions frontend/src/app/admin/regions/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface Team {
interface Region {
id: string;
name: string;
label: string;
postgres_host: string;
postgres_port: number;
postgres_admin_user: string;
Expand All @@ -65,6 +66,7 @@ export default function RegionsPage() {
const [selectedRegionForTeams, setSelectedRegionForTeams] = useState<Region | null>(null);
const [newRegion, setNewRegion] = useState({
name: '',
label: '',
postgres_host: '',
postgres_port: 5432,
postgres_admin_user: '',
Expand Down Expand Up @@ -120,6 +122,7 @@ export default function RegionsPage() {
setIsAddingRegion(false);
setNewRegion({
name: '',
label: '',
postgres_host: '',
postgres_port: 5432,
postgres_admin_user: '',
Expand Down Expand Up @@ -167,6 +170,7 @@ export default function RegionsPage() {
mutationFn: async (regionData: Region) => {
type UpdateData = {
name: string;
label: string;
postgres_host: string;
postgres_port: number;
postgres_admin_user: string;
Expand All @@ -179,6 +183,7 @@ export default function RegionsPage() {

const updateData: UpdateData = {
name: regionData.name,
label: regionData.label,
postgres_host: regionData.postgres_host,
postgres_port: regionData.postgres_port,
postgres_admin_user: regionData.postgres_admin_user,
Expand Down Expand Up @@ -371,6 +376,15 @@ export default function RegionsPage() {
required
/>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">Label</label>
<Input
value={newRegion.label}
onChange={(e) => setNewRegion({ ...newRegion, label: e.target.value })}
placeholder="us-east-1"
required
/>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">Postgres Host</label>
<Input
Expand Down Expand Up @@ -429,7 +443,7 @@ export default function RegionsPage() {
/>
</div>
</div>
<div className="flex items-center space-x-2">
<div className="flex items-center space-x-2">
<input
type="checkbox"
id="is_dedicated"
Expand Down Expand Up @@ -467,6 +481,7 @@ export default function RegionsPage() {
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead>Label</TableHead>
<TableHead>Postgres Host</TableHead>
<TableHead>Type</TableHead>
<TableHead>Status</TableHead>
Expand All @@ -478,6 +493,7 @@ export default function RegionsPage() {
{paginatedData.map((region) => (
<TableRow key={region.id}>
<TableCell>{region.name}</TableCell>
<TableCell>{region.label}</TableCell>
<TableCell>{region.postgres_host}</TableCell>
<TableCell>
<Badge variant={region.is_dedicated ? "default" : "secondary"}>
Expand Down Expand Up @@ -551,6 +567,15 @@ export default function RegionsPage() {
required
/>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">Label</label>
<Input
value={editingRegion.label}
onChange={(e) => setEditingRegion({ ...editingRegion, label: e.target.value })}
placeholder="US East 1"
required
/>
</div>
<div className="space-y-2">
<label className="text-sm font-medium">Postgres Host</label>
<Input
Expand Down Expand Up @@ -607,7 +632,7 @@ export default function RegionsPage() {
/>
</div>
</div>
<div className="flex items-center space-x-2">
<div className="flex items-center space-x-2">
<input
type="checkbox"
id="edit_is_dedicated"
Expand Down
10 changes: 5 additions & 5 deletions scripts/add_test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def create_test_data():
selected_product = random.choice(existing_products)
print(f"Selected product for teams: {selected_product.name} (ID: {selected_product.id})")

# 1. Team with one user, created 32 days ago
# 1. Team with one user, created 32 days ago
if "Test Team 1" not in existing_teams:
print("\n1. Creating team with one user (created 32 days ago)...")
team1 = DBTeam(
Expand Down Expand Up @@ -108,7 +108,7 @@ def create_test_data():
team1 = existing_teams["Test Team 1"]
print(f"\n1. Team 1 already exists: {team1.name} (ID: {team1.id})")

# 2. Team with one user, always_free=True, created 20 days ago
# 2. Team with one user, always_free=True, created 20 days ago
if "Test Team 2 - Always Free" not in existing_teams:
print("\n2. Creating team with one user, always_free=True (created 20 days ago)...")
team2 = DBTeam(
Expand Down Expand Up @@ -139,7 +139,7 @@ def create_test_data():
team2 = existing_teams["Test Team 2 - Always Free"]
print(f"\n2. Team 2 already exists: {team2.name} (ID: {team2.id})")

# 3. Team with one user and product association
# 3. Team with one user and product association
if "Test Team 3 - With Product" not in existing_teams:
print("\n3. Creating team with one user and product association...")
team3 = DBTeam(
Expand Down Expand Up @@ -180,7 +180,7 @@ def create_test_data():
team3 = existing_teams["Test Team 3 - With Product"]
print(f"\n3. Team 3 already exists: {team3.name} (ID: {team3.id})")

# 4. Team with one user, created 40 days ago, with payment 35 days ago, and product association
# 4. Team with one user, created 40 days ago, with payment 35 days ago, and product association
if "Test Team 4 - With Payment History" not in existing_teams:
print("\n4. Creating team with one user, payment history, and product association...")
team4 = DBTeam(
Expand Down Expand Up @@ -223,7 +223,7 @@ def create_test_data():
team4 = existing_teams["Test Team 4 - With Payment History"]
print(f"\n4. Team 4 already exists: {team4.name} (ID: {team4.id})")

# 5. Team with one user, no products, created 20 days ago
# 5. Team with one user, no products, created 20 days ago
if "Test Team 5 - No Products" not in existing_teams:
print("\n5. Creating team with one user, no products (created 20 days ago)...")
team5 = DBTeam(
Expand Down
Loading
Loading