Electronic records (21 CFR Part 11)
Audit Trail <smart-audit-trail>
AuditTrail displays audit trail entries for review, as required by 21 CFR Part 11 ยง11.10(e).
<smart-audit-trail> · 17 properties, 7 methods, 5 events · source/modules/smart.audittrail.js
Usage in Blazor
The Razor component is <AuditTrail> in Smart.Blazor.Industrial: every property is a parameter in PascalCase, every event an EventCallback<Event> named On<Event> whose ev["Detail"] is the typed detail class, and the methods are called on the @ref. String choices are enums. In a Blazor Web App (.NET 8 and later) the page needs an interactive render mode, for example @rendermode InteractiveServer; a statically rendered component stays empty.
@using Smart.Blazor.Industrial
@* .NET 8 and later: an interactive render mode, on the page or for the whole app *@
@rendermode InteractiveServer
<AuditTrail @ref="auditTrail" ShowMilliseconds="true" ShowReview="true"
OnReviewRequest="OnReviewRequest" />
@code {
AuditTrail auditTrail;
void OnReviewRequest(Event ev)
{
AuditTrailReviewRequestEventDetail detail = ev["Detail"];
}
// void AddEntry(object entry)
void Call() => auditTrail.AddEntry(new { });
}
Properties
| Parameter | Type, default | Description |
|---|---|---|
Entries | IEnumerable<object> | Sets or retrieves the entries, as { seq, id, at, system, user, userName, action, record, field, oldValue, newValue, reason, signature, previousHash, hash }, in sequence. For a running feed use addEntry(), which verifies only the entry it adds. |
Columns | IEnumerable<object> | Sets or retrieves the columns shown, in order, from seq, at, user, action, record, field, oldValue, newValue, reason, signature and system. Empty shows all but system. |
SortDirection | AuditTrailSortDirection | Sets or retrieves the order by sequence: newest first, or oldest first. The Time header toggles it. |
Filter | AuditTrailFilter | Sets or retrieves the filter as { text, user, action, from, to }. text is searched across the entry, user and action are matched exactly, and from and to are ISO strings or epoch milliseconds. The toolbar edits the filter and raises the filterChange event. |
ShowToolbar | bool | Determines whether the search, filters, integrity badge and export buttons are shown. |
ShowIntegrity | bool | Determines whether the hash chain is verified and its verdict shown. |
Genesis | string | Sets or retrieves the previousHash the first entry must carry, when the chain did not start at ''. |
ExpectedHead | string | Sets or retrieves the hash of an entry known to have been written - an anchor kept outside the trail, for example by the server. A hash chain verifies from its first entry to its last, so a copy with its newest entries removed is a shorter chain that is still intact; with an anchor the verdict fails when the chain does not contain this hash. Entries added after the anchor was taken do not fail it. Empty does not check. |
ExpectedCount | int | Sets or retrieves how many entries the trail is known to have held - an anchor kept outside the trail. The verdict fails when fewer entries are given, so removing the newest entries is detected. More entries are fine. 0 does not check. |
RequireChain | bool | Determines whether entries that carry no hash at all are a failure. On (the default), a list without hashes - never chained, or with its hashes stripped - is shown as 'No hash chain - N entries cannot be verified' and integrity() returns { ok: false, reason: 'unchained' }. Off, it is shown as information and integrity() returns null, for an application whose log was never chained. |
MaxRows | int | Sets or retrieves the maximum number of rows rendered. The footer shows how many entries are not rendered; they can be reached by narrowing the filter or by exporting. |
ShowMilliseconds | bool | Determines whether the time column shows milliseconds. |
ShowReview | bool | Determines whether a 'Mark reviewed' button is shown. The button raises the reviewRequest event with the entries shown; the application records the review, with a signature if required. |
Selected | string | Sets or retrieves the id of the selected entry, or ''. |
FileName | string | Sets or retrieves the base name of a downloaded export. |
Label | string | Sets or retrieves the table's caption and the accessible name. Empty shows 'Audit trail'. |
Density | AuditTrailDensity | Sets or retrieves the target size of the toolbar controls. |
Methods
| Method | Description |
|---|---|
void AddEntry(object entry) | Adds an entry, for example from a Trail subscription that keeps the viewer up to date.entry object The entry. |
Task<IEnumerable<object>> Visible() | Returns the entries the filter lets through, in display order. |
Task<int> Count() | Returns how many entries are held, filtered or not. |
Task<object> Integrity() | Returns the chain verification as { ok, count, brokenAt, reason }, or null when integrity is not shown, when there are no entries and no anchor, or when no entry carries a hash and requireChain is off. reason is 'link', 'hash', 'sequence' or 'missing' at the first entry that fails, 'unchained' when no entry carries a hash, 'count' when fewer entries than expectedCount are given, or 'head' when the chain does not contain expectedHead. The verdict is kept between refreshes: filtering and sorting do not re-verify, and addEntry() verifies only the entry it adds. |
Task<string> Export(string format) | Returns the complete trail as text, with every entry and every hash, regardless of the current filter. In CSV, a text value that a spreadsheet would run as a formula (starting with =, +, -, @, a tab or a carriage return) is prefixed with an apostrophe; numbers are written as they are. The JSON export is the exact copy that verifies.format string 'csv' or 'json'.options object { filtered: true } for what is on screen instead. |
void Download(string format) | Downloads the export as a file and raises the export event.format string 'csv' or 'json'.options object { filtered: true } for what is on screen instead. |
void Select(string id) | Selects an entry by id and raises the entrySelect event. Pass an empty string to clear the selection.id string The entry id. |
Events
Every event is an EventCallback<Event>; Event is a dictionary and ev["Detail"] converts to the detail class named under the event.
| Event | Description and detail |
|---|---|
OnEntrySelect | This event is triggered when an entry is selected by click, Enter or select().Entry object The entry. |
OnFilterChange | This event is triggered when the toolbar changes the filter.Filter object { text, user, action, from, to } as applied. |
OnIntegrityChange | This event is triggered when the chain verdict changes, an intact trail replaced by a copy that breaks, or the reverse.Integrity object { ok, count, brokenAt, reason }, or null.State string 'intact', 'broken' or 'none'. |
OnExport | This event is triggered when an export is downloaded. An export is itself an action that can be recorded in the audit trail.Format string 'csv' or 'json'.Count int How many entries were exported.FileName string The file name offered. |
OnReviewRequest | This event is triggered by the 'Mark reviewed' button. The application records the review.Entries dynamic The entries shown.Count int How many.Filter object The filter in force. |
Types
enum AuditTrailSortDirection
AuditTrailSortDirection.Asc AuditTrailSortDirection.Desc
enum AuditTrailDensity
AuditTrailDensity.Normal AuditTrailDensity.Touch
CSS variables
The component declares 10 CSS variables; the CSS page shows how to set them.
--smart-audit-size --smart-audit-background --smart-audit-header-background --smart-audit-border --smart-audit-primary --smart-audit-primary-text --smart-audit-ok-text --smart-audit-error-text --smart-audit-selected --smart-audit-readout-font