mirror of
https://github.com/stellarshenson/stellars-jupyterhub-ds.git
synced 2026-03-07 21:50:28 +00:00
Drastically reduced documentation length focusing only on essential implementation facts: - doc/notifications.md: Reduced from 250 to 35 lines - key technical facts, handler implementation, template details, dependencies, error handling - doc/ui-template-customization.md: Reduced from 132 to 55 lines - technical facts, JavaScript patterns, Bootstrap 5 syntax, CSRF protection, build process - doc/docker-socket-permissions.md: Reduced from 186 to 66 lines - implementation facts, pre-spawn hook code, built-in group system, security implications, usage All documentation now follows super-minimal "glimpse of implementation" approach with bullet points and code snippets, absent of lengthy narrative and marketing language.
1.9 KiB
1.9 KiB
Notification Broadcast System
Admin-only broadcast system sending notifications to all active JupyterLab servers simultaneously. Accessible at /hub/notifications.
Key Implementation Facts:
- Concurrent delivery using
asyncio.gather()with 5-second timeout per server - Temporary API tokens generated per broadcast (5-minute expiry via
user.new_api_token()) - Dynamic endpoint URL construction:
http://jupyterlab-{username}:8888{base_url}jupyterlab-notifications-extension/ingest - 140-character message limit with live counter
- Six notification types: default, info, success, warning, error, in-progress
- Payload includes actions array with Dismiss button
- One-line logging per server: username, message preview, type, outcome (SUCCESS/FAILED/ERROR)
Handler Implementation (services/jupyterhub/conf/bin/custom_handlers.py):
NotificationsPageHandler- Renders broadcast form at/hub/notificationsBroadcastNotificationHandler- API endpoint for sending notifications at/hub/api/notifications/broadcast- Both restricted to admin users via
@admin_onlydecorator
Template (services/jupyterhub/templates/notifications.html):
- Bootstrap 5 form with message textarea, type selector, auto-close toggle
- RequireJS wrapped JavaScript for CSRF protection
- Results display with expandable per-user status table
Dependencies:
- Requires
jupyterlab_notifications_extensioninstalled on spawned JupyterLab servers - Extension provides ingest endpoint at
/jupyterlab-notifications-extension/ingest - Extension repository: https://github.com/stellarshenson/jupyterlab_notifications_extension
Error Handling:
- Connection timeout -> "Server not responding"
- HTTP 404 -> "Notification extension not installed"
- HTTP 401/403 -> "Authentication failed"
- HTTP 500 -> "Server error processing notification"
- Failures don't block other deliveries (fault-tolerant)