@measurequick/measurequick-report-generator 1.5.142 → 1.5.143
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PDFDocument } from "pdf-lib";
|
|
1
|
+
import { PDFDocument, rgb } from "pdf-lib";
|
|
2
2
|
import * as base64 from "../base-64/icons.js";
|
|
3
3
|
import * as pdf from "../base-64/mq-vitals-heating-no-combustion.js";
|
|
4
4
|
import * as systemInfoPage from "./system-info-page.js";
|
|
@@ -446,10 +446,49 @@ export async function getReport(payload, _test) {
|
|
|
446
446
|
if (passFails[i] === "heating_efficiency_pass_fail")
|
|
447
447
|
icon = iconRangeGreen;
|
|
448
448
|
|
|
449
|
+
// Set the icon as before
|
|
449
450
|
safeSetImage(form, `ImageSubsystem${i + 1}_af_image`, icon);
|
|
450
451
|
|
|
451
452
|
const suffix = test.testInfo[passFails[i] + "_override"] ? " *" : "";
|
|
452
|
-
|
|
453
|
+
const fieldName = `SSR${i + 1}`;
|
|
454
|
+
|
|
455
|
+
// Default label for non-special cases
|
|
456
|
+
let label = pfLabels[i] + suffix;
|
|
457
|
+
|
|
458
|
+
// Special handling: Ambient CO failure should be red and show a stronger warning
|
|
459
|
+
if (passFails[i] === "ambient_pass_fail") {
|
|
460
|
+
const isFail = !(
|
|
461
|
+
meas === "Pass" ||
|
|
462
|
+
meas === "High" ||
|
|
463
|
+
meas === "Mid" ||
|
|
464
|
+
meas === "Caution"
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
if (isFail) {
|
|
468
|
+
label = "CO Ambient High, Investigate Source!";
|
|
469
|
+
try {
|
|
470
|
+
const tf = form.getTextField(fieldName);
|
|
471
|
+
tf.setText(label);
|
|
472
|
+
tf.setTextColor(rgb(1, 0, 0)); // red
|
|
473
|
+
} catch (e) {}
|
|
474
|
+
continue; // move to next item; we've already set text & color
|
|
475
|
+
} else {
|
|
476
|
+
// Non-fail states: ensure text is black
|
|
477
|
+
try {
|
|
478
|
+
const tf = form.getTextField(fieldName);
|
|
479
|
+
tf.setText(label);
|
|
480
|
+
tf.setTextColor(rgb(0, 0, 0)); // black
|
|
481
|
+
} catch (e) {}
|
|
482
|
+
continue;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// All other pass/fail items: keep existing label, ensure black text
|
|
487
|
+
try {
|
|
488
|
+
const tf = form.getTextField(fieldName);
|
|
489
|
+
tf.setText(label);
|
|
490
|
+
tf.setTextColor(rgb(0, 0, 0));
|
|
491
|
+
} catch (e) {}
|
|
453
492
|
}
|
|
454
493
|
} else safeSetText(form, `SSR1`, "Not yet reviewed");
|
|
455
494
|
|
|
@@ -421,17 +421,69 @@ export async function getReport(payload, _test) {
|
|
|
421
421
|
pfLabels.splice(3, 1);
|
|
422
422
|
}
|
|
423
423
|
for (let i = 0; i < passFails.length; i++) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
424
|
+
const meas = test.testInfo[passFails[i]];
|
|
425
|
+
|
|
426
|
+
// If no value provided, hide the label (set empty) and skip icon
|
|
427
|
+
if (meas === undefined || meas === null || meas === "") {
|
|
428
|
+
safeSetText(form, `SSR${i + 1}`, "");
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Choose icon based on value
|
|
433
|
+
let icon;
|
|
434
|
+
if (meas === "Caution") {
|
|
435
|
+
icon = iconRangeYellow;
|
|
436
|
+
} else if (meas === "Pass" || meas === "High" || meas === "Mid") {
|
|
437
|
+
icon = iconRangeGreen;
|
|
438
|
+
} else {
|
|
439
|
+
icon = iconRangeRed;
|
|
440
|
+
}
|
|
441
|
+
if (passFails[i] === "heating_efficiency_pass_fail")
|
|
431
442
|
icon = iconRangeGreen;
|
|
443
|
+
|
|
444
|
+
// Set the icon as before
|
|
432
445
|
safeSetImage(form, `ImageSubsystem${i + 1}_af_image`, icon);
|
|
433
|
-
|
|
434
|
-
|
|
446
|
+
|
|
447
|
+
const suffix = test.testInfo[passFails[i] + "_override"] ? " *" : "";
|
|
448
|
+
const fieldName = `SSR${i + 1}`;
|
|
449
|
+
|
|
450
|
+
// Default label for non-special cases
|
|
451
|
+
let label = pfLabels[i] + suffix;
|
|
452
|
+
|
|
453
|
+
// Special handling: Ambient CO failure should be red and show a stronger warning
|
|
454
|
+
if (passFails[i] === "ambient_pass_fail") {
|
|
455
|
+
const isFail = !(
|
|
456
|
+
meas === "Pass" ||
|
|
457
|
+
meas === "High" ||
|
|
458
|
+
meas === "Mid" ||
|
|
459
|
+
meas === "Caution"
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
if (isFail) {
|
|
463
|
+
label = "CO Ambient High, Investigate Source!";
|
|
464
|
+
try {
|
|
465
|
+
const tf = form.getTextField(fieldName);
|
|
466
|
+
tf.setText(label);
|
|
467
|
+
tf.setTextColor(rgb(1, 0, 0)); // red
|
|
468
|
+
} catch (e) {}
|
|
469
|
+
continue; // move to next item; we've already set text & color
|
|
470
|
+
} else {
|
|
471
|
+
// Non-fail states: ensure text is black
|
|
472
|
+
try {
|
|
473
|
+
const tf = form.getTextField(fieldName);
|
|
474
|
+
tf.setText(label);
|
|
475
|
+
tf.setTextColor(rgb(0, 0, 0)); // black
|
|
476
|
+
} catch (e) {}
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// All other pass/fail items: keep existing label, ensure black text
|
|
482
|
+
try {
|
|
483
|
+
const tf = form.getTextField(fieldName);
|
|
484
|
+
tf.setText(label);
|
|
485
|
+
tf.setTextColor(rgb(0, 0, 0));
|
|
486
|
+
} catch (e) {}
|
|
435
487
|
}
|
|
436
488
|
} else safeSetText(form, `SSR1`, "Not yet reviewed");
|
|
437
489
|
|