diff --git a/docs/en/docs/pro/exclusive.md b/docs/en/docs/pro/exclusive.md index 1f5e82c..9906126 100644 --- a/docs/en/docs/pro/exclusive.md +++ b/docs/en/docs/pro/exclusive.md @@ -54,3 +54,11 @@ You can enable site search by add `SearchProvider` to `admin_app.configure(...)` ```python await admin_app.configure(providers=[SearchProvider()]) ``` + +## Notification + +You can use notification by adding `NotificationProvider` to `admin_app.configure(...) implement by websocket. + +```python +await admin_app.configure(providers=[NotificationProvider()]) +``` diff --git a/docs/en/docs/reference/notification.md b/docs/en/docs/reference/notification.md new file mode 100644 index 0000000..21eb13a --- /dev/null +++ b/docs/en/docs/reference/notification.md @@ -0,0 +1,47 @@ +# Notification (💗 Pro only) + +`FastAPI-Admin` provide a notification center implement by websocket. + + + +## Usage + +You should add it to providers to enable it. + +```python +from fastapi import FastAPI +from fastapi_admin.app import app as admin_app +from fastapi_admin.providers.notification import NotificationProvider + +app = FastAPI() + +provider = NotificationProvider() + + +@app.on_event("startup") +async def startup(): + await admin_app.configure( + providers=[provider] + ) +``` + +There are two ways to send notifications. + +One is call `await provider.broadcast()` directly. + +```python +data = { + "title": "test", + "content": "//avatars.githubusercontent.com/u/13377178?v=4", + "image": "https://avatars.githubusercontent.com/u/13377178?v=4" +} +await provider.broadcast(data) +``` + +If you want to send notifications out of application, another way is use http api. + +```python +import requests + +requests.post('http://localhost:8000/admin/notification', json=data) +``` diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml index c73b38b..85c107b 100644 --- a/docs/en/mkdocs.yml +++ b/docs/en/mkdocs.yml @@ -52,6 +52,7 @@ nav: - reference/admin_log.md - reference/global_search.md - reference/errors.md + - reference/notification.md - Customization: - custom/page.md - custom/overwrite.md diff --git a/fastapi_admin/providers/login.py b/fastapi_admin/providers/login.py index 13b3c4b..5ad37b8 100644 --- a/fastapi_admin/providers/login.py +++ b/fastapi_admin/providers/login.py @@ -32,7 +32,7 @@ class UsernamePasswordProvider(Provider): admin_model: Type[AbstractAdmin], login_path="/login", logout_path="/logout", - template="login.html", + template="providers/login/login.html", login_title="Login to your account", login_logo_url: str = None, ): @@ -179,7 +179,7 @@ class UsernamePasswordProvider(Provider): resources=Depends(get_resources), ): return templates.TemplateResponse( - "password.html", + "providers/login/password.html", context={ "request": request, "resources": resources, diff --git a/fastapi_admin/templates/components/language.html b/fastapi_admin/templates/components/language.html new file mode 100644 index 0000000..f0bf762 --- /dev/null +++ b/fastapi_admin/templates/components/language.html @@ -0,0 +1,26 @@ +
diff --git a/fastapi_admin/templates/layout.html b/fastapi_admin/templates/layout.html index ccde0c1..d14c037 100644 --- a/fastapi_admin/templates/layout.html +++ b/fastapi_admin/templates/layout.html @@ -1,219 +1,151 @@ {% extends "base.html" %} {% block body %} -