bloomBUILD•SHIP•BLOOM
.md
Administration

Admin Panel

bloom_admin provides an automatic, server-rendered HTML administration panel modeled on Django's Admin interface.

Server-Rendered HTML Admin

Rather than requiring a separate single-page frontend app, bloom_admin renders semantic, accessible HTML directly on the server with zero client-side framework overhead.

Model Introspection

Inspects ModelMeta and FieldMeta to generate form inputs, checkboxes, and foreign key pickers automatically.

Strict Auto-Escaping

Built-in template engine auto-escapes all untrusted model content with SafeHtml wrappers to prevent XSS.

CSRF Protection

HMAC-SHA256 tokens are embedded in every form and verified on all state-changing POST and DELETE actions.

BloomAdminSite & Model Registration

Register models with custom changelist display columns, filters, and search fields:

lib/admin.dart
dart
// lib/admin.dart - Configuring the BloomAdminSite
import 'package:bloom_framework/bloom_framework.dart';
import 'package:bloom_framework/bloom_server.dart';
import 'package:bloom_db/bloom_db.dart';
import 'package:bloom_admin/bloom_admin.dart';
import 'apps/blog/models.dart';
import 'apps/accounts/models.dart';

void configureAdminSite(BloomApiRouter router, DbExecutor db) {
  // 1. Initialize admin site with branding
  final adminSite = BloomAdminSite()
    .withSiteHeader('Bloom App Administration')
    .withSiteTitle('Bloom Control Center');

  // 2. Register models with customized changelist & form options
  adminSite.register<Post>(
    meta: Post.meta,
    fromRow: Post.fromRow,
    config: const BloomModelAdminConfig(
      listDisplay: ['id', 'title', 'createdAt'],
      searchFields: ['title', 'content'],
      listFilter: ['createdAt'],
      listEditable: ['title'],
    ),
  );

  adminSite.register<User>(
    meta: User.meta,
    fromRow: User.fromRow,
    config: const BloomModelAdminConfig(
      listDisplay: ['id', 'email', 'name', 'createdAt'],
      searchFields: ['email', 'name'],
    ),
  );

  // 3. Mount all admin routes under /admin
  adminSite.mount(router, db: db, basePath: '/admin');
}

Changelists, Forms & Bulk Operations

  • Real SQL Pagination: Pagination executes via limit and offset queries against the database without in-memory dataset slicing.
  • In-place Editing & Bulk Actions: Checkbox selection enables multi-row edits (listEditable), bulk deletions, and custom bulk action handlers.
  • CSV Export: Built-in /export-csv/ endpoints export changelist datasets with active filters applied.