@measurequick/measurequick-report-generator 1.2.8 → 1.2.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@measurequick/measurequick-report-generator",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "description": "Generates PDF documents for various MeasureQuick applications.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -129,13 +129,14 @@ export async function getReport(payload) {
129
129
  let measurement;
130
130
  if (t == 0) measurement = payload.test_in[`block${blockNum}`][rowNum - 1];
131
131
  else if (t == 1) measurement = payload.test_out[`block${blockNum}`][rowNum - 1];
132
+ let embeddedIcons = section == "test_in" ? embeddedIconsTestIn : embeddedIconsTestOut;
132
133
  if (measurement) {
133
134
  if (measurement.label == "Cond. Volts/Amps") {
134
- let condDisplay = util.getElectricalData(test, "");
135
+ let condDisplay = util.getElectricalData(test, "", embeddedIcons);
135
136
  if (condDisplay.voltageIcon) form.getButton(`Block${blockNum}-Row${rowNum}-Col4`).setImage(condDisplay.voltageIcon);
136
137
  } else if (measurement.label == "AHU Volts/Amps") {
137
- let ahuDisplay = util.getElectricalData(test, "_ahu");
138
- if (ahuDisplay.voltageIcon) form.getButton(`Block${blockNum}-Row${rowNum}-Col4`).setImage(ahuDisplay.voltageIcon);
138
+ let ahuDisplay = util.getElectricalData(test, "_ahu", embeddedIcons);
139
+ if (ahuDisplay.amperageIcon) form.getButton(`Block${blockNum}-Row${rowNum}-Col4`).setImage(ahuDisplay.amperageIcon);
139
140
  }
140
141
  let units = measurement.units ? `(${measurement.units})` : "";
141
142
  form.getTextField(`Block${blockNum}-Row${rowNum}-Col1`).setText(`${measurement.label} ${units}`);
@@ -143,7 +144,6 @@ export async function getReport(payload) {
143
144
  if (!val) val = "--";
144
145
  else if (measurement.fixTo) val = val.toFixed(measurement.fixTo);
145
146
  form.getTextField(`Block${blockNum}-Row${rowNum}-Col2`).setText(`${val}`);
146
- let embeddedIcons = section == "test_in" ? embeddedIconsTestIn : embeddedIconsTestOut;
147
147
  if (blockNum != 4) {
148
148
  let rangeIcon = util.getRangeIcon(test, measurement.ref, embeddedIcons);
149
149
  if (rangeIcon && payload.meta.pdf_settings._includeRangeIndicators) form.getButton(`Block${blockNum}-Row${rowNum}-Col3`).setImage(rangeIcon);
package/util.js CHANGED
@@ -83,53 +83,53 @@ export function getRangeIcon(test, ref, embeddedIcons) {
83
83
  return rangeIcon;
84
84
  }
85
85
 
86
- export function getElectricalData(test) {
87
- let voltage = test.voltage_nominal;
88
- let phase = test.phase;
86
+ export function getElectricalData(test, suffix, embeddedIcons) {
87
+ let voltage = test.[`voltage_nominal${suffix}`];
88
+ let phase = test.[`phase${suffix}`];
89
89
  let src = '_l1';
90
90
  let vDisplay, aDisplay, vIcon, aIcon;
91
91
 
92
92
  if (test.electrical_capture_type !== 'Power') {
93
93
  if (phase === 'Single') {
94
- if ((voltage == '115' || voltage == '120') && test.data.voltage_l1 && test.data.amperage_l1) {
95
- vDisplay = (+test.data.voltage_l1).toFixed(1);
96
- aDisplay = (+test.data.amperage_l1).toFixed(1);
97
- } else if ((voltage == '115' || voltage == '120') && test.data.voltage_l1_ph_to_gnd && test.data.amperage_l1_ph_to_gnd) {
98
- vDisplay = (+test.data.voltage_l1_ph_to_gnd).toFixed(1);
99
- aDisplay = (+test.data.amperage_l1_ph_to_gnd).toFixed(1);
94
+ if ((voltage == '115' || voltage == '120') && test.data[`voltage_l1`] && test.data[`amperage_l1`]) {
95
+ vDisplay = (+test.data[`voltage_l1`]).toFixed(1);
96
+ aDisplay = (+test.data[`amperage_l1`]).toFixed(1);
97
+ } else if ((voltage == '115' || voltage == '120') && test.data[`voltage_l1_ph_to_gnd`] && test.data[`amperage_l1_ph_to_gnd`]) {
98
+ vDisplay = (+test.data[`voltage_l1_ph_to_gnd`]).toFixed(1);
99
+ aDisplay = (+test.data[`amperage_l1_ph_to_gnd`]).toFixed(1);
100
100
  src = '_l1_ph_to_gnd';
101
101
  } else if ((voltage == '208' || voltage == '230' || voltage == '240' || voltage == '460' || voltage == '480') &&
102
- test.data.voltage_l1 && test.data.amperage_l1) {
103
- vDisplay = (+test.data.voltage_l1).toFixed(1);
104
- aDisplay = (+test.data.amperage_l1).toFixed(1);
102
+ test.data[`voltage_l1`] && test.data[`amperage_l1`]) {
103
+ vDisplay = (+test.data[`voltage_l1`]).toFixed(1);
104
+ aDisplay = (+test.data[`amperage_l1`]).toFixed(1);
105
105
  } else if ((voltage == '208' || voltage == '230' || voltage == '240' || voltage == '460' || voltage == '480') &&
106
- test.data.voltage_l1_ph_to_gnd && test.data.voltage_l2_ph_to_gnd &&
107
- test.data.amperage_l1_ph_to_gnd && test.data.amperage_l2_ph_to_gnd) {
108
- vDisplay = (+test.data.voltage_l1_ph_to_gnd).toFixed(1) + " / " + (+test.data.voltage_l2_ph_to_gnd).toFixed(1);
109
- aDisplay = (+test.data.amperage_l1_ph_to_gnd).toFixed(1) + " / " + (+test.data.amperage_l2_ph_to_gnd).toFixed(1);
106
+ test.data[`voltage_l1_ph_to_gnd`] && test.data[`voltage_l2_ph_to_gnd`] &&
107
+ test.data[`amperage_l1_ph_to_gnd`] && test.data[`amperage_l2_ph_to_gnd`]) {
108
+ vDisplay = (+test.data[`voltage_l1_ph_to_gnd`]).toFixed(1) + " / " + (+test.data[`voltage_l2_ph_to_gnd`]).toFixed(1);
109
+ aDisplay = (+test.data[`amperage_l1_ph_to_gnd`]).toFixed(1) + " / " + (+test.data[`amperage_l2_ph_to_gnd`]).toFixed(1);
110
110
  src = '_l1_ph_to_gnd';
111
111
  }
112
112
  } else if (phase === 'Three' &&
113
- test.data.voltage_l1 && test.data.voltage_l2 && test.data.voltage_l3 &&
114
- test.data.amperage_l1 && test.data.amperage_l2 && test.data.amperage_l3) {
115
- vDisplay = (+test.data.voltage_l1).toFixed(1) + " / " + (+test.data.voltage_l2).toFixed(1) + " / " + (+test.data.voltage_l3).toFixed(1);
116
- aDisplay = (+test.data.amperage_l1).toFixed(1) + " / " + (+test.data.amperage_l2).toFixed(1) + " / " + (+test.data.amperage_l3).toFixed(1);
113
+ test.data[`voltage_l1`] && test.data.voltage_l2 && test.data[`voltage_l3`] &&
114
+ test.data[`amperage_l1`] && test.data.amperage_l2 && test.data[`amperage_l3`]) {
115
+ vDisplay = (+test.data[`voltage_l1`]).toFixed(1) + " / " + (+test.data[`voltage_l2`]).toFixed(1) + " / " + (+test.data[`voltage_l3`]).toFixed(1);
116
+ aDisplay = (+test.data[`amperage_l1`]).toFixed(1) + " / " + (+test.data[`amperage_l2`]).toFixed(1) + " / " + (+test.data[`amperage_l3`]).toFixed(1);
117
117
  }
118
118
  } else if (test.electrical_capture_type === 'Power') {
119
- vDisplay = (+test.data.voltage_l1).toFixed(1);
120
- aDisplay = (+test.data.amperage_l1).toFixed(1);
119
+ vDisplay = (+test.data[`voltage_l1`]).toFixed(1);
120
+ aDisplay = (+test.data[`amperage_l1`]).toFixed(1);
121
121
  }
122
122
  if (vDisplay) {
123
- if (test.source['voltage'+src] == 'ComfortGuard') vIcon = "ComfortGuard";
124
- else if (test.source['voltage'+src] == 'iDVM550') vIcon = "iDVM550";
125
- else if (test.source['voltage'+src] == 'iDVM510') vIcon = "iDVM510";
126
- else if (test.source['voltage'+src] == 'Fieldpiece') vIcon = "Fieldpiece";
123
+ if (test.source['voltage'+src] == 'ComfortGuard') vIcon = embeddedIcons.iconSensi;
124
+ else if (test.source['voltage'+src] == 'iDVM550') vIcon = embeddedIcons.iconRedfish550;
125
+ else if (test.source['voltage'+src] == 'iDVM510') vIcon = embeddedIcons.iconRedfish510;
126
+ else if (test.source['voltage'+src] == 'Fieldpiece') vIcon = embeddedIcons.iconFieldpiece;
127
127
  }
128
128
  if (aDisplay) {
129
- if (test.source['amperage'+src] == 'ComfortGuard') aIcon = "ComfortGuard";
130
- else if (test.source['amperage'+src] == 'iDVM550') aIcon = "iDVM550";
131
- else if (test.source['amperage'+src] == 'iDVM510') aIcon = "iDVM510";
132
- else if (test.source['amperage'+src] == 'Fieldpiece') aIcon = "Fieldpiece";
129
+ if (test.source['amperage'+src] == 'ComfortGuard') aIcon = embeddedIcons.iconSensi;
130
+ else if (test.source['amperage'+src] == 'iDVM550') aIcon = embeddedIcons.iconRedfish550;
131
+ else if (test.source['amperage'+src] == 'iDVM510') aIcon = embeddedIcons.iconRedfish510;
132
+ else if (test.source['amperage'+src] == 'Fieldpiece') aIcon = embeddedIcons.iconFieldpiece;
133
133
  }
134
134
  return { voltage: vDisplay, amperage: aDisplay, voltageIcon: vIcon, amperageIcon: aIcon };
135
135
  }