mirror of
https://github.com/fastapi-admin/fastapi-admin.git
synced 2026-03-13 10:32:25 +08:00
update docs
This commit is contained in:
@@ -30,7 +30,7 @@ You can check a online demo [here](https://fastapi-admin.long2ice.cn/admin/login
|
||||
- username: `admin`
|
||||
- password: `123456`
|
||||
|
||||
Or Pro version demo [here](https://fastapi-admin-pro.long2ice.cn/admin/login).
|
||||
Or pro version online demo [here](https://fastapi-admin-pro.long2ice.cn/admin/login).
|
||||
|
||||
- username: `admin`
|
||||
- password: `123456`
|
||||
|
||||
@@ -164,4 +164,4 @@ class Content(Dropdown):
|
||||
|
||||
### What's next?
|
||||
|
||||
That's all, you can run your app now. For more reference you can see [reference](/reference).
|
||||
That's all, you can run your app now. For more reference you can see [Reference](/reference).
|
||||
|
||||
@@ -32,12 +32,43 @@ Template folders used to override builtin templates.
|
||||
|
||||
## login_provider
|
||||
|
||||
You can pass subclasses of `fastapi_admin.providers.login.LoginProvider`, there is a builtin `fastapi_admin.providers.login.UsernamePasswordProvider` you can use.
|
||||
You can pass subclasses of `fastapi_admin.providers.login.LoginProvider`, there is a
|
||||
builtin `fastapi_admin.providers.login.UsernamePasswordProvider` you can use.
|
||||
|
||||
### user_model
|
||||
### admin_model
|
||||
|
||||
Subclass instance of `fastapi_admin.providers.login.UserMixin`.
|
||||
Subclass instance of `fastapi_admin.models.AbstractAdmin`.
|
||||
|
||||
### enable_captcha (💗 Pro only)
|
||||
|
||||
Show captcha in admin login page.
|
||||
|
||||
## permission_provider (💗 Pro only)
|
||||
|
||||
You can enable permission control by setting `permission_provider`.
|
||||
|
||||
### admin_model
|
||||
|
||||
Subclass of `fastapi_admin.models.AbstractAdmin`.
|
||||
|
||||
### resource_model
|
||||
|
||||
Subclass of `fastapi_admin.models.AbstractResource`.
|
||||
|
||||
### permission_model
|
||||
|
||||
Subclass of `fastapi_admin.models.AbstractPermission`.
|
||||
|
||||
### role_model
|
||||
|
||||
Subclass of `fastapi_admin.models.AbstractRole`.
|
||||
|
||||
## log_model
|
||||
|
||||
You can enable action log by set `log_model`, which is subclass of `fastapi_admin.models.AbstractLog`. After set that,
|
||||
all `delete/create/update` for model will be recorded.
|
||||
|
||||
## search_provider (💗 Pro only)
|
||||
|
||||
You can enable global search by setting `search_provider`, which is instance
|
||||
of `fastapi_admin.providers.search.SearchProvider`, and then will display a search input in all pages.
|
||||
|
||||
@@ -1,9 +1,35 @@
|
||||
# Resource
|
||||
|
||||
There are three kinds of resources, `Link`,`Model` and `Dropdown`.
|
||||
|
||||
## General configuration
|
||||
|
||||
The following are the general configurations of three kinds of resources.
|
||||
|
||||
### label
|
||||
|
||||
Nav bar menu name.
|
||||
|
||||
### icon
|
||||
|
||||
Icon name comes from <https://tabler-icons.io>, like `ti ti-user` will display a user icon in menu.
|
||||
|
||||
## Link
|
||||
|
||||
General `a` tag menu.
|
||||
|
||||
### url
|
||||
|
||||
`href` attr of `a` tag.
|
||||
|
||||
### target
|
||||
|
||||
`target` attr of `a` tag, default is `_self`.
|
||||
|
||||
## Model
|
||||
|
||||
### Field
|
||||
|
||||
### Action
|
||||
|
||||
## Dropdown
|
||||
|
||||
@@ -31,7 +31,12 @@ def create_app():
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
redis = await aioredis.create_redis_pool("redis://localhost", encoding="utf8")
|
||||
redis = await aioredis.create_redis_pool(
|
||||
f"redis://{settings.REDIS_HOST}:{settings.REDIS_PORT}",
|
||||
db=settings.REDIS_DB,
|
||||
password=settings.REDIS_PASSWORD,
|
||||
encoding="utf8",
|
||||
)
|
||||
admin_app.configure(
|
||||
logo_url="https://preview.tabler.io/static/logo-white.svg",
|
||||
login_logo_url="https://preview.tabler.io/static/logo.svg",
|
||||
|
||||
@@ -4,3 +4,7 @@ from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
DATABASE_URL = os.getenv("DATABASE_URL")
|
||||
REDIS_HOST = os.getenv("REDIS_HOST", "localhost")
|
||||
REDIS_PORT = os.getenv("REDIS_PORT", 6379)
|
||||
REDIS_PASSWORD = os.getenv("REDIS_PASSWORD")
|
||||
REDIS_DB = os.getenv("REDIS_DB", 0)
|
||||
|
||||
@@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2021-05-01 20:13+0800\n"
|
||||
"POT-Creation-Date: 2021-05-02 14:00+0800\n"
|
||||
"PO-Revision-Date: 2021-04-16 22:46+0800\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language: en_US\n"
|
||||
@@ -56,15 +56,16 @@ msgstr "Save and add another"
|
||||
msgid "return"
|
||||
msgstr "Return"
|
||||
|
||||
#: fastapi_admin/templates/layout.html:66
|
||||
#: fastapi_admin/templates/layout.html:68
|
||||
msgid "welcome"
|
||||
msgstr "Welcome"
|
||||
|
||||
#: fastapi_admin/templates/layout.html:71
|
||||
#: fastapi_admin/templates/layout.html:73
|
||||
#: fastapi_admin/templates/password.html:6
|
||||
msgid "update_password"
|
||||
msgstr "Update password"
|
||||
|
||||
#: fastapi_admin/templates/layout.html:74
|
||||
#: fastapi_admin/templates/layout.html:76
|
||||
msgid "logout"
|
||||
msgstr "Logout"
|
||||
|
||||
@@ -133,6 +134,34 @@ msgstr "Remember me"
|
||||
msgid "sign_in"
|
||||
msgstr "Sign in"
|
||||
|
||||
#: fastapi_admin/templates/password.html:12
|
||||
msgid "old_password"
|
||||
msgstr "Old password"
|
||||
|
||||
#: fastapi_admin/templates/password.html:15
|
||||
msgid "old_password_placeholder"
|
||||
msgstr "Enter old password"
|
||||
|
||||
#: fastapi_admin/templates/password.html:19
|
||||
msgid "new_password"
|
||||
msgstr "New password"
|
||||
|
||||
#: fastapi_admin/templates/password.html:22
|
||||
msgid "new_password_placeholder"
|
||||
msgstr "Enter new password"
|
||||
|
||||
#: fastapi_admin/templates/password.html:26
|
||||
msgid "re_new_password"
|
||||
msgstr "Confirm new password"
|
||||
|
||||
#: fastapi_admin/templates/password.html:29
|
||||
msgid "re_new_password_placeholder"
|
||||
msgstr "Enter new password again"
|
||||
|
||||
#: fastapi_admin/templates/password.html:32
|
||||
msgid "submit"
|
||||
msgstr "Submit"
|
||||
|
||||
#: fastapi_admin/templates/update.html:23
|
||||
msgid "save_and_return"
|
||||
msgstr "Save and return"
|
||||
|
||||
@@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PROJECT VERSION\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2021-05-01 20:13+0800\n"
|
||||
"POT-Creation-Date: 2021-05-02 14:00+0800\n"
|
||||
"PO-Revision-Date: 2021-04-16 22:46+0800\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language: zh_Hans_CN\n"
|
||||
@@ -40,7 +40,7 @@ msgstr "旧密码错误"
|
||||
|
||||
#: fastapi_admin/routes/password.py:41
|
||||
msgid "new_password_different"
|
||||
msgstr ""
|
||||
msgstr "新密码不一致"
|
||||
|
||||
#: fastapi_admin/templates/create.html:14
|
||||
#: fastapi_admin/templates/update.html:16
|
||||
@@ -56,15 +56,16 @@ msgstr "保存并新增"
|
||||
msgid "return"
|
||||
msgstr "返回"
|
||||
|
||||
#: fastapi_admin/templates/layout.html:66
|
||||
#: fastapi_admin/templates/layout.html:68
|
||||
msgid "welcome"
|
||||
msgstr ""
|
||||
msgstr "欢迎"
|
||||
|
||||
#: fastapi_admin/templates/layout.html:71
|
||||
#: fastapi_admin/templates/layout.html:73
|
||||
#: fastapi_admin/templates/password.html:6
|
||||
msgid "update_password"
|
||||
msgstr "修改密码"
|
||||
|
||||
#: fastapi_admin/templates/layout.html:74
|
||||
#: fastapi_admin/templates/layout.html:76
|
||||
msgid "logout"
|
||||
msgstr "退出登录"
|
||||
|
||||
@@ -133,6 +134,34 @@ msgstr "记住我"
|
||||
msgid "sign_in"
|
||||
msgstr "登录"
|
||||
|
||||
#: fastapi_admin/templates/password.html:12
|
||||
msgid "old_password"
|
||||
msgstr "旧密码"
|
||||
|
||||
#: fastapi_admin/templates/password.html:15
|
||||
msgid "old_password_placeholder"
|
||||
msgstr "请输入旧密码"
|
||||
|
||||
#: fastapi_admin/templates/password.html:19
|
||||
msgid "new_password"
|
||||
msgstr "新密码"
|
||||
|
||||
#: fastapi_admin/templates/password.html:22
|
||||
msgid "new_password_placeholder"
|
||||
msgstr "请输入新密码"
|
||||
|
||||
#: fastapi_admin/templates/password.html:26
|
||||
msgid "re_new_password"
|
||||
msgstr "确认新密码"
|
||||
|
||||
#: fastapi_admin/templates/password.html:29
|
||||
msgid "re_new_password_placeholder"
|
||||
msgstr "请再次输入新密码"
|
||||
|
||||
#: fastapi_admin/templates/password.html:32
|
||||
msgid "submit"
|
||||
msgstr "提交"
|
||||
|
||||
#: fastapi_admin/templates/update.html:23
|
||||
msgid "save_and_return"
|
||||
msgstr "保存并返回"
|
||||
|
||||
@@ -25,8 +25,6 @@ class Resource:
|
||||
class Link(Resource):
|
||||
url: str
|
||||
target: str = "_self"
|
||||
page_pre_title: Optional[str] = None
|
||||
page_title: Optional[str] = None
|
||||
|
||||
|
||||
class Field:
|
||||
@@ -36,11 +34,11 @@ class Field:
|
||||
input: inputs.Input
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
label: str,
|
||||
display: Optional[displays.Display] = None,
|
||||
input_: Optional[Widget] = None,
|
||||
self,
|
||||
name: str,
|
||||
label: str,
|
||||
display: Optional[displays.Display] = None,
|
||||
input_: Optional[Widget] = None,
|
||||
):
|
||||
self.name = name
|
||||
self.label = label
|
||||
@@ -205,7 +203,7 @@ class Model(Resource):
|
||||
ret.append(field)
|
||||
else:
|
||||
if (is_display and isinstance(field.display, displays.InputOnly)) or (
|
||||
not is_display and isinstance(field.input, inputs.DisplayOnly)
|
||||
not is_display and isinstance(field.input, inputs.DisplayOnly)
|
||||
):
|
||||
continue
|
||||
ret.append(field)
|
||||
|
||||
13
fastapi_admin/templates/components/alert_error.html
Normal file
13
fastapi_admin/templates/components/alert_error.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% if error %}
|
||||
<div class="alert alert-important alert-danger alert-dismissible" role="alert">
|
||||
<div class="d-flex">
|
||||
<div>
|
||||
<i class="ti ti-alert-circle"></i>
|
||||
</div>
|
||||
<div>
|
||||
{{ error }}
|
||||
</div>
|
||||
</div>
|
||||
<a class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="close"></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
37
fastapi_admin/templates/password.html
Normal file
37
fastapi_admin/templates/password.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{% extends "layout.html" %}
|
||||
{% block page_body %}
|
||||
{% include "components/alert_error.html" %}
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">{{ _('update_password') }}</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="{{ request.app.admin_path }}/password">
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label">
|
||||
{{ _('old_password') }}
|
||||
</label>
|
||||
<input class="form-control" type="password" name="old_password"
|
||||
placeholder="{{ _('old_password_placeholder') }}"/>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label">
|
||||
{{ _('new_password') }}
|
||||
</label>
|
||||
<input class="form-control" type="password" name="new_password"
|
||||
placeholder="{{ _('new_password_placeholder') }}"/>
|
||||
</div>
|
||||
<div class="form-group mb-3">
|
||||
<label class="form-label">
|
||||
{{ _('re_new_password') }}
|
||||
</label>
|
||||
<input class="form-control" type="password" name="re_new_password"
|
||||
placeholder="{{ _('re_new_password_placeholder') }}"/>
|
||||
</div>
|
||||
<div class="form-footer">
|
||||
<button type="submit" class="btn btn-primary">{{ _('submit') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user