Skip to main content

What's new in SeaORM Pro 2.0

ยท 13 min read
SeaQL Team
Chris Tsang

SeaORM Pro is an admin panel solution allowing you to quickly and easily launch an admin panel for your application - frontend development skills not required (but certainly nice to have).

An admin panel is essential for operating backend applications. But it often is an after-thought, or no dedicated resources is put into developing them.

SeaORM Pro is designed to bridge this gap, providing a solution that is both quick to implement and reliable for long-term use.

Table Viewโ€‹

There are two kinds of table view in SeaORM Pro, raw table and composite table:

Raw Tableโ€‹

Each raw table corresponds to a table in the database, by default it will display all columns for all tables. You can configure the displayed columns and other settings via TOML.

pro_admin/raw_tables/product.toml
[table]
title = "Products"
table_size = "middle"
page_size = 30
order_by = { field = "product_id", order = "desc" }
columns = [
{ title = "ID", field = "product_id", width = 80 },
{ title = "Thumbnail", field = "thumb_nail_photo", input_type = "image", width = 120 },
{ title = "Product Category", field = "name", relation = "product_category", ellipsis = false, width = 180 },
]
hidden_columns = [ "size", "weight" ]
all_columns = false

Composite Tableโ€‹

This is where SeaORM Pro shine. You can construct table views with data joining from multiple related tables. The underlying GraphQL query can be deeply nested.

Data from parent-child relations (e.g. Order -> OrderItem) are represented as collapsible nested tables. You can configure the settings via TOML.

pro_admin/composite_tables/sales_order.toml
[parent]
name = "sales_order_header"

[parent.table]
columns = [
{ title = "ID", field = "sales_order_id", width = 80 },
{ field = "order_date" },
{ field = "purchase_order_number" },
{ field = "account_number" },
{ field = "ship_method" },
{ field = "sub_total" },
{ field = "tax_amt" },
{ field = "freight" },
]
all_columns = false


[[children]]
relation = "customer"

[children.table]
columns = [
{ title = "ID", field = "customer_id", width = 80 },
{ field = "title", width = 100 },
{ field = "first_name", width = 120 },
{ field = "middle_name", width = 120 },
{ field = "last_name", width = 120 },
]
hidden_columns = [ "name_style", "suffix", "email_address", "phone", "rowguid", "created_date" ]


[[children]]
relation = "address1"

[children.table]
title = "Shipping Address"
columns = [
{ title = "ID", field = "address_id", width = 80 },
]
hidden_columns = [ "rowguid", "created_date" ]


[[children]]
relation = "address2"

[children.table]
title = "Billing Address"
columns = [
{ title = "ID", field = "address_id", width = 80 },
]
hidden_columns = [ "rowguid", "created_date" ]


[[children]]
relation = "sales_order_detail"

[children.table]
columns = [
{ title = "Thumbnail", field = "thumb_nail_photo", relation = "product", input_type = "image", width = 120 },
{ field = "name", relation = "product", width = 300 },
{ field = "product_number", relation = "product" },
{ field = "color", relation = "product" },
{ field = "size", relation = "product" },
{ field = "weight", relation = "product" },
{ field = "order_qty" },
{ field = "unit_price" },
{ field = "unit_price_discount" },
]
hidden_columns = [ "sales_order_id", "sales_order_detail_id", "product_id", "rowguid", "created_date" ]

Editorโ€‹

Data is not editable by default. You can configure create, update and delete forms via TOML. You can also configure which columns are editable. Non-editable columns will be shown as read-only.

Pop-up Editorโ€‹

By default, the pop-up editor will be used to create and update database table.

Createโ€‹

Enable create on this database table, this is disabled by default. Columns can be hidden from the create form but it's still visible on the view table.

pro_admin/raw_tables/product.toml
[create]
# Enable create for this table
enable = true
# Columns that are hidden on the create form
hidden_columns = [ "created_date" ]

Updateโ€‹

Enable update on this database table, this is disabled by default. Columns can be hidden from the update form but it's still visible on the view table. Fields can also be readonly on the update form.

pro_admin/raw_tables/product.toml
[update]
# Enable update for this table
enable = true
# Columns that are hidden on the update form
hidden_columns = [ "created_date" ]
# Columns that are readonly on the update form
readonly_columns = [ "product_id" ]

Deleteโ€‹

Enable delete on this database table, this is disabled by default.

pro_admin/raw_tables/product.toml
[delete]
# Enable delete for this table
enable = true

Model Editorโ€‹

Enable the use of model editor on this database table, this is disabled by default. The configuration of each fields are specified here in sequence, displaying across table view, create and update editor.

[editor]
# Enable model editor for this table
enable = true
# Title field to be shown
title_field = "address_line1"
# Display following columns in sequence
fields = [
{ title = "ID", field = "address_id", span = 8 },
{ field = "rowguid", span = 8 },
{ field = "created_date", span = 8 },
{ field = "address_line1", span = 12, input_type = "textarea", rows = 4 },
{ field = "address_line2", span = 12, input_type = "textarea", rows = 4 },
{ field = "city", span = 6 },
{ field = "state_province", span = 6 },
{ field = "country_region", span = 6 },
{ field = "postal_code", span = 6 },
]

Role-Based Access Controlโ€‹

SeaORM Pro has been updated to support the latest features in SeaORM 2.0. Role-Based Access Control (RBAC) is fully integrated into SeaORM Pro Plus. It offers a GUI editor to edit RBAC permissions and assign user roles. Without the corresponding select permission, users will not be able to see relevant tables in the GUI. Similarly, edit buttons will be hidden if user does not have update permission.

Opt-in RBACโ€‹

Upon upgrading to SeaORM 2.0, you can opt-in RBAC by enabling the rbac feature flag in the Rust backend:

Cargo.toml
seaography = { version = "2.0", features = ["rbac"] }

And enabling RBAC in the SeaORM Pro admin panel:

pro_admin/config.toml
[site.rbac]
# Is RBAC enabled?
enable = true

Role Permissionsโ€‹

View Role Hierarchy Diagramโ€‹

Role has a self-referencing relation, and they form a DAG (Directed Acyclic Graph). Most commonly they form a hierarchy tree that somewhat resembles an organization chart.

A simple tree example:

admin <- manager <- public
<- ...etc.

Update Role Permissionโ€‹

Each role has their own set of permissions. On runtime, the engine will walk the role hierarchy and take the union of all permissions of the sub-graph.

The actions we can perform on resources. There are 4 basic permissions, select, insert, update and delete. You can define more for your application.

Role Hierarchyโ€‹

Each role has their own set of permissions. On runtime, the engine will walk the role hierarchy and take the union of all permissions of the sub-graph.

User Roleโ€‹

User has a 1-1 relationship with role, meaning each user can only be assigned at most 1 role.

User Overrideโ€‹

The schema is a mirror of above: User <-> Permission <-> Resource, with an extra grant field, false means deny.

What's Next?โ€‹

There's really a lot we want to build, to make SeaORM Pro suit the needs of every project. Please consider being a sponsor and take part in shaping its future!

Here's what we have in mind:

  • Single Sign On: To be able to sign-in with Google Workspace or Microsoft Business email.
  • Audit Log: And so, we'd want to keep a record of users' action and being able to audit them.
  • Advanced Dashboard: We want to make it super easy to design graphs and charts for the Admin Dashboard.
  • Tasks: To be able to visualize and control scheduled tasks, and kick start once off tasks in ad-hoc way.
  • Data Export: Export data to various formats, including CSV, Excel, and DataFrame!

๐ŸŒŸ Sponsorsโ€‹

Gold Sponsorโ€‹

QDX pioneers quantum dynamics-powered drug discovery, leveraging AI and supercomputing to accelerate molecular modeling. We're grateful to QDX for sponsoring the development of SeaORM, the SQL toolkit that powers their data intensive applications.

GitHub Sponsorsโ€‹

If you feel generous, a small donation will be greatly appreciated, and goes a long way towards sustaining the organization.

A big shout out to our GitHub sponsors:

Godwin Effiong
Adam Israel
Ryan Swart
OteroRafael
Yuta Hinokuma
wh7f
MS
Numeus
Data Intuitive
Caido Community
Marcus Buffett
MasakiMiyazaki
KallyDev
Manfred Lee
Afonso Barracha
Dean Sheather

๐Ÿฆ€ Rustacean Sticker Packโ€‹

The Rustacean Sticker Pack is the perfect way to express your passion for Rust. Our stickers are made with a premium water-resistant vinyl with a unique matte finish.

Sticker Pack Contents:

  • Logo of SeaQL projects: SeaQL, SeaORM, SeaQuery, Seaography
  • Mascots: Ferris the Crab x 3, Terres the Hermit Crab
  • The Rustacean wordmark

Support SeaQL and get a Sticker Pack!

Rustacean Sticker Pack by SeaQL