Dashboard implementation

The server-rendered web dashboard, for contributors. None of these are part of the public API and they can change in any release.

DearDiary._ASSETS_DIR — Constant

The embedded dashboard. Every page is rendered server-side from the service layer and served as a self-contained HTML document: the stylesheet and script in assets/ui/ are inlined, and only fonts, the logo, and artifact downloads go through extra requests.

render_page maps a URL path to a page, and the _handle_* functions below adapt that to the HTTP handlers start_ui_server registers. Sessions and sign-in live in auth.jl, user management in pages/users.jl, and the editing forms in pages/edit.jl.

source
DearDiary._badge_select — Function
_badge_select(ctx, action, name, options, value, tone; label)

A lifecycle control styled like the status badge it replaces. A pointer pick submits at once; a keyboard change reveals the otherwise hidden Apply button so arrowing through the options never submits by itself.

source
DearDiary._csrf_token — Function
_csrf_token(request::HTTP.Request)::String

A per-session token embedded in every form and checked on every POST. It is an HMAC of the session token, so it cannot be forged without the secret and changes with each sign-in. With authentication off there is no session, so the token is derived from a fixed seed.

source
DearDiary._experiment_charts — Function
_experiment_charts(rows)::Vector

One chart per metric key across the experiment's iterations. When every iteration logged the key once, the chart is a scatter of final values by ordinal; otherwise each iteration becomes a line. Only the most recent _MAX_CHARTED_ITERATIONS iterations are plotted.

source
DearDiary._form — Function
_form(action, csrf, children...; confirm=nothing, class="dd-form")

A same-origin POST form carrying the session's CSRF token. confirm asks the browser for confirmation before submitting, for destructive actions.

source
DearDiary._handle_entity_post — Function
_handle_entity_post(ctx::PageContext, request::HTTP.Request)::HTTP.Response

Apply an edit, tag, kill, or delete form to a tracking record, with the same permission checks as the REST routes: project changes need an administrator, edits need update permission, tags need create permission, and deletes need delete permission.

source
DearDiary._handle_login — Function
_handle_login(context)::HTTP.Response

GET /login renders the sign-in form; POST /login checks the credentials the same way POST /auth does and, on success, sets the session cookie and redirects to next.

source
DearDiary._handle_logout — Function
_handle_logout(context)::HTTP.Response

POST /logout clears the session cookie. The CSRF token is required like any other post.

source
DearDiary._handle_page — Function
_handle_page(context)::HTTP.Response

Serve a dashboard page. Without a viewer, redirect to the sign-in form (or report the missing default user when authentication is off). A GET renders the page; a POST goes to the user-management or record-editing handler that owns the path.

source
DearDiary._handle_users_post — Function
_handle_users_post(ctx::PageContext, request::HTTP.Request)::HTTP.Response

Apply a user-management form. Authorization mirrors the REST routes: anyone may edit their own profile and password, only admins may create accounts, change roles, grant project access, or delete accounts, and the seeded default account keeps its protections.

source
DearDiary._hero — Function
_hero(; title, lede, lede_empty, meta, tags, actions)

Page header. title and lede accept either text or a DOM node, so a page can drop an inline editor in place of the plain heading. tags sits under the metadata line and actions (live pill, actions menu) in the top-right corner.

source
DearDiary._inline_edit — Function
_inline_edit(ctx, id, action, view, control; label, trigger)

Click-to-edit control: view shows the current value next to a pencil button; the button swaps it for a small form posting control to action. trigger replaces the pencil with a custom opener, for empty states such as "Add a description".

source
DearDiary._iteration_charts — Function
_iteration_charts(metrics)::Vector

One line chart per metric key that was logged at more than one step. Keys logged once are summarised in the metric tiles instead, since a single point makes a poor line.

source
DearDiary._iteration_rows — Function
_iteration_rows(iterations)::Vector{IterationRow}

Everything the experiment page needs per iteration, in tree order: ordinal, lineage, parameters, metric series, and tags.

source
DearDiary._iteration_status — Function
_iteration_status(status_id::Integer)::NamedTuple

Map an IterationStatus id to the badge tone and label the dashboard renders. Unknown ids fall back to a neutral tone so a corrupted row never breaks a page.

source
DearDiary._menu — Function
_menu(items...)

The page's actions menu: a details element that drops a list of actions from a "more" button. Returns nothing when there is nothing to offer, so read-only viewers see no menu.

source
DearDiary._menu_action — Function
_menu_action(ctx, label, action; confirm, danger, hint, disabled)

One entry of the actions menu. disabled is the reason the action is unavailable right now; the entry then stays visible but inert, with the reason in a tooltip, following the rule that a control which may become available is disabled while one the viewer may never use is hidden.

source
DearDiary._ordinals — Function
_ordinals(iterations)::Dict{String,Int}

Per-experiment ordinals ("Iteration 1, 2, 3…") keyed by iteration id. UUID ids carry no order, so the ordinal follows created_date, which is also how get_iterations sorts.

source
DearDiary._page_context — Function
_page_context(request::HTTP.Request)::Optional{PageContext}

Resolve the viewer for a request, or nothing when authentication is on and the session cookie is missing or stale.

source
DearDiary._post_allowed — Function
_post_allowed(request::HTTP.Request, fields)::Bool

Accept a form post only when it carries the session's CSRF token and the browser does not mark it as cross-site.

source
DearDiary._project_editors — Function
_project_editors(ctx, project, tags)

The hero pieces of a project page: inline name and description editors and the actions menu for administrators, and a tag opener for anyone with create permission.

source
DearDiary._render_user — Function
_render_user(ctx::PageContext, user::User)::Page

Profile, password, role, and project access for one account. The viewer edits their own account here (/settings); admins reach any account from the users list.

source
DearDiary._render_users — Function
_render_users(ctx::PageContext)::Page

Every account with its role and project access, plus the form to add one. Admins only.

source
DearDiary._series — Function
_series(metrics)::Dict{String,Vector{Tuple{Int64,Float64}}}

Group metric rows by key into (step, value) series sorted by step.

source
DearDiary._serve_favicon_ico — Function
_serve_favicon_ico(context)::HTTP.Response

Browsers request /favicon.ico on their own. Serve the package logo there so the request resolves even though the page links the icon explicitly.

source
DearDiary._session_token — Function
_session_token(request::HTTP.Request)::Optional{String}

The JWT carried by the dashboard session cookie, or nothing when absent.

source
DearDiary._session_user — Function
_session_user(request::HTTP.Request)::Optional{User}

The viewer behind a request: the seeded default user when authentication is off, otherwise the user named by a valid session cookie, or nothing.

source
DearDiary._tip — Function
_tip(node, text)

Wrap node so a short explanation appears on hover or focus. Used for controls that are present but unavailable right now, so the reason is one hover away instead of hidden. The text is also rendered for screen readers, which never see the tooltip.

source
DearDiary._token_user — Function
_token_user(token::AbstractString)::Optional{User}

Validate a JWT against the configured secret and return its user. Signature, expiry, and claim checks match the REST AuthMiddleware; any failure yields nothing.

source
DearDiary._tree_order — Function
_tree_order(iterations)::Vector{Tuple{Iteration,Int}}

Flatten an experiment's iterations so every child follows its parent, paired with its nesting depth. Orphans whose parent lives in another experiment (or was deleted) are treated as roots so they never vanish from the table.

source
DearDiary._versions_for_iteration — Function
_versions_for_iteration(project_id, iteration_id)::Vector{Tuple{Model,ModelVersion}}

Model versions registered from a given iteration, scanned across the project's registry.

source
DearDiary.Access — Type
Access

What the viewer may do to the records of one project, mirroring the REST middlewares: administrators may do everything, members need the matching project permission.

Fields

  • update::Bool: May edit names, descriptions, notes, statuses, and stages.
  • create::Bool: May add tags.
  • delete::Bool: May delete records and model versions.
source
DearDiary.Page — Type
Page

A rendered dashboard page before it is wrapped in the document shell.

Fields

  • title::String: Browser tab title.
  • crumbs::Vector: Breadcrumb trail as label => href pairs; the current page has nothing.
  • body::Vector{Any}: DOM nodes placed inside the main column.
  • live::Bool: true while the page shows a running iteration and carries the live-refresh pill.
  • status::Int: HTTP status the page is served with.
  • chrome::Bool: false for pages rendered without the top bar and footer (sign-in).
source
DearDiary.PageContext — Type
PageContext

What a page needs to know about the request it answers.

Fields

  • viewer::User: The signed-in user (or the seeded default when auth is off).
  • path::String: Request path, used to mark the active navigation entry.
  • query::Dict{String,String}: Query parameters, used for one-shot notices after a form.
  • csrf::String: Token embedded in every form on the page.
source
DearDiary.render_page — Function
render_page(path::AbstractString, ctx::PageContext)::Tuple{Int,String}
render_page(path::AbstractString)::Tuple{Int,String}

Render the dashboard page at path (for example / or /iteration/<id>) for the viewer in ctx. The one-argument form renders as the seeded default user. Unknown paths and ids the viewer cannot read render the not-found page, admin-only pages render a forbidden page for members, and a rendering error renders the error page with status 500.

Arguments

  • path::AbstractString: The request path, without query string.
  • ctx::PageContext: The viewer, path, query, and CSRF token of the request.

Returns

A (status, html) tuple: the HTTP status and the complete HTML document.

source
DearDiary.start_ui_server — Function
start_ui_server(host::AbstractString, port::Integer)::Bonito.HTTPServer.Server

Boot the embedded DearDiary dashboard on host:port. The server runs in a sibling task alongside the REST API server so a single DearDiary.run call exposes both endpoints on different ports.

Pages are plain HTTP handlers (see render_page); no Bonito session or JavaScript bundle is involved, so booting needs neither a browser nor a bundler. When DEARDIARY_ENABLE_AUTH is on, /login and /logout manage the session cookie the other pages require.

Call stop_ui_server to shut it down. DearDiary.stop closes both the REST and UI servers together.

Arguments

  • host::AbstractString: Interface to bind.
  • port::Integer: Port to listen on.

Returns

The running Bonito.HTTPServer.Server.

source
DearDiary.stop_ui_server — Function
stop_ui_server(server::Optional{Bonito.HTTPServer.Server})::Nothing

Shut down the UI server.

Arguments

  • server: The instance start_ui_server returned, or nothing to do nothing so DearDiary.stop need not check whether the UI ever booted.
source