Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xnuinside/gino-admin
Admin Panel for GinoORM - ready to up & run (just add your models)
https://github.com/xnuinside/gino-admin
admin admin-panel async database database-management fastapi gino gino-orm postgresql python sanic sanic-framework
Last synced: 12 days ago
JSON representation
Admin Panel for GinoORM - ready to up & run (just add your models)
- Host: GitHub
- URL: https://github.com/xnuinside/gino-admin
- Owner: xnuinside
- License: mit
- Created: 2020-04-19T17:22:55.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-08T02:36:38.000Z (over 1 year ago)
- Last Synced: 2024-05-07T18:11:39.314Z (6 months ago)
- Topics: admin, admin-panel, async, database, database-management, fastapi, gino, gino-orm, postgresql, python, sanic, sanic-framework
- Language: Python
- Homepage: https://gino-admin.readthedocs.io/en/latest/
- Size: 2.87 MB
- Stars: 47
- Watchers: 5
- Forks: 10
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.txt
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-fastapi - :octocat: gino-admin :star: 40+ :fork_and_knife: 1+ - Admin Panel for GinoORM, ready to up & run (just add your models). (Admin)
README
## Gino-Admin
(Unsupported, I don't work on this library anymore right now - feel free to use & do anything if you want)![Gino-Admin Logo](docs/img/logo/g_logo.svg)
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/Z8Z237B0Q)
Docs (state: in process): [Gino-Admin docs](https://gino-admin.readthedocs.io/en/latest/ui_screens.html)
Play with Demo (current master 0.2.3) [>>>> Gino-Admin demo <<<<](http://www.xnu-im.space/gino_admin_demo/login) (login: admin, pass: 1234)
![badge1](https://img.shields.io/pypi/v/gino_admin) ![badge2](https://img.shields.io/pypi/l/gino_admin) ![badge3](https://img.shields.io/pypi/pyversions/gino_admin)
Admin Panel for PostgreSQL DB with Gino ORM and Sanic
![Table view](docs/img/table_view_new.png)
![Load Presets](docs/img/db_presets.png)### How to install
```bash
pip install gino-admin==0.3.0
```
### How to use
You can find several code examples in [examples/](examples/) folder.
### Supported features
- Auth by login/pass with cookie check
- Create(Add new) item by one for the Model
- Delete all rows/per element
- Copy existed element (data table row)
- Edit existed data (table row)
- Search/sort in tables
- Deepcopy element (recursive copy all rows/objects that depend on chosen as ForeignKey)
- [Upload/export data from/to CSV](https://gino-admin.readthedocs.io/en/latest/csv_upload.html#upload-csv-files)
- SQL-Runner (execute SQL-queries)
- [Presets: Define order and Load to DB bunch of CSV-files](https://gino-admin.readthedocs.io/en/latest/presets.html)
- Init DB (Full clean up behavior: Drop tables & Recreate)
- [Composite CSV: Load multiple relative tables in one CSV-file](https://gino-admin.readthedocs.io/en/latest/csv_upload.html#composite-csv-to-upload)
- History logs on changes (log for admin panel actions - edit, delete, add, init_db, load presets and etc)
- Support multiple users for Admin panel (add, edit, remove users from 'Admin Users' page)
- UI Colors customizing### TODO:
- Add possible to add new Presets from GUI
- Select multiple rows for delete
- Copy/deepcopy multiple items
- Edit multiple items (?)
- Roles for Admin Panel users (split accessess)
- Filters in Table's columns
- Other staff on [Gino Project Dashboard](https://github.com/xnuinside/gino-admin/projects/1)### Supported Data Types
- JSONB, JSON
- Time, DateTime, Date
- Boolean, String, Decimal, Numeric, Float and etc.To see the full list of supported types take a look here:
[gino_admin/types.py](gino_admin/types.py)If you don't see type that you need - open the github issue with request and I will add it https://github.com/xnuinside/gino-admin/issues.
Or you can open PR by yourself and I will be glad to review it.### How to run Gino-Admin
#### Run with Cli
```bash
gino-admin run #module_name_with_models -d postgresql://%(DB_USER):%(DB_PASSWORD)@%(DB_HOST):%(DB_PORT)/%(DB)
gino-admin run --help # use to get cli help
Optional params:
-d --db
Expected format: postgresql://%(DB_USER):%(DB_PASSWORD)@%(DB_HOST):%(DB_PORT)/%(DB)
Example: postgresql://gino:gino@%gino:5432/gino (based on DB settings in examples/)
Notice: DB credentials can be set up as env variables with 'SANIC_' prefix
-h --host
-p --port
-c --config Example: -c "presets_folder=examples/base_example/src/csv_to_upload;some_property=1"
Notice: all fields that not supported in config will be ignored, like 'some_property' in example
--no-auth Run Admin Panel without Auth in UI
-u --user Admin User login & password
Expected format: login:password
Example: admin:1234
Notice: user also can be defined from env variable with 'SANIC_' prefix - check Auth section example```
Example:
```bash
gino-admin run examples/run_from_cli/src/db.py --db postgresql://gino:gino@localhost:5432/gino -u admin:1234
```
#### Run Admin Panel as Standalone App (no matter that framework you use in main app)
You can use Gino Admin as stand alone web app.
Does not matter what Framework used for your main App and that Gino Ext used to init Gino().Code example in: examples/fastapi_as_main_app
How to run example in: examples/fastapi_as_main_app/how_to_run_example.txtYou need to create **admin.py** (for example, you can use any name) to run admin panel:
```python
import osfrom gino_admin import create_admin_app
# import module with your models
import models# gino admin uses Sanic as a framework, so you can define most params as environment variables with 'SANIC_' prefix
# in example used this way to define DB credentials & login-password to admin panel# but you can use 'db_uri' in config to define creds for Database
# check examples/colored_ui/src/app.py as exampleos.environ["SANIC_DB_HOST"] = os.getenv("DB_HOST", "localhost")
os.environ["SANIC_DB_DATABASE"] = "gino"
os.environ["SANIC_DB_USER"] = "gino"
os.environ["SANIC_DB_PASSWORD"] = "gino"os.environ["SANIC_ADMIN_USER"] = "admin"
os.environ["SANIC_ADMIN_PASSWORD"] = "1234"current_path = os.path.dirname(os.path.abspath(__file__))
if __name__ == "__main__":
# host & port - will be used to up on them admin app
# config - Gino Admin configuration - check docs to see all possible properties,
# that allow set path to presets folder or custom_hash_method, optional parameter
# db_models - list of db.Models classes (tables) that you want to see in Admin Panel
create_admin_app(
host="0.0.0.0",
port=os.getenv("PORT", 5000),
db=models.db,
db_models=[models.User, models.City, models.GiftCard, models.Country],
config={
"presets_folder": os.path.join(current_path, "csv_to_upload")},
)
```All environment variables you can move to define in docker or .env files as you wish, they not needed to be define in '.py', this is just for example shortness.
#### Add Admin Panel to existed Sanic application as '/admin' route
Create in your project 'admin.py' file and use `add_admin_panel` from from gino_admin import add_admin_panel
Code example in: examples/base_example
How to run example in: examples/base_example/how_to_run_example.txtExample:
```python
from from gino_admin import add_admin_panel
# your app code
add_admin_panel(
app, db, [User, Place, City, GiftCard], custom_hash_method=custom_hash_method
)
```
Where:* 'app': your Sanic application
* 'db' : from gino.ext.sanic import Gino; db = Gino() and
* [User, Place, City, GiftCard] - list of models that you want to add in Admin Panel to maintain
* custom_hash_method - optional parameter to define you own hash method to encrypt all '_hash' columns of your Models.In admin panel _hash fields will be displayed without '_hash' prefix and fields values will be hidden like '******'
### Presets
Load multiple CSV to DB in order by one click.
Presets described that CSV-s files and in that order need to be loaded in DB.Read the docs: [Presets](https://gino-admin.readthedocs.io/en/latest/presets.html)
### Composite CSV to Upload
Composite CSV - one file that contains data for several relative tables.
Read the docs: [Composite CSV to Upload](https://gino-admin.readthedocs.io/en/latest/csv_upload.html#composite-csv-to-upload)
### Config Gino Admin
Read the docs: [Config](https://gino-admin.readthedocs.io/en/latest/config.html)
### Init DB
Init DB feature used for doing full clean up DB - it drop all tables & create them after Drop for all models in Admin Panel.
### Upload from CSV
Files-samples for example project can be found here: **examples/base_example/src/csv_to_upload**
### Authorization
Read in docs: [Authorization](https://gino-admin.readthedocs.io/en/latest/authorization.html)
### Limitations
In current version, for correct work of Deepcopy feature in Admin Panel model MUST contain at least one unique or primary_key Column (field).
### Screens:
Check in docs: [UI Screens](https://gino-admin.readthedocs.io/en/latest/ui_screens.html)
## Changelog
**v0.3.0**### New Features:
1. Added support for 'hide_columns' argument in admin panel configuration, example: examples/base_example/src/app.py
Argument removes those columns from admin panel 'edit' section.
You can pass column directly for one model, or global hide by name, for example:hide_columns = [ModelName.id, 'pk']
This mean that for the model ModelName on 'edit' page column 'id' will be hided.
And globally for all models will be hided columns with name 'pk'.### Improvements
1. Dependencies was updated
**v0.2.5**
1. Added favicon.ico
2. Updated Sanic version (by the way, I plan to move admin panel to FastAPI in next major release)
3. Other dependencies also updated
4. Fixed issue with stop admin panel server**v0.2.4**
1. Fixed issue with loop from https://github.com/xnuinside/gino-admin/issues/37