Add 'use main stack settings' toggle for third-party integration credentials

Each of Newbook, Resos, SambaPOS, SMTP, and Nextcloud now has a checkbox at the
top of its credentials block. When enabled, the app reads auth credentials from
the central stack settings service (SETTINGS_URL + STACK_INTERNAL_SECRET) and
the local auth fields are grayed out. App-specific fields (base path, GL codes,
keywords, sync intervals, etc.) remain editable regardless.

Backend: new use_global_* columns on kitchen_settings, migration, global_settings_service
with apply_global_overrides() for in-memory credential injection, GET /api/settings/global-status
endpoint, and apply_global_overrides() called in test-connection endpoints and FileArchivalService.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-12 21:57:10 +00:00
parent 62417d59de
commit d7898ba897
10 changed files with 356 additions and 34 deletions

View file

@ -45,6 +45,7 @@ class ResosSettingsResponse(BaseModel):
resos_arrival_widget_service_filter: str | None # Service type: breakfast/lunch/dinner/other
sambapos_food_gl_codes: str | None # Phase 8.1
sambapos_beverage_gl_codes: str | None # Phase 8.1
use_global_resos: bool = False
class Config:
from_attributes = True
@ -67,6 +68,7 @@ class ResosSettingsUpdate(BaseModel):
resos_arrival_widget_service_filter: str | None = None # Opening hour ID for arrivals widget filter
sambapos_food_gl_codes: str | None = None # Phase 8.1
sambapos_beverage_gl_codes: str | None = None # Phase 8.1
use_global_resos: bool | None = None
class DailyStatsResponse(BaseModel):
@ -149,7 +151,8 @@ async def get_resos_settings(
resos_flag_icon_mapping=settings.resos_flag_icon_mapping,
resos_arrival_widget_service_filter=settings.resos_arrival_widget_service_filter,
sambapos_food_gl_codes=settings.sambapos_food_gl_codes, # Phase 8.1
sambapos_beverage_gl_codes=settings.sambapos_beverage_gl_codes # Phase 8.1
sambapos_beverage_gl_codes=settings.sambapos_beverage_gl_codes, # Phase 8.1
use_global_resos=settings.use_global_resos or False,
)
@ -203,6 +206,8 @@ async def update_resos_settings(
settings.sambapos_food_gl_codes = update.sambapos_food_gl_codes
if update.sambapos_beverage_gl_codes is not None:
settings.sambapos_beverage_gl_codes = update.sambapos_beverage_gl_codes
if update.use_global_resos is not None:
settings.use_global_resos = update.use_global_resos
await db.commit()
logger.info(f"[Resos PATCH] After commit - upcoming_sync_enabled={settings.resos_upcoming_sync_enabled}")
@ -220,6 +225,9 @@ async def test_resos_connection(
)
settings = result.scalar_one()
from services.global_settings_service import apply_global_overrides
await apply_global_overrides(settings)
if not settings.resos_api_key:
raise HTTPException(status_code=400, detail="Resos API key not configured")