@measurequick/measurequick-report-generator 1.0.53 → 1.0.55
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/graphics.js +15 -0
- package/img/icon-flag-black.png +0 -0
- package/img/icon-flag-green.png +0 -0
- package/img/icon-flag-red.png +0 -0
- package/img/icon-flag-yellow.png +0 -0
- package/img/icon-range-green.png +0 -0
- package/img/icon-range-red.png +0 -0
- package/img/icon-stability.png +0 -0
- package/index.js +2 -2
- package/jspdf/mq-report-generator.js +9 -14
- package/{pdflib/mq-system-vitals-report-generator.js → mq-system-vitals-report-generator.js} +20 -8
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as mqReportGenerator from "./jspdf/mq-report-generator.js";
|
|
2
|
-
import * as mqSystemVitalsReportGenerator from "./
|
|
2
|
+
import * as mqSystemVitalsReportGenerator from "./mq-system-vitals-report-generator.js";
|
|
3
3
|
|
|
4
4
|
export function generateReport(reportType, payload) {
|
|
5
5
|
if (reportType == "mqStandard") reportType = "mqCooling";
|
|
6
6
|
switch (reportType) {
|
|
7
7
|
case "mqCooling":
|
|
8
8
|
case "mqHeating": return mqReportGenerator.generateReport(reportType, payload);
|
|
9
|
-
case "
|
|
9
|
+
case "mqSystemVitals": return mqSystemVitalsReportGenerator.generateReport(payload);
|
|
10
10
|
default: return false;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -8,8 +8,6 @@ let reportData;
|
|
|
8
8
|
let currentSnapshot;
|
|
9
9
|
|
|
10
10
|
export function generateReport(reportType, payload) {
|
|
11
|
-
console.log("reportType " + reportType);
|
|
12
|
-
console.log(payload);
|
|
13
11
|
try {
|
|
14
12
|
reportData = JSON.parse(JSON.stringify(payload));
|
|
15
13
|
let testNumber = 0;
|
|
@@ -115,7 +113,6 @@ function printBodyData(currentSnapshot) {
|
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
function printBodySection(currentSnapshot, measurementSection, xLeft, xRight, y) {
|
|
118
|
-
console.log("David: " + measurementSection + ": " + JSON.stringify(reportData.snapshots[currentSnapshot]));
|
|
119
116
|
let dataPoints = JSON.parse(reportData.snapshots[currentSnapshot][measurementSection]);
|
|
120
117
|
let printRangeIcons = true;
|
|
121
118
|
let units = "";
|
|
@@ -147,6 +144,7 @@ function printBodySection(currentSnapshot, measurementSection, xLeft, xRight, y)
|
|
|
147
144
|
valueText = `${dataPoint} / ${secondaryDataPoint}`;
|
|
148
145
|
} else valueText = `${dataPoint}`;
|
|
149
146
|
if (templateRef.label) doc.text(labelText, xLeft, y);
|
|
147
|
+
if (isNaN(valueText) || !valueText) valueText = "--";
|
|
150
148
|
doc.text(valueText, alignRight(valueText, xRight, 8), y);
|
|
151
149
|
if (printRangeIcons) {
|
|
152
150
|
let rangeIconRef = getRangeIcon(key, valueBeforeEditing, currentSnapshot);
|
|
@@ -227,18 +225,16 @@ function printDiagnosticPage() {
|
|
|
227
225
|
doc.addPage();
|
|
228
226
|
printBoilerPlateDiagnostic();
|
|
229
227
|
printSubsystemReview();
|
|
230
|
-
printSystemDiagnostics();
|
|
228
|
+
// printSystemDiagnostics();
|
|
231
229
|
printCorrectiveActions();
|
|
232
230
|
}
|
|
233
231
|
|
|
234
232
|
function printSubsystemReview() {
|
|
235
233
|
let y = 1;
|
|
236
234
|
let templateRef = templates[`${reportData.meta.reportType}SubsystemReview`];
|
|
237
|
-
console.log("templateRef is " + templateRef);
|
|
238
235
|
let ssr = JSON.parse(reportData.subsystemReview);
|
|
239
236
|
for (let i = 0; i < Object.keys(ssr).length; i++) {
|
|
240
237
|
let key = Object.keys(ssr)[i];
|
|
241
|
-
console.log("key is " + key);
|
|
242
238
|
doc.text(templateRef[key], .25, y);
|
|
243
239
|
doc.text(ssr[key], 3, y);
|
|
244
240
|
y += .15;
|
|
@@ -247,7 +243,6 @@ function printSubsystemReview() {
|
|
|
247
243
|
|
|
248
244
|
function printSystemDiagnostics() {
|
|
249
245
|
let y = 1;
|
|
250
|
-
console.log("DIAG: " + reportData.systemDiagnostics);
|
|
251
246
|
let diagnostics = JSON.parse(reportData.systemDiagnostics);
|
|
252
247
|
for (let i = 0; i < Object.keys(diagnostics).length; i++) {
|
|
253
248
|
let key = Object.keys(diagnostics)[i];
|
|
@@ -341,13 +336,13 @@ function printPhotoPages() {
|
|
|
341
336
|
}
|
|
342
337
|
currentQuadrant++;
|
|
343
338
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
339
|
+
if (currentSection[key].hasNotes && currentSection[key].notes != "") {
|
|
340
|
+
let notes = doc.splitTextToSize(`${currentSection[key].notes}`, 7.5);
|
|
341
|
+
doc.setFontStyle("bold");
|
|
342
|
+
doc.text("Notes:", x, y + hPic + .3);
|
|
343
|
+
doc.setFontStyle("normal");
|
|
344
|
+
doc.text(notes, x, y + hPic + .4);
|
|
345
|
+
}
|
|
351
346
|
}
|
|
352
347
|
}
|
|
353
348
|
}
|
package/{pdflib/mq-system-vitals-report-generator.js → mq-system-vitals-report-generator.js}
RENAMED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { PDFDocument } from 'pdf-lib';
|
|
2
|
+
import * as base64 from './graphics.js';
|
|
2
3
|
|
|
3
4
|
export async function generateReport(payload) {
|
|
4
5
|
// fetch and load form
|
|
5
|
-
const formPdfBytes =
|
|
6
|
+
const formPdfBytes = _base64ToArrayBuffer(base64.systemVitalsPdfTemplate)
|
|
6
7
|
const pdfDoc = await PDFDocument.load(formPdfBytes);
|
|
7
8
|
|
|
8
9
|
// fetch resources
|
|
9
|
-
const iconRangeGreenBytes =
|
|
10
|
-
const iconRangeRedBytes =
|
|
11
|
-
const iconFlagBlackBytes =
|
|
12
|
-
const iconFlagGreenBytes =
|
|
13
|
-
const iconFlagRedBytes =
|
|
14
|
-
const iconFlagYellowBytes =
|
|
15
|
-
const iconStabilityBytes =
|
|
10
|
+
const iconRangeGreenBytes = _base64ToArrayBuffer(base64.iconRangeGreen);
|
|
11
|
+
const iconRangeRedBytes = _base64ToArrayBuffer(base64.iconRangeRed);
|
|
12
|
+
const iconFlagBlackBytes = _base64ToArrayBuffer(base64.iconFlagBlack);
|
|
13
|
+
const iconFlagGreenBytes = _base64ToArrayBuffer(base64.iconFlagGreen);
|
|
14
|
+
const iconFlagRedBytes = _base64ToArrayBuffer(base64.iconFlagRed);
|
|
15
|
+
const iconFlagYellowBytes = _base64ToArrayBuffer(base64.iconFlagYellow);
|
|
16
|
+
const iconStabilityBytes = _base64ToArrayBuffer(base64.iconStability);
|
|
16
17
|
|
|
17
18
|
// load resources
|
|
18
19
|
const iconRangeGreen = await pdfDoc.embedPng(iconRangeGreenBytes);
|
|
@@ -163,3 +164,14 @@ function getTextFields(payload) {
|
|
|
163
164
|
"fltrFace": payload.test.data.velocity_face_filter1 ? payload.test.data.velocity_face_filter1.toFixed(1) + " SCFM" : "--"
|
|
164
165
|
}
|
|
165
166
|
}
|
|
167
|
+
|
|
168
|
+
function _base64ToArrayBuffer(base64) {
|
|
169
|
+
base64 = base64.replace(/^[^,]+,/, '').replace(/\s/g, '');
|
|
170
|
+
var binary_string = window.atob(base64);
|
|
171
|
+
var len = binary_string.length;
|
|
172
|
+
var bytes = new Uint8Array(len);
|
|
173
|
+
for (var i = 0; i < len; i++) {
|
|
174
|
+
bytes[i] = binary_string.charCodeAt(i);
|
|
175
|
+
}
|
|
176
|
+
return bytes.buffer;
|
|
177
|
+
}
|