@mastra/playground-ui 71.0.0-alpha.7 → 71.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/domains/agents/chat/stream-error-message.cjs.js +13 -6
- package/dist/domains/agents/chat/stream-error-message.cjs.js.map +1 -1
- package/dist/domains/agents/chat/stream-error-message.es.js +13 -6
- package/dist/domains/agents/chat/stream-error-message.es.js.map +1 -1
- package/dist/domains/agents/chat/use-chat-send-handler.cjs.js +4 -1
- package/dist/domains/agents/chat/use-chat-send-handler.cjs.js.map +1 -1
- package/dist/domains/agents/chat/use-chat-send-handler.es.js +4 -1
- package/dist/domains/agents/chat/use-chat-send-handler.es.js.map +1 -1
- package/dist/domains/dashboards/components/stateless-widget.cjs.js.map +1 -1
- package/dist/domains/dashboards/components/stateless-widget.es.js.map +1 -1
- package/dist/domains/dashboards/components/view-tabs.cjs.js +30 -0
- package/dist/domains/dashboards/components/view-tabs.cjs.js.map +1 -0
- package/dist/domains/dashboards/components/view-tabs.d.ts +1 -0
- package/dist/domains/dashboards/components/view-tabs.es.js +29 -0
- package/dist/domains/dashboards/components/view-tabs.es.js.map +1 -0
- package/dist/domains/dashboards/hooks/use-widget-views.cjs.js +24 -5
- package/dist/domains/dashboards/hooks/use-widget-views.cjs.js.map +1 -1
- package/dist/domains/dashboards/hooks/use-widget-views.es.js +24 -6
- package/dist/domains/dashboards/hooks/use-widget-views.es.js.map +1 -1
- package/dist/domains/dashboards/kinds/scores/scores-widget.cjs.js +2 -2
- package/dist/domains/dashboards/kinds/scores/scores-widget.cjs.js.map +1 -1
- package/dist/domains/dashboards/kinds/scores/scores-widget.es.js +1 -1
- package/dist/domains/dashboards/kinds/scores/scores-widget.es.js.map +1 -1
- package/dist/domains/dashboards/kinds/table/table-tabs.cjs.js +0 -11
- package/dist/domains/dashboards/kinds/table/table-tabs.cjs.js.map +1 -1
- package/dist/domains/dashboards/kinds/table/table-tabs.es.js +0 -11
- package/dist/domains/dashboards/kinds/table/table-tabs.es.js.map +1 -1
- package/dist/domains/dashboards/kinds/table/table-widget.cjs.js.map +1 -1
- package/dist/domains/dashboards/kinds/table/table-widget.es.js.map +1 -1
- package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.cjs.js +1 -1
- package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.cjs.js.map +1 -1
- package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.es.js +1 -1
- package/dist/domains/dashboards/kinds/timeseries/timeseries-widget.es.js.map +1 -1
- package/dist/domains/dashboards/lib/chrome.cjs.js +1 -23
- package/dist/domains/dashboards/lib/chrome.cjs.js.map +1 -1
- package/dist/domains/dashboards/lib/chrome.es.js +2 -23
- package/dist/domains/dashboards/lib/chrome.es.js.map +1 -1
- package/dist/domains/dashboards/lib/view-labels.cjs.js +9 -7
- package/dist/domains/dashboards/lib/view-labels.cjs.js.map +1 -1
- package/dist/domains/dashboards/lib/view-labels.es.js +9 -7
- package/dist/domains/dashboards/lib/view-labels.es.js.map +1 -1
- package/dist/domains/dashboards/metrics-dashboard.cjs.js +1 -1
- package/dist/domains/dashboards/metrics-dashboard.cjs.js.map +1 -1
- package/dist/domains/dashboards/metrics-dashboard.es.js +1 -1
- package/dist/domains/dashboards/metrics-dashboard.es.js.map +1 -1
- package/dist/domains/dashboards/widget-kind.cjs.js.map +1 -1
- package/dist/domains/dashboards/widget-kind.es.js.map +1 -1
- package/dist/domains/dashboards.cjs.js +1 -1
- package/dist/domains/dashboards.es.js +1 -1
- package/dist/domains/metrics/components/breakdown/breakdown-table.cjs.js +2 -2
- package/dist/domains/metrics/components/breakdown/breakdown-table.cjs.js.map +1 -1
- package/dist/domains/metrics/components/breakdown/breakdown-table.es.js +2 -2
- package/dist/domains/metrics/components/breakdown/breakdown-table.es.js.map +1 -1
- package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.cjs.js +4 -2
- package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.cjs.js.map +1 -1
- package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.es.js +4 -2
- package/dist/domains/metrics/components/distinct-ids/distinct-ids-chart.es.js.map +1 -1
- package/dist/src/domains/agents/chat/stream-error-message.d.ts +16 -11
- package/dist/src/domains/dashboards/components/stateless-widget.d.ts +1 -2
- package/dist/src/domains/dashboards/components/view-tabs.d.ts +13 -0
- package/dist/src/domains/dashboards/hooks/use-widget-views.d.ts +11 -5
- package/dist/src/domains/dashboards/lib/chrome.d.ts +4 -13
- package/dist/src/domains/dashboards/lib/view-labels.d.ts +3 -3
- package/dist/src/domains/dashboards/widget-kind.d.ts +2 -3
- package/package.json +12 -11
- package/dist/domains/dashboards/kinds/table/table-view-tabs.cjs.js +0 -32
- package/dist/domains/dashboards/kinds/table/table-view-tabs.cjs.js.map +0 -1
- package/dist/domains/dashboards/kinds/table/table-view-tabs.d.ts +0 -1
- package/dist/domains/dashboards/kinds/table/table-view-tabs.es.js +0 -31
- package/dist/domains/dashboards/kinds/table/table-view-tabs.es.js.map +0 -1
- package/dist/src/domains/dashboards/kinds/table/table-view-tabs.d.ts +0 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-widget-views.es.js","names":[],"sources":["../../../../src/domains/dashboards/hooks/use-widget-views.
|
|
1
|
+
{"version":3,"file":"use-widget-views.es.js","names":[],"sources":["../../../../src/domains/dashboards/hooks/use-widget-views.tsx"],"sourcesContent":["import type { DashboardWidget, DashboardWidgetView } from '@mastra/client-js';\nimport { useState } from 'react';\nimport type { DrilldownScope } from '../../metrics/drilldown';\nimport { ViewTabs } from '../components/view-tabs';\nimport { viewLabel } from '../lib/chrome';\nimport type { ViewHeading } from '../lib/chrome';\nimport { viewDrilldown, targetScope } from '../lib/definition';\nimport type { OnDashboardDrilldown } from '../lib/definition';\nimport type { DashboardExpand, ResolvedView } from '../widget-kind';\n\n/**\n * The card heading for the open view: the widget's title, with several views as tabs under it\n * (`toolbar`). With somewhere to expand to, the title stays alone instead, and `ExpandAction` links there.\n */\nexport function viewTitle(\n widget: DashboardWidget,\n views: readonly DashboardWidgetView[],\n index: number,\n onChoose: (index: number) => void,\n expand?: DashboardExpand,\n): ViewHeading {\n if (expand?.href(widget)) {\n // The card and its expand link need a name: a blank title falls back to the first view's label.\n return { title: widget.title?.trim() ? widget.title : viewLabel(views[0]?.label, 0) };\n }\n if (views.length < 2) return { title: widget.title ?? '' };\n return {\n title: widget.title ?? '',\n toolbar: <ViewTabs labels={views.map((v, i) => viewLabel(v.label, i))} index={index} onChoose={onChoose} />,\n };\n}\n\nexport type Views<Options> = readonly [ResolvedView<Options>, ...ResolvedView<Options>[]];\n\n/**\n * The open view of a widget, `wanted` when it has one (else the first), and the card heading for it\n * (`title`, and with several views their tabs as `toolbar`, unless the widget has somewhere to\n * `expand` to) to spread into `ChartCard`; picking a view calls `onChoose`.\n */\nexport function viewMenu<Options>(\n widget: DashboardWidget,\n views: Views<Options>,\n wanted: number,\n onChoose: (index: number) => void,\n expand?: DashboardExpand,\n) {\n const index = views[wanted] ? wanted : 0;\n return { view: views[index] ?? views[0], index, heading: viewTitle(widget, views, index, onChoose, expand) };\n}\n\n/** `viewMenu` with the open view held here: `defaultIndex` until one is picked. */\nexport function useViewMenu<Options>(\n widget: DashboardWidget,\n views: Views<Options>,\n defaultIndex = 0,\n expand?: DashboardExpand,\n) {\n const [chosen, choose] = useState<number>();\n return viewMenu(widget, views, chosen ?? defaultIndex, choose, expand);\n}\n\n/** What clicking a bucket or row opens, with what was clicked; `undefined` when the view has no click target. */\nexport function useDrilldown(\n widget: DashboardWidget,\n view: DashboardWidgetView,\n onDrilldown: OnDashboardDrilldown | undefined,\n) {\n const { click } = viewDrilldown(widget, view);\n if (!onDrilldown || !click) return undefined;\n return (clicked: DrilldownScope) => onDrilldown(click.page, { ...targetScope(click), ...clicked });\n}\n\n/** Whether the view has an action button to show (`DrilldownAction`). */\nexport const hasDrilldownAction = (\n widget: DashboardWidget,\n view: DashboardWidgetView,\n onDrilldown: OnDashboardDrilldown | undefined,\n) => onDrilldown !== undefined && viewDrilldown(widget, view).action !== undefined;\n"],"mappings":";;;;;;;;;;AAcA,SAAgB,UACd,QACA,OACA,OACA,UACA,QACa;CACb,IAAI,QAAQ,KAAK,MAAM,GAErB,OAAO,EAAE,OAAO,OAAO,OAAO,KAAK,IAAI,OAAO,QAAQ,UAAU,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE;CAEtF,IAAI,MAAM,SAAS,GAAG,OAAO,EAAE,OAAO,OAAO,SAAS,GAAG;CACzD,OAAO;EACL,OAAO,OAAO,SAAS;EACvB,SAAS,oBAAC,UAAD;GAAU,QAAQ,MAAM,KAAK,GAAG,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC;GAAU;GAAiB;EAAW,CAAA;CAC5G;AACF;;;;;;AASA,SAAgB,SACd,QACA,OACA,QACA,UACA,QACA;CACA,MAAM,QAAQ,MAAM,UAAU,SAAS;CACvC,OAAO;EAAE,MAAM,MAAM,UAAU,MAAM;EAAI;EAAO,SAAS,UAAU,QAAQ,OAAO,OAAO,UAAU,MAAM;CAAE;AAC7G;;AAGA,SAAgB,YACd,QACA,OACA,eAAe,GACf,QACA;CACA,MAAM,CAAC,QAAQ,UAAU,SAAiB;CAC1C,OAAO,SAAS,QAAQ,OAAO,UAAU,cAAc,QAAQ,MAAM;AACvE;;AAGA,SAAgB,aACd,QACA,MACA,aACA;CACA,MAAM,EAAE,UAAU,cAAc,QAAQ,IAAI;CAC5C,IAAI,CAAC,eAAe,CAAC,OAAO,OAAO,KAAA;CACnC,QAAQ,YAA4B,YAAY,MAAM,MAAM;EAAE,GAAG,YAAY,KAAK;EAAG,GAAG;CAAQ,CAAC;AACnG;;AAGA,IAAa,sBACX,QACA,MACA,gBACG,gBAAgB,KAAA,KAAa,cAAc,QAAQ,IAAI,CAAC,CAAC,WAAW,KAAA"}
|
|
@@ -7,8 +7,8 @@ const require_domains_metrics_lib_chart_colors = require("../../../metrics/lib/c
|
|
|
7
7
|
const require_domains_metrics_lib_metrics_buckets = require("../../../metrics/lib/metrics-buckets.cjs.js");
|
|
8
8
|
const require_domains_dashboards_components_widget_chrome = require("../../components/widget-chrome.cjs.js");
|
|
9
9
|
const require_domains_dashboards_components_widget_controls = require("../../components/widget-controls.cjs.js");
|
|
10
|
+
const require_domains_dashboards_hooks_use_widget_views = require("../../hooks/use-widget-views.cjs.js");
|
|
10
11
|
const require_domains_dashboards_lib_alert_actions = require("../../lib/alert-actions.cjs.js");
|
|
11
|
-
const require_domains_dashboards_lib_chrome = require("../../lib/chrome.cjs.js");
|
|
12
12
|
const require_domains_dashboards_lib_format = require("../../lib/format.cjs.js");
|
|
13
13
|
const require_domains_dashboards_lib_scores = require("../../lib/scores.cjs.js");
|
|
14
14
|
const require_MetricsLineChart = require("../../../../MetricsLineChart-DupSN9YT.cjs");
|
|
@@ -24,7 +24,7 @@ var SCORER_COLORS = [
|
|
|
24
24
|
];
|
|
25
25
|
function ScoresWidget({ widget, views, gate, discovered, results, onRetry, expand, dragHandle, onTitleChange, actions, alert }) {
|
|
26
26
|
const [view] = views;
|
|
27
|
-
const title =
|
|
27
|
+
const title = require_domains_dashboards_hooks_use_widget_views.viewTitle(widget, [view], 0, () => {}, expand);
|
|
28
28
|
const expandHref = expand?.href(widget);
|
|
29
29
|
const heading = require_domains_dashboards_lib_alert_actions.withAction({
|
|
30
30
|
...title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scores-widget.cjs.js","names":["CHART_COLORS","viewTitle","withAction","ExpandAction","PendingChartCard","pendingHeading","alertAction","bucketPlan","intervalHours","scorersOf","ChartCard","ChartCardError","shapeScores","ChartArea","MetricsLineChart","FORMATTERS","BUCKET_AXIS"],"sources":["../../../../../src/domains/dashboards/kinds/scores/scores-widget.tsx"],"sourcesContent":["import { ChartArea } from '../../../metrics/components/chart-area';\nimport { ChartCard } from '../../../metrics/components/chart-card';\nimport { ChartCardError } from '../../../metrics/components/chart-card-error';\nimport { BUCKET_AXIS } from '../../../metrics/lib/chart-axis';\nimport { CHART_COLORS } from '../../../metrics/lib/chart-colors';\nimport { bucketPlan, intervalHours } from '../../../metrics/lib/metrics-buckets';\nimport { PendingChartCard } from '../../components/widget-chrome';\nimport { ExpandAction } from '../../components/widget-controls';\nimport {
|
|
1
|
+
{"version":3,"file":"scores-widget.cjs.js","names":["CHART_COLORS","viewTitle","withAction","ExpandAction","PendingChartCard","pendingHeading","alertAction","bucketPlan","intervalHours","scorersOf","ChartCard","ChartCardError","shapeScores","ChartArea","MetricsLineChart","FORMATTERS","BUCKET_AXIS"],"sources":["../../../../../src/domains/dashboards/kinds/scores/scores-widget.tsx"],"sourcesContent":["import { ChartArea } from '../../../metrics/components/chart-area';\nimport { ChartCard } from '../../../metrics/components/chart-card';\nimport { ChartCardError } from '../../../metrics/components/chart-card-error';\nimport { BUCKET_AXIS } from '../../../metrics/lib/chart-axis';\nimport { CHART_COLORS } from '../../../metrics/lib/chart-colors';\nimport { bucketPlan, intervalHours } from '../../../metrics/lib/metrics-buckets';\nimport { PendingChartCard } from '../../components/widget-chrome';\nimport { ExpandAction } from '../../components/widget-controls';\nimport { viewTitle } from '../../hooks/use-widget-views';\nimport { alertAction, pendingHeading, withAction } from '../../lib/alert-actions';\nimport type { ViewHeading } from '../../lib/chrome';\nimport { FORMATTERS } from '../../lib/format';\nimport type { DashboardPageContext, DashboardResult } from '../../lib/requests';\nimport { scorersOf, shapeScores } from '../../lib/scores';\nimport type { ResolvedView, WidgetKindProps } from '../../widget-kind';\nimport type { ScoresOptions } from './options';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\nimport { MetricsLineChart } from '@/ds/components/MetricsLineChart';\n\n/** Scores aren't problems, so no warm hues; past five scorers the colors repeat. */\nconst SCORER_COLORS = [\n CHART_COLORS.green,\n CHART_COLORS.sky,\n CHART_COLORS.violet,\n CHART_COLORS.teal,\n CHART_COLORS.indigo,\n];\n\nexport function ScoresWidget({\n widget,\n views,\n gate,\n discovered,\n results,\n onRetry,\n expand,\n dragHandle,\n onTitleChange,\n actions,\n alert,\n}: WidgetKindProps<ScoresOptions>) {\n const [view] = views;\n // Scores show their first view only, so the title is plain; with somewhere to expand to, an action links there.\n const title = viewTitle(widget, [view], 0, () => {}, expand);\n const expandHref = expand?.href(widget);\n const heading = withAction(\n { ...title, dragHandle, onTitleChange, actions },\n expand && expandHref && <ExpandAction title={title.title} href={expandHref} LinkComponent={expand.LinkComponent} />,\n );\n // The card, and the host's actions, stay while the view waits, so e.g. a pinned widget can still be unpinned.\n if (gate.status === 'pending')\n return <PendingChartCard gate={gate.gate} heading={pendingHeading(heading, gate.gate, alert, widget, view)} />;\n return (\n <ScoresView\n heading={withAction(\n heading,\n // The scorers' means over the range: what the card's lines average to.\n alertAction(alert, widget, view, {\n page: gate.page,\n values: [\n { label: view.label?.trim() || widget.title?.trim() || 'Scores', value: { query: view.options.average } },\n ],\n }),\n )}\n view={view}\n page={gate.page}\n discovered={discovered}\n results={results}\n onRetry={onRetry}\n />\n );\n}\n\nfunction ScoresView({\n heading,\n view,\n page,\n discovered,\n results,\n onRetry,\n}: {\n heading: ViewHeading;\n view: ResolvedView<ScoresOptions>;\n page: DashboardPageContext;\n discovered: (DashboardResult | undefined)[];\n results: (DashboardResult | undefined)[];\n onRetry: () => void;\n}) {\n const { options } = view;\n const { interval } = bucketPlan(page.window.start, page.window.end);\n const stepHours = intervalHours(interval);\n const scorers = scorersOf(view.queries, discovered[0]?.data);\n // One answer per scorer in each list, in `scorers`' order.\n const means = results.slice(0, scorers.length);\n const points = results.slice(scorers.length, scorers.length * 2);\n\n const all = [...discovered, ...results].filter(r => r !== undefined);\n const failed = all.filter(r => r.isError);\n if (failed.length > 0) {\n return (\n <ChartCard {...heading}>\n <ChartCardError error={failed[0]?.error} onRetry={onRetry} />\n </ChartCard>\n );\n }\n\n const isLoading = all.some(r => r.isLoading);\n const { buckets, lines } = shapeScores(\n isLoading ? [] : scorers,\n means.map(r => r?.data),\n points.map(r => r?.data),\n page.window,\n stepHours,\n );\n const series: MetricsLineChartSeries[] = lines.map(({ scorerId, name }, i) => ({\n dataKey: scorerId,\n label: name,\n color: SCORER_COLORS[i % SCORER_COLORS.length] ?? CHART_COLORS.neutral,\n }));\n\n return (\n <ChartCard {...heading} isUpdating={all.some(r => r.isRefetching)}>\n <ChartArea isEmpty={!isLoading && lines.length === 0}>\n <MetricsLineChart\n lineStyle=\"thin\"\n data={isLoading ? [] : buckets}\n series={series}\n height=\"fill\"\n yDomain={[0, 1]}\n valueFormatter={FORMATTERS.score.value}\n axisFormatter={FORMATTERS.score.axis}\n isLoading={isLoading}\n {...BUCKET_AXIS}\n />\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,IAAM,gBAAgB;CACpBA,yCAAAA,aAAa;CACbA,yCAAAA,aAAa;CACbA,yCAAAA,aAAa;CACbA,yCAAAA,aAAa;CACbA,yCAAAA,aAAa;AACf;AAEA,SAAgB,aAAa,EAC3B,QACA,OACA,MACA,YACA,SACA,SACA,QACA,YACA,eACA,SACA,SACiC;CACjC,MAAM,CAAC,QAAQ;CAEf,MAAM,QAAQC,kDAAAA,UAAU,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM;CAC3D,MAAM,aAAa,QAAQ,KAAK,MAAM;CACtC,MAAM,UAAUC,6CAAAA,WACd;EAAE,GAAG;EAAO;EAAY;EAAe;CAAQ,GAC/C,UAAU,cAAc,iBAAA,GAAA,kBAAA,IAAA,CAACC,sDAAAA,cAAD;EAAc,OAAO,MAAM;EAAO,MAAM;EAAY,eAAe,OAAO;CAAgB,CAAA,CACpH;CAEA,IAAI,KAAK,WAAW,WAClB,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,oDAAAA,kBAAD;EAAkB,MAAM,KAAK;EAAM,SAASC,6CAAAA,eAAe,SAAS,KAAK,MAAM,OAAO,QAAQ,IAAI;CAAI,CAAA;CAC/G,OACE,iBAAA,GAAA,kBA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GACvB,KAAK,QACL,SACF;CACA,MAAM,SAAmC,MAAM,KAAK,EAAE,UAAU,QAAQ,OAAO;EAC7E,SAAS;EACT,OAAO;EACP,OAAO,cAAc,IAAI,cAAc,WAAWZ,yCAAAA,aAAa;CACjE,EAAE;CAEF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACU,8CAAAA,WAAD;EAAW,GAAI;EAAS,YAAY,IAAI,MAAK,MAAK,EAAE,YAAY;EAC9D,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACG,8CAAAA,WAAD;GAAW,SAAS,CAAC,aAAa,MAAM,WAAW;GACjD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,yBAAAA,kBAAD;IACE,WAAU;IACV,MAAM,YAAY,CAAC,IAAI;IACf;IACR,QAAO;IACP,SAAS,CAAC,GAAG,CAAC;IACd,gBAAgBC,sCAAAA,WAAW,MAAM;IACjC,eAAeA,sCAAAA,WAAW,MAAM;IACrB;IACX,GAAIC,uCAAAA;GACL,CAAA;EACQ,CAAA;CACF,CAAA;AAEf"}
|
|
@@ -6,8 +6,8 @@ import { CHART_COLORS } from "../../../metrics/lib/chart-colors.es.js";
|
|
|
6
6
|
import { bucketPlan, intervalHours } from "../../../metrics/lib/metrics-buckets.es.js";
|
|
7
7
|
import { PendingChartCard } from "../../components/widget-chrome.es.js";
|
|
8
8
|
import { ExpandAction } from "../../components/widget-controls.es.js";
|
|
9
|
+
import { viewTitle } from "../../hooks/use-widget-views.es.js";
|
|
9
10
|
import { alertAction, pendingHeading, withAction } from "../../lib/alert-actions.es.js";
|
|
10
|
-
import { viewTitle } from "../../lib/chrome.es.js";
|
|
11
11
|
import { FORMATTERS } from "../../lib/format.es.js";
|
|
12
12
|
import { scorersOf, shapeScores } from "../../lib/scores.es.js";
|
|
13
13
|
import { t as MetricsLineChart } from "../../../../MetricsLineChart-vgZTYICl.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scores-widget.es.js","names":[],"sources":["../../../../../src/domains/dashboards/kinds/scores/scores-widget.tsx"],"sourcesContent":["import { ChartArea } from '../../../metrics/components/chart-area';\nimport { ChartCard } from '../../../metrics/components/chart-card';\nimport { ChartCardError } from '../../../metrics/components/chart-card-error';\nimport { BUCKET_AXIS } from '../../../metrics/lib/chart-axis';\nimport { CHART_COLORS } from '../../../metrics/lib/chart-colors';\nimport { bucketPlan, intervalHours } from '../../../metrics/lib/metrics-buckets';\nimport { PendingChartCard } from '../../components/widget-chrome';\nimport { ExpandAction } from '../../components/widget-controls';\nimport {
|
|
1
|
+
{"version":3,"file":"scores-widget.es.js","names":[],"sources":["../../../../../src/domains/dashboards/kinds/scores/scores-widget.tsx"],"sourcesContent":["import { ChartArea } from '../../../metrics/components/chart-area';\nimport { ChartCard } from '../../../metrics/components/chart-card';\nimport { ChartCardError } from '../../../metrics/components/chart-card-error';\nimport { BUCKET_AXIS } from '../../../metrics/lib/chart-axis';\nimport { CHART_COLORS } from '../../../metrics/lib/chart-colors';\nimport { bucketPlan, intervalHours } from '../../../metrics/lib/metrics-buckets';\nimport { PendingChartCard } from '../../components/widget-chrome';\nimport { ExpandAction } from '../../components/widget-controls';\nimport { viewTitle } from '../../hooks/use-widget-views';\nimport { alertAction, pendingHeading, withAction } from '../../lib/alert-actions';\nimport type { ViewHeading } from '../../lib/chrome';\nimport { FORMATTERS } from '../../lib/format';\nimport type { DashboardPageContext, DashboardResult } from '../../lib/requests';\nimport { scorersOf, shapeScores } from '../../lib/scores';\nimport type { ResolvedView, WidgetKindProps } from '../../widget-kind';\nimport type { ScoresOptions } from './options';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\nimport { MetricsLineChart } from '@/ds/components/MetricsLineChart';\n\n/** Scores aren't problems, so no warm hues; past five scorers the colors repeat. */\nconst SCORER_COLORS = [\n CHART_COLORS.green,\n CHART_COLORS.sky,\n CHART_COLORS.violet,\n CHART_COLORS.teal,\n CHART_COLORS.indigo,\n];\n\nexport function ScoresWidget({\n widget,\n views,\n gate,\n discovered,\n results,\n onRetry,\n expand,\n dragHandle,\n onTitleChange,\n actions,\n alert,\n}: WidgetKindProps<ScoresOptions>) {\n const [view] = views;\n // Scores show their first view only, so the title is plain; with somewhere to expand to, an action links there.\n const title = viewTitle(widget, [view], 0, () => {}, expand);\n const expandHref = expand?.href(widget);\n const heading = withAction(\n { ...title, dragHandle, onTitleChange, actions },\n expand && expandHref && <ExpandAction title={title.title} href={expandHref} LinkComponent={expand.LinkComponent} />,\n );\n // The card, and the host's actions, stay while the view waits, so e.g. a pinned widget can still be unpinned.\n if (gate.status === 'pending')\n return <PendingChartCard gate={gate.gate} heading={pendingHeading(heading, gate.gate, alert, widget, view)} />;\n return (\n <ScoresView\n heading={withAction(\n heading,\n // The scorers' means over the range: what the card's lines average to.\n alertAction(alert, widget, view, {\n page: gate.page,\n values: [\n { label: view.label?.trim() || widget.title?.trim() || 'Scores', value: { query: view.options.average } },\n ],\n }),\n )}\n view={view}\n page={gate.page}\n discovered={discovered}\n results={results}\n onRetry={onRetry}\n />\n );\n}\n\nfunction ScoresView({\n heading,\n view,\n page,\n discovered,\n results,\n onRetry,\n}: {\n heading: ViewHeading;\n view: ResolvedView<ScoresOptions>;\n page: DashboardPageContext;\n discovered: (DashboardResult | undefined)[];\n results: (DashboardResult | undefined)[];\n onRetry: () => void;\n}) {\n const { options } = view;\n const { interval } = bucketPlan(page.window.start, page.window.end);\n const stepHours = intervalHours(interval);\n const scorers = scorersOf(view.queries, discovered[0]?.data);\n // One answer per scorer in each list, in `scorers`' order.\n const means = results.slice(0, scorers.length);\n const points = results.slice(scorers.length, scorers.length * 2);\n\n const all = [...discovered, ...results].filter(r => r !== undefined);\n const failed = all.filter(r => r.isError);\n if (failed.length > 0) {\n return (\n <ChartCard {...heading}>\n <ChartCardError error={failed[0]?.error} onRetry={onRetry} />\n </ChartCard>\n );\n }\n\n const isLoading = all.some(r => r.isLoading);\n const { buckets, lines } = shapeScores(\n isLoading ? [] : scorers,\n means.map(r => r?.data),\n points.map(r => r?.data),\n page.window,\n stepHours,\n );\n const series: MetricsLineChartSeries[] = lines.map(({ scorerId, name }, i) => ({\n dataKey: scorerId,\n label: name,\n color: SCORER_COLORS[i % SCORER_COLORS.length] ?? CHART_COLORS.neutral,\n }));\n\n return (\n <ChartCard {...heading} isUpdating={all.some(r => r.isRefetching)}>\n <ChartArea isEmpty={!isLoading && lines.length === 0}>\n <MetricsLineChart\n lineStyle=\"thin\"\n data={isLoading ? [] : buckets}\n series={series}\n height=\"fill\"\n yDomain={[0, 1]}\n valueFormatter={FORMATTERS.score.value}\n axisFormatter={FORMATTERS.score.axis}\n isLoading={isLoading}\n {...BUCKET_AXIS}\n />\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoBA,IAAM,gBAAgB;CACpB,aAAa;CACb,aAAa;CACb,aAAa;CACb,aAAa;CACb,aAAa;AACf;AAEA,SAAgB,aAAa,EAC3B,QACA,OACA,MACA,YACA,SACA,SACA,QACA,YACA,eACA,SACA,SACiC;CACjC,MAAM,CAAC,QAAQ;CAEf,MAAM,QAAQ,UAAU,QAAQ,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM;CAC3D,MAAM,aAAa,QAAQ,KAAK,MAAM;CACtC,MAAM,UAAU,WACd;EAAE,GAAG;EAAO;EAAY;EAAe;CAAQ,GAC/C,UAAU,cAAc,oBAAC,cAAD;EAAc,OAAO,MAAM;EAAO,MAAM;EAAY,eAAe,OAAO;CAAgB,CAAA,CACpH;CAEA,IAAI,KAAK,WAAW,WAClB,OAAO,oBAAC,kBAAD;EAAkB,MAAM,KAAK;EAAM,SAAS,eAAe,SAAS,KAAK,MAAM,OAAO,QAAQ,IAAI;CAAI,CAAA;CAC/G,OACE,oBAAC,YAAD;EACE,SAAS,WACP,SAEA,YAAY,OAAO,QAAQ,MAAM;GAC/B,MAAM,KAAK;GACX,QAAQ,CACN;IAAE,OAAO,KAAK,OAAO,KAAK,KAAK,OAAO,O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AAC,aAAa,MAAM,WAAW;GACjD,UAAA,oBAAC,kBAAD;IACE,WAAU;IACV,MAAM,YAAY,CAAC,IAAI;IACf;IACR,QAAO;IACP,SAAS,CAAC,GAAG,CAAC;IACd,gBAAgB,WAAW,MAAM;IACjC,eAAe,WAAW,MAAM;IACrB;IACX,GAAI;GACL,CAAA;EACQ,CAAA;CACF,CAAA;AAEf"}
|
|
@@ -6,7 +6,6 @@ const require_domains_dashboards_lib_table = require("../../lib/table.cjs.js");
|
|
|
6
6
|
const require_domains_dashboards_kinds_table_table_frame = require("./table-frame.cjs.js");
|
|
7
7
|
const require_domains_dashboards_kinds_table_table_plan = require("./table-plan.cjs.js");
|
|
8
8
|
const require_domains_dashboards_kinds_table_table_view = require("./table-view.cjs.js");
|
|
9
|
-
const require_domains_dashboards_kinds_table_table_view_tabs = require("./table-view-tabs.cjs.js");
|
|
10
9
|
const require_MetricsCard = require("../../../../MetricsCard-CVft2Kgg.cjs");
|
|
11
10
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
11
|
// src/domains/dashboards/kinds/table/table-tabs.tsx
|
|
@@ -35,18 +34,8 @@ function TableTabs({ page, blocked, ...props }) {
|
|
|
35
34
|
value: c.options.value
|
|
36
35
|
}))
|
|
37
36
|
});
|
|
38
|
-
const viewTabs = views.length > 1 && {
|
|
39
|
-
title: props.widget.title ?? "",
|
|
40
|
-
titleMenu: void 0,
|
|
41
|
-
toolbar: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_domains_dashboards_kinds_table_table_view_tabs.TableViewTabs, {
|
|
42
|
-
views,
|
|
43
|
-
index,
|
|
44
|
-
onChoose: choose
|
|
45
|
-
})
|
|
46
|
-
};
|
|
47
37
|
const heading = require_domains_dashboards_lib_alert_actions.withAction({
|
|
48
38
|
...menu.heading,
|
|
49
|
-
...viewTabs,
|
|
50
39
|
dragHandle: props.dragHandle,
|
|
51
40
|
onTitleChange: props.onTitleChange,
|
|
52
41
|
actions: props.actions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-tabs.cjs.js","names":["viewMenu","openTab","alertAction","parseColumns","isValueColumn","
|
|
1
|
+
{"version":3,"file":"table-tabs.cjs.js","names":["viewMenu","openTab","alertAction","parseColumns","isValueColumn","withAction","TableFrame","MetricsCard","unsupportedMessage","TableView"],"sources":["../../../../../src/domains/dashboards/kinds/table/table-tabs.tsx"],"sourcesContent":["import { viewMenu } from '../../hooks/use-widget-views';\nimport { alertAction, withAction } from '../../lib/alert-actions';\nimport { unsupportedMessage } from '../../lib/chrome';\nimport type { BlockedFields } from '../../lib/gate';\nimport type { DashboardPageContext } from '../../lib/requests';\nimport { isValueColumn, parseColumns } from '../../lib/table';\nimport type { TableOptions } from '../../lib/table';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { TableFrame } from './table-frame';\nimport { openTab } from './table-plan';\nimport { TableView } from './table-view';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\n\ntype Props = WidgetKindProps<TableOptions>;\n\n/** Filters an aggregate can't apply, named as the filter bar names them. */\nconst FILTER_NAMES: Record<string, string> = {\n serviceName: 'service',\n requestId: 'request ID',\n experimentId: 'experiment',\n tags: 'tags',\n provider: 'provider',\n model: 'model',\n};\n\nexport function TableTabs({ page, blocked, ...props }: Props & { page: DashboardPageContext; blocked: BlockedFields }) {\n const { views, state, discovered, onStateChange } = props;\n // Picking a tab starts it on its own default sort.\n const choose = (i: number) => onStateChange({ view: i });\n const menu = viewMenu(props.widget, views, openTab(views, blocked, state, discovered), choose);\n const { view, index } = menu;\n const unsupported = blocked(view.queries);\n const alert = alertAction(\n props.alert,\n props.widget,\n view,\n unsupported\n ? { blocked: unsupported, names: FILTER_NAMES }\n : {\n page,\n values: parseColumns(view.columns)\n .columns.filter(isValueColumn)\n .map(c => ({ label: c.label, value: c.options.value })),\n },\n );\n const heading = withAction(\n {\n ...menu.heading,\n dragHandle: props.dragHandle,\n onTitleChange: props.onTitleChange,\n actions: props.actions,\n },\n alert,\n );\n\n if (unsupported) {\n return (\n <TableFrame heading={heading}>\n <MetricsCard.NoData message={unsupportedMessage(unsupported, FILTER_NAMES)} />\n </TableFrame>\n );\n }\n // Unkeyed: picking a tab clears `sort` and `compared` in the widget state. Local state added to\n // `TableView` would carry over to the next tab instead, so key it on `index` if that happens.\n return <TableView {...props} index={index} view={view} heading={heading} page={page} />;\n}\n"],"mappings":";;;;;;;;;;;;AAgBA,IAAM,eAAuC;CAC3C,aAAa;CACb,WAAW;CACX,cAAc;CACd,MAAM;CACN,UAAU;CACV,OAAO;AACT;AAEA,SAAgB,UAAU,EAAE,MAAM,SAAS,GAAG,SAAyE;CACrH,MAAM,EAAE,OAAO,OAAO,YAAY,kBAAkB;CAEpD,MAAM,UAAU,MAAc,cAAc,EAAE,MAAM,EAAE,CAAC;CACvD,MAAM,OAAOA,kDAAAA,SAAS,MAAM,QAAQ,OAAOC,kDAAAA,QAAQ,OAAO,SAAS,OAAO,UAAU,GAAG,MAAM;CAC7F,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,cAAc,QAAQ,KAAK,OAAO;CACxC,MAAM,QAAQC,6CAAAA,YACZ,MAAM,OACN,MAAM,QACN,MACA,cACI;EAAE,SAAS;EAAa,OAAO;CAAa,IAC5C;EACE;EACA,QAAQC,qCAAAA,aAAa,KAAK,OAAO,CAAC,CAC/B,QAAQ,OAAOC,qCAAAA,aAAa,CAAC,CAC7B,KAAI,OAAM;GAAE,OAAO,EAAE;GAAO,OAAO,EAAE,QAAQ;EAAM,EAAE;CAC1D,CACN;CACA,MAAM,UAAUC,6CAAAA,WACd;EACE,GAAG,KAAK;EACR,YAAY,MAAM;EAClB,eAAe,MAAM;EACrB,SAAS,MAAM;CACjB,GACA,KACF;CAEA,IAAI,aACF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,mDAAAA,YAAD;EAAqB;EACnB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,oBAAAA,YAAY,QAAb,EAAoB,SAASC,sCAAAA,mBAAmB,aAAa,YAAY,EAAI,CAAA;CACnE,CAAA;CAKhB,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,kDAAAA,WAAD;EAAW,GAAI;EAAc;EAAa;EAAe;EAAe;CAAO,CAAA;AACxF"}
|
|
@@ -5,7 +5,6 @@ import { isValueColumn, parseColumns } from "../../lib/table.es.js";
|
|
|
5
5
|
import { TableFrame } from "./table-frame.es.js";
|
|
6
6
|
import { openTab } from "./table-plan.es.js";
|
|
7
7
|
import { TableView } from "./table-view.es.js";
|
|
8
|
-
import { TableViewTabs } from "./table-view-tabs.es.js";
|
|
9
8
|
import { n as MetricsCard } from "../../../../MetricsCard-Iav_wvjB.js";
|
|
10
9
|
import { jsx } from "react/jsx-runtime";
|
|
11
10
|
// src/domains/dashboards/kinds/table/table-tabs.tsx
|
|
@@ -34,18 +33,8 @@ function TableTabs({ page, blocked, ...props }) {
|
|
|
34
33
|
value: c.options.value
|
|
35
34
|
}))
|
|
36
35
|
});
|
|
37
|
-
const viewTabs = views.length > 1 && {
|
|
38
|
-
title: props.widget.title ?? "",
|
|
39
|
-
titleMenu: void 0,
|
|
40
|
-
toolbar: /* @__PURE__ */ jsx(TableViewTabs, {
|
|
41
|
-
views,
|
|
42
|
-
index,
|
|
43
|
-
onChoose: choose
|
|
44
|
-
})
|
|
45
|
-
};
|
|
46
36
|
const heading = withAction({
|
|
47
37
|
...menu.heading,
|
|
48
|
-
...viewTabs,
|
|
49
38
|
dragHandle: props.dragHandle,
|
|
50
39
|
onTitleChange: props.onTitleChange,
|
|
51
40
|
actions: props.actions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-tabs.es.js","names":[],"sources":["../../../../../src/domains/dashboards/kinds/table/table-tabs.tsx"],"sourcesContent":["import { viewMenu } from '../../hooks/use-widget-views';\nimport { alertAction, withAction } from '../../lib/alert-actions';\nimport { unsupportedMessage } from '../../lib/chrome';\nimport type { BlockedFields } from '../../lib/gate';\nimport type { DashboardPageContext } from '../../lib/requests';\nimport { isValueColumn, parseColumns } from '../../lib/table';\nimport type { TableOptions } from '../../lib/table';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { TableFrame } from './table-frame';\nimport { openTab } from './table-plan';\nimport { TableView } from './table-view';\nimport {
|
|
1
|
+
{"version":3,"file":"table-tabs.es.js","names":[],"sources":["../../../../../src/domains/dashboards/kinds/table/table-tabs.tsx"],"sourcesContent":["import { viewMenu } from '../../hooks/use-widget-views';\nimport { alertAction, withAction } from '../../lib/alert-actions';\nimport { unsupportedMessage } from '../../lib/chrome';\nimport type { BlockedFields } from '../../lib/gate';\nimport type { DashboardPageContext } from '../../lib/requests';\nimport { isValueColumn, parseColumns } from '../../lib/table';\nimport type { TableOptions } from '../../lib/table';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { TableFrame } from './table-frame';\nimport { openTab } from './table-plan';\nimport { TableView } from './table-view';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\n\ntype Props = WidgetKindProps<TableOptions>;\n\n/** Filters an aggregate can't apply, named as the filter bar names them. */\nconst FILTER_NAMES: Record<string, string> = {\n serviceName: 'service',\n requestId: 'request ID',\n experimentId: 'experiment',\n tags: 'tags',\n provider: 'provider',\n model: 'model',\n};\n\nexport function TableTabs({ page, blocked, ...props }: Props & { page: DashboardPageContext; blocked: BlockedFields }) {\n const { views, state, discovered, onStateChange } = props;\n // Picking a tab starts it on its own default sort.\n const choose = (i: number) => onStateChange({ view: i });\n const menu = viewMenu(props.widget, views, openTab(views, blocked, state, discovered), choose);\n const { view, index } = menu;\n const unsupported = blocked(view.queries);\n const alert = alertAction(\n props.alert,\n props.widget,\n view,\n unsupported\n ? { blocked: unsupported, names: FILTER_NAMES }\n : {\n page,\n values: parseColumns(view.columns)\n .columns.filter(isValueColumn)\n .map(c => ({ label: c.label, value: c.options.value })),\n },\n );\n const heading = withAction(\n {\n ...menu.heading,\n dragHandle: props.dragHandle,\n onTitleChange: props.onTitleChange,\n actions: props.actions,\n },\n alert,\n );\n\n if (unsupported) {\n return (\n <TableFrame heading={heading}>\n <MetricsCard.NoData message={unsupportedMessage(unsupported, FILTER_NAMES)} />\n </TableFrame>\n );\n }\n // Unkeyed: picking a tab clears `sort` and `compared` in the widget state. Local state added to\n // `TableView` would carry over to the next tab instead, so key it on `index` if that happens.\n return <TableView {...props} index={index} view={view} heading={heading} page={page} />;\n}\n"],"mappings":";;;;;;;;;;;AAgBA,IAAM,eAAuC;CAC3C,aAAa;CACb,WAAW;CACX,cAAc;CACd,MAAM;CACN,UAAU;CACV,OAAO;AACT;AAEA,SAAgB,UAAU,EAAE,MAAM,SAAS,GAAG,SAAyE;CACrH,MAAM,EAAE,OAAO,OAAO,YAAY,kBAAkB;CAEpD,MAAM,UAAU,MAAc,cAAc,EAAE,MAAM,EAAE,CAAC;CACvD,MAAM,OAAO,SAAS,MAAM,QAAQ,OAAO,QAAQ,OAAO,SAAS,OAAO,UAAU,GAAG,MAAM;CAC7F,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,cAAc,QAAQ,KAAK,OAAO;CACxC,MAAM,QAAQ,YACZ,MAAM,OACN,MAAM,QACN,MACA,cACI;EAAE,SAAS;EAAa,OAAO;CAAa,IAC5C;EACE;EACA,QAAQ,aAAa,KAAK,OAAO,CAAC,CAC/B,QAAQ,OAAO,aAAa,CAAC,CAC7B,KAAI,OAAM;GAAE,OAAO,EAAE;GAAO,OAAO,EAAE,QAAQ;EAAM,EAAE;CAC1D,CACN;CACA,MAAM,UAAU,WACd;EACE,GAAG,KAAK;EACR,YAAY,MAAM;EAClB,eAAe,MAAM;EACrB,SAAS,MAAM;CACjB,GACA,KACF;CAEA,IAAI,aACF,OACE,oBAAC,YAAD;EAAqB;EACnB,UAAA,oBAAC,YAAY,QAAb,EAAoB,SAAS,mBAAmB,aAAa,YAAY,EAAI,CAAA;CACnE,CAAA;CAKhB,OAAO,oBAAC,WAAD;EAAW,GAAI;EAAc;EAAa;EAAe;EAAe;CAAO,CAAA;AACxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-widget.cjs.js","names":["ChartCard","MetricsCard","TableTabs"],"sources":["../../../../../src/domains/dashboards/kinds/table/table-widget.tsx"],"sourcesContent":["import { ChartCard } from '../../../metrics/components/chart-card';\nimport type { TableOptions } from '../../lib/table';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { TableTabs } from './table-tabs';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\n\n/**\n * Groups as a sortable table, one view per tab. It waits on the aggregate gates every tab needs, so tabs\n * don't come and go; a tab whose gate can't apply the page's filters says so.\n */\nexport function TableWidget(props: WidgetKindProps<TableOptions>) {\n const { gate } = props;\n if (gate.status === 'pending') {\n return (\n <ChartCard\n title={props.widget.title ?? ''}\n dragHandle={props.dragHandle}\n // Renameable while loading too
|
|
1
|
+
{"version":3,"file":"table-widget.cjs.js","names":["ChartCard","MetricsCard","TableTabs"],"sources":["../../../../../src/domains/dashboards/kinds/table/table-widget.tsx"],"sourcesContent":["import { ChartCard } from '../../../metrics/components/chart-card';\nimport type { TableOptions } from '../../lib/table';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { TableTabs } from './table-tabs';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\n\n/**\n * Groups as a sortable table, one view per tab. It waits on the aggregate gates every tab needs, so tabs\n * don't come and go; a tab whose gate can't apply the page's filters says so.\n */\nexport function TableWidget(props: WidgetKindProps<TableOptions>) {\n const { gate } = props;\n if (gate.status === 'pending') {\n return (\n <ChartCard\n title={props.widget.title ?? ''}\n dragHandle={props.dragHandle}\n // Renameable while loading too, like the loaded card.\n onTitleChange={props.onTitleChange}\n actions={props.actions}\n bodyHeight=\"fit\"\n >\n <MetricsCard.Loading />\n </ChartCard>\n );\n }\n return <TableTabs {...props} page={gate.page} blocked={gate.blocked} />;\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAgB,YAAY,OAAsC;CAChE,MAAM,EAAE,SAAS;CACjB,IAAI,KAAK,WAAW,WAClB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,8CAAAA,WAAD;EACE,OAAO,MAAM,OAAO,SAAS;EAC7B,YAAY,MAAM;EAElB,eAAe,MAAM;EACrB,SAAS,MAAM;EACf,YAAW;EAEX,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,oBAAAA,YAAY,SAAb,CAAsB,CAAA;CACb,CAAA;CAGf,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAACC,kDAAAA,WAAD;EAAW,GAAI;EAAO,MAAM,KAAK;EAAM,SAAS,KAAK;CAAU,CAAA;AACxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-widget.es.js","names":[],"sources":["../../../../../src/domains/dashboards/kinds/table/table-widget.tsx"],"sourcesContent":["import { ChartCard } from '../../../metrics/components/chart-card';\nimport type { TableOptions } from '../../lib/table';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { TableTabs } from './table-tabs';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\n\n/**\n * Groups as a sortable table, one view per tab. It waits on the aggregate gates every tab needs, so tabs\n * don't come and go; a tab whose gate can't apply the page's filters says so.\n */\nexport function TableWidget(props: WidgetKindProps<TableOptions>) {\n const { gate } = props;\n if (gate.status === 'pending') {\n return (\n <ChartCard\n title={props.widget.title ?? ''}\n dragHandle={props.dragHandle}\n // Renameable while loading too
|
|
1
|
+
{"version":3,"file":"table-widget.es.js","names":[],"sources":["../../../../../src/domains/dashboards/kinds/table/table-widget.tsx"],"sourcesContent":["import { ChartCard } from '../../../metrics/components/chart-card';\nimport type { TableOptions } from '../../lib/table';\nimport type { WidgetKindProps } from '../../widget-kind';\nimport { TableTabs } from './table-tabs';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\n\n/**\n * Groups as a sortable table, one view per tab. It waits on the aggregate gates every tab needs, so tabs\n * don't come and go; a tab whose gate can't apply the page's filters says so.\n */\nexport function TableWidget(props: WidgetKindProps<TableOptions>) {\n const { gate } = props;\n if (gate.status === 'pending') {\n return (\n <ChartCard\n title={props.widget.title ?? ''}\n dragHandle={props.dragHandle}\n // Renameable while loading too, like the loaded card.\n onTitleChange={props.onTitleChange}\n actions={props.actions}\n bodyHeight=\"fit\"\n >\n <MetricsCard.Loading />\n </ChartCard>\n );\n }\n return <TableTabs {...props} page={gate.page} blocked={gate.blocked} />;\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,YAAY,OAAsC;CAChE,MAAM,EAAE,SAAS;CACjB,IAAI,KAAK,WAAW,WAClB,OACE,oBAAC,WAAD;EACE,OAAO,MAAM,OAAO,SAAS;EAC7B,YAAY,MAAM;EAElB,eAAe,MAAM;EACrB,SAAS,MAAM;EACf,YAAW;EAEX,UAAA,oBAAC,YAAY,SAAb,CAAsB,CAAA;CACb,CAAA;CAGf,OAAO,oBAAC,WAAD;EAAW,GAAI;EAAO,MAAM,KAAK;EAAM,SAAS,KAAK;CAAU,CAAA;AACxE"}
|
|
@@ -85,7 +85,7 @@ function TimeseriesView({ widget, view, heading: own, page, onDrilldown, alert,
|
|
|
85
85
|
}), heading.actions] }) : heading.actions,
|
|
86
86
|
total: !withRangeTotals || failed.length ? void 0 : rangeTotals.length ? rangeTotals : format.value(0),
|
|
87
87
|
isLoading,
|
|
88
|
-
toolbar: lines.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
88
|
+
toolbar: (heading.toolbar || lines.length > 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_MetricsCard.MetricsCard.Toolbar, { children: [heading.toolbar, lines.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MetricsLineChart.MetricsLineChartLegend, { series: lines })] })
|
|
89
89
|
};
|
|
90
90
|
if (failed.length) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_domains_metrics_components_chart_card.ChartCard, {
|
|
91
91
|
...layout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeseries-widget.cjs.js","names":["viewMenu","withAction","ExpandAction","PendingChartCard","pendingHeading","alertAction","timeseriesAlertValues","useDrilldown","shapeTimeseries","answersById","FORMATTERS","chartColor","hasDrilldownAction","_Fragment","DrilldownAction","MetricsCard","MetricsLineChartLegend","ChartCard","ChartCardError","bucketWindow","EDGE_BUCKET_AXIS","BUCKET_AXIS","ChartArea","MetricsStackedBarChart","MetricsLineChart"],"sources":["../../../../../src/domains/dashboards/kinds/timeseries/timeseries-widget.tsx"],"sourcesContent":["import { ChartArea } from '../../../metrics/components/chart-area';\nimport { ChartCard } from '../../../metrics/components/chart-card';\nimport { ChartCardError } from '../../../metrics/components/chart-card-error';\nimport { BUCKET_AXIS, EDGE_BUCKET_AXIS } from '../../../metrics/lib/chart-axis';\nimport { bucketWindow } from '../../../metrics/lib/metrics-buckets';\nimport { PendingChartCard } from '../../components/widget-chrome';\nimport { DrilldownAction, ExpandAction } from '../../components/widget-controls';\nimport { hasDrilldownAction, useDrilldown, viewMenu } from '../../hooks/use-widget-views';\nimport { alertAction, pendingHeading, withAction } from '../../lib/alert-actions';\nimport type { ViewHeading } from '../../lib/chrome';\nimport { chartColor, FORMATTERS } from '../../lib/format';\nimport type { DashboardPageContext } from '../../lib/requests';\nimport { shapeTimeseries, timeseriesAlertValues } from '../../lib/timeseries';\nimport type { TimeseriesOptions } from '../../lib/timeseries';\nimport { answersById } from '../../lib/values';\nimport type { ResolvedView, WidgetKindProps } from '../../widget-kind';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\nimport { MetricsLineChart, MetricsLineChartLegend } from '@/ds/components/MetricsLineChart';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\nimport { MetricsStackedBarChart } from '@/ds/components/MetricsStackedBarChart';\n\ntype Props = WidgetKindProps<TimeseriesOptions>;\ntype ViewProps = Props & {\n view: ResolvedView<TimeseriesOptions>;\n heading: ViewHeading;\n page: DashboardPageContext;\n};\n\nexport function TimeseriesWidget(props: Props) {\n const { gate, state, onStateChange } = props;\n const menu = viewMenu(\n props.widget,\n props.views,\n state.view ?? 0,\n i => onStateChange({ ...state, view: i }),\n props.expand,\n );\n const { view } = menu;\n const { expand } = props;\n const expandHref = expand?.href(props.widget);\n const heading = withAction(\n {\n ...menu.heading,\n dragHandle: props.dragHandle,\n onTitleChange: props.onTitleChange,\n actions: props.actions,\n },\n expand && expandHref && (\n <ExpandAction title={menu.heading.title} href={expandHref} LinkComponent={expand.LinkComponent} />\n ),\n );\n if (gate.status === 'pending')\n return (\n <PendingChartCard\n gate={gate.gate}\n heading={pendingHeading(heading, gate.gate, props.alert, props.widget, view)}\n />\n );\n return <TimeseriesView {...props} view={view} heading={heading} page={gate.page} />;\n}\n\nfunction TimeseriesView({ widget, view, heading: own, page, onDrilldown, alert, results, onRetry }: ViewProps) {\n // Drilldown, then the alert, then the expand link and the host's actions.\n const heading = withAction(\n own,\n alertAction(alert, widget, view, { page, values: timeseriesAlertValues(view.options) }),\n );\n const { options } = view;\n const sent = results.filter(r => r !== undefined);\n const hasTraceQueries = view.queries.some(q => q.source === 'traceAggregate' || q.source === 'spanAggregate');\n const onClick = useDrilldown(widget, view, onDrilldown);\n\n const isLoading = sent.some(r => r.isLoading);\n const shaped = shapeTimeseries({\n options,\n responses: answersById(\n view.queries,\n results.map(r => r?.data),\n ),\n window: page.window,\n hasTraceQueries,\n });\n const format = FORMATTERS[options.format];\n const lines: MetricsLineChartSeries[] = shaped.series.map(s => ({\n dataKey: s.dataKey,\n label: s.label,\n color: chartColor(s.color),\n emphasis: s.emphasis,\n }));\n // Series with a range total each show theirs, marked like their line: they count different things.\n const rangeTotals = shaped.series.flatMap(s =>\n s.rangeTotal === undefined\n ? []\n : [{ label: s.label, value: format.value(s.rangeTotal), color: chartColor(s.color) }],\n );\n const withRangeTotals = options.series.some(s => s.rangeTotal !== undefined);\n const failed = sent.filter(r => r.isError);\n\n const layout = {\n ...heading,\n actions: hasDrilldownAction(widget, view, onDrilldown) ? (\n <>\n <DrilldownAction widget={widget} view={view} onDrilldown={onDrilldown} />\n {heading.actions}\n </>\n ) : (\n heading.actions\n ),\n // Range totals per series; with no series in the range, one plain 0. None while a request\n // failed, so no total sits beside the error.\n total: !withRangeTotals || failed.length ? undefined : rangeTotals.length ? rangeTotals : format.value(0),\n isLoading,\n toolbar: lines.length > 0 && (\n <MetricsCard.Toolbar>\n <MetricsLineChartLegend series={lines} />\n </MetricsCard.Toolbar>\n ),\n };\n\n if (failed.length) {\n return (\n <ChartCard {...layout}>\n {hasTraceQueries ? <ChartCardError error={failed[0]?.error} onRetry={onRetry} /> : <ChartCardError />}\n </ChartCard>\n );\n }\n\n const totalFormat = FORMATTERS[options.total?.format ?? options.format];\n // An empty range totals 0, a peak included, like the cards around it.\n const total = options.total && totalFormat.value(shaped.total ?? 0);\n\n const chart = {\n data: shaped.data,\n series: lines,\n height: 'fill' as const,\n xLabels: options.xLabels,\n showLegend: false,\n valueFormatter: format.value,\n axisFormatter: options.axis === false ? undefined : format.axis,\n onBucketClick:\n onClick &&\n ((row: Record<string, unknown>) => onClick({ window: bucketWindow(Number(row.ts), shaped.stepHours) })),\n isLoading,\n ...(options.xLabels ? EDGE_BUCKET_AXIS : BUCKET_AXIS),\n };\n const yDomain = shaped.flat && options.flatYDomain ? options.flatYDomain : options.yDomain;\n\n return (\n <ChartCard {...layout} total={layout.total ?? total} isUpdating={sent.some(r => r.isRefetching)}>\n <ChartArea isEmpty={!isLoading && shaped.empty}>\n {options.chart === 'stackedBar' ? (\n <MetricsStackedBarChart {...chart} />\n ) : (\n <MetricsLineChart {...chart} yDomain={yDomain} lineStyle=\"thin\" />\n )}\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,SAAgB,iBAAiB,OAAc;CAC7C,MAAM,EAAE,MAAM,OAAO,kBAAkB;CACvC,MAAM,OAAOA,kDAAAA,SACX,MAAM,QACN,MAAM,OACN,MAAM,QAAQ,IACd,MAAK,cAAc;EAAE,GAAG;EAAO,MAAM;CAAE,CAAC,GACxC,MAAM,MACR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riesAlertValues","useDrilldown","shapeTimeseries","answersById","FORMATTERS","chartColor","hasDrilldownAction","_Fragment","DrilldownAction","MetricsCard","MetricsLineChartLegend","ChartCard","ChartCardError","bucketWindow","EDGE_BUCKET_AXIS","BUCKET_AXIS","ChartArea","MetricsStackedBarChart","MetricsLineChart"],"sources":["../../../../../src/domains/dashboards/kinds/timeseries/timeseries-widget.tsx"],"sourcesContent":["import { ChartArea } from '../../../metrics/components/chart-area';\nimport { ChartCard } from '../../../metrics/components/chart-card';\nimport { ChartCardError } from '../../../metrics/components/chart-card-error';\nimport { BUCKET_AXIS, EDGE_BUCKET_AXIS } from '../../../metrics/lib/chart-axis';\nimport { bucketWindow } from '../../../metrics/lib/metrics-buckets';\nimport { PendingChartCard } from '../../components/widget-chrome';\nimport { DrilldownAction, ExpandAction } from '../../components/widget-controls';\nimport { hasDrilldownAction, useDrilldown, viewMenu } from '../../hooks/use-widget-views';\nimport { alertAction, pendingHeading, withAction } from '../../lib/alert-actions';\nimport type { ViewHeading } from '../../lib/chrome';\nimport { chartColor, FORMATTERS } from '../../lib/format';\nimport type { DashboardPageContext } from '../../lib/requests';\nimport { shapeTimeseries, timeseriesAlertValues } from '../../lib/timeseries';\nimport type { TimeseriesOptions } from '../../lib/timeseries';\nimport { answersById } from '../../lib/values';\nimport type { ResolvedView, WidgetKindProps } from '../../widget-kind';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\nimport { MetricsLineChart, MetricsLineChartLegend } from '@/ds/components/MetricsLineChart';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\nimport { MetricsStackedBarChart } from '@/ds/components/MetricsStackedBarChart';\n\ntype Props = WidgetKindProps<TimeseriesOptions>;\ntype ViewProps = Props & {\n view: ResolvedView<TimeseriesOptions>;\n heading: ViewHeading;\n page: DashboardPageContext;\n};\n\nexport function TimeseriesWidget(props: Props) {\n const { gate, state, onStateChange } = props;\n const menu = viewMenu(\n props.widget,\n props.views,\n state.view ?? 0,\n i => onStateChange({ ...state, view: i }),\n props.expand,\n );\n const { view } = menu;\n const { expand } = props;\n const expandHref = expand?.href(props.widget);\n const heading = withAction(\n {\n ...menu.heading,\n dragHandle: props.dragHandle,\n onTitleChange: props.onTitleChange,\n actions: props.actions,\n },\n expand && expandHref && (\n <ExpandAction title={menu.heading.title} href={expandHref} LinkComponent={expand.LinkComponent} />\n ),\n );\n if (gate.status === 'pending')\n return (\n <PendingChartCard\n gate={gate.gate}\n heading={pendingHeading(heading, gate.gate, props.alert, props.widget, view)}\n />\n );\n return <TimeseriesView {...props} view={view} heading={heading} page={gate.page} />;\n}\n\nfunction TimeseriesView({ widget, view, heading: own, page, onDrilldown, alert, results, onRetry }: ViewProps) {\n // Drilldown, then the alert, then the expand link and the host's actions.\n const heading = withAction(\n own,\n alertAction(alert, widget, view, { page, values: timeseriesAlertValues(view.options) }),\n );\n const { options } = view;\n const sent = results.filter(r => r !== undefined);\n const hasTraceQueries = view.queries.some(q => q.source === 'traceAggregate' || q.source === 'spanAggregate');\n const onClick = useDrilldown(widget, view, onDrilldown);\n\n const isLoading = sent.some(r => r.isLoading);\n const shaped = shapeTimeseries({\n options,\n responses: answersById(\n view.queries,\n results.map(r => r?.data),\n ),\n window: page.window,\n hasTraceQueries,\n });\n const format = FORMATTERS[options.format];\n const lines: MetricsLineChartSeries[] = shaped.series.map(s => ({\n dataKey: s.dataKey,\n label: s.label,\n color: chartColor(s.color),\n emphasis: s.emphasis,\n }));\n // Series with a range total each show theirs, marked like their line: they count different things.\n const rangeTotals = shaped.series.flatMap(s =>\n s.rangeTotal === undefined\n ? []\n : [{ label: s.label, value: format.value(s.rangeTotal), color: chartColor(s.color) }],\n );\n const withRangeTotals = options.series.some(s => s.rangeTotal !== undefined);\n const failed = sent.filter(r => r.isError);\n\n const layout = {\n ...heading,\n actions: hasDrilldownAction(widget, view, onDrilldown) ? (\n <>\n <DrilldownAction widget={widget} view={view} onDrilldown={onDrilldown} />\n {heading.actions}\n </>\n ) : (\n heading.actions\n ),\n // Range totals per series; with no series in the range, one plain 0. None while a request\n // failed, so no total sits beside the error.\n total: !withRangeTotals || failed.length ? undefined : rangeTotals.length ? rangeTotals : format.value(0),\n isLoading,\n // The view tabs on the left, the legend on the right: one row, so the plot starts where its neighbours' do.\n toolbar: (heading.toolbar || lines.length > 0) && (\n <MetricsCard.Toolbar>\n {heading.toolbar}\n {lines.length > 0 && <MetricsLineChartLegend series={lines} />}\n </MetricsCard.Toolbar>\n ),\n };\n\n if (failed.length) {\n return (\n <ChartCard {...layout}>\n {hasTraceQueries ? <ChartCardError error={failed[0]?.error} onRetry={onRetry} /> : <ChartCardError />}\n </ChartCard>\n );\n }\n\n const totalFormat = FORMATTERS[options.total?.format ?? options.format];\n // An empty range totals 0, a peak included, like the cards around it.\n const total = options.total && totalFormat.value(shaped.total ?? 0);\n\n const chart = {\n data: shaped.data,\n series: lines,\n height: 'fill' as const,\n xLabels: options.xLabels,\n showLegend: false,\n valueFormatter: format.value,\n axisFormatter: options.axis === false ? undefined : format.axis,\n onBucketClick:\n onClick &&\n ((row: Record<string, unknown>) => onClick({ window: bucketWindow(Number(row.ts), shaped.stepHours) })),\n isLoading,\n ...(options.xLabels ? EDGE_BUCKET_AXIS : BUCKET_AXIS),\n };\n const yDomain = shaped.flat && options.flatYDomain ? options.flatYDomain : options.yDomain;\n\n return (\n <ChartCard {...layout} total={layout.total ?? total} isUpdating={sent.some(r => r.isRefetching)}>\n <ChartArea isEmpty={!isLoading && shaped.empty}>\n {options.chart === 'stackedBar' ? (\n <MetricsStackedBarChart {...chart} />\n ) : (\n <MetricsLineChart {...chart} yDomain={yDomain} lineStyle=\"thin\" />\n )}\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,SAAgB,iBAAiB,OAAc;CAC7C,MAAM,EAAE,MAAM,OAAO,kBAAkB;CACvC,MAAM,OAAOA,kDAAAA,SACX,MAAM,QACN,MAAM,OACN,MAAM,QAAQ,IACd,MAAK,cAA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;CACF,CAAA;AAEf"}
|
|
@@ -84,7 +84,7 @@ function TimeseriesView({ widget, view, heading: own, page, onDrilldown, alert,
|
|
|
84
84
|
}), heading.actions] }) : heading.actions,
|
|
85
85
|
total: !withRangeTotals || failed.length ? void 0 : rangeTotals.length ? rangeTotals : format.value(0),
|
|
86
86
|
isLoading,
|
|
87
|
-
toolbar: lines.length > 0 && /* @__PURE__ */
|
|
87
|
+
toolbar: (heading.toolbar || lines.length > 0) && /* @__PURE__ */ jsxs(MetricsCard.Toolbar, { children: [heading.toolbar, lines.length > 0 && /* @__PURE__ */ jsx(MetricsLineChartLegend, { series: lines })] })
|
|
88
88
|
};
|
|
89
89
|
if (failed.length) return /* @__PURE__ */ jsx(ChartCard, {
|
|
90
90
|
...layout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeseries-widget.es.js","names":["_Fragment"],"sources":["../../../../../src/domains/dashboards/kinds/timeseries/timeseries-widget.tsx"],"sourcesContent":["import { ChartArea } from '../../../metrics/components/chart-area';\nimport { ChartCard } from '../../../metrics/components/chart-card';\nimport { ChartCardError } from '../../../metrics/components/chart-card-error';\nimport { BUCKET_AXIS, EDGE_BUCKET_AXIS } from '../../../metrics/lib/chart-axis';\nimport { bucketWindow } from '../../../metrics/lib/metrics-buckets';\nimport { PendingChartCard } from '../../components/widget-chrome';\nimport { DrilldownAction, ExpandAction } from '../../components/widget-controls';\nimport { hasDrilldownAction, useDrilldown, viewMenu } from '../../hooks/use-widget-views';\nimport { alertAction, pendingHeading, withAction } from '../../lib/alert-actions';\nimport type { ViewHeading } from '../../lib/chrome';\nimport { chartColor, FORMATTERS } from '../../lib/format';\nimport type { DashboardPageContext } from '../../lib/requests';\nimport { shapeTimeseries, timeseriesAlertValues } from '../../lib/timeseries';\nimport type { TimeseriesOptions } from '../../lib/timeseries';\nimport { answersById } from '../../lib/values';\nimport type { ResolvedView, WidgetKindProps } from '../../widget-kind';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\nimport { MetricsLineChart, MetricsLineChartLegend } from '@/ds/components/MetricsLineChart';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\nimport { MetricsStackedBarChart } from '@/ds/components/MetricsStackedBarChart';\n\ntype Props = WidgetKindProps<TimeseriesOptions>;\ntype ViewProps = Props & {\n view: ResolvedView<TimeseriesOptions>;\n heading: ViewHeading;\n page: DashboardPageContext;\n};\n\nexport function TimeseriesWidget(props: Props) {\n const { gate, state, onStateChange } = props;\n const menu = viewMenu(\n props.widget,\n props.views,\n state.view ?? 0,\n i => onStateChange({ ...state, view: i }),\n props.expand,\n );\n const { view } = menu;\n const { expand } = props;\n const expandHref = expand?.href(props.widget);\n const heading = withAction(\n {\n ...menu.heading,\n dragHandle: props.dragHandle,\n onTitleChange: props.onTitleChange,\n actions: props.actions,\n },\n expand && expandHref && (\n <ExpandAction title={menu.heading.title} href={expandHref} LinkComponent={expand.LinkComponent} />\n ),\n );\n if (gate.status === 'pending')\n return (\n <PendingChartCard\n gate={gate.gate}\n heading={pendingHeading(heading, gate.gate, props.alert, props.widget, view)}\n />\n );\n return <TimeseriesView {...props} view={view} heading={heading} page={gate.page} />;\n}\n\nfunction TimeseriesView({ widget, view, heading: own, page, onDrilldown, alert, results, onRetry }: ViewProps) {\n // Drilldown, then the alert, then the expand link and the host's actions.\n const heading = withAction(\n own,\n alertAction(alert, widget, view, { page, values: timeseriesAlertValues(view.options) }),\n );\n const { options } = view;\n const sent = results.filter(r => r !== undefined);\n const hasTraceQueries = view.queries.some(q => q.source === 'traceAggregate' || q.source === 'spanAggregate');\n const onClick = useDrilldown(widget, view, onDrilldown);\n\n const isLoading = sent.some(r => r.isLoading);\n const shaped = shapeTimeseries({\n options,\n responses: answersById(\n view.queries,\n results.map(r => r?.data),\n ),\n window: page.window,\n hasTraceQueries,\n });\n const format = FORMATTERS[options.format];\n const lines: MetricsLineChartSeries[] = shaped.series.map(s => ({\n dataKey: s.dataKey,\n label: s.label,\n color: chartColor(s.color),\n emphasis: s.emphasis,\n }));\n // Series with a range total each show theirs, marked like their line: they count different things.\n const rangeTotals = shaped.series.flatMap(s =>\n s.rangeTotal === undefined\n ? []\n : [{ label: s.label, value: format.value(s.rangeTotal), color: chartColor(s.color) }],\n );\n const withRangeTotals = options.series.some(s => s.rangeTotal !== undefined);\n const failed = sent.filter(r => r.isError);\n\n const layout = {\n ...heading,\n actions: hasDrilldownAction(widget, view, onDrilldown) ? (\n <>\n <DrilldownAction widget={widget} view={view} onDrilldown={onDrilldown} />\n {heading.actions}\n </>\n ) : (\n heading.actions\n ),\n // Range totals per series; with no series in the range, one plain 0. None while a request\n // failed, so no total sits beside the error.\n total: !withRangeTotals || failed.length ? undefined : rangeTotals.length ? rangeTotals : format.value(0),\n isLoading,\n toolbar: lines.length > 0 && (\n <MetricsCard.Toolbar>\n <MetricsLineChartLegend series={lines}
|
|
1
|
+
{"version":3,"file":"timeseries-widget.es.js","names":["_Fragment"],"sources":["../../../../../src/domains/dashboards/kinds/timeseries/timeseries-widget.tsx"],"sourcesContent":["import { ChartArea } from '../../../metrics/components/chart-area';\nimport { ChartCard } from '../../../metrics/components/chart-card';\nimport { ChartCardError } from '../../../metrics/components/chart-card-error';\nimport { BUCKET_AXIS, EDGE_BUCKET_AXIS } from '../../../metrics/lib/chart-axis';\nimport { bucketWindow } from '../../../metrics/lib/metrics-buckets';\nimport { PendingChartCard } from '../../components/widget-chrome';\nimport { DrilldownAction, ExpandAction } from '../../components/widget-controls';\nimport { hasDrilldownAction, useDrilldown, viewMenu } from '../../hooks/use-widget-views';\nimport { alertAction, pendingHeading, withAction } from '../../lib/alert-actions';\nimport type { ViewHeading } from '../../lib/chrome';\nimport { chartColor, FORMATTERS } from '../../lib/format';\nimport type { DashboardPageContext } from '../../lib/requests';\nimport { shapeTimeseries, timeseriesAlertValues } from '../../lib/timeseries';\nimport type { TimeseriesOptions } from '../../lib/timeseries';\nimport { answersById } from '../../lib/values';\nimport type { ResolvedView, WidgetKindProps } from '../../widget-kind';\nimport { MetricsCard } from '@/ds/components/MetricsCard';\nimport { MetricsLineChart, MetricsLineChartLegend } from '@/ds/components/MetricsLineChart';\nimport type { MetricsLineChartSeries } from '@/ds/components/MetricsLineChart';\nimport { MetricsStackedBarChart } from '@/ds/components/MetricsStackedBarChart';\n\ntype Props = WidgetKindProps<TimeseriesOptions>;\ntype ViewProps = Props & {\n view: ResolvedView<TimeseriesOptions>;\n heading: ViewHeading;\n page: DashboardPageContext;\n};\n\nexport function TimeseriesWidget(props: Props) {\n const { gate, state, onStateChange } = props;\n const menu = viewMenu(\n props.widget,\n props.views,\n state.view ?? 0,\n i => onStateChange({ ...state, view: i }),\n props.expand,\n );\n const { view } = menu;\n const { expand } = props;\n const expandHref = expand?.href(props.widget);\n const heading = withAction(\n {\n ...menu.heading,\n dragHandle: props.dragHandle,\n onTitleChange: props.onTitleChange,\n actions: props.actions,\n },\n expand && expandHref && (\n <ExpandAction title={menu.heading.title} href={expandHref} LinkComponent={expand.LinkComponent} />\n ),\n );\n if (gate.status === 'pending')\n return (\n <PendingChartCard\n gate={gate.gate}\n heading={pendingHeading(heading, gate.gate, props.alert, props.widget, view)}\n />\n );\n return <TimeseriesView {...props} view={view} heading={heading} page={gate.page} />;\n}\n\nfunction TimeseriesView({ widget, view, heading: own, page, onDrilldown, alert, results, onRetry }: ViewProps) {\n // Drilldown, then the alert, then the expand link and the host's actions.\n const heading = withAction(\n own,\n alertAction(alert, widget, view, { page, values: timeseriesAlertValues(view.options) }),\n );\n const { options } = view;\n const sent = results.filter(r => r !== undefined);\n const hasTraceQueries = view.queries.some(q => q.source === 'traceAggregate' || q.source === 'spanAggregate');\n const onClick = useDrilldown(widget, view, onDrilldown);\n\n const isLoading = sent.some(r => r.isLoading);\n const shaped = shapeTimeseries({\n options,\n responses: answersById(\n view.queries,\n results.map(r => r?.data),\n ),\n window: page.window,\n hasTraceQueries,\n });\n const format = FORMATTERS[options.format];\n const lines: MetricsLineChartSeries[] = shaped.series.map(s => ({\n dataKey: s.dataKey,\n label: s.label,\n color: chartColor(s.color),\n emphasis: s.emphasis,\n }));\n // Series with a range total each show theirs, marked like their line: they count different things.\n const rangeTotals = shaped.series.flatMap(s =>\n s.rangeTotal === undefined\n ? []\n : [{ label: s.label, value: format.value(s.rangeTotal), color: chartColor(s.color) }],\n );\n const withRangeTotals = options.series.some(s => s.rangeTotal !== undefined);\n const failed = sent.filter(r => r.isError);\n\n const layout = {\n ...heading,\n actions: hasDrilldownAction(widget, view, onDrilldown) ? (\n <>\n <DrilldownAction widget={widget} view={view} onDrilldown={onDrilldown} />\n {heading.actions}\n </>\n ) : (\n heading.actions\n ),\n // Range totals per series; with no series in the range, one plain 0. None while a request\n // failed, so no total sits beside the error.\n total: !withRangeTotals || failed.length ? undefined : rangeTotals.length ? rangeTotals : format.value(0),\n isLoading,\n // The view tabs on the left, the legend on the right: one row, so the plot starts where its neighbours' do.\n toolbar: (heading.toolbar || lines.length > 0) && (\n <MetricsCard.Toolbar>\n {heading.toolbar}\n {lines.length > 0 && <MetricsLineChartLegend series={lines} />}\n </MetricsCard.Toolbar>\n ),\n };\n\n if (failed.length) {\n return (\n <ChartCard {...layout}>\n {hasTraceQueries ? <ChartCardError error={failed[0]?.error} onRetry={onRetry} /> : <ChartCardError />}\n </ChartCard>\n );\n }\n\n const totalFormat = FORMATTERS[options.total?.format ?? options.format];\n // An empty range totals 0, a peak included, like the cards around it.\n const total = options.total && totalFormat.value(shaped.total ?? 0);\n\n const chart = {\n data: shaped.data,\n series: lines,\n height: 'fill' as const,\n xLabels: options.xLabels,\n showLegend: false,\n valueFormatter: format.value,\n axisFormatter: options.axis === false ? undefined : format.axis,\n onBucketClick:\n onClick &&\n ((row: Record<string, unknown>) => onClick({ window: bucketWindow(Number(row.ts), shaped.stepHours) })),\n isLoading,\n ...(options.xLabels ? EDGE_BUCKET_AXIS : BUCKET_AXIS),\n };\n const yDomain = shaped.flat && options.flatYDomain ? options.flatYDomain : options.yDomain;\n\n return (\n <ChartCard {...layout} total={layout.total ?? total} isUpdating={sent.some(r => r.isRefetching)}>\n <ChartArea isEmpty={!isLoading && shaped.empty}>\n {options.chart === 'stackedBar' ? (\n <MetricsStackedBarChart {...chart} />\n ) : (\n <MetricsLineChart {...chart} yDomain={yDomain} lineStyle=\"thin\" />\n )}\n </ChartArea>\n </ChartCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,SAAgB,iBAAiB,OAAc;CAC7C,MAAM,EAAE,MAAM,OAAO,kBAAkB;CACvC,MAAM,OAAO,SACX,MAAM,QACN,MAAM,OACN,MAAM,QAAQ,IACd,MAAK,cAAc;EAAE,GAAG;EAAO,MAAM;CAAE,CAAC,GACxC,MAAM,MACR;CACA,MAAM,EAAE,SAAS;CACjB,MAAM,EAAE,WAAW;CACnB,MAAM,aAAa,QAAQ,KAAK,MAAM,MAAM;CAC5C,MAAM,UAAU,WACd;EACE,GAAG,KAAK;EACR,YAAY,MAAM;EAClB,eAAe,MAAM;EACrB,SAAS,MAAM;CACjB,GACA,UAAU,cACR,oBAAC,cAAD;EAAc,OAAO,KAAK,QAAQ;EAAO,MAAM;EAAY,eAAe,OAAO;CAAgB,CAAA,CAErG;CACA,IAAI,KAAK,WAAW,WAClB,OACE,oBAAC,kBAAD;EACE,MAAM,KAAK;EACX,SAAS,eAAe,SAAS,KAAK,MAAM,MAAM,OAAO,MAAM,QAAQ,IAAI;CAC5E,CAAA;CAEL,OAAO,oBAAC,gBAAD;EAAgB,GAAI;EAAa;EAAe;EAAS,MAAM,KAAK;CAAO,CAAA;AACpF;AAEA,SAAS,eAAe,EAAE,QAAQ,MAAM,SAAS,KAAK,MAAM,aAAa,OAAO,SAAS,WAAsB;CAE7G,MAAM,UAAU,WACd,KACA,YAAY,OAAO,QAAQ,MAAM;EAAE;EAAM,QAAQ,sBAAsB,KAAK,OAAO;CAAE,CAAC,CACxF;CACA,MAAM,EAAE,YAAY;CACpB,MAAM,OAAO,QAAQ,QAAO,MAAK,MAAM,KAAA,CAA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,EAAA,CAAA;CAEzB;CAEA,IAAI,OAAO,QACT,OACE,oBAAC,WAAD;EAAW,GAAI;EACZ,UAAA,kBAAkB,oBAAC,gBAAD;GAAgB,OAAO,OAAO,EAAE,EAAE;GAAgB;EAAU,CAAA,IAAI,oBAAC,gBAAD,CAAiB,CAAA;CAC3F,CAAA;CAIf,MAAM,cAAc,WAAW,QAAQ,OAAO,UAAU,QAAQ;CAEhE,MAAM,QAAQ,QAAQ,SAAS,YAAY,MAAM,OAAO,SAAS,CAAC;CAElE,MAAM,QAAQ;EACZ,MAAM,OAAO;EACb,QAAQ;EACR,QAAQ;EACR,SAAS,QAAQ;EACjB,YAAY;EACZ,gBAAgB,OAAO;EACvB,eAAe,QAAQ,SAAS,QAAQ,KAAA,IAAY,OAAO;EAC3D,eACE,aACE,QAAiC,QAAQ,EAAE,QAAQ,aAAa,OAAO,IAAI,EAAE,GAAG,OAAO,SAAS,EAAE,CAAC;EACvG;EACA,GAAI,QAAQ,UAAU,mBAAmB;CAC3C;CACA,MAAM,UAAU,OAAO,QAAQ,QAAQ,cAAc,QAAQ,cAAc,QAAQ;CAEnF,OACE,oBAAC,WAAD;EAAW,GAAI;EAAQ,OAAO,OAAO,SAAS;EAAO,YAAY,KAAK,MAAK,MAAK,EAAE,YAAY;EAC5F,UAAA,oBAAC,WAAD;GAAW,SAAS,CAAC,aAAa,OAAO;GACtC,UAAA,QAAQ,UAAU,eACjB,oBAAC,wBAAD,EAAwB,GAAI,MAAQ,CAAA,IAEpC,oBAAC,kBAAD;IAAkB,GAAI;IAAgB;IAAS,WAAU;GAAQ,CAAA;EAE1D,CAAA;CACF,CAAA;AAEf"}
|
|
@@ -7,37 +7,15 @@ var FILTER_NAMES = {
|
|
|
7
7
|
experimentId: "experiment"
|
|
8
8
|
};
|
|
9
9
|
var unsupportedMessage = (fields, names = FILTER_NAMES) => `Not available with a ${fields.map((f) => names[f] ?? f).join(" or ")} filter.`;
|
|
10
|
-
/** A view's value in the
|
|
10
|
+
/** A view's value in the widget's state: its label in kebab case (`Token usage` → `token-usage`), or its position when unlabelled or blank. */
|
|
11
11
|
var viewValue = (label, index) => {
|
|
12
12
|
const trimmed = label?.trim();
|
|
13
13
|
return trimmed ? trimmed.toLowerCase().replace(/\s+/g, "-") : String(index);
|
|
14
14
|
};
|
|
15
15
|
/** A view's visible name: its label, or `View n` when unlabelled or blank, so every option has an accessible name. */
|
|
16
16
|
var viewLabel = (label, index) => label?.trim() || `View ${index + 1}`;
|
|
17
|
-
/**
|
|
18
|
-
* The card title for the open view: the widget's title for a single view; with several, the open
|
|
19
|
-
* view's label, as a menu of every view (as the metrics cards switch views). With somewhere to
|
|
20
|
-
* expand to, the widget's title stays plain instead, and `ExpandAction` links there.
|
|
21
|
-
*/
|
|
22
|
-
function viewTitle(widget, views, index, onChoose, expand) {
|
|
23
|
-
if (expand?.href(widget)) return { title: widget.title?.trim() ? widget.title : viewLabel(views[0]?.label, 0) };
|
|
24
|
-
if (views.length < 2) return { title: widget.title ?? "" };
|
|
25
|
-
const options = views.map((v, i) => ({
|
|
26
|
-
value: viewValue(v.label, i),
|
|
27
|
-
label: viewLabel(v.label, i)
|
|
28
|
-
}));
|
|
29
|
-
return {
|
|
30
|
-
title: options[index]?.label ?? "",
|
|
31
|
-
titleMenu: {
|
|
32
|
-
value: options[index]?.value ?? "",
|
|
33
|
-
onValueChange: (value) => onChoose(options.findIndex((o) => o.value === value)),
|
|
34
|
-
options
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
17
|
exports.unsupportedMessage = unsupportedMessage;
|
|
39
18
|
exports.viewLabel = viewLabel;
|
|
40
|
-
exports.viewTitle = viewTitle;
|
|
41
19
|
exports.viewValue = viewValue;
|
|
42
20
|
|
|
43
21
|
//# sourceMappingURL=chrome.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chrome.cjs.js","names":[],"sources":["../../../../src/domains/dashboards/lib/chrome.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"chrome.cjs.js","names":[],"sources":["../../../../src/domains/dashboards/lib/chrome.ts"],"sourcesContent":["import type { ChartCardProps } from '../../metrics/components/chart-card';\n\n/**\n * What a widget's card shows in its top bar: `title`, plus its actions: the drilldown, the alert,\n * the expand link, then the host's. Several views are tabs in its `toolbar`, under the title.\n */\nexport type ViewHeading = Pick<ChartCardProps, 'title' | 'dragHandle' | 'onTitleChange' | 'actions' | 'toolbar'>;\n\n/** Filters a gate can't apply, named as the filter bar names them. */\nconst FILTER_NAMES: Record<string, string> = {\n serviceName: 'service',\n requestId: 'request ID',\n experimentId: 'experiment',\n};\n\nexport const unsupportedMessage = (fields: string[], names: Record<string, string> = FILTER_NAMES) =>\n `Not available with a ${fields.map(f => names[f] ?? f).join(' or ')} filter.`;\n\n/** A view's value in the widget's state: its label in kebab case (`Token usage` → `token-usage`), or its position when unlabelled or blank. */\nexport const viewValue = (label: string | undefined, index: number) => {\n const trimmed = label?.trim();\n return trimmed ? trimmed.toLowerCase().replace(/\\s+/g, '-') : String(index);\n};\n\n/** A view's visible name: its label, or `View n` when unlabelled or blank, so every option has an accessible name. */\nexport const viewLabel = (label: string | undefined, index: number) => label?.trim() || `View ${index + 1}`;\n"],"mappings":";;;AASA,IAAM,eAAuC;CAC3C,aAAa;CACb,WAAW;CACX,cAAc;AAChB;AAEA,IAAa,sBAAsB,QAAkB,QAAgC,iBACnF,wBAAwB,OAAO,KAAI,MAAK,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE;;AAGtE,IAAa,aAAa,OAA2B,UAAkB;CACrE,MAAM,UAAU,OAAO,KAAK;CAC5B,OAAO,UAAU,QAAQ,YAAY,CAAC,CAAC,QAAQ,QAAQ,GAAG,IAAI,OAAO,KAAK;AAC5E;;AAGA,IAAa,aAAa,OAA2B,UAAkB,OAAO,KAAK,KAAK,QAAQ,QAAQ"}
|
|
@@ -6,34 +6,13 @@ var FILTER_NAMES = {
|
|
|
6
6
|
experimentId: "experiment"
|
|
7
7
|
};
|
|
8
8
|
var unsupportedMessage = (fields, names = FILTER_NAMES) => `Not available with a ${fields.map((f) => names[f] ?? f).join(" or ")} filter.`;
|
|
9
|
-
/** A view's value in the
|
|
9
|
+
/** A view's value in the widget's state: its label in kebab case (`Token usage` → `token-usage`), or its position when unlabelled or blank. */
|
|
10
10
|
var viewValue = (label, index) => {
|
|
11
11
|
const trimmed = label?.trim();
|
|
12
12
|
return trimmed ? trimmed.toLowerCase().replace(/\s+/g, "-") : String(index);
|
|
13
13
|
};
|
|
14
14
|
/** A view's visible name: its label, or `View n` when unlabelled or blank, so every option has an accessible name. */
|
|
15
15
|
var viewLabel = (label, index) => label?.trim() || `View ${index + 1}`;
|
|
16
|
-
|
|
17
|
-
* The card title for the open view: the widget's title for a single view; with several, the open
|
|
18
|
-
* view's label, as a menu of every view (as the metrics cards switch views). With somewhere to
|
|
19
|
-
* expand to, the widget's title stays plain instead, and `ExpandAction` links there.
|
|
20
|
-
*/
|
|
21
|
-
function viewTitle(widget, views, index, onChoose, expand) {
|
|
22
|
-
if (expand?.href(widget)) return { title: widget.title?.trim() ? widget.title : viewLabel(views[0]?.label, 0) };
|
|
23
|
-
if (views.length < 2) return { title: widget.title ?? "" };
|
|
24
|
-
const options = views.map((v, i) => ({
|
|
25
|
-
value: viewValue(v.label, i),
|
|
26
|
-
label: viewLabel(v.label, i)
|
|
27
|
-
}));
|
|
28
|
-
return {
|
|
29
|
-
title: options[index]?.label ?? "",
|
|
30
|
-
titleMenu: {
|
|
31
|
-
value: options[index]?.value ?? "",
|
|
32
|
-
onValueChange: (value) => onChoose(options.findIndex((o) => o.value === value)),
|
|
33
|
-
options
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export { unsupportedMessage, viewLabel, viewTitle, viewValue };
|
|
16
|
+
export { unsupportedMessage, viewLabel, viewValue };
|
|
38
17
|
|
|
39
18
|
//# sourceMappingURL=chrome.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chrome.es.js","names":[],"sources":["../../../../src/domains/dashboards/lib/chrome.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"chrome.es.js","names":[],"sources":["../../../../src/domains/dashboards/lib/chrome.ts"],"sourcesContent":["import type { ChartCardProps } from '../../metrics/components/chart-card';\n\n/**\n * What a widget's card shows in its top bar: `title`, plus its actions: the drilldown, the alert,\n * the expand link, then the host's. Several views are tabs in its `toolbar`, under the title.\n */\nexport type ViewHeading = Pick<ChartCardProps, 'title' | 'dragHandle' | 'onTitleChange' | 'actions' | 'toolbar'>;\n\n/** Filters a gate can't apply, named as the filter bar names them. */\nconst FILTER_NAMES: Record<string, string> = {\n serviceName: 'service',\n requestId: 'request ID',\n experimentId: 'experiment',\n};\n\nexport const unsupportedMessage = (fields: string[], names: Record<string, string> = FILTER_NAMES) =>\n `Not available with a ${fields.map(f => names[f] ?? f).join(' or ')} filter.`;\n\n/** A view's value in the widget's state: its label in kebab case (`Token usage` → `token-usage`), or its position when unlabelled or blank. */\nexport const viewValue = (label: string | undefined, index: number) => {\n const trimmed = label?.trim();\n return trimmed ? trimmed.toLowerCase().replace(/\\s+/g, '-') : String(index);\n};\n\n/** A view's visible name: its label, or `View n` when unlabelled or blank, so every option has an accessible name. */\nexport const viewLabel = (label: string | undefined, index: number) => label?.trim() || `View ${index + 1}`;\n"],"mappings":";;AASA,IAAM,eAAuC;CAC3C,aAAa;CACb,WAAW;CACX,cAAc;AAChB;AAEA,IAAa,sBAAsB,QAAkB,QAAgC,iBACnF,wBAAwB,OAAO,KAAI,MAAK,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE;;AAGtE,IAAa,aAAa,OAA2B,UAAkB;CACrE,MAAM,UAAU,OAAO,KAAK;CAC5B,OAAO,UAAU,QAAQ,YAAY,CAAC,CAAC,QAAQ,QAAQ,GAAG,IAAI,OAAO,KAAK;AAC5E;;AAGA,IAAa,aAAa,OAA2B,UAAkB,OAAO,KAAK,KAAK,QAAQ,QAAQ"}
|
|
@@ -14,19 +14,21 @@ function sharedWords(words) {
|
|
|
14
14
|
while (words.length > 1 && words.every((w) => w.length > shared + 1 && w[shared] === first[shared])) shared++;
|
|
15
15
|
return shared;
|
|
16
16
|
}
|
|
17
|
+
var reversed = (words) => words.map((w) => [...w].reverse());
|
|
17
18
|
/**
|
|
18
|
-
* Short tab names for a card's views: their labels without the words they all start with,
|
|
19
|
+
* Short tab names for a card's views: their labels without the words they all start or end with,
|
|
19
20
|
* capitalised ("Breakdown by agent", "Breakdown by tool" → "Agents", "Tools"; after "by", the
|
|
20
|
-
* rest names what each row is, so it reads as a plural
|
|
21
|
-
* shorten to the same name, stay as they are.
|
|
21
|
+
* rest names what each row is, so it reads as a plural. "Agent latency", "Tool latency" → "Agent",
|
|
22
|
+
* "Tool"). Labels that share nothing, or that would shorten to the same name, stay as they are.
|
|
22
23
|
*/
|
|
23
24
|
function shortViewLabels(labels) {
|
|
24
25
|
const words = labels.map((label) => label.split(/\s+/));
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const leading = sharedWords(words);
|
|
27
|
+
const trailing = sharedWords(reversed(words.map((w) => w.slice(leading))));
|
|
28
|
+
if (leading === 0 && trailing === 0) return [...labels];
|
|
29
|
+
const byRows = words[0]?.[leading - 1]?.toLowerCase() === "by";
|
|
28
30
|
const names = words.map((w) => {
|
|
29
|
-
const rest = w.slice(
|
|
31
|
+
const rest = w.slice(leading, w.length - trailing);
|
|
30
32
|
const last = rest.pop() ?? "";
|
|
31
33
|
const name = [...rest, byRows ? plural(last) : last].join(" ");
|
|
32
34
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-labels.cjs.js","names":[],"sources":["../../../../src/domains/dashboards/lib/view-labels.ts"],"sourcesContent":["/** \"agent\" → \"agents\", \"entity\" → \"entities\", \"box\" → \"boxes\"; a word already ending in \"s\" (\"teams\") stays. */\nconst plural = (word: string) => {\n if (/s$/i.test(word)) return word;\n if (/[^aeiou]y$/i.test(word)) return `${word.slice(0, -1)}ies`;\n if (/(x|z|ch|sh)$/i.test(word)) return `${word}es`;\n return `${word}s`;\n};\n\n/** How many leading words every label shares, leaving each at least one word of its own. */\nfunction sharedWords(words: readonly string[][]): number {\n const [first = []] = words;\n let shared = 0;\n while (words.length > 1 && words.every(w => w.length > shared + 1 && w[shared] === first[shared])) shared++;\n return shared;\n}\n\n/**\n * Short tab names for a card's views: their labels without the words they all start with,\n * capitalised (\"Breakdown by agent\", \"Breakdown by tool\" → \"Agents\", \"Tools\"; after \"by\", the\n * rest names what each row is, so it reads as a plural). Labels that share nothing, or that would
|
|
1
|
+
{"version":3,"file":"view-labels.cjs.js","names":[],"sources":["../../../../src/domains/dashboards/lib/view-labels.ts"],"sourcesContent":["/** \"agent\" → \"agents\", \"entity\" → \"entities\", \"box\" → \"boxes\"; a word already ending in \"s\" (\"teams\") stays. */\nconst plural = (word: string) => {\n if (/s$/i.test(word)) return word;\n if (/[^aeiou]y$/i.test(word)) return `${word.slice(0, -1)}ies`;\n if (/(x|z|ch|sh)$/i.test(word)) return `${word}es`;\n return `${word}s`;\n};\n\n/** How many leading words every label shares, leaving each at least one word of its own. */\nfunction sharedWords(words: readonly string[][]): number {\n const [first = []] = words;\n let shared = 0;\n while (words.length > 1 && words.every(w => w.length > shared + 1 && w[shared] === first[shared])) shared++;\n return shared;\n}\n\nconst reversed = (words: readonly string[][]) => words.map(w => [...w].reverse());\n\n/**\n * Short tab names for a card's views: their labels without the words they all start or end with,\n * capitalised (\"Breakdown by agent\", \"Breakdown by tool\" → \"Agents\", \"Tools\"; after \"by\", the\n * rest names what each row is, so it reads as a plural. \"Agent latency\", \"Tool latency\" → \"Agent\",\n * \"Tool\"). Labels that share nothing, or that would shorten to the same name, stay as they are.\n */\nexport function shortViewLabels(labels: readonly string[]): string[] {\n const words = labels.map(label => label.split(/\\s+/));\n const leading = sharedWords(words);\n const trailing = sharedWords(reversed(words.map(w => w.slice(leading))));\n if (leading === 0 && trailing === 0) return [...labels];\n const byRows = words[0]?.[leading - 1]?.toLowerCase() === 'by';\n const names = words.map(w => {\n const rest = w.slice(leading, w.length - trailing);\n const last = rest.pop() ?? '';\n const name = [...rest, byRows ? plural(last) : last].join(' ');\n return name.charAt(0).toUpperCase() + name.slice(1);\n });\n // Two views that shorten to the same name (\"by team\", \"by teams\") keep their labels, to tell apart.\n return new Set(names).size === names.length ? names : [...labels];\n}\n"],"mappings":";;;AACA,IAAM,UAAU,SAAiB;CAC/B,IAAI,MAAM,KAAK,IAAI,GAAG,OAAO;CAC7B,IAAI,cAAc,KAAK,IAAI,GAAG,OAAO,GAAG,KAAK,MAAM,GAAG,EAAE,EAAE;CAC1D,IAAI,gBAAgB,KAAK,IAAI,GAAG,OAAO,GAAG,KAAK;CAC/C,OAAO,GAAG,KAAK;AACjB;;AAGA,SAAS,YAAY,OAAoC;CACvD,MAAM,CAAC,QAAQ,CAAC,KAAK;CACrB,IAAI,SAAS;CACb,OAAO,MAAM,SAAS,KAAK,MAAM,OAAM,MAAK,EAAE,SAAS,SAAS,KAAK,EAAE,YAAY,MAAM,OAAO,GAAG;CACnG,OAAO;AACT;AAEA,IAAM,YAAY,UAA+B,MAAM,KAAI,MAAK,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;;;;;;;AAQhF,SAAgB,gBAAgB,QAAqC;CACnE,MAAM,QAAQ,OAAO,KAAI,UAAS,MAAM,MAAM,KAAK,CAAC;CACpD,MAAM,UAAU,YAAY,KAAK;CACjC,MAAM,WAAW,YAAY,SAAS,MAAM,KAAI,MAAK,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC;CACvE,IAAI,YAAY,KAAK,aAAa,GAAG,OAAO,CAAC,GAAG,MAAM;CACtD,MAAM,SAAS,MAAM,EAAE,GAAG,UAAU,EAAE,EAAE,YAAY,MAAM;CAC1D,MAAM,QAAQ,MAAM,KAAI,MAAK;EAC3B,MAAM,OAAO,EAAE,MAAM,SAAS,EAAE,SAAS,QAAQ;EACjD,MAAM,OAAO,KAAK,IAAI,KAAK;EAC3B,MAAM,OAAO,CAAC,GAAG,MAAM,SAAS,OAAO,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,GAAG;EAC7D,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,KAAK,MAAM,CAAC;CACpD,CAAC;CAED,OAAO,IAAI,IAAI,KAAK,CAAC,CAAC,SAAS,MAAM,SAAS,QAAQ,CAAC,GAAG,MAAM;AAClE"}
|
|
@@ -13,19 +13,21 @@ function sharedWords(words) {
|
|
|
13
13
|
while (words.length > 1 && words.every((w) => w.length > shared + 1 && w[shared] === first[shared])) shared++;
|
|
14
14
|
return shared;
|
|
15
15
|
}
|
|
16
|
+
var reversed = (words) => words.map((w) => [...w].reverse());
|
|
16
17
|
/**
|
|
17
|
-
* Short tab names for a card's views: their labels without the words they all start with,
|
|
18
|
+
* Short tab names for a card's views: their labels without the words they all start or end with,
|
|
18
19
|
* capitalised ("Breakdown by agent", "Breakdown by tool" → "Agents", "Tools"; after "by", the
|
|
19
|
-
* rest names what each row is, so it reads as a plural
|
|
20
|
-
* shorten to the same name, stay as they are.
|
|
20
|
+
* rest names what each row is, so it reads as a plural. "Agent latency", "Tool latency" → "Agent",
|
|
21
|
+
* "Tool"). Labels that share nothing, or that would shorten to the same name, stay as they are.
|
|
21
22
|
*/
|
|
22
23
|
function shortViewLabels(labels) {
|
|
23
24
|
const words = labels.map((label) => label.split(/\s+/));
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const leading = sharedWords(words);
|
|
26
|
+
const trailing = sharedWords(reversed(words.map((w) => w.slice(leading))));
|
|
27
|
+
if (leading === 0 && trailing === 0) return [...labels];
|
|
28
|
+
const byRows = words[0]?.[leading - 1]?.toLowerCase() === "by";
|
|
27
29
|
const names = words.map((w) => {
|
|
28
|
-
const rest = w.slice(
|
|
30
|
+
const rest = w.slice(leading, w.length - trailing);
|
|
29
31
|
const last = rest.pop() ?? "";
|
|
30
32
|
const name = [...rest, byRows ? plural(last) : last].join(" ");
|
|
31
33
|
return name.charAt(0).toUpperCase() + name.slice(1);
|