@measurequick/measurequick-report-generator 1.5.219 → 1.5.220
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
|
|
@@ -652,21 +677,32 @@ export async function getReport(payload, _test) {
|
|
|
652
677
|
if (coValue !== null && !isNaN(coValue)) {
|
|
653
678
|
icon = getCOIcon(coValue);
|
|
654
679
|
const stateText = getCOStateText(coValue);
|
|
655
|
-
|
|
680
|
+
|
|
681
|
+
// Format label based on CO level
|
|
682
|
+
if (coValue <= 8) {
|
|
683
|
+
// Normal - just show value
|
|
684
|
+
label = "Ambient CO: " + Math.round(coValue) + " ppm" + suffix;
|
|
685
|
+
} else {
|
|
686
|
+
// Elevated/Dangerous/Emergency - show level and "Investigate!"
|
|
687
|
+
label = "CO Ambient " + stateText + " " + Math.round(coValue) + " ppm, Investigate!" + suffix;
|
|
688
|
+
}
|
|
656
689
|
|
|
657
690
|
// Set text color based on CO level
|
|
658
|
-
|
|
659
|
-
|
|
691
|
+
// Orange for Elevated, Red for Dangerous, Dark Red for Emergency
|
|
692
|
+
if (coValue >= 70) {
|
|
693
|
+
textColor = rgb(0.72, 0.11, 0.11); // Dark red for Emergency
|
|
694
|
+
} else if (coValue >= 36) {
|
|
695
|
+
textColor = rgb(0.96, 0.26, 0.21); // Red for Dangerous
|
|
660
696
|
} else if (coValue >= 9) {
|
|
661
|
-
textColor = rgb(
|
|
697
|
+
textColor = rgb(1, 0.6, 0); // Orange for Elevated
|
|
662
698
|
}
|
|
663
699
|
} else {
|
|
664
700
|
// No CO value, use pass/fail status
|
|
665
701
|
const isFail = !(meas === "Pass" || meas === "High" || meas === "Mid" || meas === "Caution");
|
|
666
702
|
if (isFail) {
|
|
667
|
-
label = "CO Ambient
|
|
668
|
-
textColor = rgb(1, 0, 0);
|
|
669
|
-
icon =
|
|
703
|
+
label = "CO Ambient Elevated, Investigate!" + suffix;
|
|
704
|
+
textColor = rgb(1, 0.6, 0); // Orange
|
|
705
|
+
icon = iconRangeYellow;
|
|
670
706
|
}
|
|
671
707
|
}
|
|
672
708
|
}
|