@perses-dev/timeseries-table-plugin 0.6.0
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/LICENSE +201 -0
- package/README.md +41 -0
- package/__mf/css/async/341.53436797.css +1 -0
- package/__mf/css/async/759.53436797.css +1 -0
- package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
- package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
- package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
- package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
- package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
- package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
- package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
- package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
- package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
- package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
- package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
- package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
- package/__mf/js/795.a00f14d5.js +5 -0
- package/__mf/js/TimeSeriesTable.78b6adc4.js +5 -0
- package/__mf/js/async/156.edaa1366.js +1 -0
- package/__mf/js/async/173.7677c422.js +2 -0
- package/__mf/js/async/173.7677c422.js.LICENSE.txt +19 -0
- package/__mf/js/async/570.4e5c2806.js +1 -0
- package/__mf/js/async/620.989f65d2.js +2 -0
- package/__mf/js/async/620.989f65d2.js.LICENSE.txt +9 -0
- package/__mf/js/async/621.966dfe80.js +111 -0
- package/__mf/js/async/621.966dfe80.js.LICENSE.txt +52 -0
- package/__mf/js/async/651.f2005980.js +1 -0
- package/__mf/js/async/694.46f61549.js +1 -0
- package/__mf/js/async/740.64988389.js +1 -0
- package/__mf/js/async/75.65fec995.js +1 -0
- package/__mf/js/async/770.46d7d5f9.js +1 -0
- package/__mf/js/async/960.d242a960.js +2 -0
- package/__mf/js/async/960.d242a960.js.LICENSE.txt +8 -0
- package/__mf/js/async/964.7386b918.js +2 -0
- package/__mf/js/async/964.7386b918.js.LICENSE.txt +9 -0
- package/__mf/js/async/998.e20cf478.js +65 -0
- package/__mf/js/async/998.e20cf478.js.LICENSE.txt +59 -0
- package/__mf/js/async/__federation_expose_TimeSeriesTable.0774ca0f.js +1 -0
- package/__mf/js/main.857476c9.js +1 -0
- package/lib/TimeSeriesTable.d.ts +8 -0
- package/lib/TimeSeriesTable.d.ts.map +1 -0
- package/lib/TimeSeriesTable.js +29 -0
- package/lib/TimeSeriesTable.js.map +1 -0
- package/lib/TimeSeriesTablePanel.d.ts +7 -0
- package/lib/TimeSeriesTablePanel.d.ts.map +1 -0
- package/lib/TimeSeriesTablePanel.js +33 -0
- package/lib/TimeSeriesTablePanel.js.map +1 -0
- package/lib/bootstrap.d.ts +2 -0
- package/lib/bootstrap.d.ts.map +1 -0
- package/lib/bootstrap.js +19 -0
- package/lib/bootstrap.js.map +1 -0
- package/lib/cjs/TimeSeriesTable.js +35 -0
- package/lib/cjs/TimeSeriesTablePanel.js +41 -0
- package/lib/cjs/bootstrap.js +26 -0
- package/lib/cjs/components/DataTable.js +185 -0
- package/lib/cjs/components/HistogramChart.js +121 -0
- package/lib/cjs/components/SeriesName.js +100 -0
- package/lib/cjs/components/index.js +20 -0
- package/lib/cjs/env.d.js +14 -0
- package/lib/cjs/getPluginModule.js +27 -0
- package/lib/cjs/index-federation.js +55 -0
- package/lib/cjs/index.js +29 -0
- package/lib/cjs/model.js +5 -0
- package/lib/cjs/setup-tests.js +19 -0
- package/lib/cjs/test/mock-query-results.js +417 -0
- package/lib/components/DataTable.d.ts +18 -0
- package/lib/components/DataTable.d.ts.map +1 -0
- package/lib/components/DataTable.js +173 -0
- package/lib/components/DataTable.js.map +1 -0
- package/lib/components/HistogramChart.d.ts +16 -0
- package/lib/components/HistogramChart.d.ts.map +1 -0
- package/lib/components/HistogramChart.js +113 -0
- package/lib/components/HistogramChart.js.map +1 -0
- package/lib/components/SeriesName.d.ts +11 -0
- package/lib/components/SeriesName.d.ts.map +1 -0
- package/lib/components/SeriesName.js +95 -0
- package/lib/components/SeriesName.js.map +1 -0
- package/lib/components/index.d.ts +4 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +5 -0
- package/lib/components/index.js.map +1 -0
- package/lib/env.d.js +15 -0
- package/lib/env.d.js.map +1 -0
- package/lib/getPluginModule.d.ts +6 -0
- package/lib/getPluginModule.d.ts.map +1 -0
- package/lib/getPluginModule.js +16 -0
- package/lib/getPluginModule.js.map +1 -0
- package/lib/index-federation.d.ts +1 -0
- package/lib/index-federation.d.ts.map +1 -0
- package/lib/index-federation.js +15 -0
- package/lib/index-federation.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -0
- package/lib/index.js.map +1 -0
- package/lib/model.d.ts +3 -0
- package/lib/model.d.ts.map +1 -0
- package/lib/model.js +4 -0
- package/lib/model.js.map +1 -0
- package/lib/setup-tests.d.ts +2 -0
- package/lib/setup-tests.d.ts.map +1 -0
- package/lib/setup-tests.js +17 -0
- package/lib/setup-tests.js.map +1 -0
- package/lib/test/mock-query-results.d.ts +136 -0
- package/lib/test/mock-query-results.d.ts.map +1 -0
- package/lib/test/mock-query-results.js +389 -0
- package/lib/test/mock-query-results.js.map +1 -0
- package/mf-manifest.json +212 -0
- package/mf-stats.json +242 -0
- package/package.json +54 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { TimeSeriesData, HistogramValue } from '@perses-dev/core';
|
|
3
|
+
import { PanelData } from '@perses-dev/plugin-system';
|
|
4
|
+
export interface DataTableProps {
|
|
5
|
+
result: Array<PanelData<TimeSeriesData>>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Designed to display timeseries data in a prometheus like table format.
|
|
9
|
+
* The first column will contain the metric name and label combination, and the second column will contain the values.
|
|
10
|
+
* This is inspired by prometheus DataTable.
|
|
11
|
+
* https://github.com/prometheus/prometheus/blob/2524a915915d7eb1b1207152d2e0ce5771193404/web/ui/react-app/src/pages/graph/DataTable.tsx
|
|
12
|
+
* @param result timeseries query result
|
|
13
|
+
* @constructor
|
|
14
|
+
*/
|
|
15
|
+
export declare const DataTable: ({ result }: DataTableProps) => ReactElement | null;
|
|
16
|
+
export declare const bucketRangeString: ([boundaryRule, leftBoundary, rightBoundary]: [number, string, string, string]) => string;
|
|
17
|
+
export declare const histogramTable: (h: HistogramValue) => ReactNode;
|
|
18
|
+
//# sourceMappingURL=DataTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../src/components/DataTable.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAY,YAAY,EAAE,SAAS,EAAW,MAAM,OAAO,CAAC;AAEnE,OAAO,EAAc,cAAc,EAAyC,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACrH,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAMtD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC;CAC1C;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,YAAY,cAAc,KAAG,YAAY,GAAG,IAoBrE,CAAC;AA2CF,eAAO,MAAM,iBAAiB,GAAI,6CAA6C,CAC7E,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,CACP,KAAG,MAEH,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,GAAG,cAAc,KAAG,SAsBlD,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { Fragment, useMemo } from 'react';
|
|
15
|
+
import { Alert, Stack, Table, TableBody, TableCell, TableHead, TableRow, Typography } from '@mui/material';
|
|
16
|
+
import { SeriesName } from './SeriesName';
|
|
17
|
+
import { HistogramChart } from './HistogramChart';
|
|
18
|
+
const MAX_FORMATABLE_SERIES = 1000;
|
|
19
|
+
/**
|
|
20
|
+
* Designed to display timeseries data in a prometheus like table format.
|
|
21
|
+
* The first column will contain the metric name and label combination, and the second column will contain the values.
|
|
22
|
+
* This is inspired by prometheus DataTable.
|
|
23
|
+
* https://github.com/prometheus/prometheus/blob/2524a915915d7eb1b1207152d2e0ce5771193404/web/ui/react-app/src/pages/graph/DataTable.tsx
|
|
24
|
+
* @param result timeseries query result
|
|
25
|
+
* @constructor
|
|
26
|
+
*/ export const DataTable = ({ result })=>{
|
|
27
|
+
const series = useMemo(()=>result.flatMap((d)=>d.data).flatMap((d)=>d?.series || []), [
|
|
28
|
+
result
|
|
29
|
+
]);
|
|
30
|
+
const rows = useMemo(()=>buildRows(series), [
|
|
31
|
+
series
|
|
32
|
+
]);
|
|
33
|
+
if (!result) {
|
|
34
|
+
return /*#__PURE__*/ _jsx(Typography, {
|
|
35
|
+
children: "No data"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
39
|
+
children: [
|
|
40
|
+
series.length >= MAX_FORMATABLE_SERIES && /*#__PURE__*/ _jsxs(Alert, {
|
|
41
|
+
severity: "warning",
|
|
42
|
+
children: [
|
|
43
|
+
"Showing more than ",
|
|
44
|
+
MAX_FORMATABLE_SERIES,
|
|
45
|
+
" series, turning off label formatting for performance reasons."
|
|
46
|
+
]
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ _jsx(Table, {
|
|
49
|
+
className: "data-table",
|
|
50
|
+
children: /*#__PURE__*/ _jsx(TableBody, {
|
|
51
|
+
children: rows
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
function buildRows(series) {
|
|
58
|
+
const isFormatted = series.length < MAX_FORMATABLE_SERIES; // only format series names if we have less than 1000 series for performance reasons
|
|
59
|
+
return series.map((s, seriesIdx)=>{
|
|
60
|
+
const displayTimeStamps = (s.values?.length ?? 0) > 1;
|
|
61
|
+
const valuesAndTimes = s.values ? s.values.map((v, valIdx)=>{
|
|
62
|
+
return /*#__PURE__*/ _jsxs(Typography, {
|
|
63
|
+
children: [
|
|
64
|
+
v[1],
|
|
65
|
+
" ",
|
|
66
|
+
displayTimeStamps && /*#__PURE__*/ _jsxs("span", {
|
|
67
|
+
children: [
|
|
68
|
+
"@",
|
|
69
|
+
v[0]
|
|
70
|
+
]
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
}, valIdx);
|
|
74
|
+
}) : [];
|
|
75
|
+
const histogramsAndTimes = s.histograms ? s.histograms.map((h, hisIdx)=>{
|
|
76
|
+
return /*#__PURE__*/ _jsxs(Fragment, {
|
|
77
|
+
children: [
|
|
78
|
+
/*#__PURE__*/ _jsx(HistogramChart, {
|
|
79
|
+
width: 400,
|
|
80
|
+
height: 200,
|
|
81
|
+
data: {
|
|
82
|
+
buckets: h[1].buckets
|
|
83
|
+
}
|
|
84
|
+
}),
|
|
85
|
+
" ",
|
|
86
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
87
|
+
flexDirection: "row",
|
|
88
|
+
justifyContent: "space-between",
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
91
|
+
children: [
|
|
92
|
+
"Total count: ",
|
|
93
|
+
h[1].count
|
|
94
|
+
]
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
97
|
+
children: [
|
|
98
|
+
"Sum: ",
|
|
99
|
+
h[1].sum
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
}),
|
|
104
|
+
histogramTable(h[1])
|
|
105
|
+
]
|
|
106
|
+
}, -hisIdx);
|
|
107
|
+
}) : [];
|
|
108
|
+
return /*#__PURE__*/ _jsxs(TableRow, {
|
|
109
|
+
style: {
|
|
110
|
+
whiteSpace: 'pre'
|
|
111
|
+
},
|
|
112
|
+
children: [
|
|
113
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
114
|
+
children: /*#__PURE__*/ _jsx(SeriesName, {
|
|
115
|
+
name: s.name,
|
|
116
|
+
formattedName: s.formattedName,
|
|
117
|
+
labels: s.labels,
|
|
118
|
+
isFormatted: isFormatted
|
|
119
|
+
})
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
122
|
+
children: s.histograms ? histogramsAndTimes : valuesAndTimes
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
}, seriesIdx);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const leftDelim = (br)=>br === 3 || br === 1 ? '[' : '(';
|
|
129
|
+
const rightDelim = (br)=>br === 3 || br === 0 ? ']' : ')';
|
|
130
|
+
export const bucketRangeString = ([boundaryRule, leftBoundary, rightBoundary])=>{
|
|
131
|
+
return `${leftDelim(boundaryRule)}${leftBoundary} -> ${rightBoundary}${rightDelim(boundaryRule)}`;
|
|
132
|
+
};
|
|
133
|
+
export const histogramTable = (h)=>/*#__PURE__*/ _jsxs(Table, {
|
|
134
|
+
children: [
|
|
135
|
+
/*#__PURE__*/ _jsx(TableHead, {
|
|
136
|
+
children: /*#__PURE__*/ _jsx(TableRow, {
|
|
137
|
+
children: /*#__PURE__*/ _jsx(TableCell, {
|
|
138
|
+
style: {
|
|
139
|
+
textAlign: 'center'
|
|
140
|
+
},
|
|
141
|
+
colSpan: 2,
|
|
142
|
+
children: "Histogram Sample"
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
}),
|
|
146
|
+
/*#__PURE__*/ _jsxs(TableBody, {
|
|
147
|
+
children: [
|
|
148
|
+
/*#__PURE__*/ _jsxs(TableRow, {
|
|
149
|
+
children: [
|
|
150
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
151
|
+
children: "Range"
|
|
152
|
+
}),
|
|
153
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
154
|
+
children: "Count"
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
}),
|
|
158
|
+
h.buckets?.map((b, i)=>/*#__PURE__*/ _jsxs(TableRow, {
|
|
159
|
+
children: [
|
|
160
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
161
|
+
children: bucketRangeString(b)
|
|
162
|
+
}),
|
|
163
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
164
|
+
children: b[3]
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
}, i))
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=DataTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DataTable.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Fragment, ReactElement, ReactNode, useMemo } from 'react';\nimport { Alert, Stack, Table, TableBody, TableCell, TableHead, TableRow, Typography } from '@mui/material';\nimport { TimeSeries, TimeSeriesData, BucketTuple, TimeSeriesHistogramTuple, HistogramValue } from '@perses-dev/core';\nimport { PanelData } from '@perses-dev/plugin-system';\nimport { SeriesName } from './SeriesName';\nimport { HistogramChart } from './HistogramChart';\n\nconst MAX_FORMATABLE_SERIES = 1000;\n\nexport interface DataTableProps {\n result: Array<PanelData<TimeSeriesData>>;\n}\n\n/**\n * Designed to display timeseries data in a prometheus like table format.\n * The first column will contain the metric name and label combination, and the second column will contain the values.\n * This is inspired by prometheus DataTable.\n * https://github.com/prometheus/prometheus/blob/2524a915915d7eb1b1207152d2e0ce5771193404/web/ui/react-app/src/pages/graph/DataTable.tsx\n * @param result timeseries query result\n * @constructor\n */\nexport const DataTable = ({ result }: DataTableProps): ReactElement | null => {\n const series = useMemo(() => result.flatMap((d) => d.data).flatMap((d) => d?.series || []), [result]);\n const rows = useMemo(() => buildRows(series), [series]);\n\n if (!result) {\n return <Typography>No data</Typography>;\n }\n\n return (\n <>\n {series.length >= MAX_FORMATABLE_SERIES && (\n <Alert severity=\"warning\">\n Showing more than {MAX_FORMATABLE_SERIES} series, turning off label formatting for performance reasons.\n </Alert>\n )}\n <Table className=\"data-table\">\n <TableBody>{rows}</TableBody>\n </Table>\n </>\n );\n};\n\nfunction buildRows(series: TimeSeries[]): ReactNode[] {\n const isFormatted = series.length < MAX_FORMATABLE_SERIES; // only format series names if we have less than 1000 series for performance reasons\n return series.map((s, seriesIdx) => {\n const displayTimeStamps = (s.values?.length ?? 0) > 1;\n const valuesAndTimes = s.values\n ? s.values.map((v, valIdx) => {\n return (\n <Typography key={valIdx}>\n {v[1]} {displayTimeStamps && <span>@{v[0]}</span>}\n </Typography>\n );\n })\n : [];\n const histogramsAndTimes = s.histograms\n ? s.histograms.map((h: TimeSeriesHistogramTuple, hisIdx: number) => {\n return (\n <Fragment key={-hisIdx}>\n <HistogramChart width={400} height={200} data={{ buckets: h[1].buckets! }} /> {/* TODO: calc size ? */}\n <Stack flexDirection=\"row\" justifyContent=\"space-between\">\n <Typography>Total count: {h[1].count}</Typography>\n <Typography>Sum: {h[1].sum}</Typography>\n </Stack>\n {histogramTable(h[1])}\n </Fragment>\n );\n })\n : [];\n return (\n <TableRow style={{ whiteSpace: 'pre' }} key={seriesIdx}>\n <TableCell>\n <SeriesName name={s.name} formattedName={s.formattedName} labels={s.labels} isFormatted={isFormatted} />\n </TableCell>\n <TableCell>{s.histograms ? histogramsAndTimes : valuesAndTimes}</TableCell>\n </TableRow>\n );\n });\n}\n\nconst leftDelim = (br: number): string => (br === 3 || br === 1 ? '[' : '(');\nconst rightDelim = (br: number): string => (br === 3 || br === 0 ? ']' : ')');\n\nexport const bucketRangeString = ([boundaryRule, leftBoundary, rightBoundary]: [\n number,\n string,\n string,\n string,\n]): string => {\n return `${leftDelim(boundaryRule)}${leftBoundary} -> ${rightBoundary}${rightDelim(boundaryRule)}`;\n};\n\nexport const histogramTable = (h: HistogramValue): ReactNode => (\n <Table>\n <TableHead>\n <TableRow>\n <TableCell style={{ textAlign: 'center' }} colSpan={2}>\n Histogram Sample\n </TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n <TableRow>\n <TableCell>Range</TableCell>\n <TableCell>Count</TableCell>\n </TableRow>\n {h.buckets?.map((b: BucketTuple, i: number) => (\n <TableRow key={i}>\n <TableCell>{bucketRangeString(b)}</TableCell>\n <TableCell>{b[3]}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n);\n"],"names":["Fragment","useMemo","Alert","Stack","Table","TableBody","TableCell","TableHead","TableRow","Typography","SeriesName","HistogramChart","MAX_FORMATABLE_SERIES","DataTable","result","series","flatMap","d","data","rows","buildRows","length","severity","className","isFormatted","map","s","seriesIdx","displayTimeStamps","values","valuesAndTimes","v","valIdx","span","histogramsAndTimes","histograms","h","hisIdx","width","height","buckets","flexDirection","justifyContent","count","sum","histogramTable","style","whiteSpace","name","formattedName","labels","leftDelim","br","rightDelim","bucketRangeString","boundaryRule","leftBoundary","rightBoundary","textAlign","colSpan","b","i"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ModeOption } from '@perses-dev/components';
|
|
2
|
+
import { BucketTuple, FormatOptions } from '@perses-dev/core';
|
|
3
|
+
import { ReactElement } from 'react';
|
|
4
|
+
export interface HistogramChartData {
|
|
5
|
+
buckets: BucketTuple[];
|
|
6
|
+
}
|
|
7
|
+
export interface HistogramChartProps {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
data?: HistogramChartData;
|
|
11
|
+
format?: FormatOptions;
|
|
12
|
+
mode?: ModeOption;
|
|
13
|
+
exponential?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function HistogramChart({ width, height, data }: HistogramChartProps): ReactElement | null;
|
|
16
|
+
//# sourceMappingURL=HistogramChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HistogramChart.d.ts","sourceRoot":"","sources":["../../../src/components/HistogramChart.tsx"],"names":[],"mappings":"AACA,OAAO,EAAU,UAAU,EAAkB,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAI9D,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAI9C,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,mBAAmB,GAAG,YAAY,GAAG,IAAI,CAkFhG"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
import { EChart, useChartsTheme } from '@perses-dev/components';
|
|
4
|
+
import { CustomChart } from 'echarts/charts';
|
|
5
|
+
import { use } from 'echarts/core';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
use([
|
|
8
|
+
CustomChart
|
|
9
|
+
]);
|
|
10
|
+
export function HistogramChart({ width, height, data }) {
|
|
11
|
+
const chartsTheme = useChartsTheme();
|
|
12
|
+
const transformedData = useMemo(()=>{
|
|
13
|
+
if (!data) return [];
|
|
14
|
+
return data.buckets.map(([bucket, upperBound, lowerBound, count])=>{
|
|
15
|
+
return {
|
|
16
|
+
value: [
|
|
17
|
+
parseFloat(upperBound),
|
|
18
|
+
parseFloat(lowerBound),
|
|
19
|
+
parseFloat(count),
|
|
20
|
+
bucket
|
|
21
|
+
],
|
|
22
|
+
itemStyle: {
|
|
23
|
+
color: chartsTheme.echartsTheme[0]
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
}, [
|
|
28
|
+
chartsTheme.echartsTheme,
|
|
29
|
+
data
|
|
30
|
+
]);
|
|
31
|
+
const option = useMemo(()=>{
|
|
32
|
+
if (!transformedData) return chartsTheme.noDataOption;
|
|
33
|
+
return {
|
|
34
|
+
title: {
|
|
35
|
+
show: false
|
|
36
|
+
},
|
|
37
|
+
tooltip: {},
|
|
38
|
+
xAxis: {
|
|
39
|
+
scale: false,
|
|
40
|
+
max: Math.ceil(transformedData[transformedData.length - 1]?.value[1] ?? 1)
|
|
41
|
+
},
|
|
42
|
+
yAxis: {},
|
|
43
|
+
series: [
|
|
44
|
+
{
|
|
45
|
+
type: 'custom',
|
|
46
|
+
renderItem: function(params, api) {
|
|
47
|
+
const yValue = api.value(2);
|
|
48
|
+
const start = api.coord([
|
|
49
|
+
api.value(0),
|
|
50
|
+
yValue
|
|
51
|
+
]);
|
|
52
|
+
const size = api.size?.([
|
|
53
|
+
api.value(1) - api.value(0),
|
|
54
|
+
yValue
|
|
55
|
+
]);
|
|
56
|
+
const style = api.style?.();
|
|
57
|
+
return {
|
|
58
|
+
type: 'rect',
|
|
59
|
+
shape: {
|
|
60
|
+
x: start[0],
|
|
61
|
+
y: start[1],
|
|
62
|
+
width: size[0],
|
|
63
|
+
height: size[1]
|
|
64
|
+
},
|
|
65
|
+
style: style
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
label: {
|
|
69
|
+
show: false
|
|
70
|
+
},
|
|
71
|
+
dimensions: [
|
|
72
|
+
'from',
|
|
73
|
+
'to'
|
|
74
|
+
],
|
|
75
|
+
encode: {
|
|
76
|
+
x: [
|
|
77
|
+
0,
|
|
78
|
+
1
|
|
79
|
+
],
|
|
80
|
+
y: 2,
|
|
81
|
+
tooltip: [
|
|
82
|
+
0,
|
|
83
|
+
1
|
|
84
|
+
],
|
|
85
|
+
itemName: 2
|
|
86
|
+
},
|
|
87
|
+
data: transformedData
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
};
|
|
91
|
+
}, [
|
|
92
|
+
chartsTheme.noDataOption,
|
|
93
|
+
transformedData
|
|
94
|
+
]);
|
|
95
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
96
|
+
style: {
|
|
97
|
+
width: width,
|
|
98
|
+
height: height
|
|
99
|
+
},
|
|
100
|
+
sx: {
|
|
101
|
+
overflow: 'auto'
|
|
102
|
+
},
|
|
103
|
+
children: /*#__PURE__*/ _jsx(EChart, {
|
|
104
|
+
sx: {
|
|
105
|
+
minHeight: height
|
|
106
|
+
},
|
|
107
|
+
option: option,
|
|
108
|
+
theme: chartsTheme.echartsTheme
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=HistogramChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/HistogramChart.tsx"],"sourcesContent":["import { Box } from '@mui/material';\nimport { EChart, ModeOption, useChartsTheme } from '@perses-dev/components';\nimport { BucketTuple, FormatOptions } from '@perses-dev/core';\nimport { CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams } from 'echarts';\nimport { CustomChart } from 'echarts/charts';\nimport { EChartsCoreOption, use } from 'echarts/core';\nimport { ReactElement, useMemo } from 'react';\n\nuse([CustomChart]);\n\nexport interface HistogramChartData {\n buckets: BucketTuple[];\n}\n\nexport interface HistogramChartProps {\n width: number;\n height: number;\n data?: HistogramChartData;\n format?: FormatOptions;\n mode?: ModeOption;\n exponential?: boolean;\n}\n\nexport function HistogramChart({ width, height, data }: HistogramChartProps): ReactElement | null {\n const chartsTheme = useChartsTheme();\n\n const transformedData = useMemo(() => {\n if (!data) return [];\n\n return data.buckets.map(([bucket, upperBound, lowerBound, count]) => {\n return {\n value: [parseFloat(upperBound), parseFloat(lowerBound), parseFloat(count), bucket],\n itemStyle: {\n color: chartsTheme.echartsTheme[0],\n },\n };\n });\n }, [chartsTheme.echartsTheme, data]);\n\n const option: EChartsCoreOption = useMemo(() => {\n if (!transformedData) return chartsTheme.noDataOption;\n\n return {\n title: {\n show: false,\n },\n tooltip: {},\n xAxis: {\n scale: false,\n max: Math.ceil(transformedData[transformedData.length - 1]?.value[1] ?? 1),\n },\n yAxis: {},\n series: [\n {\n type: 'custom',\n renderItem: function (params: CustomSeriesRenderItemParams, api: CustomSeriesRenderItemAPI) {\n const yValue = api.value(2);\n const start = api.coord([api.value(0), yValue]);\n const size = api.size?.([(api.value(1) as number) - (api.value(0) as number), yValue]) as number[];\n const style = api.style?.();\n\n return {\n type: 'rect',\n shape: {\n x: start[0],\n y: start[1],\n width: size[0],\n height: size[1],\n },\n style: style,\n };\n },\n label: {\n show: false,\n },\n dimensions: ['from', 'to'],\n encode: {\n x: [0, 1],\n y: 2,\n tooltip: [0, 1],\n itemName: 2,\n },\n data: transformedData,\n },\n ],\n };\n }, [chartsTheme.noDataOption, transformedData]);\n\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{ overflow: 'auto' }}\n >\n <EChart\n sx={{\n minHeight: height,\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n />\n </Box>\n );\n}\n"],"names":["Box","EChart","useChartsTheme","CustomChart","use","useMemo","HistogramChart","width","height","data","chartsTheme","transformedData","buckets","map","bucket","upperBound","lowerBound","count","value","parseFloat","itemStyle","color","echartsTheme","option","noDataOption","title","show","tooltip","xAxis","scale","max","Math","ceil","length","yAxis","series","type","renderItem","params","api","yValue","start","coord","size","style","shape","x","y","label","dimensions","encode","itemName","sx","overflow","minHeight","theme"],"mappings":";AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,MAAM,EAAcC,cAAc,QAAQ,yBAAyB;AAG5E,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAA4BC,GAAG,QAAQ,eAAe;AACtD,SAAuBC,OAAO,QAAQ,QAAQ;AAE9CD,IAAI;IAACD;CAAY;AAejB,OAAO,SAASG,eAAe,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAuB;IACzE,MAAMC,cAAcR;IAEpB,MAAMS,kBAAkBN,QAAQ;QAC9B,IAAI,CAACI,MAAM,OAAO,EAAE;QAEpB,OAAOA,KAAKG,OAAO,CAACC,GAAG,CAAC,CAAC,CAACC,QAAQC,YAAYC,YAAYC,MAAM;YAC9D,OAAO;gBACLC,OAAO;oBAACC,WAAWJ;oBAAaI,WAAWH;oBAAaG,WAAWF;oBAAQH;iBAAO;gBAClFM,WAAW;oBACTC,OAAOX,YAAYY,YAAY,CAAC,EAAE;gBACpC;YACF;QACF;IACF,GAAG;QAACZ,YAAYY,YAAY;QAAEb;KAAK;IAEnC,MAAMc,SAA4BlB,QAAQ;QACxC,IAAI,CAACM,iBAAiB,OAAOD,YAAYc,YAAY;QAErD,OAAO;YACLC,OAAO;gBACLC,MAAM;YACR;YACAC,SAAS,CAAC;YACVC,OAAO;gBACLC,OAAO;gBACPC,KAAKC,KAAKC,IAAI,CAACrB,eAAe,CAACA,gBAAgBsB,MAAM,GAAG,EAAE,EAAEf,KAAK,CAAC,EAAE,IAAI;YAC1E;YACAgB,OAAO,CAAC;YACRC,QAAQ;gBACN;oBACEC,MAAM;oBACNC,YAAY,SAAUC,MAAoC,EAAEC,GAA8B;wBACxF,MAAMC,SAASD,IAAIrB,KAAK,CAAC;wBACzB,MAAMuB,QAAQF,IAAIG,KAAK,CAAC;4BAACH,IAAIrB,KAAK,CAAC;4BAAIsB;yBAAO;wBAC9C,MAAMG,OAAOJ,IAAII,IAAI,GAAG;4BAAEJ,IAAIrB,KAAK,CAAC,KAAiBqB,IAAIrB,KAAK,CAAC;4BAAesB;yBAAO;wBACrF,MAAMI,QAAQL,IAAIK,KAAK;wBAEvB,OAAO;4BACLR,MAAM;4BACNS,OAAO;gCACLC,GAAGL,KAAK,CAAC,EAAE;gCACXM,GAAGN,KAAK,CAAC,EAAE;gCACXlC,OAAOoC,IAAI,CAAC,EAAE;gCACdnC,QAAQmC,IAAI,CAAC,EAAE;4BACjB;4BACAC,OAAOA;wBACT;oBACF;oBACAI,OAAO;wBACLtB,MAAM;oBACR;oBACAuB,YAAY;wBAAC;wBAAQ;qBAAK;oBAC1BC,QAAQ;wBACNJ,GAAG;4BAAC;4BAAG;yBAAE;wBACTC,GAAG;wBACHpB,SAAS;4BAAC;4BAAG;yBAAE;wBACfwB,UAAU;oBACZ;oBACA1C,MAAME;gBACR;aACD;QACH;IACF,GAAG;QAACD,YAAYc,YAAY;QAAEb;KAAgB;IAE9C,qBACE,KAACX;QACC4C,OAAO;YACLrC,OAAOA;YACPC,QAAQA;QACV;QACA4C,IAAI;YAAEC,UAAU;QAAO;kBAEvB,cAAA,KAACpD;YACCmD,IAAI;gBACFE,WAAW9C;YACb;YACAe,QAAQA;YACRgC,OAAO7C,YAAYY,YAAY;;;AAIvC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Labels } from '@perses-dev/core';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
interface SeriesNameProps {
|
|
4
|
+
name: string;
|
|
5
|
+
labels?: Labels;
|
|
6
|
+
formattedName?: string;
|
|
7
|
+
isFormatted?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function SeriesName({ name, labels, formattedName, isFormatted }: SeriesNameProps): ReactElement;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=SeriesName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SeriesName.d.ts","sourceRoot":"","sources":["../../../src/components/SeriesName.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAc,MAAM,OAAO,CAAC;AAIjD,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAMD,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,EAAE,eAAe,GAAG,YAAY,CAKtG"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { useSnackbar } from '@perses-dev/components';
|
|
15
|
+
import { Typography } from '@mui/material';
|
|
16
|
+
/*
|
|
17
|
+
* Display a series with labels in bold and with a copy to clipboard feature if isFormatted is enabled
|
|
18
|
+
* Else it will only display the series in plain text (mostly use for performance reasons)
|
|
19
|
+
*/ export function SeriesName({ name, labels, formattedName, isFormatted }) {
|
|
20
|
+
if (isFormatted && labels && Object.keys(labels).length > 0) {
|
|
21
|
+
return /*#__PURE__*/ _jsx(FormatedSeriesName, {
|
|
22
|
+
labels: labels
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return /*#__PURE__*/ _jsx(Typography, {
|
|
26
|
+
sx: {
|
|
27
|
+
textWrap: 'auto'
|
|
28
|
+
},
|
|
29
|
+
children: formattedName ?? name
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function FormatedSeriesName({ labels }) {
|
|
33
|
+
const { infoSnackbar } = useSnackbar();
|
|
34
|
+
const labelNodes = [];
|
|
35
|
+
let first = true;
|
|
36
|
+
function copyToClipboard(e) {
|
|
37
|
+
const copyText = e.currentTarget.innerText || '';
|
|
38
|
+
navigator.clipboard.writeText(copyText.trim()).then(()=>{
|
|
39
|
+
infoSnackbar(`Copied label matcher: ${copyText}`);
|
|
40
|
+
}).catch((reason)=>{
|
|
41
|
+
console.error(`unable to copy text: ${reason}`);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
for(const label in labels){
|
|
45
|
+
if (label === '__name__') {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
labelNodes.push(/*#__PURE__*/ _jsxs("span", {
|
|
49
|
+
children: [
|
|
50
|
+
!first && ', ',
|
|
51
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
52
|
+
display: "inline",
|
|
53
|
+
component: "span",
|
|
54
|
+
sx: {
|
|
55
|
+
'&:hover': {
|
|
56
|
+
cursor: 'pointer',
|
|
57
|
+
textDecoration: 'underline'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
onClick: copyToClipboard,
|
|
61
|
+
title: "Click to copy label matcher",
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
64
|
+
children: label
|
|
65
|
+
}),
|
|
66
|
+
"=",
|
|
67
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
68
|
+
children: [
|
|
69
|
+
'"',
|
|
70
|
+
labels[label],
|
|
71
|
+
'"'
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
})
|
|
76
|
+
]
|
|
77
|
+
}, label));
|
|
78
|
+
if (first) {
|
|
79
|
+
first = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return /*#__PURE__*/ _jsxs(Typography, {
|
|
83
|
+
sx: {
|
|
84
|
+
textWrap: 'auto'
|
|
85
|
+
},
|
|
86
|
+
children: [
|
|
87
|
+
labels ? labels.__name__ : '',
|
|
88
|
+
'{',
|
|
89
|
+
labelNodes,
|
|
90
|
+
'}'
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//# sourceMappingURL=SeriesName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/SeriesName.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Labels } from '@perses-dev/core';\nimport { ReactElement, MouseEvent } from 'react';\nimport { useSnackbar } from '@perses-dev/components';\nimport { Typography } from '@mui/material';\n\ninterface SeriesNameProps {\n name: string;\n labels?: Labels;\n formattedName?: string;\n isFormatted?: boolean;\n}\n\n/*\n * Display a series with labels in bold and with a copy to clipboard feature if isFormatted is enabled\n * Else it will only display the series in plain text (mostly use for performance reasons)\n */\nexport function SeriesName({ name, labels, formattedName, isFormatted }: SeriesNameProps): ReactElement {\n if (isFormatted && labels && Object.keys(labels).length > 0) {\n return <FormatedSeriesName labels={labels} />;\n }\n return <Typography sx={{ textWrap: 'auto' }}>{formattedName ?? name}</Typography>;\n}\n\nfunction FormatedSeriesName({ labels }: { labels: Labels }): ReactElement {\n const { infoSnackbar } = useSnackbar();\n\n const labelNodes: ReactElement[] = [];\n let first = true;\n\n function copyToClipboard(e: MouseEvent<HTMLSpanElement>): void {\n const copyText = e.currentTarget.innerText || '';\n navigator.clipboard\n .writeText(copyText.trim())\n .then(() => {\n infoSnackbar(`Copied label matcher: ${copyText}`);\n })\n .catch((reason) => {\n console.error(`unable to copy text: ${reason}`);\n });\n }\n\n for (const label in labels) {\n if (label === '__name__') {\n continue;\n }\n\n labelNodes.push(\n <span key={label}>\n {!first && ', '}\n <Typography\n display=\"inline\"\n component=\"span\"\n sx={{\n '&:hover': {\n cursor: 'pointer',\n textDecoration: 'underline',\n },\n }}\n onClick={copyToClipboard}\n title=\"Click to copy label matcher\"\n >\n <strong>{label}</strong>=<span>"{labels[label]}"</span>\n </Typography>\n </span>\n );\n\n if (first) {\n first = false;\n }\n }\n\n return (\n <Typography sx={{ textWrap: 'auto' }}>\n {labels ? labels.__name__ : ''}\n {'{'}\n {labelNodes}\n {'}'}\n </Typography>\n );\n}\n"],"names":["useSnackbar","Typography","SeriesName","name","labels","formattedName","isFormatted","Object","keys","length","FormatedSeriesName","sx","textWrap","infoSnackbar","labelNodes","first","copyToClipboard","e","copyText","currentTarget","innerText","navigator","clipboard","writeText","trim","then","catch","reason","console","error","label","push","span","display","component","cursor","textDecoration","onClick","title","strong","__name__"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAIjC,SAASA,WAAW,QAAQ,yBAAyB;AACrD,SAASC,UAAU,QAAQ,gBAAgB;AAS3C;;;CAGC,GACD,OAAO,SAASC,WAAW,EAAEC,IAAI,EAAEC,MAAM,EAAEC,aAAa,EAAEC,WAAW,EAAmB;IACtF,IAAIA,eAAeF,UAAUG,OAAOC,IAAI,CAACJ,QAAQK,MAAM,GAAG,GAAG;QAC3D,qBAAO,KAACC;YAAmBN,QAAQA;;IACrC;IACA,qBAAO,KAACH;QAAWU,IAAI;YAAEC,UAAU;QAAO;kBAAIP,iBAAiBF;;AACjE;AAEA,SAASO,mBAAmB,EAAEN,MAAM,EAAsB;IACxD,MAAM,EAAES,YAAY,EAAE,GAAGb;IAEzB,MAAMc,aAA6B,EAAE;IACrC,IAAIC,QAAQ;IAEZ,SAASC,gBAAgBC,CAA8B;QACrD,MAAMC,WAAWD,EAAEE,aAAa,CAACC,SAAS,IAAI;QAC9CC,UAAUC,SAAS,CAChBC,SAAS,CAACL,SAASM,IAAI,IACvBC,IAAI,CAAC;YACJZ,aAAa,CAAC,sBAAsB,EAAEK,UAAU;QAClD,GACCQ,KAAK,CAAC,CAACC;YACNC,QAAQC,KAAK,CAAC,CAAC,qBAAqB,EAAEF,QAAQ;QAChD;IACJ;IAEA,IAAK,MAAMG,SAAS1B,OAAQ;QAC1B,IAAI0B,UAAU,YAAY;YACxB;QACF;QAEAhB,WAAWiB,IAAI,eACb,MAACC;;gBACE,CAACjB,SAAS;8BACX,MAACd;oBACCgC,SAAQ;oBACRC,WAAU;oBACVvB,IAAI;wBACF,WAAW;4BACTwB,QAAQ;4BACRC,gBAAgB;wBAClB;oBACF;oBACAC,SAASrB;oBACTsB,OAAM;;sCAEN,KAACC;sCAAQT;;wBAAe;sCAAC,MAACE;;gCAAK;gCAAO5B,MAAM,CAAC0B,MAAM;gCAAC;;;;;;WAd7CA;QAmBb,IAAIf,OAAO;YACTA,QAAQ;QACV;IACF;IAEA,qBACE,MAACd;QAAWU,IAAI;YAAEC,UAAU;QAAO;;YAChCR,SAASA,OAAOoC,QAAQ,GAAG;YAC3B;YACA1B;YACA;;;AAGP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/index.ts"],"sourcesContent":["export * from './DataTable';\nexport * from './HistogramChart';\nexport * from './SeriesName';\n"],"names":[],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,eAAe"}
|
package/lib/env.d.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
/// <reference types="@rsbuild/core/types" />
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=env.d.js.map
|
package/lib/env.d.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/env.d.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6CAA6C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import packageJson from '../package.json';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the plugin module information from package.json
|
|
4
|
+
*/ export function getPluginModule() {
|
|
5
|
+
const { name, version, perses } = packageJson;
|
|
6
|
+
return {
|
|
7
|
+
kind: 'PluginModule',
|
|
8
|
+
metadata: {
|
|
9
|
+
name,
|
|
10
|
+
version
|
|
11
|
+
},
|
|
12
|
+
spec: perses
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=getPluginModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AACA,OAAOA,iBAAiB,kBAAkB;AAE1C;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAClC,OAAO;QACLK,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index-federation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-federation.d.ts","sourceRoot":"","sources":["../../src/index-federation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import('./bootstrap');
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index-federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index-federation.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport('./bootstrap');\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,MAAM,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './components/DataTable';
|
|
2
|
+
export { getPluginModule } from './getPluginModule';
|
|
3
|
+
export * from './model';
|
|
4
|
+
export * from './components/SeriesName';
|
|
5
|
+
export * from './TimeSeriesTable';
|
|
6
|
+
export * from './TimeSeriesTablePanel';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,SAAS,CAAC;AACxB,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './components/DataTable';
|
|
2
|
+
export { getPluginModule } from './getPluginModule';
|
|
3
|
+
export * from './model';
|
|
4
|
+
export * from './components/SeriesName';
|
|
5
|
+
export * from './TimeSeriesTable';
|
|
6
|
+
export * from './TimeSeriesTablePanel';
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './components/DataTable';\nexport { getPluginModule } from './getPluginModule';\nexport * from './model';\nexport * from './components/SeriesName';\nexport * from './TimeSeriesTable';\nexport * from './TimeSeriesTablePanel';\n"],"names":["getPluginModule"],"mappings":"AAAA,cAAc,yBAAyB;AACvC,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU;AACxB,cAAc,0BAA0B;AACxC,cAAc,oBAAoB;AAClC,cAAc,yBAAyB"}
|
package/lib/model.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,sBAAsB;CAAG"}
|
package/lib/model.js
ADDED