Frontend: Dashboard

Build admin panels and dashboards quickly using the dashboard package.

Dashboards & Admin Layouts

Dracory builds dashboard-style screens on top of the shared layout system in internal/layouts. There is no separate dashboard dependency — pages are composed in pure Go with github.com/dracory/hb and rendered through a layout's ToHTML().

Public / User Dashboard Pages

User-facing dashboard pages use layouts.NewPageLayout exactly like any other page — the navbar adapts to the signed-in user automatically:

import (
    "net/http"
    "project/internal/layouts"
    baselayouts "github.com/dracory/base/layouts"
    "github.com/dracory/hb"
)

func (c *controller) Handler(w http.ResponseWriter, r *http.Request) string {
    content := hb.Div().Class("container py-4").
        Child(hb.H1().Text("Dashboard")).
        Child(hb.Div().Class("row").
            Child(hb.Div().Class("col-md-4").Text("Widget A")).
            Child(hb.Div().Class("col-md-4").Text("Widget B")).
            Child(hb.Div().Class("col-md-4").Text("Widget C")))

    return layouts.NewPageLayout(c.app, r, baselayouts.Options{
        Title:   "Dashboard",
        Content: content,
    }).ToHTML()
}

Admin Pages

Admin screens live under internal/controllers/admin and render through the internal/controllers/admin/layout package, which wraps the shared page scaffold with the admin navbar and menus:

import adminlayout "project/internal/controllers/admin/layout"

func (c *controller) Handler(w http.ResponseWriter, r *http.Request) string {
    return adminlayout.New(c.app, r, baselayouts.Options{
        Title:   "Admin > Overview",
        Content: hb.Div().Text("Admin content"),
    }).ToHTML()
}
  • adminlayout.New(app, r, options) – renders a full admin page with the admin navbar and theme support.
  • adminlayout.Page(elements...) – wraps a set of hb.TagInterface fragments into a page body.
  • adminlayout.NewCrud(app, r, title, content, styleURLs, style, jsURLs, js) – renders an admin page preloaded with jQuery, jQuery UI, and the blockarea script used by the legacy CRUD screens.

External Admin Modules

The built-in admin sections (blog, shop, logs, files, users) are provided by the standalone github.com/dracory/blogadmin, shopadmin, logadmin, fileadmin, and useradmin modules. The host project wires them through internal/controllers/admin/adapters/, which supplies the layout function, LLM factory, and customer resolver each module needs. A single catch-all route per section delegates to the module's Handler.

Themes & Navigation

  • Admin and public pages share the Bootlegance theme system — see the Layouts page for theme switching via GET /theme and layouts.ThemeDropdown.
  • Navbar menu items are declared with layouts.MenuItem in internal/layouts/page_main_menu_items.go (public) and internal/controllers/admin/layout/main_menu_items.go (admin).