@openshift-migration-advisor/shared-components 0.27.0 → 0.28.0-09381b4d22e5
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/charts/MigrationDonutChart.d.ts.map +1 -1
- package/dist/charts/MigrationDonutChart.js +7 -0
- package/dist/report/ChartExportProvider.d.ts +4 -3
- package/dist/report/ChartExportProvider.d.ts.map +1 -1
- package/dist/report/ChartExportProvider.js +7 -4
- package/dist/report/ClustersOverview.d.ts +24 -0
- package/dist/report/ClustersOverview.d.ts.map +1 -0
- package/dist/report/ClustersOverview.js +228 -0
- package/dist/report/ClustersOverviewStyles.d.ts +12 -0
- package/dist/report/ClustersOverviewStyles.d.ts.map +1 -0
- package/dist/report/ClustersOverviewStyles.js +101 -0
- package/dist/report/CpuAndMemoryOverview.d.ts +19 -0
- package/dist/report/CpuAndMemoryOverview.d.ts.map +1 -0
- package/dist/report/CpuAndMemoryOverview.js +112 -0
- package/dist/report/FeatureStatusBadge.js +1 -1
- package/dist/report/ReportExportMenu.d.ts +1 -0
- package/dist/report/ReportExportMenu.d.ts.map +1 -1
- package/dist/report/ReportExportMenu.js +38 -4
- package/dist/report/StorageOverview.d.ts +27 -0
- package/dist/report/StorageOverview.d.ts.map +1 -0
- package/dist/report/StorageOverview.js +319 -0
- package/dist/report/VMMigrationStatus.d.ts +33 -0
- package/dist/report/VMMigrationStatus.d.ts.map +1 -0
- package/dist/report/VMMigrationStatus.js +129 -0
- package/dist/report/captureChartElement.d.ts +6 -1
- package/dist/report/captureChartElement.d.ts.map +1 -1
- package/dist/report/captureChartElement.js +41 -12
- package/dist/report/chartExport.d.ts +23 -0
- package/dist/report/chartExport.d.ts.map +1 -1
- package/dist/report/chartExport.js +21 -1
- package/dist/report/chartExportContext.d.ts +6 -2
- package/dist/report/chartExportContext.d.ts.map +1 -1
- package/dist/report/dashboardStyles.d.ts +6 -0
- package/dist/report/dashboardStyles.d.ts.map +1 -1
- package/dist/report/dashboardStyles.js +7 -4
- package/dist/report/index.d.ts +7 -3
- package/dist/report/index.d.ts.map +1 -1
- package/dist/report/index.js +4 -0
- package/dist/report/pdfExport.d.ts +2 -2
- package/dist/report/pdfExport.d.ts.map +1 -1
- package/dist/report/pdfExport.js +52 -3
- package/dist/report/reportExportOptions.d.ts +13 -2
- package/dist/report/reportExportOptions.d.ts.map +1 -1
- package/dist/report/reportExportOptions.js +13 -5
- package/package.json +2 -2
- package/src/charts/MigrationDonutChart.tsx +9 -0
- package/src/report/ChartExportProvider.tsx +18 -6
- package/src/report/ClustersOverview.tsx +451 -0
- package/src/report/ClustersOverviewStyles.ts +110 -0
- package/src/report/CpuAndMemoryOverview.tsx +277 -0
- package/src/report/FeatureStatusBadge.tsx +1 -1
- package/src/report/ReportExportMenu.tsx +69 -13
- package/src/report/StorageOverview.tsx +629 -0
- package/src/report/VMMigrationStatus.tsx +358 -0
- package/src/report/__tests__/ChartExportProvider.test.tsx +110 -2
- package/src/report/__tests__/ClustersOverview.test.tsx +241 -0
- package/src/report/__tests__/CpuAndMemoryOverview.test.tsx +200 -0
- package/src/report/__tests__/StorageOverview.test.tsx +223 -0
- package/src/report/__tests__/VMMigrationStatus.test.tsx +178 -0
- package/src/report/__tests__/captureChartElement.test.ts +120 -0
- package/src/report/__tests__/chartExportPackagers.test.ts +75 -0
- package/src/report/captureChartElement.ts +55 -10
- package/src/report/chartExport.ts +41 -1
- package/src/report/chartExportContext.tsx +9 -1
- package/src/report/dashboardStyles.ts +7 -4
- package/src/report/index.ts +24 -0
- package/src/report/pdfExport.ts +81 -2
- package/src/report/reportExportOptions.ts +28 -5
package/src/report/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ export {
|
|
|
9
9
|
} from "./ChartDownloadButton.js";
|
|
10
10
|
export {
|
|
11
11
|
type BuildChartDocument,
|
|
12
|
+
type BuildPdfDocument,
|
|
12
13
|
type CaptureChartElement,
|
|
13
14
|
ChartExportProvider,
|
|
14
15
|
type ChartExportProviderProps,
|
|
@@ -16,6 +17,15 @@ export {
|
|
|
16
17
|
type ZipChartFiles,
|
|
17
18
|
} from "./ChartExportProvider.js";
|
|
18
19
|
export { ChartExportSurface } from "./ChartExportSurface.js";
|
|
20
|
+
export {
|
|
21
|
+
ClustersOverview,
|
|
22
|
+
type ClustersOverviewProps,
|
|
23
|
+
type InventoryDataLike,
|
|
24
|
+
} from "./ClustersOverview.js";
|
|
25
|
+
export {
|
|
26
|
+
CpuAndMemoryOverview,
|
|
27
|
+
type CpuAndMemoryOverviewProps,
|
|
28
|
+
} from "./CpuAndMemoryOverview.js";
|
|
19
29
|
export { captureChartElement } from "./captureChartElement.js";
|
|
20
30
|
export {
|
|
21
31
|
CHART_EXPORT_CAPTURING_ATTR,
|
|
@@ -32,6 +42,8 @@ export {
|
|
|
32
42
|
chartExportViewsFromLabels,
|
|
33
43
|
chartPngFilename,
|
|
34
44
|
downloadBlob,
|
|
45
|
+
type PdfTextPage,
|
|
46
|
+
type PdfTextPageItem,
|
|
35
47
|
type RegisteredChart,
|
|
36
48
|
releaseCanvas,
|
|
37
49
|
restoreChartExportViews,
|
|
@@ -180,9 +192,16 @@ export {
|
|
|
180
192
|
export { ReportTable, type ReportTableProps } from "./ReportTable.js";
|
|
181
193
|
export {
|
|
182
194
|
type ReportExportOption,
|
|
195
|
+
type ReportExportSection,
|
|
183
196
|
type StandardReportExportHandlers,
|
|
197
|
+
type StandardReportExportOptionsConfig,
|
|
184
198
|
standardReportExportOptions,
|
|
185
199
|
} from "./reportExportOptions.js";
|
|
200
|
+
export {
|
|
201
|
+
type StorageDiskTierData,
|
|
202
|
+
StorageOverview,
|
|
203
|
+
type StorageOverviewProps,
|
|
204
|
+
} from "./StorageOverview.js";
|
|
186
205
|
export { SupportTierBadge } from "./SupportTierBadge.js";
|
|
187
206
|
export {
|
|
188
207
|
ALL_TIERS_FILTER,
|
|
@@ -194,6 +213,11 @@ export {
|
|
|
194
213
|
VCenterClusterDetails,
|
|
195
214
|
type VCenterClusterDetailsProps,
|
|
196
215
|
} from "./VCenterClusterDetails.js";
|
|
216
|
+
export {
|
|
217
|
+
type IssuesBreakdownLike,
|
|
218
|
+
VMMigrationStatus,
|
|
219
|
+
type VMMigrationStatusProps,
|
|
220
|
+
} from "./VMMigrationStatus.js";
|
|
197
221
|
export {
|
|
198
222
|
VmPowerStates,
|
|
199
223
|
type VmPowerStatesProps,
|
package/src/report/pdfExport.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import jsPDF from "jspdf";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type ChartCaptureSource,
|
|
4
|
+
type PdfTextPage,
|
|
5
|
+
releaseCanvas,
|
|
6
|
+
} from "./chartExport.js";
|
|
3
7
|
import { fitPdfImageSize, placePdfBlock, sliceCanvas } from "./pdfPage.js";
|
|
4
8
|
|
|
5
9
|
const MARGIN_MM = 10;
|
|
@@ -10,6 +14,7 @@ const PAGE_BACKGROUND = "#ffffff";
|
|
|
10
14
|
export async function buildPdfFromCharts(
|
|
11
15
|
charts: ChartCaptureSource[],
|
|
12
16
|
documentTitle: string,
|
|
17
|
+
extraPages: PdfTextPage[] = [],
|
|
13
18
|
): Promise<Blob> {
|
|
14
19
|
const pdf = new jsPDF("p", "mm", "a4");
|
|
15
20
|
const pageWidth = pdf.internal.pageSize.getWidth();
|
|
@@ -22,7 +27,7 @@ export async function buildPdfFromCharts(
|
|
|
22
27
|
addCoverPage(
|
|
23
28
|
pdf,
|
|
24
29
|
documentTitle,
|
|
25
|
-
charts.map((chart) => chart.title),
|
|
30
|
+
[...charts.map((chart) => chart.title), ...extraPages.map((p) => p.title)],
|
|
26
31
|
pageWidth,
|
|
27
32
|
pageHeight,
|
|
28
33
|
);
|
|
@@ -63,6 +68,10 @@ export async function buildPdfFromCharts(
|
|
|
63
68
|
}
|
|
64
69
|
}
|
|
65
70
|
|
|
71
|
+
if (extraPages.length > 0) {
|
|
72
|
+
addExtraPages(pdf, extraPages, pageWidth, pageHeight);
|
|
73
|
+
}
|
|
74
|
+
|
|
66
75
|
addPageNumbers(pdf, pageWidth, pageHeight);
|
|
67
76
|
return pdf.output("blob");
|
|
68
77
|
}
|
|
@@ -138,6 +147,76 @@ function addChartImage(
|
|
|
138
147
|
}
|
|
139
148
|
}
|
|
140
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Append one native-text PDF page per entry in `extraPages`, rendered as
|
|
152
|
+
* label/value rows rather than a captured image. Each page starts fresh so
|
|
153
|
+
* its content never bleeds into a chart page.
|
|
154
|
+
*/
|
|
155
|
+
function addExtraPages(
|
|
156
|
+
pdf: jsPDF,
|
|
157
|
+
extraPages: PdfTextPage[],
|
|
158
|
+
pageWidth: number,
|
|
159
|
+
pageHeight: number,
|
|
160
|
+
): void {
|
|
161
|
+
const LABEL_COL_WIDTH = 68; // mm — enough for the longest label
|
|
162
|
+
const VALUE_COL_X = MARGIN_MM + LABEL_COL_WIDTH;
|
|
163
|
+
const VALUE_COL_WIDTH = pageWidth - MARGIN_MM - LABEL_COL_WIDTH;
|
|
164
|
+
const LINE_HEIGHT = 7; // mm between rows
|
|
165
|
+
|
|
166
|
+
for (const page of extraPages) {
|
|
167
|
+
pdf.addPage();
|
|
168
|
+
let y = MARGIN_MM + 8;
|
|
169
|
+
|
|
170
|
+
pdf.setFontSize(16);
|
|
171
|
+
pdf.setFont("helvetica", "bold");
|
|
172
|
+
pdf.text(page.title, MARGIN_MM, y);
|
|
173
|
+
y += 10;
|
|
174
|
+
|
|
175
|
+
pdf.setDrawColor(0, 103, 187);
|
|
176
|
+
pdf.setLineWidth(0.5);
|
|
177
|
+
pdf.line(MARGIN_MM, y, pageWidth - MARGIN_MM, y);
|
|
178
|
+
y += 10;
|
|
179
|
+
|
|
180
|
+
pdf.setFontSize(11);
|
|
181
|
+
|
|
182
|
+
for (const item of page.items) {
|
|
183
|
+
pdf.setFont("helvetica", "bold");
|
|
184
|
+
const labelLines = pdf.splitTextToSize(
|
|
185
|
+
item.label,
|
|
186
|
+
LABEL_COL_WIDTH - 4,
|
|
187
|
+
) as string[];
|
|
188
|
+
pdf.text(labelLines, MARGIN_MM, y);
|
|
189
|
+
|
|
190
|
+
pdf.setFont("helvetica", "normal");
|
|
191
|
+
const valueLines = pdf.splitTextToSize(
|
|
192
|
+
item.value,
|
|
193
|
+
VALUE_COL_WIDTH,
|
|
194
|
+
) as string[];
|
|
195
|
+
pdf.text(valueLines, VALUE_COL_X, y);
|
|
196
|
+
|
|
197
|
+
y += LINE_HEIGHT * Math.max(labelLines.length, valueLines.length);
|
|
198
|
+
|
|
199
|
+
if (y > pageHeight - MARGIN_MM - 25) {
|
|
200
|
+
pdf.addPage();
|
|
201
|
+
y = MARGIN_MM + 10;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (page.footer) {
|
|
206
|
+
y += 4;
|
|
207
|
+
pdf.setFontSize(9);
|
|
208
|
+
pdf.setFont("helvetica", "bolditalic");
|
|
209
|
+
const footerLines = pdf.splitTextToSize(
|
|
210
|
+
page.footer,
|
|
211
|
+
pageWidth - MARGIN_MM * 2,
|
|
212
|
+
) as string[];
|
|
213
|
+
pdf.text(footerLines, MARGIN_MM, y);
|
|
214
|
+
pdf.setFont("helvetica", "normal");
|
|
215
|
+
pdf.setFontSize(11);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
141
220
|
function addPageNumbers(
|
|
142
221
|
pdf: jsPDF,
|
|
143
222
|
pageWidth: number,
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
export interface ReportExportSection {
|
|
2
|
+
id: string;
|
|
3
|
+
label: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
export interface ReportExportOption {
|
|
2
7
|
key: string;
|
|
3
8
|
label: string;
|
|
4
9
|
description?: string;
|
|
5
10
|
onSelect: () => void;
|
|
6
11
|
isDisabled?: boolean;
|
|
12
|
+
/** When set, the menu groups rows and shows `label` as the group heading. */
|
|
13
|
+
section?: ReportExportSection;
|
|
7
14
|
}
|
|
8
15
|
|
|
9
16
|
export interface StandardReportExportHandlers {
|
|
@@ -12,22 +19,38 @@ export interface StandardReportExportHandlers {
|
|
|
12
19
|
onExportHtml?: () => void;
|
|
13
20
|
}
|
|
14
21
|
|
|
22
|
+
export type StandardReportExportOptionsConfig = StandardReportExportHandlers & {
|
|
23
|
+
/** Dropdown group label for PDF / HTML / PNG. Default: `"Assessment report"`. */
|
|
24
|
+
assessmentSectionLabel?: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const DEFAULT_ASSESSMENT_SECTION: ReportExportSection = {
|
|
28
|
+
id: "assessment-report",
|
|
29
|
+
label: "Assessment report",
|
|
30
|
+
};
|
|
31
|
+
|
|
15
32
|
/**
|
|
16
|
-
*
|
|
33
|
+
* Optional helper for chart-based assessment downloads. Omit a handler to hide
|
|
34
|
+
* that format. Override `assessmentSectionLabel` if product copy differs per app.
|
|
17
35
|
*/
|
|
18
36
|
export const standardReportExportOptions = ({
|
|
19
37
|
onExportPdf,
|
|
20
38
|
onExportPng,
|
|
21
39
|
onExportHtml,
|
|
22
|
-
|
|
40
|
+
assessmentSectionLabel,
|
|
41
|
+
}: StandardReportExportOptionsConfig): ReportExportOption[] => {
|
|
42
|
+
const section: ReportExportSection = assessmentSectionLabel
|
|
43
|
+
? { ...DEFAULT_ASSESSMENT_SECTION, label: assessmentSectionLabel }
|
|
44
|
+
: DEFAULT_ASSESSMENT_SECTION;
|
|
45
|
+
|
|
23
46
|
const options: ReportExportOption[] = [];
|
|
24
47
|
|
|
25
48
|
if (onExportPdf) {
|
|
26
49
|
options.push({
|
|
27
50
|
key: "pdf",
|
|
28
51
|
label: "PDF",
|
|
29
|
-
description: "Export the report as a PDF",
|
|
30
52
|
onSelect: onExportPdf,
|
|
53
|
+
section,
|
|
31
54
|
});
|
|
32
55
|
}
|
|
33
56
|
|
|
@@ -35,8 +58,8 @@ export const standardReportExportOptions = ({
|
|
|
35
58
|
options.push({
|
|
36
59
|
key: "html",
|
|
37
60
|
label: "HTML",
|
|
38
|
-
description: "Export the report as HTML",
|
|
39
61
|
onSelect: onExportHtml,
|
|
62
|
+
section,
|
|
40
63
|
});
|
|
41
64
|
}
|
|
42
65
|
|
|
@@ -44,8 +67,8 @@ export const standardReportExportOptions = ({
|
|
|
44
67
|
options.push({
|
|
45
68
|
key: "png",
|
|
46
69
|
label: "PNG",
|
|
47
|
-
description: "Download all charts as PNG files",
|
|
48
70
|
onSelect: onExportPng,
|
|
71
|
+
section,
|
|
49
72
|
});
|
|
50
73
|
}
|
|
51
74
|
|