@openshift-migration-advisor/shared-components 0.27.0 → 0.28.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/dist/report/ChartExportProvider.d.ts +3 -2
- package/dist/report/ChartExportProvider.d.ts.map +1 -1
- package/dist/report/ChartExportProvider.js +3 -3
- 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/captureChartElement.d.ts.map +1 -1
- package/dist/report/captureChartElement.js +28 -8
- package/dist/report/chartExport.d.ts +23 -0
- package/dist/report/chartExport.d.ts.map +1 -1
- package/dist/report/chartExport.js +20 -0
- package/dist/report/chartExportContext.d.ts +6 -2
- package/dist/report/chartExportContext.d.ts.map +1 -1
- package/dist/report/index.d.ts +4 -2
- package/dist/report/index.d.ts.map +1 -1
- package/dist/report/index.js +2 -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/report/ChartExportProvider.tsx +13 -5
- package/src/report/ClustersOverview.tsx +451 -0
- package/src/report/ClustersOverviewStyles.ts +110 -0
- package/src/report/CpuAndMemoryOverview.tsx +277 -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__/captureChartElement.test.ts +73 -0
- package/src/report/__tests__/chartExportPackagers.test.ts +75 -0
- package/src/report/captureChartElement.ts +37 -7
- package/src/report/chartExport.ts +40 -0
- package/src/report/chartExportContext.tsx +9 -1
- package/src/report/index.ts +12 -0
- package/src/report/pdfExport.ts +81 -2
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,
|