@measurequick/measurequick-report-generator 1.5.219 → 1.5.221
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
|
@@ -318,23 +318,48 @@ export async function getReport(payload, _test) {
|
|
|
318
318
|
|
|
319
319
|
if (coHigh) {
|
|
320
320
|
VH_LOG("Setting CO warnings in form fields: COWarning / COWarning2");
|
|
321
|
-
// Find the highest severity level
|
|
321
|
+
// Find the highest severity level and the ambient CO reading
|
|
322
322
|
var highestLevel = "Elevated";
|
|
323
|
-
var
|
|
323
|
+
var ambientReading = null;
|
|
324
324
|
for (var r = 0; r < reasons.length; r++) {
|
|
325
|
-
if (reasons[r].
|
|
325
|
+
if (reasons[r].type === "Ambient") ambientReading = reasons[r];
|
|
326
326
|
if (reasons[r].level === "Emergency") highestLevel = "Emergency";
|
|
327
327
|
else if (reasons[r].level === "Dangerous" && highestLevel !== "Emergency") highestLevel = "Dangerous";
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
// Build
|
|
331
|
-
var
|
|
330
|
+
// Build warning message focused on ambient CO
|
|
331
|
+
var warningMsg, warningMsg2;
|
|
332
|
+
if (ambientReading) {
|
|
333
|
+
warningMsg = "WARNING: " + ambientReading.level + " Ambient CO Detected: " + Math.round(ambientReading.value) + " ppm\nVentilate the area and investigate source.";
|
|
334
|
+
warningMsg2 = "WARNING: " + ambientReading.level + " Ambient CO Detected: " + Math.round(ambientReading.value) + " ppm. Ventilate the area and investigate source.";
|
|
335
|
+
} else {
|
|
336
|
+
// Fallback if no ambient reading (use first reading)
|
|
337
|
+
var firstReading = reasons[0];
|
|
338
|
+
warningMsg = "WARNING: " + firstReading.level + " " + firstReading.type + " CO Detected: " + Math.round(firstReading.value) + " ppm\nVentilate the area and investigate source.";
|
|
339
|
+
warningMsg2 = "WARNING: " + firstReading.level + " " + firstReading.type + " CO Detected: " + Math.round(firstReading.value) + " ppm. Ventilate the area and investigate source.";
|
|
340
|
+
}
|
|
332
341
|
|
|
333
|
-
|
|
334
|
-
|
|
342
|
+
// Set text with color based on severity level
|
|
343
|
+
// Orange for Elevated, Red for Dangerous, Dark Red for Emergency
|
|
344
|
+
var warningColor;
|
|
345
|
+
if (highestLevel === "Emergency") {
|
|
346
|
+
warningColor = rgb(0.72, 0.11, 0.11); // Dark red (#b71c1c)
|
|
347
|
+
} else if (highestLevel === "Dangerous") {
|
|
348
|
+
warningColor = rgb(0.96, 0.26, 0.21); // Red (#f44336)
|
|
349
|
+
} else {
|
|
350
|
+
warningColor = rgb(1, 0.6, 0); // Orange (#ff9800)
|
|
351
|
+
}
|
|
335
352
|
|
|
336
|
-
|
|
337
|
-
|
|
353
|
+
try {
|
|
354
|
+
var tf1 = form.getTextField("COWarning");
|
|
355
|
+
tf1.setText(warningMsg);
|
|
356
|
+
tf1.setTextColor(warningColor);
|
|
357
|
+
} catch (e) {}
|
|
358
|
+
try {
|
|
359
|
+
var tf2 = form.getTextField("COWarning2");
|
|
360
|
+
tf2.setText(warningMsg2);
|
|
361
|
+
tf2.setTextColor(warningColor);
|
|
362
|
+
} catch (e) {}
|
|
338
363
|
} else {
|
|
339
364
|
VH_LOG("Clearing CO warnings (values within threshold)");
|
|
340
365
|
// clear warnings if not applicable
|
|
@@ -644,29 +669,39 @@ export async function getReport(payload, _test) {
|
|
|
644
669
|
|
|
645
670
|
// Special handling for Ambient CO
|
|
646
671
|
if (passFails[i] === "ambient_pass_fail") {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
: null;
|
|
672
|
+
// Use coAmbRaw which is already defined and validated earlier in the function
|
|
673
|
+
const coValue = isFinite(coAmbRaw) ? coAmbRaw : null;
|
|
650
674
|
|
|
651
675
|
// Use CO-specific icon based on actual value
|
|
652
|
-
if (coValue !== null
|
|
676
|
+
if (coValue !== null) {
|
|
653
677
|
icon = getCOIcon(coValue);
|
|
654
678
|
const stateText = getCOStateText(coValue);
|
|
655
|
-
|
|
679
|
+
|
|
680
|
+
// Format label based on CO level
|
|
681
|
+
if (coValue <= 8) {
|
|
682
|
+
// Normal - just show value
|
|
683
|
+
label = "Ambient CO: " + Math.round(coValue) + " ppm" + suffix;
|
|
684
|
+
} else {
|
|
685
|
+
// Elevated/Dangerous/Emergency - show level and "Investigate!"
|
|
686
|
+
label = "CO Ambient " + stateText + " " + Math.round(coValue) + " ppm, Investigate!" + suffix;
|
|
687
|
+
}
|
|
656
688
|
|
|
657
689
|
// Set text color based on CO level
|
|
658
|
-
|
|
659
|
-
|
|
690
|
+
// Orange for Elevated, Red for Dangerous, Dark Red for Emergency
|
|
691
|
+
if (coValue >= 70) {
|
|
692
|
+
textColor = rgb(0.72, 0.11, 0.11); // Dark red for Emergency
|
|
693
|
+
} else if (coValue >= 36) {
|
|
694
|
+
textColor = rgb(0.96, 0.26, 0.21); // Red for Dangerous
|
|
660
695
|
} else if (coValue >= 9) {
|
|
661
|
-
textColor = rgb(
|
|
696
|
+
textColor = rgb(1, 0.6, 0); // Orange for Elevated
|
|
662
697
|
}
|
|
663
698
|
} else {
|
|
664
699
|
// No CO value, use pass/fail status
|
|
665
700
|
const isFail = !(meas === "Pass" || meas === "High" || meas === "Mid" || meas === "Caution");
|
|
666
701
|
if (isFail) {
|
|
667
|
-
label = "CO Ambient
|
|
668
|
-
textColor = rgb(1, 0, 0);
|
|
669
|
-
icon =
|
|
702
|
+
label = "CO Ambient Elevated, Investigate!" + suffix;
|
|
703
|
+
textColor = rgb(1, 0.6, 0); // Orange
|
|
704
|
+
icon = iconRangeYellow;
|
|
670
705
|
}
|
|
671
706
|
}
|
|
672
707
|
}
|