@openshift-migration-advisor/shared-components 0.27.0 → 0.28.0-47af17e06309
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/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 +6 -2
- 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/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/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 +22 -0
- package/src/report/pdfExport.ts +81 -2
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,
|
|
@@ -183,6 +195,11 @@ export {
|
|
|
183
195
|
type StandardReportExportHandlers,
|
|
184
196
|
standardReportExportOptions,
|
|
185
197
|
} from "./reportExportOptions.js";
|
|
198
|
+
export {
|
|
199
|
+
type StorageDiskTierData,
|
|
200
|
+
StorageOverview,
|
|
201
|
+
type StorageOverviewProps,
|
|
202
|
+
} from "./StorageOverview.js";
|
|
186
203
|
export { SupportTierBadge } from "./SupportTierBadge.js";
|
|
187
204
|
export {
|
|
188
205
|
ALL_TIERS_FILTER,
|
|
@@ -194,6 +211,11 @@ export {
|
|
|
194
211
|
VCenterClusterDetails,
|
|
195
212
|
type VCenterClusterDetailsProps,
|
|
196
213
|
} from "./VCenterClusterDetails.js";
|
|
214
|
+
export {
|
|
215
|
+
type IssuesBreakdownLike,
|
|
216
|
+
VMMigrationStatus,
|
|
217
|
+
type VMMigrationStatusProps,
|
|
218
|
+
} from "./VMMigrationStatus.js";
|
|
197
219
|
export {
|
|
198
220
|
VmPowerStates,
|
|
199
221
|
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,
|