webdevpuneet.com

Bootstrap Audit Log Viewer — Free HTML CSS JS Snippet

Bootstrap Audit Log Viewer · Dashboards · Plain HTML, CSS & JS · Live preview

CategoryDashboards

Copy & paste

Source Code

<div class="container py-5 d-flex justify-content-center">
  <div class="card bsaudit-card">
    <div class="card-body p-3">
      <div class="d-flex gap-2 mb-2">
        <input type="search" class="form-control form-control-sm" id="bsauditSearch" placeholder="Search actor or action...">
        <select class="form-select form-select-sm" id="bsauditType" style="max-width:130px;">
          <option value="">All types</option>
          <option value="security">Security</option>
          <option value="content">Content</option>
          <option value="billing">Billing</option>
        </select>
      </div>
      <p class="small text-muted mb-2" id="bsauditCount"></p>
      <ul class="list-unstyled mb-0" id="bsauditList"></ul>
    </div>
  </div>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month, 7 days free), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Text search and the type dropdown combine with real AND logic, not an accidental OR
Search matches both actor name and action text, with matches safely highlighted in both
The highlight query is escaped for safe RegExp use, and the source text is HTML-escaped before rendering
Each entry's severity tone is stored independently of its category, not derived automatically from it
A live "X of Y events" count reflects exactly what both active filters currently allow through

About this UI Snippet

Bootstrap Audit Log Viewer — HTML, CSS & JavaScript

Screenshot of the Bootstrap Audit Log Viewer snippet rendered live

Search text and the type dropdown filter the exact same LOG array together inside one render() call — matches only keeps an entry where both typeOk and textOk are true, so searching "dana" while the type filter is set to "Content" correctly shows nothing (Dana's visible actions here are security-type), rather than the two filters accidentally behaving as an OR and returning a confusing mixed result.

The search box matches against both the actor's name and the action text in one pass, and every match gets the same safe-highlighting treatment used in bootstrap-search-results-highlighting — the query is escaped before being used to build a RegExp (so a search containing a regex-special character can't break or misbehave), and the source text is HTML-escaped before highlighting (so an actor name or action text can never be misinterpreted as markup).

Each entry's tone field is independent of its type field — a security event can be a routine invite (secondary) or a genuinely concerning new-device sign-in (warning), which is why tone is stored per entry rather than derived automatically from type; two events of the same category don't necessarily carry the same real-world severity.

Step by step

How to Use

  1. 1
    Load the snippetAll 7 audit events show, each tagged with a colored type badge and a relative time.
  2. 2
    Type "dana" in the search boxThe list narrows live to Dana's two events, with "Dana" highlighted in yellow in each.
  3. 3
    Select "Content" from the type dropdown while still searching "dana"The list empties, since none of Dana's visible events are content-type — both filters apply together.
  4. 4
    Clear the search and leave "Content" selectedOnly the content-type events show, regardless of actor.
  5. 5
    Reset both filtersAll 7 events reappear, and the count reads "7 of 7 events".

Real-world uses

Common Use Cases

🛡️
Admin security dashboards
Let administrators search by actor or action text while narrowing by event type, with both filters combining through real AND logic in a single render call.
📑
Compliance and SOC2 reporting
Provide a searchable, filterable activity history for auditors, with matching text highlighted safely after the source is HTML-escaped.
🔎
Customer support investigations
Look up everything one user did before a complaint, typing their name to see matches across both the actor and action columns.
🔐
Permission change reviews
Pair with the Bootstrap permission matrix so administrators can see who changed access and what each role can currently do.

Got questions?

Frequently Asked Questions

They combine with AND logic — an entry must satisfy both the current search text and the current type selection (when either is set) to appear, which is why searching one actor while filtering to an unrelated type can correctly return zero results.

Yes — the query is escaped before being used to build a RegExp, the same technique used in bootstrap-search-results-highlighting, so typing a character like "(" or "*" searches for it literally instead of breaking or matching unpredictably.

Two events of the same type can carry very different real-world significance — a routine invite and a suspicious new-device sign-in are both "security" events, but only one deserves a warning-colored badge, which is why tone is set per entry rather than inferred from type.

Yes. Keep LOG as static data, track search and type filter in component state, and derive the filtered/highlighted list in the render function using the same combined AND-filter and escape-then-highlight approach.