@measurequick/measurequick-report-generator 1.0.62 → 1.0.64
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.
|
@@ -11,16 +11,11 @@ export function generateReport(reportType, payload) {
|
|
|
11
11
|
try {
|
|
12
12
|
doc = new jsPDF(templates.docOptions);
|
|
13
13
|
reportData = JSON.parse(JSON.stringify(payload));
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
printBodyData(currentSnapshot);
|
|
20
|
-
printFooterData();
|
|
21
|
-
resizeAndPrintStaticImages();
|
|
22
|
-
testNumber++;
|
|
23
|
-
}
|
|
14
|
+
printBoilerPlateStandard();
|
|
15
|
+
printHeaderData();
|
|
16
|
+
printBodyData(reportData.test);
|
|
17
|
+
printFooterData();
|
|
18
|
+
resizeAndPrintStaticImages();
|
|
24
19
|
printDiagnosticPage();
|
|
25
20
|
printInfoPage();
|
|
26
21
|
printPhotoPages();
|
|
@@ -31,11 +26,12 @@ export function generateReport(reportType, payload) {
|
|
|
31
26
|
}
|
|
32
27
|
|
|
33
28
|
function printBoilerPlateStandard() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
let theme = JSON.parse(reportData.reportSettings).colorTheme;
|
|
30
|
+
if (theme == "dark") {
|
|
31
|
+
doc.addImage(graphics.headerMeasureQuick, "JPEG", 0, 0, 8.5, 1);
|
|
32
|
+
doc.addImage(graphics.footerMeasureQuick, "JPEG", 0, 7.75, 8.5, 4.5);
|
|
33
|
+
}
|
|
34
|
+
let mqLogo = theme == "dark" ? graphics.companyLogoMeasureQuickLight : graphics.companyLogoMeasureQuickDark;
|
|
39
35
|
doc.addImage(mqLogo, "JPEG", .25, 10, 2.15625, .5);
|
|
40
36
|
doc.setLineWidth(0.025);
|
|
41
37
|
doc.setDrawColor(0);
|
|
@@ -62,14 +58,20 @@ function printBoilerPlateStandard() {
|
|
|
62
58
|
doc.text(headers.headerSection4Subsection3, 2.25, 5.655);
|
|
63
59
|
doc.setFontSize(6.5);
|
|
64
60
|
doc.setFontStyle("bolditalic");
|
|
65
|
-
doc.setTextColor(255, 255, 255);
|
|
61
|
+
theme == "dark" ? doc.setTextColor(255, 255, 255) : doc.setTextColor(0, 0, 0);
|
|
66
62
|
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.`;
|
|
67
63
|
disclaimer = doc.splitTextToSize(disclaimer.toUpperCase(), 8);
|
|
68
64
|
doc.text(disclaimer, .125, 10.66);
|
|
65
|
+
doc.setTextColor(255, 255, 255);
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
function printBoilerPlateDiagnostic() {
|
|
72
|
-
doc.addImage(graphics.headerMeasureQuick, "JPEG", 0, 0, 8.5, 1);
|
|
69
|
+
if (JSON.parse(reportData.reportSettings).colorTheme == "dark") doc.addImage(graphics.headerMeasureQuick, "JPEG", 0, 0, 8.5, 1);
|
|
70
|
+
doc.setFontSize(12);
|
|
71
|
+
doc.setFontStyle("bold");
|
|
72
|
+
JSON.parse(reportData.reportSettings).colorTheme == "dark" ? doc.setTextColor(255, 255, 255) : doc.setTextColor(0, 0, 0);
|
|
73
|
+
doc.text("Diagnostic Report", .25, .35);
|
|
74
|
+
doc.setTextColor(255, 255, 255);
|
|
73
75
|
doc.setLineWidth(0.025);
|
|
74
76
|
doc.setDrawColor(0);
|
|
75
77
|
doc.setFillColor(242, 242, 242);
|
|
@@ -92,7 +94,9 @@ function printHeaderData() {
|
|
|
92
94
|
do { size -= .5; } while ((doc.getStringUnitWidth(reportData.meta.reportName) * size / 72) > 4.5);
|
|
93
95
|
doc.setFontSize(size);
|
|
94
96
|
doc.setFontStyle("bold");
|
|
97
|
+
JSON.parse(reportData.reportSettings).colorTheme == "dark" ? doc.setTextColor(255, 255, 255) : doc.setTextColor(0, 0, 0);
|
|
95
98
|
doc.text(reportData.meta.reportName, 0.25, .75);
|
|
99
|
+
doc.setTextColor(255, 255, 255);
|
|
96
100
|
}
|
|
97
101
|
|
|
98
102
|
function printBodyData(currentSnapshot) {
|
|
@@ -114,8 +118,7 @@ function printBodyData(currentSnapshot) {
|
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
function printBodySection(currentSnapshot, measurementSection, xLeft, xRight, y) {
|
|
117
|
-
let dataPoints = JSON.parse(
|
|
118
|
-
let printRangeIcons = true;
|
|
121
|
+
let dataPoints = JSON.parse(currentSnapshot[measurementSection]);
|
|
119
122
|
let units = "";
|
|
120
123
|
let labelText = "";
|
|
121
124
|
let valueText = "";
|
|
@@ -129,10 +132,11 @@ function printBodySection(currentSnapshot, measurementSection, xLeft, xRight, y)
|
|
|
129
132
|
let valueBeforeEditing = dataPoint;
|
|
130
133
|
let templateRef = templates[measurementSection][key];
|
|
131
134
|
if (templateRef) {
|
|
132
|
-
|
|
135
|
+
labelText = templateRef.label;
|
|
136
|
+
if (templateRef.hasOwnProperty("units")) {
|
|
133
137
|
units = Array.isArray(templateRef.units) ? `(${templateRef.units[0]} / ${templateRef.units[1]})` : `(${templateRef.units})`;
|
|
134
|
-
|
|
135
|
-
labelText
|
|
138
|
+
labelText += ` ${units}:`;
|
|
139
|
+
} else labelText += ':';
|
|
136
140
|
if (templateRef.hasOwnProperty("roundTo")) {
|
|
137
141
|
dataPoint *= 1;
|
|
138
142
|
dataPoint = dataPoint.toFixed(templateRef.roundTo);
|
|
@@ -146,13 +150,23 @@ function printBodySection(currentSnapshot, measurementSection, xLeft, xRight, y)
|
|
|
146
150
|
valueText = `${dataPoint} / ${secondaryDataPoint}`;
|
|
147
151
|
} else valueText = `${dataPoint}`;
|
|
148
152
|
if (templateRef.label) doc.text(labelText, xLeft, y);
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (
|
|
153
|
+
if (!valueText) valueText = "--";
|
|
154
|
+
let fs = 8;
|
|
155
|
+
if (key == "capacityActualNormalized" || key == "capacitySensibleNormalized" || key == "capacityLatentNormalized") {
|
|
156
|
+
doc.setFontSize(6);
|
|
157
|
+
fs = 6;
|
|
158
|
+
y -= .05;
|
|
159
|
+
}
|
|
160
|
+
doc.text(valueText, alignRight(valueText, xRight, fs), y);
|
|
161
|
+
if (key == "capacityActualNormalized" || key == "capacitySensibleNormalized" || key == "capacityLatentNormalized") {
|
|
162
|
+
doc.setFontSize(8);
|
|
163
|
+
y += .05;
|
|
164
|
+
}
|
|
165
|
+
if (JSON.parse(reportData.reportSettings).includeRangeIndicators) {
|
|
152
166
|
let rangeIconRef = getRangeIcon(key, valueBeforeEditing, currentSnapshot);
|
|
153
167
|
if (rangeIconRef) doc.addImage(graphics[rangeIconRef], "JPEG", xRight + .05, y - .12, .16, .16);
|
|
154
168
|
}
|
|
155
|
-
let toolIconRef = getToolIcon(
|
|
169
|
+
let toolIconRef = getToolIcon(JSON.parse(currentSnapshot.toolIcons)[key]);
|
|
156
170
|
if (toolIconRef) doc.addImage(graphics[toolIconRef], "JPEG", xRight + .25, y - .12, .16, .16);
|
|
157
171
|
y += (s * sMultiplier);
|
|
158
172
|
} else if (key == "newColumn") {
|
|
@@ -256,7 +270,7 @@ function printSystemDiagnostics() {
|
|
|
256
270
|
else if (score > 1 && score < 10) diagnosticIcon = graphics.iconFlagRed;
|
|
257
271
|
else if (score >= 10 && score < 15) diagnosticIcon = graphics.iconFlagYellow;
|
|
258
272
|
else if (score >= 15) diagnosticIcon = graphics.iconFlagBlack;
|
|
259
|
-
if (diagnosticIcon) doc.addImage(diagnosticIcon, "PNG", 7.
|
|
273
|
+
if (diagnosticIcon) doc.addImage(diagnosticIcon, "PNG", 7.8, y + .1, .18, .18);
|
|
260
274
|
y += .2;
|
|
261
275
|
doc.text(diagnostics[key].title, 4.4375, y);
|
|
262
276
|
doc.text(`${diagnostics[key].score}`, 7.5, y);
|
|
@@ -445,6 +459,11 @@ function resizeAndPrintStaticImages() {
|
|
|
445
459
|
profileImage = profileSettings.base64ProfilePhotoSquare;
|
|
446
460
|
if (profileImage)
|
|
447
461
|
doc.addImage(profileImage, "PNG", x_profile, y_profile, size_profile, size_profile);
|
|
462
|
+
if (profileSettings.techName) {
|
|
463
|
+
doc.setTextColor(0, 0, 0);
|
|
464
|
+
doc.text(profileSettings.techName, x_profile, y_profile + size_profile);
|
|
465
|
+
doc.setTextColor(255, 255, 255);
|
|
466
|
+
}
|
|
448
467
|
}
|
|
449
468
|
}
|
|
450
469
|
|
|
@@ -475,12 +494,12 @@ function setColor(measure) {
|
|
|
475
494
|
function getRangeIcon(key, actualValue, currentSnapshot) {
|
|
476
495
|
// Special Case
|
|
477
496
|
let rangeIconRef = null;
|
|
478
|
-
if (key == '
|
|
497
|
+
if (key == 'systemBenchmarked') {
|
|
479
498
|
if (actualValue == 'Yes') rangeIconRef = "iconThumbprintGreen";
|
|
480
499
|
else if (actualValue == 'Yes, under duress') rangeIconRef = "iconCautionTriangleYellow";
|
|
481
500
|
else rangeIconRef = "iconThumbprintRed";
|
|
482
501
|
} else {
|
|
483
|
-
let ranges = JSON.parse(
|
|
502
|
+
let ranges = JSON.parse(currentSnapshot.rangeIcons);
|
|
484
503
|
let target = null, low = null, high = null;
|
|
485
504
|
if (ranges[key]) {
|
|
486
505
|
target = parseFloat(ranges[key]);
|
package/package.json
CHANGED
|
@@ -284,11 +284,9 @@ export const indoorMeasurements = {
|
|
|
284
284
|
},
|
|
285
285
|
"airHandlerVoltage": {
|
|
286
286
|
"label": "AHU Voltage",
|
|
287
|
-
"roundTo": 1
|
|
288
287
|
},
|
|
289
288
|
"airHandlerAmperage": {
|
|
290
289
|
"label": "AHU Amperage",
|
|
291
|
-
"roundTo": 1
|
|
292
290
|
},
|
|
293
291
|
"power_factor_ahu": {
|
|
294
292
|
"label": "AHU Power Factor",
|