@measurequick/measurequick-report-generator 1.0.52 → 1.0.53
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/index.js +9 -463
- package/jspdf/mq-report-generator.js +459 -0
- package/package.json +1 -1
- package/pdflib/mq-system-vitals-report-generator.js +165 -0
- package/templates/js/templates.js +306 -35
- package/templates/pdf/MQ-system-vitals-report.pdf +0 -0
- package/scripts/fillable-pdf-gen/mq-standard-fillable.js +0 -0
- package/scripts/fillable-pdf-gen/mq-system-vitals-fillable.js +0 -48
- package/scripts/raw-data-pdf-gen/mq-standard-raw-data.js +0 -0
package/index.js
CHANGED
|
@@ -1,466 +1,12 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
import * as request from "./templates/js/request.js";
|
|
4
|
-
import { PDFDocument } from 'pdf-lib';
|
|
5
|
-
import * as mqStandardRawData from "./scripts/raw-data-pdf-gen/mq-standard-raw-data.js";
|
|
6
|
-
import * as mqStandardFillable from "./scripts/fillable-pdf-gen/mq-standard-fillable.js";
|
|
7
|
-
import * as mqSystemVitalsFillable from "./scripts/fillable-pdf-gen/mq-system-vitals-fillable.js";
|
|
1
|
+
import * as mqReportGenerator from "./jspdf/mq-report-generator.js";
|
|
2
|
+
import * as mqSystemVitalsReportGenerator from "./pdflib/mq-system-vitals-report-generator.js";
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// if (generationMethod == "rawData") report = mqStandardRawData.generateReport(payload);
|
|
17
|
-
// else if (generationMethod == "fillable") report = mqStandardFillable.generateReport(payload);
|
|
18
|
-
// return report;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getMqSystemVitalsReport(payload) {
|
|
22
|
-
let report = mqSystemVitalsFillable.generateReport(payload);
|
|
23
|
-
return report;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function getFillableReport() {
|
|
27
|
-
const dataUri = templates.mqStandardFillablePdfBase64;
|
|
28
|
-
const pdfDoc = await PDFDocument.load(dataUri);
|
|
29
|
-
return pdfDoc;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function getReport(data=null) {
|
|
33
|
-
try {
|
|
34
|
-
reportData = (data == null) ?
|
|
35
|
-
JSON.parse(JSON.stringify(request.body)) :
|
|
36
|
-
JSON.parse(JSON.stringify(data));
|
|
37
|
-
let testNumber = 0;
|
|
38
|
-
for (currentSnapshot in reportData.snapshots) {
|
|
39
|
-
if (testNumber > 0) doc.addPage();
|
|
40
|
-
printBoilerPlateStandard();
|
|
41
|
-
printHeaderData();
|
|
42
|
-
printBodyData(currentSnapshot);
|
|
43
|
-
printFooterData();
|
|
44
|
-
resizeAndPrintStaticImages();
|
|
45
|
-
testNumber++;
|
|
46
|
-
}
|
|
47
|
-
printDiagnosticPage();
|
|
48
|
-
printInfoPage();
|
|
49
|
-
printPhotoPages();
|
|
50
|
-
return doc.output("datauristring");
|
|
51
|
-
} catch (e) {
|
|
52
|
-
return doc.output("datauristring");
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function printBoilerPlateStandard() {
|
|
57
|
-
doc.addImage(graphics.headerMeasureQuick, "JPEG", 0, 0, 8.5, 1);
|
|
58
|
-
doc.addImage(graphics.footerMeasureQuick, "JPEG", 0, 7.75, 8.5, 4.5);
|
|
59
|
-
let mqLogo = graphics.companyLogoMeasureQuickLight;
|
|
60
|
-
if (reportData.meta.reportTheme == "light")
|
|
61
|
-
mqLogo = graphics.companyLogoMeasureQuickDark;
|
|
62
|
-
doc.addImage(mqLogo, "JPEG", .25, 10, 2.15625, .5);
|
|
63
|
-
doc.setLineWidth(0.025);
|
|
64
|
-
doc.setDrawColor(0);
|
|
65
|
-
doc.setFillColor(242, 242, 242);
|
|
66
|
-
doc.rect(.125, 1.125, 2.667, 3, "F");
|
|
67
|
-
doc.rect(2.917, 1.125, 2.667, 3, "F");
|
|
68
|
-
doc.rect(5.709, 1.125, 2.667, 3, "F");
|
|
69
|
-
doc.rect(.125, 4.25, 4.0625, 3.375, "F");
|
|
70
|
-
doc.addImage(graphics.iconSunshine, "JPEG", .4585, 1.625, 2, 2);
|
|
71
|
-
doc.addImage(graphics.iconHouse, "JPEG", 3.252, 1.625, 2, 2);
|
|
72
|
-
doc.addImage(graphics.iconInfo, "JPEG", 6.044, 1.625, 2, 2);
|
|
73
|
-
doc.addImage(graphics.iconPerformance, "JPEG", 1.15625, 4.9375, 2, 2);
|
|
74
|
-
doc.setFontStyle("bold");
|
|
75
|
-
doc.setFontSize(9);
|
|
76
|
-
doc.text("Outdoor Measurements", .25, 1.33);
|
|
77
|
-
doc.text("Indoor Measurements", 3.042, 1.33);
|
|
78
|
-
doc.text("Weather Data", 5.834, 1.33);
|
|
79
|
-
doc.text("Performance Calculations", .25, 4.435);
|
|
80
|
-
doc.setFontSize(8);
|
|
81
|
-
doc.text("Capacity Calculations", .25, 4.655);
|
|
82
|
-
doc.text("Air-side Performance", 2.25, 4.655);
|
|
83
|
-
doc.text("Energy Efficiency", 2.25, 5.655);
|
|
84
|
-
doc.setFontSize(6.5);
|
|
85
|
-
doc.setFontStyle("bolditalic");
|
|
86
|
-
doc.setTextColor(255, 255, 255);
|
|
87
|
-
let disclaimer = `Disclaimer: This report was prepared by your service technician who is solely responsible for its content. This report is provided “as-is” excluding all warranties expressed or implied including without limitation the warranty of merchantability. ©2017-${new Date().getFullYear()} Manifold Cloud Services Ltd.`;
|
|
88
|
-
disclaimer = doc.splitTextToSize(disclaimer.toUpperCase(), 8);
|
|
89
|
-
doc.text(disclaimer, .125, 10.66);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function printBoilerPlateDiagnostic() {
|
|
93
|
-
doc.addImage(graphics.headerMeasureQuick, "JPEG", 0, 0, 8.5, 1);
|
|
94
|
-
doc.setLineWidth(0.025);
|
|
95
|
-
doc.setDrawColor(0);
|
|
96
|
-
doc.setFillColor(242, 242, 242);
|
|
97
|
-
doc.setTextColor(0, 0, 0);
|
|
98
|
-
doc.setFontSize(9);
|
|
99
|
-
doc.setFontStyle('bold');
|
|
100
|
-
doc.rect(.125, 3.3, 8.25, 7.6, "F");
|
|
101
|
-
doc.rect(.125, .6, 4.0625, 2.6, "F");
|
|
102
|
-
doc.rect(4.3125, .6, 4.0625, 2.6, "F");
|
|
103
|
-
doc.text("System Diagnostics", 4.4375, .8);
|
|
104
|
-
doc.text("Subsystem Review", .25, .8);
|
|
105
|
-
doc.text('Corrective Actions', .25, 3.5);
|
|
106
|
-
doc.setFontSize(8);
|
|
107
|
-
doc.setFontStyle('normal');
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function printHeaderData() {
|
|
112
|
-
let size = 13.5;
|
|
113
|
-
do { size -= .5; } while ((doc.getStringUnitWidth(reportData.meta.reportName) * size / 72) > 4.5);
|
|
114
|
-
doc.setFontSize(size);
|
|
115
|
-
doc.setFontStyle("bold");
|
|
116
|
-
doc.text(reportData.meta.reportName, 0.25, .75);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function printBodyData(currentSnapshot) {
|
|
120
|
-
doc.setTextColor(0, 0, 0);
|
|
121
|
-
doc.setFontType("normal");
|
|
122
|
-
doc.setFontSize(8);
|
|
123
|
-
printBodySection(currentSnapshot, "outdoorMeasurements", .25, 2.317, 1.55);
|
|
124
|
-
printBodySection(currentSnapshot, "indoorMeasurements", 3.042, 5.109, 1.55);
|
|
125
|
-
printBodySection(currentSnapshot, "systemProfileWeatherData", 5.834, 7.9, 1.55);
|
|
126
|
-
printBodySection(currentSnapshot, "performanceData", .25, 2, 4.855);
|
|
127
|
-
printGeolocationMap();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function printBodySection(currentSnapshot, measurementSection, xLeft, xRight, y) {
|
|
131
|
-
let dataPoints = JSON.parse(reportData.snapshots[currentSnapshot][measurementSection]);
|
|
132
|
-
let printRangeIcons = true;
|
|
133
|
-
let units = "";
|
|
134
|
-
let labelText = "";
|
|
135
|
-
let valueText = "";
|
|
136
|
-
let yTop = y;
|
|
137
|
-
let s = .18;
|
|
138
|
-
let sMultiplier = measurementSection == "performanceData" ? 2 : 1;
|
|
139
|
-
|
|
140
|
-
for (let key in dataPoints.values) {
|
|
141
|
-
let dataPoint = dataPoints.values[key];
|
|
142
|
-
let valueBeforeEditing = dataPoint;
|
|
143
|
-
let templateRef = templates[measurementSection][key];
|
|
144
|
-
if (templateRef) {
|
|
145
|
-
if (templateRef.hasOwnProperty("units"))
|
|
146
|
-
units = Array.isArray(templateRef.units) ? `(${templateRef.units[0]} / ${templateRef.units[1]})` : `(${templateRef.units})`;
|
|
147
|
-
else units = "";
|
|
148
|
-
labelText = `${templateRef.label} ${units}:`;
|
|
149
|
-
if (templateRef.hasOwnProperty("roundTo")) {
|
|
150
|
-
dataPoint *= 1;
|
|
151
|
-
dataPoint = dataPoint.toFixed(templateRef.roundTo);
|
|
152
|
-
}
|
|
153
|
-
if (templateRef.hasOwnProperty("secondaryValue")) {
|
|
154
|
-
let secondaryDataPoint = dataPoints.values[templateRef.secondaryValue];
|
|
155
|
-
if (templateRef.hasOwnProperty("roundTo")) {
|
|
156
|
-
secondaryDataPoint *= 1;
|
|
157
|
-
secondaryDataPoint = secondaryDataPoint.toFixed(templateRef.roundTo);
|
|
158
|
-
}
|
|
159
|
-
valueText = `${dataPoint} / ${secondaryDataPoint}`;
|
|
160
|
-
} else valueText = `${dataPoint}`;
|
|
161
|
-
if (templateRef.label) doc.text(labelText, xLeft, y);
|
|
162
|
-
doc.text(valueText, alignRight(valueText, xRight, 8), y);
|
|
163
|
-
if (printRangeIcons) {
|
|
164
|
-
let rangeIconRef = getRangeIcon(key, valueBeforeEditing, currentSnapshot);
|
|
165
|
-
if (rangeIconRef) doc.addImage(graphics[rangeIconRef], "JPEG", xRight + .05, y - .12, .16, .16);
|
|
166
|
-
}
|
|
167
|
-
let toolIconRef = getToolIcon(reportData.snapshots[currentSnapshot].toolIcons[key]);
|
|
168
|
-
if (toolIconRef) doc.addImage(graphics[toolIconRef], "JPEG", xRight + .25, y - .12, .16, .16);
|
|
169
|
-
y += (s * sMultiplier);
|
|
170
|
-
} else if (key == "newColumn") {
|
|
171
|
-
sMultiplier = 1;
|
|
172
|
-
xLeft = 2.25;
|
|
173
|
-
xRight = 3.9;
|
|
174
|
-
y = yTop;
|
|
175
|
-
} else if (key == "newRow") {
|
|
176
|
-
y += .35;
|
|
177
|
-
}
|
|
4
|
+
export function generateReport(reportType, payload) {
|
|
5
|
+
if (reportType == "mqStandard") reportType = "mqCooling";
|
|
6
|
+
switch (reportType) {
|
|
7
|
+
case "mqCooling":
|
|
8
|
+
case "mqHeating": return mqReportGenerator.generateReport(reportType, payload);
|
|
9
|
+
case "mqSystemVitalsFillable": return mqSystemVitalsReportGenerator.generateReport(payload);
|
|
10
|
+
default: return false;
|
|
178
11
|
}
|
|
179
12
|
}
|
|
180
|
-
|
|
181
|
-
function printGeolocationMap() {
|
|
182
|
-
doc.addImage(reportData.staticPhotos.geolocationMap, "PNG", 4.3125, 4.25, 4.0625, 3.375);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function printProfilePicture() {
|
|
186
|
-
let coords = templates.profilePictureCoordinates[reportData.meta.profilePicturePlacement];
|
|
187
|
-
doc.addImage(reportData.staticPhotos.profilePicture, "JPEG", coords.x, coords.y, coords.w, coords.h);
|
|
188
|
-
doc.text(reportData.meta.techName, alignRight(reportData.meta.techName, 8.4, 8), coords.y + 1.2);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function printCompanyLogo() {
|
|
192
|
-
let coords = templates.companyLogoCoordinates[reportData.meta.companyLogoPlacement];
|
|
193
|
-
doc.addImage(reportData.staticPhotos.companyLogo, "JPEG", coords.x, coords.y, coords.w, coords.h);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function printFooterData() {
|
|
197
|
-
let s = .15;
|
|
198
|
-
let x = .2;
|
|
199
|
-
let y = 8;
|
|
200
|
-
let equipmentLabels = ["Make", "Model", "Serial"];
|
|
201
|
-
let i = -1;
|
|
202
|
-
doc.setTextColor(255, 255, 255);
|
|
203
|
-
doc.setFontType("bold");
|
|
204
|
-
doc.setFontSize(12);
|
|
205
|
-
doc.text("Customer", x, y);
|
|
206
|
-
doc.text("Equipment", x + 2.5, y);
|
|
207
|
-
doc.setFontSize(8);
|
|
208
|
-
y += .2;
|
|
209
|
-
doc.setFontSize(10);
|
|
210
|
-
y += .05;
|
|
211
|
-
let footer = JSON.parse(reportData.footerData);
|
|
212
|
-
for (let key in footer) {
|
|
213
|
-
doc.setFontType("normal");
|
|
214
|
-
if (key.includes("header")) {
|
|
215
|
-
i = 0;
|
|
216
|
-
doc.setFontStyle("bold");
|
|
217
|
-
y += .1;
|
|
218
|
-
} else if (key == "systemCoords") {
|
|
219
|
-
s = .12;
|
|
220
|
-
x += 2.5;
|
|
221
|
-
y = 8.2;
|
|
222
|
-
doc.setFontStyle("bold");
|
|
223
|
-
doc.setFontSize(8);
|
|
224
|
-
doc.text("ID", x, y);
|
|
225
|
-
doc.setFontStyle("normal");
|
|
226
|
-
y += s;
|
|
227
|
-
}
|
|
228
|
-
let prefix = "";
|
|
229
|
-
if (i > -1) {
|
|
230
|
-
prefix = `${equipmentLabels[i]}: `;
|
|
231
|
-
i++;
|
|
232
|
-
}
|
|
233
|
-
doc.text(`${prefix}${footer[key]}`, x, y);
|
|
234
|
-
y += s;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function printDiagnosticPage() {
|
|
239
|
-
doc.addPage();
|
|
240
|
-
printBoilerPlateDiagnostic();
|
|
241
|
-
printSubsystemReview();
|
|
242
|
-
printSystemDiagnostics();
|
|
243
|
-
printCorrectiveActions();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function printSubsystemReview() {
|
|
247
|
-
let y = 1;
|
|
248
|
-
let ssr = JSON.parse(reportData.subsystemReview);
|
|
249
|
-
for (let i = 0; i < Object.keys(ssr).length; i++) {
|
|
250
|
-
let key = Object.keys(ssr)[i];
|
|
251
|
-
doc.text(templates.coolingSubsystemReview[key], .25, y);
|
|
252
|
-
doc.text(ssr[key], 3, y);
|
|
253
|
-
y += .15;
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function printSystemDiagnostics() {
|
|
258
|
-
let y = 1;
|
|
259
|
-
let diagnostics = JSON.parse(reportData.systemDiagnostics);
|
|
260
|
-
for (let i = 0; i < Object.keys(diagnostics).length; i++) {
|
|
261
|
-
let key = Object.keys(diagnostics)[i];
|
|
262
|
-
// let score = diagnostics[key].score;
|
|
263
|
-
// let diagnosticIcon = null;
|
|
264
|
-
// //if (type === 'stability') icon = stability;
|
|
265
|
-
// if (score > 1 && score < 10) diagnosticIcon = graphics.iconFlagRed;
|
|
266
|
-
// else if (score >= 10 && score < 15) diagnosticIcon = graphics.iconFlagYellow;
|
|
267
|
-
// else if (score >= 15) diagnosticIcon = graphics.iconFlagBlack;
|
|
268
|
-
// if (diagnosticIcon) doc.addImage(graphics[diagnosticIcon], "JPEG", 7.8, y, .25, .25);
|
|
269
|
-
y += .2;
|
|
270
|
-
doc.text(diagnostics[key].title, 4.4375, y);
|
|
271
|
-
doc.text(`${diagnostics[key].score}`, 7.5, y);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function printCorrectiveActions() {
|
|
276
|
-
let y = 3.8;
|
|
277
|
-
doc.setFontSize(9);
|
|
278
|
-
let ca = JSON.parse(reportData.correctiveActions);
|
|
279
|
-
for (let i = 0; i < Object.keys(ca).length; i++) {
|
|
280
|
-
let sectionKey = Object.keys(ca)[i];
|
|
281
|
-
for (let j = 0; j < Object.keys(ca[sectionKey]).length; j++) {
|
|
282
|
-
let actionKey = Object.keys(ca[sectionKey])[j];
|
|
283
|
-
let action = ca[sectionKey][actionKey];
|
|
284
|
-
if (actionKey == "header") {
|
|
285
|
-
doc.setFontSize(10);
|
|
286
|
-
doc.setFontStyle("bold");
|
|
287
|
-
doc.text(action, .25, y);
|
|
288
|
-
} else {
|
|
289
|
-
doc.setFontSize(8);
|
|
290
|
-
doc.setFontStyle("normal");
|
|
291
|
-
doc.text(actionKey, .25, y);
|
|
292
|
-
}
|
|
293
|
-
y += .18;
|
|
294
|
-
}
|
|
295
|
-
y += .1;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function printPhotoPages() {
|
|
300
|
-
let photoSectionMapping = ["project", "equipment", "site", "customer"];
|
|
301
|
-
let x, y, header, currentQuadrant, currentSection;
|
|
302
|
-
for (let i = 0; i < 4; i++) { // loops through the 4 main sections of photos, listed above (photoSectionMapping)
|
|
303
|
-
currentSection = reportData[`${photoSectionMapping[i]}Photos`];
|
|
304
|
-
if (Object.keys(currentSection).length > 0) doc.addPage();
|
|
305
|
-
else break;
|
|
306
|
-
currentQuadrant = 1;
|
|
307
|
-
x = templates.photoCoordinates[`quadrant${currentQuadrant}`].x;
|
|
308
|
-
y = templates.photoCoordinates[`quadrant${currentQuadrant}`].y;
|
|
309
|
-
doc.setFontStyle("bold");
|
|
310
|
-
doc.text(`${photoSectionMapping[i][0].toUpperCase()}${photoSectionMapping[i].slice(1)} Photos`, x, y - .2);
|
|
311
|
-
doc.setFontStyle("normal");
|
|
312
|
-
for (let key in currentSection) { // loops through the "subsections" of each main photo section
|
|
313
|
-
if (currentSection[key].photos) {
|
|
314
|
-
for (let j = 0; j < currentSection[key].photos.length; j++) { // loops through the photos[] array within each subsection, of each main photo section
|
|
315
|
-
let currentPhoto = currentSection[key].photos[j];
|
|
316
|
-
if (currentQuadrant === 3) {
|
|
317
|
-
doc.setLineWidth(0.025);
|
|
318
|
-
doc.setDrawColor(194, 197, 204);
|
|
319
|
-
doc.line(.25, 5.5, 8.25, 5.5);
|
|
320
|
-
} else if (currentQuadrant === 5) {
|
|
321
|
-
doc.addPage();
|
|
322
|
-
currentQuadrant = 1;
|
|
323
|
-
}
|
|
324
|
-
x = templates.photoCoordinates[`quadrant${currentQuadrant}`].x;
|
|
325
|
-
y = templates.photoCoordinates[`quadrant${currentQuadrant}`].y;
|
|
326
|
-
if (currentPhoto.base64) {
|
|
327
|
-
doc.text(getPhotoSectionNameFromTag(currentPhoto.tag), x, y);
|
|
328
|
-
let wPicMax = 3.75,
|
|
329
|
-
hPicMax = 4,
|
|
330
|
-
wPic = wPicMax,
|
|
331
|
-
hPic = hPicMax,
|
|
332
|
-
r = currentPhoto.aspect_ratio * 1;
|
|
333
|
-
if (r >= 1) { // logo is a landscape image
|
|
334
|
-
wPic = wPicMax;
|
|
335
|
-
hPic = wPic / r;
|
|
336
|
-
if (hPic > hPicMax) { // calculated h is too large for the available space
|
|
337
|
-
hPic = hPicMax;
|
|
338
|
-
wPic = hPic * r;
|
|
339
|
-
}
|
|
340
|
-
} else { // logo is a portrait image
|
|
341
|
-
hPic = hPicMax;
|
|
342
|
-
wPic = hPic * r;
|
|
343
|
-
if (wPic > wPicMax) { // calculated w is too large for the available space
|
|
344
|
-
wPic = wPicMax;
|
|
345
|
-
hPic = wPic / r;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
doc.addImage(currentPhoto.base64, "JPEG", x, y + .1, wPic, hPic);
|
|
349
|
-
}
|
|
350
|
-
currentQuadrant++;
|
|
351
|
-
}
|
|
352
|
-
// if (currentSection[key].hasNotes && currentSection[key].notes != "") {
|
|
353
|
-
// let notes = doc.splitTextToSize(`${currentSection[key].notes}`, 7.5);
|
|
354
|
-
// doc.setFontStyle("bold");
|
|
355
|
-
// doc.text("Notes:", x, y + hPic + .3);
|
|
356
|
-
// doc.setFontStyle("normal");
|
|
357
|
-
// doc.text(notes, x, y + hPic + .4);
|
|
358
|
-
// }
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
function printInfoPage() {
|
|
365
|
-
let infoPage = templates[`${reportData.meta.reportType}InfoPage`];
|
|
366
|
-
doc.addPage();
|
|
367
|
-
doc.setTextColor(0, 0, 0);
|
|
368
|
-
doc.setFontStyle("bold");
|
|
369
|
-
doc.setFontSize(14);
|
|
370
|
-
doc.text(infoPage.header, .5, .6);
|
|
371
|
-
doc.setFontSize(12);
|
|
372
|
-
for (let i = 0; i < infoPage.subheader.length; i++) {
|
|
373
|
-
let y = infoPage.y[i];
|
|
374
|
-
doc.setFontStyle("bold");
|
|
375
|
-
doc.text(infoPage.subheader[i], .5, y);
|
|
376
|
-
y += .2;
|
|
377
|
-
doc.setFontStyle("normal");
|
|
378
|
-
doc.text(doc.splitTextToSize(infoPage.body[i], 7.5), .5, y);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function getPhotoSectionNameFromTag(tag) {
|
|
383
|
-
let tagPrefixRemoved = tag.substr(tag.indexOf('_'));
|
|
384
|
-
let tagUnderscoresReplaced = tagPrefixRemoved.replaceAll('_', ' ');
|
|
385
|
-
let sectionName = `${tagUnderscoresReplaced.charAt(0).toUpperCase()}${tagUnderscoresReplaced.slice(1)}`;
|
|
386
|
-
return sectionName;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
function resizeAndPrintStaticImages() {
|
|
390
|
-
let wMax = 2.25,
|
|
391
|
-
hMax = .7,
|
|
392
|
-
x_profile = 6.9,
|
|
393
|
-
y_profile = 8.13,
|
|
394
|
-
size_profile = 1.25,
|
|
395
|
-
x_name = 8.15,
|
|
396
|
-
y_name = 8.025,
|
|
397
|
-
r = reportData.meta.companyLogoAspectRatio,
|
|
398
|
-
xOffset = 0,
|
|
399
|
-
yOffset = 0,
|
|
400
|
-
w = 0,
|
|
401
|
-
h = 0,
|
|
402
|
-
x = 6,
|
|
403
|
-
y = .2;
|
|
404
|
-
if (reportData.meta.companyLogoPlacement !== "header") {
|
|
405
|
-
x = 6;
|
|
406
|
-
y = 8;
|
|
407
|
-
x_profile = 7.375;
|
|
408
|
-
y_profile = .15;
|
|
409
|
-
size_profile = reportData.meta.reportTheme === 'dark' ? .8 : .9;
|
|
410
|
-
x_name = 7.25;
|
|
411
|
-
y_name = .5;
|
|
412
|
-
wMax = 2.25;
|
|
413
|
-
hMax = .8
|
|
414
|
-
}
|
|
415
|
-
if (r >= 1) {
|
|
416
|
-
w = wMax;
|
|
417
|
-
h = w / r;
|
|
418
|
-
if (h > hMax) {
|
|
419
|
-
h = hMax;
|
|
420
|
-
w = h * r;
|
|
421
|
-
}
|
|
422
|
-
} else {
|
|
423
|
-
h = hMax;
|
|
424
|
-
w = h * r;
|
|
425
|
-
if (w > wMax) {
|
|
426
|
-
w = wMax;
|
|
427
|
-
h = w / r;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
if (w < wMax) x = 8.5 - .25 - w;
|
|
431
|
-
doc.setFontSize(12);
|
|
432
|
-
doc.setFontType("bold");
|
|
433
|
-
doc.setTextColor(255, 255, 255);
|
|
434
|
-
if (reportData.meta.companyLogoPlacement == "Header" && h < hMax)
|
|
435
|
-
y = y + ((hMax - h) / 2);
|
|
436
|
-
doc.addImage(reportData.staticPhotos.companyLogo, "JPEG", x, y, w, h);
|
|
437
|
-
doc.addImage(reportData.staticPhotos.profilePicture, "JPEG", x_profile, y_profile, size_profile, size_profile);
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
function getToolIcon(measurementSource) {
|
|
441
|
-
switch (measurementSource) {
|
|
442
|
-
case "Fieldpiece": return "companyLogoFieldpiece";
|
|
443
|
-
default: return null;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
function getRangeIcon(key, actualValue, currentSnapshot) {
|
|
448
|
-
let ranges = JSON.parse(reportData.snapshots[currentSnapshot].rangeIcons);
|
|
449
|
-
let target = null, low = null, high = null;
|
|
450
|
-
let rangeIconRef = null;
|
|
451
|
-
if (ranges[key]) {
|
|
452
|
-
target = parseFloat(ranges[key]);
|
|
453
|
-
if (ranges[`${key}_ideal_low`]) low = target - parseFloat(ranges[`${key}_ideal_low`]);
|
|
454
|
-
if (ranges[`${key}_ideal_high`]) high = target + parseFloat(ranges[`${key}_ideal_high`]);
|
|
455
|
-
if (target && low && high) {
|
|
456
|
-
if (actualValue < low) rangeIconRef = "iconRangeLow";
|
|
457
|
-
else if (actualValue > high) rangeIconRef = "iconRangeHigh";
|
|
458
|
-
else rangeIconRef = "iconRangeNormal";
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
return rangeIconRef;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
function alignRight(text, rightAlign, fontSize) {
|
|
465
|
-
return rightAlign - doc.getStringUnitWidth(text) * fontSize / 72;
|
|
466
|
-
}
|