@openshift-migration-advisor/shared-components 0.25.0 → 0.27.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/README.md +25 -0
- package/dist/report/ChartDownloadButton.d.ts +11 -0
- package/dist/report/ChartDownloadButton.d.ts.map +1 -0
- package/dist/report/ChartDownloadButton.js +24 -0
- package/dist/report/ChartExportProvider.d.ts +22 -0
- package/dist/report/ChartExportProvider.d.ts.map +1 -0
- package/dist/report/ChartExportProvider.js +222 -0
- package/dist/report/ChartExportSurface.d.ts +12 -0
- package/dist/report/ChartExportSurface.d.ts.map +1 -0
- package/dist/report/ChartExportSurface.js +32 -0
- package/dist/report/ErrorTable.d.ts +18 -0
- package/dist/report/ErrorTable.d.ts.map +1 -0
- package/dist/report/ErrorTable.js +20 -0
- package/dist/report/HostPowerStates.d.ts +0 -1
- package/dist/report/HostPowerStates.d.ts.map +1 -1
- package/dist/report/HostPowerStates.js +2 -2
- package/dist/report/HostsOverview.d.ts +13 -0
- package/dist/report/HostsOverview.d.ts.map +1 -0
- package/dist/report/HostsOverview.js +84 -0
- package/dist/report/InfrastructureSummary.d.ts.map +1 -1
- package/dist/report/InfrastructureSummary.js +6 -2
- package/dist/report/NetworkOverview.d.ts +31 -0
- package/dist/report/NetworkOverview.d.ts.map +1 -0
- package/dist/report/NetworkOverview.js +201 -0
- package/dist/report/OSDistribution.d.ts +0 -2
- package/dist/report/OSDistribution.d.ts.map +1 -1
- package/dist/report/OSDistribution.js +8 -5
- package/dist/report/OsUpgradeRecommendationPopover.d.ts +0 -1
- package/dist/report/OsUpgradeRecommendationPopover.d.ts.map +1 -1
- package/dist/report/OsUpgradeRecommendationPopover.js +4 -3
- package/dist/report/PowerStateCard.d.ts +0 -1
- package/dist/report/PowerStateCard.d.ts.map +1 -1
- package/dist/report/PowerStateCard.js +4 -2
- package/dist/report/ReportExportMenu.d.ts +19 -0
- package/dist/report/ReportExportMenu.d.ts.map +1 -0
- package/dist/report/ReportExportMenu.js +31 -0
- package/dist/report/ReportTable.d.ts +14 -0
- package/dist/report/ReportTable.d.ts.map +1 -0
- package/dist/report/ReportTable.js +23 -0
- package/dist/report/SupportTierBadge.d.ts +0 -1
- package/dist/report/SupportTierBadge.d.ts.map +1 -1
- package/dist/report/SupportTierBadge.js +1 -21
- package/dist/report/VCenterClusterDetails.d.ts +0 -1
- package/dist/report/VCenterClusterDetails.d.ts.map +1 -1
- package/dist/report/VCenterClusterDetails.js +9 -4
- package/dist/report/VmPowerStates.d.ts +0 -1
- package/dist/report/VmPowerStates.d.ts.map +1 -1
- package/dist/report/VmPowerStates.js +2 -2
- package/dist/report/WarningsTable.d.ts +9 -0
- package/dist/report/WarningsTable.d.ts.map +1 -0
- package/dist/report/WarningsTable.js +20 -0
- package/dist/report/captureChartElement.d.ts +8 -0
- package/dist/report/captureChartElement.d.ts.map +1 -0
- package/dist/report/captureChartElement.js +284 -0
- package/dist/report/chartExport.d.ts +57 -0
- package/dist/report/chartExport.d.ts.map +1 -0
- package/dist/report/chartExport.js +162 -0
- package/dist/report/chartExportContext.d.ts +28 -0
- package/dist/report/chartExportContext.d.ts.map +1 -0
- package/dist/report/chartExportContext.js +36 -0
- package/dist/report/chartExportFilenames.d.ts +4 -0
- package/dist/report/chartExportFilenames.d.ts.map +1 -0
- package/dist/report/chartExportFilenames.js +16 -0
- package/dist/report/constants.d.ts +2 -0
- package/dist/report/constants.d.ts.map +1 -1
- package/dist/report/constants.js +2 -0
- package/dist/report/dashboardStyles.d.ts +0 -4
- package/dist/report/dashboardStyles.d.ts.map +1 -1
- package/dist/report/dashboardStyles.js +0 -19
- package/dist/report/htmlExport.d.ts +9 -0
- package/dist/report/htmlExport.d.ts.map +1 -0
- package/dist/report/htmlExport.js +65 -0
- package/dist/report/index.d.ts +18 -0
- package/dist/report/index.d.ts.map +1 -1
- package/dist/report/index.js +18 -0
- package/dist/report/pdfExport.d.ts +3 -0
- package/dist/report/pdfExport.d.ts.map +1 -0
- package/dist/report/pdfExport.js +82 -0
- package/dist/report/pdfPage.d.ts +15 -0
- package/dist/report/pdfPage.d.ts.map +1 -0
- package/dist/report/pdfPage.js +44 -0
- package/dist/report/reportExportOptions.d.ts +17 -0
- package/dist/report/reportExportOptions.d.ts.map +1 -0
- package/dist/report/reportExportOptions.js +31 -0
- package/dist/report/zipChartPngs.d.ts +3 -0
- package/dist/report/zipChartPngs.d.ts.map +1 -0
- package/dist/report/zipChartPngs.js +8 -0
- package/package.json +7 -2
- package/src/report/ChartDownloadButton.tsx +59 -0
- package/src/report/ChartExportProvider.tsx +384 -0
- package/src/report/ChartExportSurface.tsx +60 -0
- package/src/report/ErrorTable.tsx +85 -0
- package/src/report/HostPowerStates.tsx +0 -3
- package/src/report/HostsOverview.tsx +185 -0
- package/src/report/InfrastructureSummary.tsx +48 -31
- package/src/report/NetworkOverview.tsx +405 -0
- package/src/report/OSDistribution.tsx +46 -42
- package/src/report/OsUpgradeRecommendationPopover.tsx +3 -4
- package/src/report/PowerStateCard.tsx +49 -36
- package/src/report/ReportExportMenu.tsx +119 -0
- package/src/report/ReportTable.tsx +81 -0
- package/src/report/SupportTierBadge.tsx +12 -40
- package/src/report/VCenterClusterDetails.tsx +38 -16
- package/src/report/VmPowerStates.tsx +0 -3
- package/src/report/WarningsTable.tsx +75 -0
- package/src/report/__tests__/ChartExportProvider.test.tsx +474 -0
- package/src/report/__tests__/HostsOverview.test.tsx +145 -0
- package/src/report/__tests__/InfrastructureSummary.test.tsx +0 -22
- package/src/report/__tests__/NetworkOverview.test.tsx +269 -0
- package/src/report/__tests__/OSDistribution.test.tsx +10 -11
- package/src/report/__tests__/captureChartElement.test.ts +132 -0
- package/src/report/__tests__/chartExportPackagers.test.ts +224 -0
- package/src/report/captureChartElement.ts +368 -0
- package/src/report/chartExport.ts +237 -0
- package/src/report/chartExportContext.tsx +84 -0
- package/src/report/chartExportFilenames.ts +21 -0
- package/src/report/constants.ts +2 -0
- package/src/report/dashboardStyles.ts +0 -23
- package/src/report/htmlExport.ts +83 -0
- package/src/report/index.ts +95 -0
- package/src/report/pdfExport.ts +154 -0
- package/src/report/pdfPage.ts +83 -0
- package/src/report/reportExportOptions.ts +53 -0
- package/src/report/zipChartPngs.ts +10 -0
|
@@ -39,20 +39,9 @@ export const dashboardStyles = {
|
|
|
39
39
|
flex-direction: column;
|
|
40
40
|
justify-content: space-between;
|
|
41
41
|
overflow: hidden !important;
|
|
42
|
-
`,
|
|
43
|
-
cardPrint: css `
|
|
44
|
-
border: 1px solid #d2d2d2 !important;
|
|
45
|
-
border-radius: 10px;
|
|
46
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
47
|
-
min-height: unset;
|
|
48
|
-
max-height: unset;
|
|
49
|
-
page-break-inside: avoid;
|
|
50
42
|
`,
|
|
51
43
|
storageCardOverflowHidden: css `
|
|
52
44
|
overflow: hidden;
|
|
53
|
-
`,
|
|
54
|
-
storageCardOverflowVisible: css `
|
|
55
|
-
overflow: visible;
|
|
56
45
|
`,
|
|
57
46
|
storageChartWrapper: css `
|
|
58
47
|
display: flex;
|
|
@@ -60,14 +49,6 @@ export const dashboardStyles = {
|
|
|
60
49
|
align-items: center;
|
|
61
50
|
width: 100%;
|
|
62
51
|
padding: 20px 0;
|
|
63
|
-
`,
|
|
64
|
-
storageExportSectionMargin: css `
|
|
65
|
-
margin-bottom: 24px;
|
|
66
|
-
`,
|
|
67
|
-
storageExportSectionTitle: css `
|
|
68
|
-
font-size: 14px;
|
|
69
|
-
font-weight: 600;
|
|
70
|
-
margin-bottom: 12px;
|
|
71
52
|
`,
|
|
72
53
|
storageFlexFullWidth: css `
|
|
73
54
|
width: 100%;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ChartCaptureSource } from "./chartExport.js";
|
|
2
|
+
export interface HtmlReportImage {
|
|
3
|
+
name: string;
|
|
4
|
+
dataUrl: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function escapeHtml(value: string): string;
|
|
7
|
+
export declare function buildHtmlReport(documentTitle: string, images: HtmlReportImage[], generatedAt?: Date): string;
|
|
8
|
+
export declare function buildHtmlFromCharts(charts: ChartCaptureSource[], documentTitle: string): Promise<Blob>;
|
|
9
|
+
//# sourceMappingURL=htmlExport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"htmlExport.d.ts","sourceRoot":"","sources":["../../src/report/htmlExport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAiB,MAAM,kBAAkB,CAAC;AAE1E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,eAAe,EAAE,EACzB,WAAW,OAAa,GACvB,MAAM,CAwCR;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { releaseCanvas } from "./chartExport.js";
|
|
2
|
+
export function escapeHtml(value) {
|
|
3
|
+
return value
|
|
4
|
+
.replace(/&/g, "&")
|
|
5
|
+
.replace(/</g, "<")
|
|
6
|
+
.replace(/>/g, ">")
|
|
7
|
+
.replace(/"/g, """)
|
|
8
|
+
.replace(/'/g, "'");
|
|
9
|
+
}
|
|
10
|
+
export function buildHtmlReport(documentTitle, images, generatedAt = new Date()) {
|
|
11
|
+
const sections = images
|
|
12
|
+
.map((image) => `
|
|
13
|
+
<section>
|
|
14
|
+
<h2>${escapeHtml(image.name)}</h2>
|
|
15
|
+
<img src="${image.dataUrl}" alt="${escapeHtml(image.name)}" />
|
|
16
|
+
</section>`)
|
|
17
|
+
.join("\n");
|
|
18
|
+
return `<!DOCTYPE html>
|
|
19
|
+
<html lang="en">
|
|
20
|
+
<head>
|
|
21
|
+
<meta charset="utf-8" />
|
|
22
|
+
<title>${escapeHtml(documentTitle)}</title>
|
|
23
|
+
<style>
|
|
24
|
+
body {
|
|
25
|
+
font-family: RedHatText, Helvetica, Arial, sans-serif;
|
|
26
|
+
margin: 32px auto;
|
|
27
|
+
max-width: 1100px;
|
|
28
|
+
background: #fff;
|
|
29
|
+
color: #151515;
|
|
30
|
+
}
|
|
31
|
+
h1 { font-size: 28px; margin-bottom: 8px; }
|
|
32
|
+
h2 { font-size: 18px; margin: 32px 0 12px; }
|
|
33
|
+
.meta { color: #6a6e73; margin-bottom: 24px; }
|
|
34
|
+
img {
|
|
35
|
+
width: 100%;
|
|
36
|
+
height: auto;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
39
|
+
</head>
|
|
40
|
+
<body>
|
|
41
|
+
<h1>${escapeHtml(documentTitle)}</h1>
|
|
42
|
+
<p class="meta">Generated ${escapeHtml(generatedAt.toLocaleString())}</p>
|
|
43
|
+
${sections}
|
|
44
|
+
</body>
|
|
45
|
+
</html>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
export async function buildHtmlFromCharts(charts, documentTitle) {
|
|
49
|
+
const images = [];
|
|
50
|
+
for (const chart of charts) {
|
|
51
|
+
const canvas = await chart.capture();
|
|
52
|
+
try {
|
|
53
|
+
images.push({
|
|
54
|
+
name: chart.title,
|
|
55
|
+
dataUrl: canvas.toDataURL("image/png"),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
releaseCanvas(canvas);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return new Blob([buildHtmlReport(documentTitle, images)], {
|
|
63
|
+
type: "text/html;charset=utf-8",
|
|
64
|
+
});
|
|
65
|
+
}
|
package/dist/report/index.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
export { CARD_EMPTY_STATE_DESCRIPTION, CardEmptyState, type CardEmptyStateProps, } from "./CardEmptyState.js";
|
|
2
|
+
export { ChartDownloadButton, ChartHeaderActions, } from "./ChartDownloadButton.js";
|
|
3
|
+
export { type BuildChartDocument, type CaptureChartElement, ChartExportProvider, type ChartExportProviderProps, type EncodeChartPng, type ZipChartFiles, } from "./ChartExportProvider.js";
|
|
4
|
+
export { ChartExportSurface } from "./ChartExportSurface.js";
|
|
5
|
+
export { captureChartElement } from "./captureChartElement.js";
|
|
6
|
+
export { CHART_EXPORT_CAPTURING_ATTR, CHART_EXPORT_HIDE_ATTR, CHART_EXPORT_SCROLL_ATTR, type ChartCaptureSource, type ChartExportFile, type ChartExportMeta, type ChartExportView, canvasToBlob, chartExportHideProps, chartExportRootStyle, chartExportScrollProps, chartExportViewsFromLabels, chartPngFilename, downloadBlob, type RegisteredChart, releaseCanvas, restoreChartExportViews, shouldIgnoreChartExportElement, slugifyExportName, sortRegisteredChartsByDocumentOrder, toBulkChartCaptureSources, } from "./chartExport.js";
|
|
7
|
+
export { type ChartExportApi, type ChartExportFormat, useChartExport, useRegisterChart, } from "./chartExportContext.js";
|
|
8
|
+
export { getChartExportFilename, getChartZipFilename, getDatedChartExportBasename, } from "./chartExportFilenames.js";
|
|
2
9
|
export { chartColorFailure, chartColorSuccess, REPORT_CARD_EMPTY_STATE_TITLES, } from "./constants.js";
|
|
3
10
|
export { DashboardEmptyStateBase, type DashboardEmptyStateBaseProps, } from "./DashboardEmptyStateBase.js";
|
|
4
11
|
export { dashboardStyles, tableFullWidthStyle } from "./dashboardStyles.js";
|
|
5
12
|
export { EmptySearchResults, type EmptySearchResultsProps, } from "./EmptySearchResults.js";
|
|
13
|
+
export { ErrorTable, type ErrorTableProps, type MigrationIssueLike, } from "./ErrorTable.js";
|
|
6
14
|
export { FeatureStatusBadge, type FeatureStatusBadgeProps, } from "./FeatureStatusBadge.js";
|
|
7
15
|
export { HostPowerStates, type HostPowerStatesProps, } from "./HostPowerStates.js";
|
|
16
|
+
export { type HostLike, HostsOverview, type HostsOverviewProps, } from "./HostsOverview.js";
|
|
17
|
+
export { buildHtmlFromCharts, buildHtmlReport, escapeHtml, type HtmlReportImage, } from "./htmlExport.js";
|
|
8
18
|
export { InfrastructureSummary, type InfrastructureSummaryProps, } from "./InfrastructureSummary.js";
|
|
9
19
|
export type { ClusterDetailRow, ClusterDetailsModel, FeatureStatus, HostCapability, InfrastructureSummaryModel, InventoryCluster, InventoryDatastore, InventoryHost, InventoryInfra, InventoryNetwork, InventoryVms, NetworkLabel, } from "./infrastructureSummaryModel.js";
|
|
10
20
|
export { booleanToFeatureStatus, buildClusterDetailRows, buildClusterDetails, buildInfrastructureSummary, countVCenters, formatVSphereVersion, hostCapabilityStatus, visibleNetworks, vsanStatus, } from "./infrastructureSummaryModel.js";
|
|
21
|
+
export { type NetworkInfraLike, type NetworkLike, NetworkOverview, type NetworkOverviewProps, type NicCountHistogram, type NicCountSummary, } from "./NetworkOverview.js";
|
|
11
22
|
export { OSBarChart, OSDistribution } from "./OSDistribution.js";
|
|
12
23
|
export { OsSupportTiersHelpPopover } from "./OsSupportTiersHelpPopover.js";
|
|
13
24
|
export { OsUpgradeNotice } from "./OsUpgradeNotice.js";
|
|
@@ -16,10 +27,17 @@ export type { OSDistributionEntry, SupportTierBadgeStyle, } from "./osSupportTie
|
|
|
16
27
|
export { getSupportTierBadgeColor, getSupportTierBadgeInlineStyle, getSupportTierDefinition, getSupportTierLegendLabel, getSupportTierSortOrder, hasOsUpgradeNotice, ORDERED_SUPPORT_TIERS, resolveSupportTier, SUPPORT_TIER_BADGE_COLORS, SUPPORT_TIER_BADGE_INLINE_STYLES, SUPPORT_TIER_DEFINITIONS, SUPPORT_TIER_LABELS, SUPPORT_TIER_LEARN_MORE_URL, SupportTier, } from "./osSupportTier.js";
|
|
17
28
|
export { default as PopoverIcon } from "./PopoverIcon.js";
|
|
18
29
|
export { PowerStateCard, type PowerStateCardProps, } from "./PowerStateCard.js";
|
|
30
|
+
export { buildPdfFromCharts } from "./pdfExport.js";
|
|
31
|
+
export { type PdfExportSegment, sliceCanvas, splitSegmentForPageHeight, } from "./pdfPage.js";
|
|
19
32
|
export type { PowerStateChartModel } from "./powerStates.js";
|
|
20
33
|
export { buildHostPowerStateChart, buildVmPowerStateChart, HOST_POWER_COLORS, VM_POWER_COLORS, } from "./powerStates.js";
|
|
34
|
+
export { ExportReportButton, type ExportReportButtonProps, ReportExportMenu, type ReportExportMenuProps, } from "./ReportExportMenu.js";
|
|
35
|
+
export { ReportTable, type ReportTableProps } from "./ReportTable.js";
|
|
36
|
+
export { type ReportExportOption, type StandardReportExportHandlers, standardReportExportOptions, } from "./reportExportOptions.js";
|
|
21
37
|
export { SupportTierBadge } from "./SupportTierBadge.js";
|
|
22
38
|
export { ALL_TIERS_FILTER, type OsBarChartViewModel, type OsTableRow, useOsBarChartViewModel, } from "./useOsBarChartViewModel.js";
|
|
23
39
|
export { VCenterClusterDetails, type VCenterClusterDetailsProps, } from "./VCenterClusterDetails.js";
|
|
24
40
|
export { VmPowerStates, type VmPowerStatesProps, } from "./VmPowerStates.js";
|
|
41
|
+
export { WarningsTable, type WarningsTableProps, } from "./WarningsTable.js";
|
|
42
|
+
export { zipChartPngs } from "./zipChartPngs.js";
|
|
25
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,cAAc,EACd,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,8BAA8B,GAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,KAAK,4BAA4B,GAClC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,kBAAkB,EACl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AAc,EACd,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/report/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,cAAc,EACd,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,sBAAsB,EACtB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,KAAK,eAAe,E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AsB,EACtB,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,gBAAgB,EAChB,KAAK,qBAAqB,GAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,4BAA4B,EACjC,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EACL,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/report/index.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
export { CARD_EMPTY_STATE_DESCRIPTION, CardEmptyState, } from "./CardEmptyState.js";
|
|
2
|
+
export { ChartDownloadButton, ChartHeaderActions, } from "./ChartDownloadButton.js";
|
|
3
|
+
export { ChartExportProvider, } from "./ChartExportProvider.js";
|
|
4
|
+
export { ChartExportSurface } from "./ChartExportSurface.js";
|
|
5
|
+
export { captureChartElement } from "./captureChartElement.js";
|
|
6
|
+
export { CHART_EXPORT_CAPTURING_ATTR, CHART_EXPORT_HIDE_ATTR, CHART_EXPORT_SCROLL_ATTR, canvasToBlob, chartExportHideProps, chartExportRootStyle, chartExportScrollProps, chartExportViewsFromLabels, chartPngFilename, downloadBlob, releaseCanvas, restoreChartExportViews, shouldIgnoreChartExportElement, slugifyExportName, sortRegisteredChartsByDocumentOrder, toBulkChartCaptureSources, } from "./chartExport.js";
|
|
7
|
+
export { useChartExport, useRegisterChart, } from "./chartExportContext.js";
|
|
8
|
+
export { getChartExportFilename, getChartZipFilename, getDatedChartExportBasename, } from "./chartExportFilenames.js";
|
|
2
9
|
export { chartColorFailure, chartColorSuccess, REPORT_CARD_EMPTY_STATE_TITLES, } from "./constants.js";
|
|
3
10
|
export { DashboardEmptyStateBase, } from "./DashboardEmptyStateBase.js";
|
|
4
11
|
export { dashboardStyles, tableFullWidthStyle } from "./dashboardStyles.js";
|
|
5
12
|
export { EmptySearchResults, } from "./EmptySearchResults.js";
|
|
13
|
+
export { ErrorTable, } from "./ErrorTable.js";
|
|
6
14
|
export { FeatureStatusBadge, } from "./FeatureStatusBadge.js";
|
|
7
15
|
export { HostPowerStates, } from "./HostPowerStates.js";
|
|
16
|
+
export { HostsOverview, } from "./HostsOverview.js";
|
|
17
|
+
export { buildHtmlFromCharts, buildHtmlReport, escapeHtml, } from "./htmlExport.js";
|
|
8
18
|
export { InfrastructureSummary, } from "./InfrastructureSummary.js";
|
|
9
19
|
export { booleanToFeatureStatus, buildClusterDetailRows, buildClusterDetails, buildInfrastructureSummary, countVCenters, formatVSphereVersion, hostCapabilityStatus, visibleNetworks, vsanStatus, } from "./infrastructureSummaryModel.js";
|
|
20
|
+
export { NetworkOverview, } from "./NetworkOverview.js";
|
|
10
21
|
export { OSBarChart, OSDistribution } from "./OSDistribution.js";
|
|
11
22
|
export { OsSupportTiersHelpPopover } from "./OsSupportTiersHelpPopover.js";
|
|
12
23
|
export { OsUpgradeNotice } from "./OsUpgradeNotice.js";
|
|
@@ -14,8 +25,15 @@ export { OsNameCell, OsUpgradeRecommendationPopover, } from "./OsUpgradeRecommen
|
|
|
14
25
|
export { getSupportTierBadgeColor, getSupportTierBadgeInlineStyle, getSupportTierDefinition, getSupportTierLegendLabel, getSupportTierSortOrder, hasOsUpgradeNotice, ORDERED_SUPPORT_TIERS, resolveSupportTier, SUPPORT_TIER_BADGE_COLORS, SUPPORT_TIER_BADGE_INLINE_STYLES, SUPPORT_TIER_DEFINITIONS, SUPPORT_TIER_LABELS, SUPPORT_TIER_LEARN_MORE_URL, SupportTier, } from "./osSupportTier.js";
|
|
15
26
|
export { default as PopoverIcon } from "./PopoverIcon.js";
|
|
16
27
|
export { PowerStateCard, } from "./PowerStateCard.js";
|
|
28
|
+
export { buildPdfFromCharts } from "./pdfExport.js";
|
|
29
|
+
export { sliceCanvas, splitSegmentForPageHeight, } from "./pdfPage.js";
|
|
17
30
|
export { buildHostPowerStateChart, buildVmPowerStateChart, HOST_POWER_COLORS, VM_POWER_COLORS, } from "./powerStates.js";
|
|
31
|
+
export { ExportReportButton, ReportExportMenu, } from "./ReportExportMenu.js";
|
|
32
|
+
export { ReportTable } from "./ReportTable.js";
|
|
33
|
+
export { standardReportExportOptions, } from "./reportExportOptions.js";
|
|
18
34
|
export { SupportTierBadge } from "./SupportTierBadge.js";
|
|
19
35
|
export { ALL_TIERS_FILTER, useOsBarChartViewModel, } from "./useOsBarChartViewModel.js";
|
|
20
36
|
export { VCenterClusterDetails, } from "./VCenterClusterDetails.js";
|
|
21
37
|
export { VmPowerStates, } from "./VmPowerStates.js";
|
|
38
|
+
export { WarningsTable, } from "./WarningsTable.js";
|
|
39
|
+
export { zipChartPngs } from "./zipChartPngs.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdfExport.d.ts","sourceRoot":"","sources":["../../src/report/pdfExport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,EAAiB,MAAM,kBAAkB,CAAC;AAQ1E,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,kBAAkB,EAAE,EAC5B,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC,CAuDf"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import jsPDF from "jspdf";
|
|
2
|
+
import { releaseCanvas } from "./chartExport.js";
|
|
3
|
+
import { fitPdfImageSize, placePdfBlock, sliceCanvas } from "./pdfPage.js";
|
|
4
|
+
const MARGIN_MM = 10;
|
|
5
|
+
const GAP_MM = 8;
|
|
6
|
+
/** Flatten captures onto white; jsPDF cannot embed transparent PNG alpha cleanly. */
|
|
7
|
+
const PAGE_BACKGROUND = "#ffffff";
|
|
8
|
+
export async function buildPdfFromCharts(charts, documentTitle) {
|
|
9
|
+
const pdf = new jsPDF("p", "mm", "a4");
|
|
10
|
+
const pageWidth = pdf.internal.pageSize.getWidth();
|
|
11
|
+
const pageHeight = pdf.internal.pageSize.getHeight();
|
|
12
|
+
const contentWidth = pageWidth - MARGIN_MM * 2;
|
|
13
|
+
const contentHeight = pageHeight - MARGIN_MM * 2;
|
|
14
|
+
const pageTop = MARGIN_MM;
|
|
15
|
+
const pageBottom = pageHeight - MARGIN_MM;
|
|
16
|
+
addCoverPage(pdf, documentTitle, charts.map((chart) => chart.title), pageWidth, pageHeight);
|
|
17
|
+
let cursorY = null;
|
|
18
|
+
for (const chart of charts) {
|
|
19
|
+
const canvas = await chart.capture();
|
|
20
|
+
try {
|
|
21
|
+
if (canvas.width < 1 || canvas.height < 1) {
|
|
22
|
+
throw new Error("Chart capture produced an empty image");
|
|
23
|
+
}
|
|
24
|
+
const size = fitPdfImageSize(canvas.width, canvas.height, contentWidth, contentHeight);
|
|
25
|
+
const placement = placePdfBlock(cursorY, size.heightMm, pageTop, pageBottom);
|
|
26
|
+
if (placement.needsNewPage) {
|
|
27
|
+
pdf.addPage();
|
|
28
|
+
}
|
|
29
|
+
addChartImage(pdf, canvas, MARGIN_MM + (contentWidth - size.widthMm) / 2, placement.y, size.widthMm, size.heightMm);
|
|
30
|
+
cursorY = placement.y + size.heightMm + GAP_MM;
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
releaseCanvas(canvas);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
addPageNumbers(pdf, pageWidth, pageHeight);
|
|
37
|
+
return pdf.output("blob");
|
|
38
|
+
}
|
|
39
|
+
function addCoverPage(pdf, documentTitle, tocItems, pageWidth, pageHeight) {
|
|
40
|
+
const contentWidth = pageWidth - MARGIN_MM * 2;
|
|
41
|
+
pdf.setFontSize(18);
|
|
42
|
+
const titleLines = pdf.splitTextToSize(documentTitle, contentWidth);
|
|
43
|
+
let titleY = MARGIN_MM + 8;
|
|
44
|
+
for (const line of titleLines) {
|
|
45
|
+
pdf.text(line, pageWidth / 2, titleY, { align: "center" });
|
|
46
|
+
titleY += 8;
|
|
47
|
+
}
|
|
48
|
+
pdf.setFontSize(11);
|
|
49
|
+
const generatedAt = new Date();
|
|
50
|
+
pdf.text(`Generated: ${generatedAt.toLocaleDateString()} ${generatedAt.toLocaleTimeString()}`, pageWidth / 2, titleY + 4, { align: "center" });
|
|
51
|
+
pdf.setFontSize(14);
|
|
52
|
+
pdf.text("Table of contents", MARGIN_MM, titleY + 16);
|
|
53
|
+
pdf.setFontSize(11);
|
|
54
|
+
let tocY = titleY + 26;
|
|
55
|
+
for (const item of tocItems) {
|
|
56
|
+
if (tocY > pageHeight - MARGIN_MM - 10) {
|
|
57
|
+
pdf.addPage();
|
|
58
|
+
tocY = MARGIN_MM;
|
|
59
|
+
}
|
|
60
|
+
pdf.text(`- ${item}`, MARGIN_MM, tocY);
|
|
61
|
+
tocY += 7;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function addChartImage(pdf, canvas, x, y, widthMm, heightMm) {
|
|
65
|
+
const flattened = sliceCanvas(canvas, canvas.width, canvas.height, 0, PAGE_BACKGROUND);
|
|
66
|
+
try {
|
|
67
|
+
pdf.addImage(flattened.toDataURL("image/jpeg", 0.92), "JPEG", x, y, widthMm, heightMm);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
releaseCanvas(flattened);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function addPageNumbers(pdf, pageWidth, pageHeight) {
|
|
74
|
+
const totalPages = pdf.getNumberOfPages();
|
|
75
|
+
pdf.setFontSize(9);
|
|
76
|
+
for (let page = 1; page <= totalPages; page++) {
|
|
77
|
+
pdf.setPage(page);
|
|
78
|
+
pdf.text(`Page ${page} of ${totalPages}`, pageWidth / 2, pageHeight - 6, {
|
|
79
|
+
align: "center",
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface PdfExportSegment {
|
|
2
|
+
top: number;
|
|
3
|
+
height: number;
|
|
4
|
+
}
|
|
5
|
+
export declare function splitSegmentForPageHeight(segment: PdfExportSegment, imgHeight: number, pageHeightPx: number): PdfExportSegment[];
|
|
6
|
+
export declare function fitPdfImageSize(pixelWidth: number, pixelHeight: number, maxWidthMm: number, maxHeightMm: number): {
|
|
7
|
+
widthMm: number;
|
|
8
|
+
heightMm: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function placePdfBlock(cursorY: number | null, blockHeightMm: number, pageTopMm: number, pageBottomMm: number): {
|
|
11
|
+
y: number;
|
|
12
|
+
needsNewPage: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function sliceCanvas(sourceCanvas: HTMLCanvasElement, width: number, height: number, offsetY: number, backgroundColor: string): HTMLCanvasElement;
|
|
15
|
+
//# sourceMappingURL=pdfPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdfPage.d.ts","sourceRoot":"","sources":["../../src/report/pdfPage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,gBAAgB,EAAE,CAcpB;AAED,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAUvC;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,CAKtC;AAED,wBAAgB,WAAW,CACzB,YAAY,EAAE,iBAAiB,EAC/B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GACtB,iBAAiB,CAsBnB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function splitSegmentForPageHeight(segment, imgHeight, pageHeightPx) {
|
|
2
|
+
const total = Math.max(1, Math.min(segment.height, imgHeight - segment.top));
|
|
3
|
+
if (pageHeightPx <= 0 || total <= pageHeightPx) {
|
|
4
|
+
return [{ top: segment.top, height: total }];
|
|
5
|
+
}
|
|
6
|
+
const slices = [];
|
|
7
|
+
let offset = 0;
|
|
8
|
+
while (offset < total) {
|
|
9
|
+
const height = Math.min(pageHeightPx, total - offset);
|
|
10
|
+
slices.push({ top: segment.top + offset, height });
|
|
11
|
+
offset += height;
|
|
12
|
+
}
|
|
13
|
+
return slices;
|
|
14
|
+
}
|
|
15
|
+
export function fitPdfImageSize(pixelWidth, pixelHeight, maxWidthMm, maxHeightMm) {
|
|
16
|
+
const safeWidth = Math.max(1, pixelWidth);
|
|
17
|
+
const safeHeight = Math.max(1, pixelHeight);
|
|
18
|
+
const widthScale = maxWidthMm / safeWidth;
|
|
19
|
+
const heightAtFullWidth = safeHeight * widthScale;
|
|
20
|
+
if (heightAtFullWidth <= maxHeightMm) {
|
|
21
|
+
return { widthMm: maxWidthMm, heightMm: heightAtFullWidth };
|
|
22
|
+
}
|
|
23
|
+
const scale = maxHeightMm / safeHeight;
|
|
24
|
+
return { widthMm: safeWidth * scale, heightMm: maxHeightMm };
|
|
25
|
+
}
|
|
26
|
+
export function placePdfBlock(cursorY, blockHeightMm, pageTopMm, pageBottomMm) {
|
|
27
|
+
if (cursorY === null || cursorY + blockHeightMm > pageBottomMm) {
|
|
28
|
+
return { y: pageTopMm, needsNewPage: true };
|
|
29
|
+
}
|
|
30
|
+
return { y: cursorY, needsNewPage: false };
|
|
31
|
+
}
|
|
32
|
+
export function sliceCanvas(sourceCanvas, width, height, offsetY, backgroundColor) {
|
|
33
|
+
const pageCanvas = document.createElement("canvas");
|
|
34
|
+
pageCanvas.width = width;
|
|
35
|
+
pageCanvas.height = height;
|
|
36
|
+
const context = pageCanvas.getContext("2d");
|
|
37
|
+
if (!context) {
|
|
38
|
+
throw new Error("Canvas 2D context unavailable");
|
|
39
|
+
}
|
|
40
|
+
context.fillStyle = backgroundColor;
|
|
41
|
+
context.fillRect(0, 0, width, height);
|
|
42
|
+
context.drawImage(sourceCanvas, 0, offsetY, width, height, 0, 0, width, height);
|
|
43
|
+
return pageCanvas;
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ReportExportOption {
|
|
2
|
+
key: string;
|
|
3
|
+
label: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
onSelect: () => void;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface StandardReportExportHandlers {
|
|
9
|
+
onExportPdf?: () => void;
|
|
10
|
+
onExportPng?: () => void;
|
|
11
|
+
onExportHtml?: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Standard report-download actions. Omit a handler to hide that format.
|
|
15
|
+
*/
|
|
16
|
+
export declare const standardReportExportOptions: ({ onExportPdf, onExportPng, onExportHtml, }: StandardReportExportHandlers) => ReportExportOption[];
|
|
17
|
+
//# sourceMappingURL=reportExportOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reportExportOptions.d.ts","sourceRoot":"","sources":["../../src/report/reportExportOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,eAAO,MAAM,2BAA2B,GAAI,6CAIzC,4BAA4B,KAAG,kBAAkB,EA+BnD,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard report-download actions. Omit a handler to hide that format.
|
|
3
|
+
*/
|
|
4
|
+
export const standardReportExportOptions = ({ onExportPdf, onExportPng, onExportHtml, }) => {
|
|
5
|
+
const options = [];
|
|
6
|
+
if (onExportPdf) {
|
|
7
|
+
options.push({
|
|
8
|
+
key: "pdf",
|
|
9
|
+
label: "PDF",
|
|
10
|
+
description: "Export the report as a PDF",
|
|
11
|
+
onSelect: onExportPdf,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (onExportHtml) {
|
|
15
|
+
options.push({
|
|
16
|
+
key: "html",
|
|
17
|
+
label: "HTML",
|
|
18
|
+
description: "Export the report as HTML",
|
|
19
|
+
onSelect: onExportHtml,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (onExportPng) {
|
|
23
|
+
options.push({
|
|
24
|
+
key: "png",
|
|
25
|
+
label: "PNG",
|
|
26
|
+
description: "Download all charts as PNG files",
|
|
27
|
+
onSelect: onExportPng,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return options;
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zipChartPngs.d.ts","sourceRoot":"","sources":["../../src/report/zipChartPngs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,wBAAsB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAM1E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openshift-migration-advisor/shared-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Shared React UI components for Migration Advisor apps (report charts, forms, OS support tiers)",
|
|
5
5
|
"author": "Montse Ortega <mortegag@redhat.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,5 +44,10 @@
|
|
|
44
44
|
"src",
|
|
45
45
|
"LICENSE",
|
|
46
46
|
"README.md"
|
|
47
|
-
]
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"html2canvas-pro": "^2.4.5",
|
|
50
|
+
"jspdf": "^4.2.1",
|
|
51
|
+
"jszip": "^3.10.2"
|
|
52
|
+
}
|
|
48
53
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Button, Flex, FlexItem } from "@patternfly/react-core";
|
|
2
|
+
import { DownloadIcon } from "@patternfly/react-icons";
|
|
3
|
+
import type { FC, ReactNode } from "react";
|
|
4
|
+
import { chartExportHideProps } from "./chartExport.js";
|
|
5
|
+
import { useChartExport } from "./chartExportContext.js";
|
|
6
|
+
|
|
7
|
+
export const ChartDownloadButton: FC<{
|
|
8
|
+
chartId: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
}> = ({ chartId, title }) => {
|
|
11
|
+
const exportApi = useChartExport();
|
|
12
|
+
if (!exportApi) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const label = title ? `Download ${title} as PNG` : "Download chart as PNG";
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Button
|
|
20
|
+
variant="plain"
|
|
21
|
+
icon={<DownloadIcon />}
|
|
22
|
+
aria-label={label}
|
|
23
|
+
isLoading={exportApi.downloadingChartId === chartId}
|
|
24
|
+
isDisabled={exportApi.isBusy}
|
|
25
|
+
onClick={() => {
|
|
26
|
+
void exportApi.downloadChart(chartId);
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
ChartDownloadButton.displayName = "ChartDownloadButton";
|
|
33
|
+
|
|
34
|
+
export const ChartHeaderActions: FC<{
|
|
35
|
+
chartId: string;
|
|
36
|
+
title?: string;
|
|
37
|
+
children?: ReactNode;
|
|
38
|
+
}> = ({ chartId, title, children }) => {
|
|
39
|
+
const exportApi = useChartExport();
|
|
40
|
+
if (!exportApi && !children) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<FlexItem {...chartExportHideProps}>
|
|
46
|
+
<Flex
|
|
47
|
+
alignItems={{ default: "alignItemsCenter" }}
|
|
48
|
+
spaceItems={{ default: "spaceItemsSm" }}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
{exportApi ? (
|
|
52
|
+
<ChartDownloadButton chartId={chartId} title={title} />
|
|
53
|
+
) : null}
|
|
54
|
+
</Flex>
|
|
55
|
+
</FlexItem>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
ChartHeaderActions.displayName = "ChartHeaderActions";
|