Skip to content

Commit 2ffb32a

Browse files
authored
Showcase enterprise enhancements (#1404)
* feat(grid): Add column chooser and CSV export Grid gains a Columns dropdown (AllowColumnChooser) where people hide, show, search, and reorder columns, by drag or by keyboard move buttons, and an Export CSV button (AllowExport) that downloads every row matching the current filters and sort across all pages, with the visible columns in display order. Both are off by default. - GridSettings: ColumnOrder and HiddenColumns, saved only when changed, so settings saved before this change still load - GridColumn: AlwaysVisible and Exportable - Grid: ResetColumnsAsync() and ExportToCsvAsync(); localizable text parameters for both features - CSV values are quoted and escaped, and text starting with =, +, -, @ is prefixed with an apostrophe against formula injection - Data providers are asked for all rows with page number and size 0 - Docs and demos on the Grid other-examples page Work item 26112002 (T-01 to T-04) * feat(demo): Add shared enterprise parts for Showcase sites Opt-in building blocks the nine kept Showcase sites will use for the enterprise baseline (WR-001, WR-002). Sites that don't opt in, including Online Learning and Travel & Stay Booking, are unchanged. - IShowcaseEnterpriseState with audit entries, notifications, and search - ShowcaseGlobalSearch, ShowcaseNotificationsMenu, and ShowcaseAuditLog (a Grid with filters, paging, column chooser, and CSV export) - ShowcaseGridViewStore and ShowcaseGridView: saved list views (filters, page size, columns, and sort) kept in the tab's session storage - ShowcaseDataState: loading, empty, and error states with Retry and a labelled demo control that simulates a loading error - ShowcaseUniqueCheck: async uniqueness check for a form field - ShowcaseFormErrors: opt-in linked error summary (ShowSummary) - Gallery categories: Business operations, SaaS and AI, Industry Work item 26112002 (T-05, T-06) * fix(grid): Give selection checkboxes accessible names Grid's selection checkboxes had no accessible name and carried role="button" (WCAG 4.1.2, 1.3.1). They are now plain labelled checkboxes: - SelectAllRowsText labels the header select-all checkbox - SelectRowText labels row checkboxes, and names the selection column header in single selection mode - RowSelectionLabel (Func<TItem, string>) gives each row its own label, for example "Select ticket #1003" Work item 26112002 (finding F-1, D-019) * feat(showcase): Turn Help Desk into an enterprise example with SLA escalation Help Desk lists move to the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states: the ticket queue (with multi-row selection feeding the bulk bar), knowledge base articles, agents, categories, SLA policies, and a new audit log page. Forms use EditForm with a linked error summary, uniqueness checks, and cross-field rules. Both headers get global search and notifications, and every change is recorded in the audit log. The seed grows to about 250 tickets. Signature workflow: SLA escalation rules on the SLA policies page. A ticket that meets a rule moves up a support tier, is flagged in the queue (Tier column, Escalated card and filter), its team lead and assignee are notified, and the escalation is written to the ticket history and the audit log. Teams gain an optional lead. Docs page, catalog component list, and footer updated. Visually hidden button text now keeps its leading space, so names read "Edit Urgent targets" rather than "EditUrgent targets". * feat(showcase): Turn HR Portal into an enterprise example with review cycles HR lists move to the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states: employees, leave approvals (with bulk approve and reject), team, leave policies, and onboarding templates. Forms use EditForm with a linked error summary, uniqueness checks, and cross-field rules, and employees gain a probation end date. Both headers get global search and notifications, every change is recorded in a new audit log page, and the seed grows to 187 employees and 302 leave requests. Signature workflow: performance review cycles. HR opens a cycle for the company or chosen departments; employees write self reviews; managers write reviews with a 1 to 5 rating; HR calibrates ratings (a note is required for a change) and releases them; employee and manager sign off; HR closes the cycle. Each step notifies whoever acts next, shows in a "Reviews waiting for you" card, and is audited. The seed has a closed mid-year cycle, an open Engineering and Product cycle, and a Sales cycle in calibration. Docs page, catalog entry, footer, home page role cards, and gallery screenshots updated. * feat(showcase): Add the enterprise baseline to Monitoring Monitoring lists move to the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states: incidents (with bulk assign, severity, acknowledge, and resolve), logs (the live tail keeps running), console and admin services, alert rules, and maintenance windows. Forms use EditForm with a linked error summary, uniqueness checks, and cross-field rules: services, alert rules, maintenance windows (no overlap on a service), incidents and their updates, subscriptions, and notification settings. The console header gets global search and a notifications bell that reads the existing inbox, every change is recorded in a new audit log page, and the seed grows to 201 incidents. The escalation policy workflow, docs, and screenshots follow in the next commit. * feat(showcase): Add escalation policies with paging to Monitoring Admins define escalation policies on a new page: the services a policy covers (or the default), page the primary on call at once, the secondary after a set number of minutes without an acknowledgement, an optional named engineer after that, and how many times to repeat. The dialog previews the policy in words with this week's rotation. When an alert opens an incident, or an engineer declares one, the covering policy pages the on-call engineers on the site clock. Each page is an in-app notification, a timeline entry, and an audit entry. Acknowledging (incident page, overview card, or bulk bar) or resolving stops paging and tells the others their page is covered. The incident page shows the policy, step, countdown, and pages sent; the queue gains a Paging column and a "Waiting for acknowledgement" filter. Docs page, catalog entry, and footer updated. * feat(showcase): Add the enterprise baseline to SaaS SaaS lists move to the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states: operator tenants (with bulk plan, status, and account manager changes), invoices (bulk retry payment), leads (bulk status with a reason), tenant members and invoices, the customer's team, and billing history. The audit page now uses the shared audit log. Forms use EditForm with a linked error summary, uniqueness checks, and cross-field rules: new tenant (name and subdomain unique, seats within the plan), tenant editor, plans, leads, team invite, workspace settings, contact, and signup. Both consoles get global search and a bell that reads the customer's existing inbox, every change is audited, and the seed grows to 260 tenants. The tab snapshot stores only what differs from the deterministic seed, so it stays small. The dunning workflow, docs, and screenshots follow in the next commit. * feat(showcase): Add dunning for failed payments to SaaS A failed renewal starts a dunning case on an operator-editable policy: retries on set days after the failure, a grace period after the last failed retry, then suspension. A retry succeeds once the customer has a working card. The operator gets a Dunning page (cases grid with bulk retry and extend grace, the policy editor with a preview, a demo clock control) and a payments panel on the tenant page (retry now, extend grace, suspend now, simulate a failed charge, and a timeline). Customers see a payment-failed banner on every workspace page, can update the card and pay now even while suspended, and recover the workspace. Every step notifies the right people and is audited. Docs page, catalog entry, and footer updated. * feat(showcase): Rename Personal Finance to Banking Operations and add the baseline The site becomes Banking Operations in the catalog, with a description and tagline that lead with the back office, and the sign-in page lists Bank operations before Customer. Routes are unchanged. Lists move to the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states: the ops review queue (bulk release and reject of held transfers, bulk hold of scheduled ones), disputes, customers and a customer's transfers and transactions, and the customer's transactions, transfers, disputes, and payees. The audit page uses the shared audit log. Forms use EditForm with a linked error summary, uniqueness checks, and cross-field rules: payees (routing number checksum), transfers (balance, card owed, and a daily payee limit; a note for large payments), disputes, budgets, alerts, and the ops decisions. Both headers get global search and a bell (the customer's reads the existing alerts feed), every action is audited with masked account numbers, and the seed grows to 240 customers. The tab snapshot stores only what differs from the seed. The AML case workflow, docs, and screenshots follow in the next commit. * feat(showcase): Add AML case management to Banking Operations Monitoring rules raise suspicious-activity alerts (structuring, rapid movement, a large first payment to a new payee, high-risk jurisdiction, velocity spikes), both in the seed and live when a customer's payment trips a rule. Operations triage them in an alert queue (bulk assign, dismiss with a reason, open one case from several alerts on a customer) and work cases: investigate, add notes and named evidence, escalate to a senior reviewer, and close with a disposition. A four-eyes rule applies: only a senior reviewer closes an escalated case, never the one who escalated it, and Reported (with a SAR filing reference) always needs that approval. Customers are never told. A Senior reviewer demo account joins the sign-in page. The account page's transaction list moves to the Grid. Docs page, README, credits, catalog entry, footer, and gallery screenshots use the Banking Operations name. * feat(showcase): Add the enterprise baseline to Project Board Project Board lists move to the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states: clients (bulk hand to an account manager), managed projects (bulk status and project manager), project boards, my tasks (bulk mark done, due date, and reassign), and a client's contacts and deals. Forms use EditForm with a linked error summary, uniqueness checks, and cross-field rules: clients (contract dates, billing details), projects (unique key and name per client, due after start, budgets), milestones, tasks (due within the project's dates, assignee on the project), contacts, and work details on the profile. The work layout gets global search and notifications, every change is audited on a new audit log page, and the seed grows to 90 clients, 218 projects, and 1,607 tasks. The tab snapshot stores only what differs from the seed. The timesheets-to-invoice workflow, docs, and screenshots follow in the next commit. * feat(showcase): Add timesheets to client invoices to Project Board Team members log hours on a weekly timesheet (quarter hours, at most 12 an entry and 24 a day, billable by default on client projects) and submit the week. Each project's manager approves its hours or returns the week with a reason. Approved billable hours become a draft invoice per client at the role's rate; the account manager removes lines, issues it on payment terms, and marks it paid, and an issued invoice past its due date shows as overdue. Projects show hours and amount against their budget, with warnings at 80% and 100%. Every step notifies whoever acts next and is audited; account managers edit the rate card. The deal editor, client activity log, and task comment and checklist inputs now validate with the error summary. Query flags such as ?created=1 now parse as numbers on the client and invoice pages; as booleans they failed to parse and stopped the page. Docs page, catalog entry, footer, home page role cards, and gallery screenshots updated. * feat(showcase): Rename E-commerce Storefront to Commerce Back Office and add the baseline The site becomes Commerce Back Office in the catalog, with a description and tagline that lead with the back office, and the sign-in page lists the Retailer first. Routes and the store brand are unchanged. Back-office lists use the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states: orders (bulk pack, ship with tracking, deliver), products (bulk publish, unpublish, move to a category), customers, offers, pricing (bulk change by percent or amount with a reason and a preview), returns (bulk approve with refund or reject with a reason; a new return page), and reviews (bulk publish or hide). Forms use EditForm with a linked error summary, uniqueness checks, and cross-field rules: products (SKU format and uniqueness), coupons, price changes, return decisions, addresses, checkout, reviews, and return requests. Both headers get global search and a bell that reads the existing notices, every change is audited on a new audit log page, and the seed grows to 120 products, 480 orders, and 217 customers. The tab snapshot stores only what differs from the seed. The purchase-order workflow, docs, and screenshots follow in the next commit. * feat(showcase): Add purchase orders and receiving to Commerce Back Office Each product has a reorder point, reorder quantity, preferred supplier, and unit cost; at or below its point it is flagged as low, with the quantity already on order shown. From the new Reorder list the retailer creates one draft purchase order per supplier, edits the lines, and submits it. Orders up to $5,000 can be approved by anyone in the back office; above that a second person must approve, so a Purchasing manager demo account joins the sign-in page. Receiving goods in full or in part adds stock at once, closes the order when nothing is outstanding, and sends the existing back-in-stock notices. Suppliers get their own page, and every step notifies the next person and is audited. Submitting a draft compares the editor with the saved order instead of the edit context's modified flags, which inputs set on their first render. Docs page, README, credits, catalog entry, footer, and gallery screenshots use the Commerce Back Office name. * feat(showcase): Add the enterprise baseline to Healthcare Healthcare lists use the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states: staff patients, check-in (bulk check in and no-show), refills (bulk approve, or deny with a reason), lab orders (bulk release, with a new lab order page), the chart's visits, labs, and prescriptions, and the patient's appointments, bills, records, lab reports, and prescriptions. Forms use EditForm with a linked error summary, uniqueness checks, and cross-field rules: booking (visit type and length, the time re-checked on submit, health plan member IDs), patient registration and edit (unique record number, date of birth, emergency contact), doctors' hours and time off (clinic hours, no overlap), refill requests and decisions, and patient and staff profiles. Both headers get global search and notifications, every change is audited without clinical content, staff views of a chart are logged and listed for the patient under "Who viewed your record", and the seed grows to 320 patients and 1,953 appointments. The tab snapshot stores only what differs from the seed. The insurance-claims workflow, docs, and screenshots follow in the next commit. * feat(showcase): Add insurance claims and denial follow-up to Healthcare A completed visit is coded with diagnosis and procedure codes (one office-visit code that fits the visit), which creates a draft claim for an insured patient. A new Billing specialist submits claims within 90 days of the visit and records each plan's answer: paid, partly paid, or denied with reason codes. A denied claim can be corrected (a new version, with what changed), resubmitted, appealed before its 60-day deadline, or closed as a write-off or billed to the patient. Patients see the plan's share and what they owe in plain words on their bills, and a pending bill can't be paid. Claims, denials, and A/R aging pages, a coding panel on the visit, notifications, and an audit trail without clinical content round it out. The visit notes, vital signs, prescribing, and lab result forms now validate with the error summary. Two field-change handlers re-raised their own event without a guard and overflowed the stack, which stopped the whole server: the claim answer dialog and the doctors' hours form. Docs page, catalog entry, footer, home page, and gallery screenshots updated. * feat(showcase): Add workspace roles and the enterprise baseline to AI Assistant The workspace gets group roles Owner, Admin, Prompt editor, and Member. One permission matrix in the state decides what each role may do and see, every admin page and action checks it, the navigation shows only what a role may use, and a roles and permissions panel shows it on the members page. There is always exactly one Owner; only the Owner hands the role on, by a confirmed transfer that names the workspace. Demo accounts for each role are listed on the sign-in page in that order. Members, shared prompts, and the prompt library use the Grid with saved views, the column chooser, CSV export, and loading, empty, and error states, with bulk role changes (the Owner and yourself are left as they are), access removal, invitation resends, and publishing. Prompt, invite, settings, and profile forms validate with the error summary, including unique titles, declared {{variables}}, and a default model that must be on. Global search, notifications, and a shared audit log page for Admins and the Owner record role, member, prompt, and policy changes without chat content. The tab snapshot stores only what differs from the seed. Spend caps, retention, sensitive-data protection, docs, and screenshots follow in the next commit. * feat(showcase): Add spend caps, retention, and sensitive-data protection to AI Assistant Admins and the Owner set a monthly workspace token cap, a default member cap, and per-member caps. At 80% chat shows a warning and the people concerned are notified once a month; at 100% the state refuses sends for that scope until a cap is raised above current use, which unblocks at once. A Spend page lists every member's usage against their cap, with bulk cap changes and a demo control to push usage up. The Owner picks a retention window and sees how many conversations it deletes before confirming. A sensitive-data policy redacts or blocks payment cards, US SSNs, IBANs, and API keys in chat messages; the member is told which kind of data, never the data, and each event goes to a review queue where an admin dismisses it or adjusts the policy. Raw values are never stored, shown, or logged; the audit log keeps masked matches only. The admin overview gains governance cards. Docs page, catalog entry, footer, home page, and gallery screenshots updated. * fix(demo): Meet WCAG contrast and reflow on the enterprise Showcase sites (T-25) - Sidebar active links: seven site frames set the active color itself; the package resolves it from its -rgb value at :root, so the white override never applied and links showed purple at about 2:1. - Shared Showcase bridge, scoped to the nine kept sites (Online Learning and Travel unchanged): outline secondary, danger, success, and warning button text at 4.5:1 or more in light and dark mode; dark-mode Callout links and text-bg-primary fills use the site colors; Grid pagination shows the current page in the site color with its contrast text and wraps at 320 CSS px. - E-commerce and Project Board panels may shrink below their tables, so the tables scroll in their own wrappers at 320 CSS px. - SaaS light brand color #a21caf (hover #86198f) so links and eyebrow labels reach 4.5:1 on the tinted surfaces; chart colors, docs, and gallery images follow. * fix(grid): Harden CSV export and the column chooser (26112002 review) - Export never throws: building the CSV (a property getter that throws) and the download call (a JSException, for example from an outdated cached script) now run inside the error handling and show ExportErrorText. - Column keys are unique within a grid: a later column with the same PropertyName (or HeaderText) is keyed Name#2, Name#3, so two columns on one property no longer crash the chooser or hide together. The chooser list is keyed on the column instance. - Dragging no longer sends a server event and re-render on every dragover; preventDefault needs no handler. - Move up and Move down at either end use aria-disabled instead of disabled, so keyboard focus stays on the button after a move. * fix: Resolve axe WCAG failures on the enterprise Showcase screens (26112002) Package (additive, 4.1.0): - Grid: sortable headers keep the column header role, report aria-sort, and hold a real button, so sorting works with Enter and Space. Filter inputs get an accessible name from the new FilterInputLabelText ("Filter by {0}"). - MindMap: each card is the tree item, with aria-level, aria-setsize, and aria-posinset, so its name is exactly the text it shows (WCAG 2.5.3); focus and the focus ring move to the card. - PdfViewer: the menu toggle is a button named by the new MoreActionsText ("More actions") instead of an <i> with aria-expanded. Showcase: - Account menu (shared, all sites): the accessible name starts with the visible initials, name, and notice count; signed out it is "Sign in, account menu". - HR org chart initials, E-commerce Add to cart and product sort, and the SaaS customer star rating name what they show. Docs: grid.mdx and pdf-viewer.mdx list the new parameters. * perf(grid): Assign column keys once; fold in re-review follow-ups (26112002) - Grid gives each column its key when the column is added (Name, then Name#2 for a repeat), so reading ColumnKey no longer scans the columns. The column chooser computes the shown columns once per render instead of once per row: a render is O(n^2) in the column count again, not n^4. - Sortable headers: one aria-sort attribute, unique sequence numbers, and a header without text names its sort button after the property. - MindMap: the card keeps a transparent outline on focus so forced-colors mode shows it; aria-posinset uses the stored sibling index. - ExportErrorText describes every export failure. - Showcase account menu: no empty role segment when the role is unknown.
1 parent 8f17320 commit 2ffb32a

209 files changed

Lines changed: 29262 additions & 5638 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@page "/showcase/ai-assistant/admin/audit"
2+
@layout AiAdminLayout
3+
4+
<PageTitle>Audit log · @AiSeedData.ProductName</PageTitle>
5+
6+
@* Admins and the Owner read it: the page's guard keeps prompt editors out, and the state shows the log to those roles only. *@
7+
<div class="container-fluid px-lg-4">
8+
<AiMemberGuard Require="AiPermission.ViewAudit">
9+
<div class="mb-3">
10+
<h1 class="pa-title mb-1">Audit log</h1>
11+
<p class="pa-lead mb-0">
12+
Who did what, and when, newest first: invitations, joins, role changes, access removed and restored, ownership transfers, shared prompts created,
13+
edited, published, unpublished, and deleted, changes to the workspace name, the model policy, retention (and how many conversations it deleted), and the
14+
spend caps, the demo control's usage, and the sensitive data policy, its events, and their reviews. Chat content and prompt text are never copied here:
15+
entries name what changed, with lengths and counts, and a sensitive match only masked, like •••• •••• •••• 4242.
16+
</p>
17+
</div>
18+
19+
<section class="pa-panel" aria-labelledby="pa-audit-title">
20+
<h2 class="visually-hidden" id="pa-audit-title">Entries</h2>
21+
<p class="small text-body-secondary mb-3">
22+
<Icon Name="IconName.Lock" class="me-1" aria-hidden="true" />Kept for this browser tab. Entries can't be changed or deleted.
23+
</p>
24+
<div class="pa-grid">
25+
<ShowcaseAuditLog ExportFileName="ai-audit-log" AriaLabel="Audit log of the workspace" />
26+
</div>
27+
</section>
28+
</AiMemberGuard>
29+
</div>

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/AiAssistant/AdminMembers.razor‎

Lines changed: 436 additions & 216 deletions
Large diffs are not rendered by default.

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/AiAssistant/AdminMembers.razor.cs‎

Lines changed: 749 additions & 233 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,44 @@
1-
/* Members and roles: the invite form, the status filter, and the members table (it scrolls inside its box on narrow screens). */
2-
.pa-admem-status {
3-
min-height: 1.5rem;
1+
/* Members and roles: the invite form, the roles and permissions matrix, the ownership transfer, and the member dialog.
2+
The list's styles (filters, bulk bar, Grid) are shared from AiFrame. */
3+
.pa-admem-email {
44
overflow-wrap: anywhere;
55
}
66

7-
.pa-admem-status:focus {
8-
outline: none;
9-
}
7+
.pa-admem-matrix th,
8+
.pa-admem-matrix td {
9+
font-size: .8125rem;
10+
}
1011

11-
.pa-admem-status:focus-visible {
12-
outline: 2px solid var(--bs-focus-ring-color, var(--sc-primary));
13-
outline-offset: 2px;
14-
}
12+
.pa-admem-matrix thead th {
13+
white-space: nowrap;
14+
}
1515

1616
/* Lines the button up with the inputs, whose labels sit above them. */
17-
@media (min-width: 1200px) {
18-
.pa-admem-invite-submit {
17+
@media (min-width: 768px) {
18+
.pa-admem-transfer-submit {
1919
padding-top: 2rem;
2020
}
2121
}
2222

23-
.pa-admem-filter {
24-
display: flex;
25-
flex-wrap: wrap;
26-
gap: .375rem;
27-
}
28-
29-
.pa-admem-count {
30-
font-variant-numeric: tabular-nums;
31-
}
32-
33-
.pa-admem-caption {
34-
caption-side: top;
35-
padding-top: 0;
36-
font-size: .8125rem;
37-
color: var(--bs-secondary-color);
38-
}
39-
40-
.pa-admem-name {
41-
min-width: 9rem;
42-
overflow-wrap: anywhere;
43-
}
44-
45-
.pa-admem-email {
46-
min-width: 11rem;
23+
/* Inside the Modal component, so ::deep from the page. */
24+
::deep .pa-admem-dialog-title {
4725
overflow-wrap: anywhere;
4826
}
4927

50-
.pa-admem-actions {
51-
display: flex;
52-
flex-wrap: nowrap;
53-
align-items: center;
54-
gap: .375rem;
28+
.pa-admem-facts {
29+
display: grid;
30+
grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
31+
gap: .5rem 1rem;
32+
margin-bottom: 1rem;
5533
}
5634

57-
.pa-admem-actions ::deep .btn {
58-
white-space: nowrap;
35+
.pa-admem-facts dt {
36+
font-size: .75rem;
37+
font-weight: 600;
38+
color: var(--bs-secondary-color);
5939
}
6040

61-
/* Inside the Modal component, so ::deep from the page. */
62-
::deep .pa-admem-dialog-title {
63-
overflow-wrap: anywhere;
64-
}
65-
66-
::deep .pa-admem-warning {
67-
padding: .625rem .75rem;
68-
border-left: .25rem solid var(--bs-warning);
69-
border-radius: 0 .5rem .5rem 0;
70-
background: var(--bs-warning-bg-subtle);
71-
color: var(--bs-warning-text-emphasis);
72-
}
41+
.pa-admem-facts dd {
42+
margin: 0;
43+
overflow-wrap: anywhere;
44+
}

‎BlazorBootstrap.Demo.RCL/Components/Pages/Showcase/AiAssistant/AdminOverview.razor‎

Lines changed: 61 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
<PageTitle>Usage analytics · @AiSeedData.ProductName</PageTitle>
55

6+
@* Admins and the Owner: prompt editors open the back office too, but this page needs the analytics permission. *@
67
<div class="container-fluid px-lg-4">
8+
<AiMemberGuard Require="AiPermission.ViewAnalytics">
79
@{
810
var quota = State.Policy.MonthlyTokenQuota;
911
var rows = MemberRows;
@@ -14,12 +16,12 @@
1416

1517
<div class="pa-adov-head mb-4">
1618
<h1 class="pa-title">Usage analytics</h1>
17-
<p class="pa-lead mb-1">How @AiSeedData.WorkspaceName uses @AiSeedData.ProductName: members, messages, and tokens by model, against the monthly quota of @AiDisplay.Tokens(quota) tokens per member.</p>
19+
<p class="pa-lead mb-1">How @State.WorkspaceName uses @AiSeedData.ProductName: members, messages, and tokens by model, against each member's monthly cap (by default @AiDisplay.Tokens(quota) tokens) and the workspace's.</p>
1820
<p class="small text-body-secondary mb-0">Sample figures: the history before today is generated; messages sent in this tab are added to it.</p>
1921
</div>
2022

2123
<section aria-label="Totals for @monthName" class="row row-cols-1 row-cols-sm-2 row-cols-xl-4 g-3 mb-4">
22-
@foreach (var total in Totals(rows, quota))
24+
@foreach (var total in Totals(rows))
2325
{
2426
<div class="col" @key="total.Label">
2527
<div class="pa-card pa-adov-kpi h-100">
@@ -31,6 +33,52 @@
3133
}
3234
</section>
3335

36+
@* Governance at a glance (AC-4, AC-7i): each card says its figure in words and links to its page. *@
37+
<section class="mb-4" aria-labelledby="pa-adov-governance-title">
38+
<h2 class="pa-section-title" id="pa-adov-governance-title">Governance</h2>
39+
<div class="row row-cols-1 row-cols-md-3 g-3">
40+
@{
41+
var workspaceSpend = State.WorkspaceSpend;
42+
var blockedMembers = State.SpendByMember().Values.Count(item => item.Level == AiSpendLevel.Blocked);
43+
var waitingEvents = State.NewDlpEventCount;
44+
var retention = State.Policy.RetentionDays;
45+
}
46+
<div class="col">
47+
<a class="pa-card pa-adov-module h-100" href="@($"{AiAdminLayout.Base}/spend")">
48+
<span class="pa-icon flex-shrink-0" aria-hidden="true"><Icon Name="IconName.PiggyBank" /></span>
49+
<span>
50+
<span class="d-block fw-bold">Spend: @workspaceSpend.Percent.ToString("0", CultureInfo.InvariantCulture)% of the workspace cap</span>
51+
<span class="d-block small text-body-secondary">
52+
@AiDisplay.Tokens(workspaceSpend.Used) of @AiDisplay.Tokens(workspaceSpend.Cap) tokens@(workspaceSpend.Level == AiSpendLevel.Blocked ? ": chat is paused for everyone" : workspaceSpend.Level == AiSpendLevel.Warning ? ": past the 80% warning" : null).
53+
@AdminMembers.Plural(blockedMembers, "member is", "members are") blocked by their own cap.
54+
</span>
55+
</span>
56+
</a>
57+
</div>
58+
<div class="col">
59+
<a class="pa-card pa-adov-module h-100" href="@($"{AiAdminLayout.Base}/settings")">
60+
<span class="pa-icon flex-shrink-0" aria-hidden="true"><Icon Name="IconName.HourglassSplit" /></span>
61+
<span>
62+
<span class="d-block fw-bold">Retention: @(retention == 0 ? "keep forever" : AdminMembers.Plural(retention, "day"))</span>
63+
<span class="d-block small text-body-secondary">
64+
@(retention == 0 ? $"Conversations are kept; {AdminMembers.Plural(State.ConversationsOlderThan(90), "conversation is", "conversations are")} older than 90 days." : $"Older conversations are deleted. The workspace holds {AdminMembers.Plural(State.ConversationCount, "conversation")}.")
65+
The Owner sets it.
66+
</span>
67+
</span>
68+
</a>
69+
</div>
70+
<div class="col">
71+
<a class="pa-card pa-adov-module h-100" href="@($"{AiAdminLayout.Base}/sensitive-data")">
72+
<span class="pa-icon flex-shrink-0" aria-hidden="true"><Icon Name="IconName.ShieldExclamation" /></span>
73+
<span>
74+
<span class="d-block fw-bold">Sensitive data: @(waitingEvents == 0 ? "nothing to review" : $"{AdminMembers.Plural(waitingEvents, "event")} to review")</span>
75+
<span class="d-block small text-body-secondary">Messages the policy redacted or blocked, with only the masked match.</span>
76+
</span>
77+
</a>
78+
</div>
79+
</div>
80+
</section>
81+
3482
<div class="row g-3 mb-4">
3583
<div class="col-xxl-8">
3684
<section class="pa-panel h-100" aria-labelledby="pa-adov-daily-title">
@@ -121,37 +169,33 @@
121169
<h2 class="pa-section-title mb-0" id="pa-adov-top-title">Top members this month</h2>
122170
<a class="small" href="@($"{AiAdminLayout.Base}/members")">Manage members and roles</a>
123171
</div>
124-
@if (rows.Count == 0)
125-
{
126-
<p class="text-body-secondary mb-0">Nobody has joined the workspace yet.</p>
127-
}
128-
else
129-
{
172+
<ShowcaseDataState IsEmpty="@(rows.Count == 0)" EmptyIcon="IconName.People" EmptyTitle="Nobody has joined the workspace yet"
173+
EmptyText="Invite people from Members and roles; their usage shows here once they chat.">
130174
<div class="table-responsive">
131175
<table class="table align-middle mb-0 pa-adov-top">
132176
<caption class="pa-adov-caption">
133-
Members by tokens used in @monthName, the most first (top @Math.Min(TopCount, rows.Count) of @rows.Count). The quota is @AiDisplay.Tokens(quota) tokens per member each month.
177+
Members by tokens used in @monthName, the most first (top @Math.Min(TopCount, rows.Count) of @rows.Count). Each share is of the member's own cap, or of the default of @AiDisplay.Tokens(quota) tokens a month.
134178
</caption>
135179
<thead>
136180
<tr>
137181
<th scope="col">Name</th>
138182
<th scope="col">Email</th>
139183
<th scope="col" class="text-end">Messages</th>
140184
<th scope="col" class="text-end">Tokens</th>
141-
<th scope="col" class="pa-adov-share">Share of quota</th>
185+
<th scope="col" class="pa-adov-share">Share of cap</th>
142186
<th scope="col">Status</th>
143187
</tr>
144188
</thead>
145189
<tbody>
146190
@foreach (var row in rows.Take(TopCount))
147191
{
148-
var percent = SharePercent(row.Tokens, quota);
192+
var percent = SharePercent(row.Tokens, State.CapOf(row.Member));
149193
<tr @key="row.Member.Email">
150194
<th scope="row" class="pa-adov-name">
151195
@row.Member.Name
152196
@if (row.Member.AccountId is not null && row.Member.AccountId == State.Identity.Current?.Id)
153197
{
154-
<span class="fw-normal text-body-secondary"> (you)</span>
198+
<span class="fw-normal text-body-secondary">&#32;(you)</span>
155199
}
156200
</th>
157201
<td class="pa-adov-email">@row.Member.Email</td>
@@ -161,7 +205,7 @@
161205
<div class="d-flex align-items-center gap-2">
162206
<Progress Height="6" Class="flex-grow-1">
163207
<ProgressBar Width="Math.Min(100, percent)" Color="@QuotaColor(percent)"
164-
aria-label="@($"{row.Member.Name}, share of quota")" aria-valuenow="@Math.Round(percent)" aria-valuemin="0" aria-valuemax="100"
208+
aria-label="@($"{row.Member.Name}, share of cap")" aria-valuenow="@Math.Round(percent)" aria-valuemin="0" aria-valuemax="100"
165209
aria-valuetext="@QuotaText(percent)" />
166210
</Progress>
167211
<span class="small text-nowrap">@QuotaText(percent)</span>
@@ -173,13 +217,13 @@
173217
</tbody>
174218
</table>
175219
</div>
176-
}
220+
</ShowcaseDataState>
177221
</section>
178222

179223
<section aria-labelledby="pa-adov-more-title">
180224
<h2 class="pa-section-title" id="pa-adov-more-title">More workspace admin</h2>
181-
<div class="row row-cols-1 row-cols-md-3 g-3">
182-
@foreach (var module in Modules)
225+
<div class="row row-cols-1 row-cols-md-2 row-cols-xxl-3 g-3">
226+
@foreach (var module in Modules.Where(module => State.Can(module.Permission)))
183227
{
184228
<div class="col" @key="module.Href">
185229
<a class="pa-card pa-adov-module h-100" href="@module.Href">
@@ -193,4 +237,5 @@
193237
}
194238
</div>
195239
</section>
240+
</AiMemberGuard>
196241
</div>

0 commit comments

Comments
 (0)