@measurequick/measurequick-report-generator 1.5.135 → 1.5.137
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,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import * as
|
|
5
|
-
import * as util from '../util.js';
|
|
6
|
-
import * as pdf from '../base-64/measurement-details-page.js';
|
|
1
|
+
import { PDFDocument } from "pdf-lib";
|
|
2
|
+
import * as base64 from "../base-64/icons.js";
|
|
3
|
+
import * as util from "../util.js";
|
|
4
|
+
import * as pdf from "../base-64/measurement-details-page.js";
|
|
7
5
|
|
|
8
6
|
let embeddedIconsTestIn = {};
|
|
9
7
|
let embeddedIconsTestOut = {};
|
|
10
8
|
|
|
11
9
|
export async function getReport(payload) {
|
|
12
10
|
try {
|
|
13
|
-
const pdfDocPg1 = await PDFDocument.load(
|
|
14
|
-
|
|
11
|
+
const pdfDocPg1 = await PDFDocument.load(
|
|
12
|
+
util._base64ToArrayBuffer(pdf.base64)
|
|
13
|
+
);
|
|
14
|
+
const pdfDocPg2 = await PDFDocument.load(
|
|
15
|
+
util._base64ToArrayBuffer(pdf.base64)
|
|
16
|
+
);
|
|
15
17
|
|
|
16
18
|
const formPg1 = pdfDocPg1.getForm();
|
|
17
19
|
const formPg2 = pdfDocPg2.getForm();
|
|
@@ -19,22 +21,60 @@ export async function getReport(payload) {
|
|
|
19
21
|
const isGoettlInstall = util.projectIsGoettl(payload.project);
|
|
20
22
|
|
|
21
23
|
let mapImagePg1, mapImagePg2;
|
|
22
|
-
if (payload.map && typeof payload.map ==
|
|
24
|
+
if (payload.map && typeof payload.map == "string") {
|
|
23
25
|
if (payload.map.includes("image/jpeg")) {
|
|
24
|
-
mapImagePg1 = await pdfDocPg1.embedJpg(
|
|
25
|
-
|
|
26
|
+
mapImagePg1 = await pdfDocPg1.embedJpg(
|
|
27
|
+
util._base64ToArrayBuffer(payload.map)
|
|
28
|
+
);
|
|
29
|
+
mapImagePg2 = await pdfDocPg2.embedJpg(
|
|
30
|
+
util._base64ToArrayBuffer(payload.map)
|
|
31
|
+
);
|
|
26
32
|
} else if (payload.map.includes("image/png")) {
|
|
27
|
-
mapImagePg1 = await pdfDocPg1.embedPng(
|
|
28
|
-
|
|
33
|
+
mapImagePg1 = await pdfDocPg1.embedPng(
|
|
34
|
+
util._base64ToArrayBuffer(payload.map)
|
|
35
|
+
);
|
|
36
|
+
mapImagePg2 = await pdfDocPg2.embedPng(
|
|
37
|
+
util._base64ToArrayBuffer(payload.map)
|
|
38
|
+
);
|
|
29
39
|
}
|
|
30
40
|
}
|
|
31
41
|
|
|
32
|
-
let labels = [
|
|
33
|
-
"
|
|
34
|
-
"
|
|
42
|
+
let labels = [
|
|
43
|
+
"iconRangeHigh",
|
|
44
|
+
"iconRangeLow",
|
|
45
|
+
"iconRangeNormal",
|
|
46
|
+
"iconTesto",
|
|
47
|
+
"iconNavac",
|
|
48
|
+
"iconCalculator",
|
|
49
|
+
"iconFieldpiece",
|
|
50
|
+
"iconUei",
|
|
51
|
+
"iconSporlanPro",
|
|
52
|
+
"iconSporlanLegacy",
|
|
53
|
+
"iconIconnect",
|
|
54
|
+
"iconImanifold",
|
|
55
|
+
"iconSensi",
|
|
56
|
+
"iconDg8",
|
|
57
|
+
"iconJb",
|
|
58
|
+
"iconBluflame",
|
|
59
|
+
"iconSauermann",
|
|
60
|
+
"iconRedfish510",
|
|
61
|
+
"iconRedfish510333",
|
|
62
|
+
"iconRedfish550",
|
|
63
|
+
"iconVolt100",
|
|
64
|
+
"iconDg1000",
|
|
65
|
+
"iconTrueflow",
|
|
66
|
+
"iconThumbprintRed",
|
|
67
|
+
"iconThumbprintGreen",
|
|
68
|
+
"iconThumbprintYellow",
|
|
35
69
|
];
|
|
36
|
-
for (let label of labels)
|
|
37
|
-
|
|
70
|
+
for (let label of labels)
|
|
71
|
+
embeddedIconsTestIn[label] = await pdfDocPg1.embedPng(
|
|
72
|
+
util._base64ToArrayBuffer(base64[label])
|
|
73
|
+
);
|
|
74
|
+
for (let label of labels)
|
|
75
|
+
embeddedIconsTestOut[label] = await pdfDocPg2.embedPng(
|
|
76
|
+
util._base64ToArrayBuffer(base64[label])
|
|
77
|
+
);
|
|
38
78
|
|
|
39
79
|
const mqLogoBytes = util._base64ToArrayBuffer(base64.mqLogo);
|
|
40
80
|
const mqLogoPg1 = await pdfDocPg1.embedPng(mqLogoBytes);
|
|
@@ -43,31 +83,110 @@ export async function getReport(payload) {
|
|
|
43
83
|
// embed company logo and profile picture
|
|
44
84
|
let profileImagePg1, companyImagePg1, profileImagePg2, companyImagePg2;
|
|
45
85
|
if (payload.meta.pdf_settings.includeProfilePic) {
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
86
|
+
if (
|
|
87
|
+
payload.meta.pdf_settings.shapeProfilePic &&
|
|
88
|
+
payload.meta.profile_settings.profilePicCircleBase64 &&
|
|
89
|
+
typeof payload.meta.profile_settings.profilePicCircleBase64 == "string"
|
|
90
|
+
) {
|
|
91
|
+
if (
|
|
92
|
+
payload.meta.profile_settings.profilePicCircleBase64.includes(
|
|
93
|
+
"image/jpeg"
|
|
94
|
+
)
|
|
95
|
+
) {
|
|
96
|
+
profileImagePg1 = await pdfDocPg1.embedJpg(
|
|
97
|
+
util._base64ToArrayBuffer(
|
|
98
|
+
payload.meta.profile_settings.profilePicCircleBase64
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
profileImagePg2 = await pdfDocPg2.embedJpg(
|
|
102
|
+
util._base64ToArrayBuffer(
|
|
103
|
+
payload.meta.profile_settings.profilePicCircleBase64
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
} else if (
|
|
107
|
+
payload.meta.profile_settings.profilePicCircleBase64.includes(
|
|
108
|
+
"image/png"
|
|
109
|
+
)
|
|
110
|
+
) {
|
|
111
|
+
profileImagePg1 = await pdfDocPg1.embedPng(
|
|
112
|
+
util._base64ToArrayBuffer(
|
|
113
|
+
payload.meta.profile_settings.profilePicCircleBase64
|
|
114
|
+
)
|
|
115
|
+
);
|
|
116
|
+
profileImagePg2 = await pdfDocPg2.embedPng(
|
|
117
|
+
util._base64ToArrayBuffer(
|
|
118
|
+
payload.meta.profile_settings.profilePicCircleBase64
|
|
119
|
+
)
|
|
120
|
+
);
|
|
53
121
|
}
|
|
54
|
-
} else if (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
122
|
+
} else if (
|
|
123
|
+
payload.meta.profile_settings.profilePicSquareBase64 &&
|
|
124
|
+
typeof payload.meta.profile_settings.profilePicSquareBase64 == "string"
|
|
125
|
+
) {
|
|
126
|
+
if (
|
|
127
|
+
payload.meta.profile_settings.profilePicSquareBase64.includes(
|
|
128
|
+
"image/jpeg"
|
|
129
|
+
)
|
|
130
|
+
) {
|
|
131
|
+
profileImagePg1 = await pdfDocPg1.embedJpg(
|
|
132
|
+
util._base64ToArrayBuffer(
|
|
133
|
+
payload.meta.profile_settings.profilePicSquareBase64
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
profileImagePg2 = await pdfDocPg2.embedJpg(
|
|
137
|
+
util._base64ToArrayBuffer(
|
|
138
|
+
payload.meta.profile_settings.profilePicSquareBase64
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
} else if (
|
|
142
|
+
payload.meta.profile_settings.profilePicSquareBase64.includes(
|
|
143
|
+
"image/png"
|
|
144
|
+
)
|
|
145
|
+
) {
|
|
146
|
+
profileImagePg1 = await pdfDocPg1.embedPng(
|
|
147
|
+
util._base64ToArrayBuffer(
|
|
148
|
+
payload.meta.profile_settings.profilePicSquareBase64
|
|
149
|
+
)
|
|
150
|
+
);
|
|
151
|
+
profileImagePg2 = await pdfDocPg2.embedPng(
|
|
152
|
+
util._base64ToArrayBuffer(
|
|
153
|
+
payload.meta.profile_settings.profilePicSquareBase64
|
|
154
|
+
)
|
|
155
|
+
);
|
|
61
156
|
}
|
|
62
157
|
}
|
|
63
158
|
}
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
159
|
+
if (
|
|
160
|
+
payload.meta.pdf_settings.includeCompanyLogo &&
|
|
161
|
+
payload.meta.profile_settings.companyLogoBase64 &&
|
|
162
|
+
typeof payload.meta.profile_settings.companyLogoBase64 == "string"
|
|
163
|
+
) {
|
|
164
|
+
if (
|
|
165
|
+
payload.meta.profile_settings.companyLogoBase64.includes("image/jpeg")
|
|
166
|
+
) {
|
|
167
|
+
companyImagePg1 = await pdfDocPg1.embedJpg(
|
|
168
|
+
util._base64ToArrayBuffer(
|
|
169
|
+
payload.meta.profile_settings.companyLogoBase64
|
|
170
|
+
)
|
|
171
|
+
);
|
|
172
|
+
companyImagePg2 = await pdfDocPg2.embedJpg(
|
|
173
|
+
util._base64ToArrayBuffer(
|
|
174
|
+
payload.meta.profile_settings.companyLogoBase64
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
} else if (
|
|
178
|
+
payload.meta.profile_settings.companyLogoBase64.includes("image/png")
|
|
179
|
+
) {
|
|
180
|
+
companyImagePg1 = await pdfDocPg1.embedPng(
|
|
181
|
+
util._base64ToArrayBuffer(
|
|
182
|
+
payload.meta.profile_settings.companyLogoBase64
|
|
183
|
+
)
|
|
184
|
+
);
|
|
185
|
+
companyImagePg2 = await pdfDocPg2.embedPng(
|
|
186
|
+
util._base64ToArrayBuffer(
|
|
187
|
+
payload.meta.profile_settings.companyLogoBase64
|
|
188
|
+
)
|
|
189
|
+
);
|
|
71
190
|
}
|
|
72
191
|
}
|
|
73
192
|
|
|
@@ -77,18 +196,40 @@ export async function getReport(payload) {
|
|
|
77
196
|
formPg1.getButton("HalfWidthLogo").setImage(companyImagePg1);
|
|
78
197
|
formPg2.getButton("ProfilePicture").setImage(profileImagePg2);
|
|
79
198
|
formPg2.getButton("HalfWidthLogo").setImage(companyImagePg2);
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
199
|
+
if (
|
|
200
|
+
payload.meta.profile_settings.techFirstName ||
|
|
201
|
+
payload.meta.profile_settings.techLastName
|
|
202
|
+
) {
|
|
203
|
+
formPg1
|
|
204
|
+
.getTextField("TechName")
|
|
205
|
+
.setText(
|
|
206
|
+
`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
|
|
207
|
+
);
|
|
208
|
+
formPg2
|
|
209
|
+
.getTextField("TechName")
|
|
210
|
+
.setText(
|
|
211
|
+
`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
|
|
212
|
+
);
|
|
83
213
|
}
|
|
84
214
|
} else if (profileImagePg1) {
|
|
85
215
|
formPg1.getButton("ProfilePicture").setImage(profileImagePg1);
|
|
86
216
|
formPg1.getButton("HalfWidthLogo").setImage(mqLogoPg1);
|
|
87
217
|
formPg2.getButton("ProfilePicture").setImage(profileImagePg2);
|
|
88
218
|
formPg2.getButton("HalfWidthLogo").setImage(mqLogoPg2);
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
219
|
+
if (
|
|
220
|
+
payload.meta.profile_settings.techFirstName ||
|
|
221
|
+
payload.meta.profile_settings.techLastName
|
|
222
|
+
) {
|
|
223
|
+
formPg1
|
|
224
|
+
.getTextField("TechName")
|
|
225
|
+
.setText(
|
|
226
|
+
`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
|
|
227
|
+
);
|
|
228
|
+
formPg2
|
|
229
|
+
.getTextField("TechName")
|
|
230
|
+
.setText(
|
|
231
|
+
`${payload.meta.profile_settings.techFirstName} ${payload.meta.profile_settings.techLastName}`
|
|
232
|
+
);
|
|
92
233
|
}
|
|
93
234
|
} else {
|
|
94
235
|
if (companyImagePg1) {
|
|
@@ -101,97 +242,286 @@ export async function getReport(payload) {
|
|
|
101
242
|
}
|
|
102
243
|
|
|
103
244
|
for (let t = 0; t < payload.tests.length; t++) {
|
|
104
|
-
let section = t == 0 ?
|
|
105
|
-
let sectionLabel = t == 0 ?
|
|
245
|
+
let section = t == 0 ? "test_in" : "test_out";
|
|
246
|
+
let sectionLabel = t == 0 ? "Test In " : "Test Out ";
|
|
106
247
|
if (payload.tests.length == 1) sectionLabel = "";
|
|
107
248
|
let form = t == 0 ? formPg1 : formPg2;
|
|
108
249
|
let test = payload.tests[t].testInfo;
|
|
109
|
-
form.getTextField(
|
|
250
|
+
form.getTextField("Header").setText(`${sectionLabel}Measurement Details`);
|
|
110
251
|
|
|
111
|
-
if (payload.meta.cName)
|
|
112
|
-
|
|
113
|
-
if (payload.meta.
|
|
114
|
-
|
|
115
|
-
if (payload.
|
|
116
|
-
|
|
252
|
+
if (payload.meta.cName)
|
|
253
|
+
form.getTextField("Name").setText(`${payload.meta.cName}`);
|
|
254
|
+
if (payload.meta.address)
|
|
255
|
+
form.getTextField("Address 1").setText(`${payload.meta.address}`);
|
|
256
|
+
if (payload.meta.address2)
|
|
257
|
+
form.getTextField("Address 2").setText(`${payload.meta.address2}`);
|
|
258
|
+
if (payload.meta.city && payload.meta.state && payload.meta.zip)
|
|
259
|
+
form
|
|
260
|
+
.getTextField("City State Zip")
|
|
261
|
+
.setText(
|
|
262
|
+
`${payload.meta.city}${payload.meta.state}${payload.meta.zip}`
|
|
263
|
+
);
|
|
264
|
+
if (payload.tests[t].created_date_string)
|
|
265
|
+
form
|
|
266
|
+
.getTextField("Date of Service")
|
|
267
|
+
.setText(payload.tests[t].created_date_string);
|
|
268
|
+
if (payload.tests[t].created_time_string)
|
|
269
|
+
form
|
|
270
|
+
.getTextField("Time of Service")
|
|
271
|
+
.setText(payload.tests[t].created_time_string);
|
|
117
272
|
|
|
118
|
-
let systemScorePercentage = payload.tests[t].testInfo.data.vitals_score
|
|
273
|
+
let systemScorePercentage = payload.tests[t].testInfo.data.vitals_score
|
|
274
|
+
? +payload.tests[t].testInfo.data.vitals_score.toFixed(0)
|
|
275
|
+
: 0;
|
|
119
276
|
let systemScoreGrade = util.getGradeFromScore(systemScorePercentage);
|
|
120
277
|
let systemScoreColor = util.getColorFromGrade(systemScoreGrade);
|
|
121
278
|
if (!payload.tests[t].testInfo.data.vitals_score) {
|
|
122
279
|
systemScorePercentage = "--";
|
|
123
280
|
systemScoreGrade = "";
|
|
124
281
|
} else systemScorePercentage += "%";
|
|
125
|
-
form
|
|
282
|
+
form
|
|
283
|
+
.getTextField(`YourSystemScore${systemScoreColor}`)
|
|
284
|
+
.setText(`${systemScorePercentage} ${systemScoreGrade}`);
|
|
126
285
|
|
|
127
|
-
if (mapImagePg1 && t == 0)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
286
|
+
if (mapImagePg1 && t == 0)
|
|
287
|
+
form.getButton("Map Image").setImage(mapImagePg1);
|
|
288
|
+
if (mapImagePg2 && t == 1)
|
|
289
|
+
form.getButton("Map Image").setImage(mapImagePg2);
|
|
290
|
+
let infoText =
|
|
291
|
+
"What Are Your System Vitals?\nJust like your health vitals, temperature, pulse, blood pressure etc, your A/C system vitals show the overall health of your air conditioning system. These vitals account for both the refrigerant and air delivery side of the system. System targets that are out of range are typically related to a system diagnostic listed below. Correcting the diagnostic faults, if possible, should put the system vitals back in the normal range.";
|
|
292
|
+
if (payload.meta.report_mode == "heating")
|
|
293
|
+
infoText =
|
|
294
|
+
"What Are Your System Vitals?\nJust like your health vitals, temperature, pulse, and\nblood pressure etc, for Heating System vitals represent\nthe overall health of your heating system. These vitals\naccount for age, safety and efficiency, fuel input as\nwell as the airside performance of the system. System\ntargets that are out of range are typically related to\nsystem diagnostics below. Correcting the system faults\nshould put the system back into the normal range.";
|
|
295
|
+
form.getTextField("Information Text").setText(infoText);
|
|
296
|
+
|
|
297
|
+
// Adjust sections for heating mode without combustion analyzer
|
|
298
|
+
if (
|
|
299
|
+
payload.meta.report_mode === "heating" &&
|
|
300
|
+
payload.tests[t].gasHeatingHasCombustionAnalyzer === false
|
|
301
|
+
) {
|
|
302
|
+
const sec = payload[section];
|
|
303
|
+
if (sec) {
|
|
304
|
+
const findIndexByTitleIncludes = (needle) => {
|
|
305
|
+
for (let i = 1; i <= 4; i++) {
|
|
306
|
+
const title = sec[`title${i}`];
|
|
307
|
+
if (
|
|
308
|
+
title &&
|
|
309
|
+
typeof title === "string" &&
|
|
310
|
+
title.toLowerCase().includes(needle)
|
|
311
|
+
)
|
|
312
|
+
return i;
|
|
313
|
+
}
|
|
314
|
+
return null;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
const combustionIdx = findIndexByTitleIncludes("combustion");
|
|
318
|
+
const performanceIdx = findIndexByTitleIncludes(
|
|
319
|
+
"performance calculations"
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
if (combustionIdx) {
|
|
323
|
+
if (performanceIdx) {
|
|
324
|
+
// Move Performance Calculations into the Combustion section position
|
|
325
|
+
sec[`title${combustionIdx}`] = "Performance";
|
|
326
|
+
sec[`block${combustionIdx}`] = Array.isArray(
|
|
327
|
+
sec[`block${performanceIdx}`]
|
|
328
|
+
)
|
|
329
|
+
? sec[`block${performanceIdx}`].slice()
|
|
330
|
+
: [];
|
|
331
|
+
|
|
332
|
+
// Clear the original Performance Calculations section
|
|
333
|
+
sec[`title${performanceIdx}`] = "";
|
|
334
|
+
sec[`block${performanceIdx}`] = [];
|
|
335
|
+
} else {
|
|
336
|
+
// No Performance Calculations section present; just remove Combustion
|
|
337
|
+
sec[`title${combustionIdx}`] = "";
|
|
338
|
+
sec[`block${combustionIdx}`] = [];
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
132
343
|
|
|
133
344
|
for (let blockNum = 1; blockNum < 5; blockNum++) {
|
|
134
345
|
let altHeader = "";
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
|
|
346
|
+
if (
|
|
347
|
+
payload.meta.report_mode == "heating" &&
|
|
348
|
+
payload.meta.multi_stage &&
|
|
349
|
+
(blockNum == 1 || blockNum == 4)
|
|
350
|
+
)
|
|
351
|
+
altHeader = "2a";
|
|
352
|
+
form
|
|
353
|
+
.getTextField(`Block${blockNum}-Title${altHeader}`)
|
|
354
|
+
.setText(payload[section][`title${blockNum}`]);
|
|
355
|
+
if (altHeader == "2a")
|
|
356
|
+
form.getTextField(`Block${blockNum}-Title2b`).setText("1st/2nd");
|
|
138
357
|
for (let rowNum = 1; rowNum < 14; rowNum++) {
|
|
139
358
|
let measurement;
|
|
140
|
-
if (t == 0)
|
|
141
|
-
|
|
142
|
-
|
|
359
|
+
if (t == 0)
|
|
360
|
+
measurement = payload.test_in[`block${blockNum}`][rowNum - 1];
|
|
361
|
+
else if (t == 1)
|
|
362
|
+
measurement = payload.test_out[`block${blockNum}`][rowNum - 1];
|
|
363
|
+
let embeddedIcons =
|
|
364
|
+
section == "test_in" ? embeddedIconsTestIn : embeddedIconsTestOut;
|
|
143
365
|
let condDisplay = util.getElectricalData(test, "", embeddedIcons);
|
|
144
366
|
let ahuDisplay = util.getElectricalData(test, "_ahu", embeddedIcons);
|
|
145
367
|
if (measurement) {
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
368
|
+
if (
|
|
369
|
+
!isGoettlInstall &&
|
|
370
|
+
measurement.label == "Cond. Volts" &&
|
|
371
|
+
condDisplay.voltageIcon
|
|
372
|
+
)
|
|
373
|
+
form
|
|
374
|
+
.getButton(`Block${blockNum}-Row${rowNum}-Col4`)
|
|
375
|
+
.setImage(condDisplay.voltageIcon);
|
|
376
|
+
else if (
|
|
377
|
+
!isGoettlInstall &&
|
|
378
|
+
measurement.label == "Cond. Amps" &&
|
|
379
|
+
condDisplay.amperageIcon
|
|
380
|
+
)
|
|
381
|
+
form
|
|
382
|
+
.getButton(`Block${blockNum}-Row${rowNum}-Col4`)
|
|
383
|
+
.setImage(condDisplay.amperageIcon);
|
|
384
|
+
else if (
|
|
385
|
+
!isGoettlInstall &&
|
|
386
|
+
measurement.label == "AHU Volts" &&
|
|
387
|
+
ahuDisplay.voltageIcon
|
|
388
|
+
)
|
|
389
|
+
form
|
|
390
|
+
.getButton(`Block${blockNum}-Row${rowNum}-Col4`)
|
|
391
|
+
.setImage(ahuDisplay.voltageIcon);
|
|
392
|
+
else if (
|
|
393
|
+
!isGoettlInstall &&
|
|
394
|
+
measurement.label == "AHU Amps" &&
|
|
395
|
+
ahuDisplay.amperageIcon
|
|
396
|
+
)
|
|
397
|
+
form
|
|
398
|
+
.getButton(`Block${blockNum}-Row${rowNum}-Col4`)
|
|
399
|
+
.setImage(ahuDisplay.amperageIcon);
|
|
151
400
|
|
|
152
401
|
let units = measurement.units ? `(${measurement.units})` : "";
|
|
153
402
|
let altLabel = "";
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
403
|
+
if (
|
|
404
|
+
payload.meta.report_mode != "heating" &&
|
|
405
|
+
blockNum == 1 &&
|
|
406
|
+
(rowNum == 4 || rowNum == 5 || rowNum == 6 || rowNum == 9)
|
|
407
|
+
)
|
|
408
|
+
altLabel = "c";
|
|
409
|
+
form
|
|
410
|
+
.getTextField(`Block${blockNum}-Row${rowNum}-Col1${altLabel}`)
|
|
411
|
+
.setText(`${measurement.label} ${units}`);
|
|
412
|
+
let val = measurement.value
|
|
413
|
+
? measurement.value
|
|
414
|
+
: +test.data[measurement.ref];
|
|
157
415
|
if (!val) val = "--";
|
|
158
|
-
else if (measurement.fixTo && typeof val ==
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
416
|
+
else if (measurement.fixTo && typeof val == "number")
|
|
417
|
+
val = val.toFixed(measurement.fixTo);
|
|
418
|
+
if (
|
|
419
|
+
(measurement.label == "Ambient CO" ||
|
|
420
|
+
measurement.label == "Return CO" ||
|
|
421
|
+
measurement.label == "Supply CO") &&
|
|
422
|
+
!measurement.value
|
|
423
|
+
)
|
|
424
|
+
val = "0.0";
|
|
425
|
+
if (typeof val == "number" || !isNaN(val))
|
|
426
|
+
val = val.toLocaleString("en-US");
|
|
427
|
+
if (measurement.fixTo && typeof val == "number")
|
|
428
|
+
val = val.toFixed(measurement.fixTo);
|
|
429
|
+
if (
|
|
430
|
+
measurement.ref == "co" ||
|
|
431
|
+
measurement.ref == "o2" ||
|
|
432
|
+
measurement.ref == "temperature_air" ||
|
|
433
|
+
measurement.ref == "temperature_stack" ||
|
|
434
|
+
measurement.ref == "coaf" ||
|
|
435
|
+
measurement.ref == "excess_air" ||
|
|
436
|
+
measurement.ref == "efficiency_gcv" ||
|
|
437
|
+
measurement.ref == "efficiency_ncv" ||
|
|
438
|
+
measurement.ref == "dew_point"
|
|
439
|
+
)
|
|
440
|
+
val = measurement.value;
|
|
441
|
+
else if (
|
|
442
|
+
measurement.ref == "pressure_fuel" ||
|
|
443
|
+
measurement.ref == "pressure_manifold" ||
|
|
444
|
+
measurement.ref == "pressure_static_total_external" ||
|
|
445
|
+
measurement.ref == "temperature_rise" ||
|
|
446
|
+
measurement.ref == "temperature_rise_target" ||
|
|
447
|
+
measurement.ref == "temperature_return" ||
|
|
448
|
+
measurement.ref == "temperature_supply" ||
|
|
449
|
+
measurement.ref == "airflow" ||
|
|
450
|
+
measurement.ref == "gas_input_rated" ||
|
|
451
|
+
measurement.ref == "gas_input_after" ||
|
|
452
|
+
measurement.ref == "gas_output"
|
|
453
|
+
)
|
|
454
|
+
val = measurement.value;
|
|
164
455
|
if (val == null || val == "null") val = "--";
|
|
165
456
|
|
|
166
|
-
if (
|
|
457
|
+
if (
|
|
458
|
+
measurement.value2 &&
|
|
459
|
+
measurement.units2 &&
|
|
460
|
+
measurement.ref2 &&
|
|
461
|
+
measurement.fixTo2
|
|
462
|
+
) {
|
|
167
463
|
//second measurement to show on same line
|
|
168
|
-
let val2 = measurement.value2
|
|
464
|
+
let val2 = measurement.value2
|
|
465
|
+
? measurement.value2
|
|
466
|
+
: +test.data[measurement.ref2];
|
|
169
467
|
if (!val2) val2 = "--";
|
|
170
|
-
else if (measurement.fixTo2 && typeof val2 ==
|
|
468
|
+
else if (measurement.fixTo2 && typeof val2 == "number")
|
|
469
|
+
val2 = val2.toFixed(measurement.fixTo2);
|
|
171
470
|
val += " / " + val2;
|
|
172
471
|
}
|
|
173
472
|
|
|
174
|
-
form
|
|
473
|
+
form
|
|
474
|
+
.getTextField(`Block${blockNum}-Row${rowNum}-Col2${altLabel}`)
|
|
475
|
+
.setText(`${val}`);
|
|
175
476
|
if (blockNum != 4) {
|
|
176
477
|
let rangeIcon;
|
|
177
478
|
|
|
178
|
-
if (
|
|
479
|
+
if (
|
|
480
|
+
measurement.label == "Ambient CO" ||
|
|
481
|
+
measurement.label == "Return CO" ||
|
|
482
|
+
measurement.label == "Supply CO"
|
|
483
|
+
) {
|
|
179
484
|
let v = measurement.value;
|
|
180
|
-
if (typeof v ==
|
|
485
|
+
if (typeof v == "string") v = parseFloat(v);
|
|
181
486
|
if (v > 9) rangeIcon = embeddedIcons.iconRangeHigh;
|
|
182
|
-
} else
|
|
487
|
+
} else
|
|
488
|
+
rangeIcon = util.getRangeIcon(
|
|
489
|
+
test,
|
|
490
|
+
measurement.ref,
|
|
491
|
+
embeddedIcons
|
|
492
|
+
);
|
|
183
493
|
|
|
184
|
-
if (rangeIcon && payload.meta.pdf_settings.includeRangeIndicators)
|
|
494
|
+
if (rangeIcon && payload.meta.pdf_settings.includeRangeIndicators)
|
|
495
|
+
form
|
|
496
|
+
.getButton(`Block${blockNum}-Row${rowNum}-Col3`)
|
|
497
|
+
.setImage(rangeIcon);
|
|
185
498
|
let toolIcon = false;
|
|
186
|
-
if (
|
|
187
|
-
|
|
499
|
+
if (
|
|
500
|
+
measurement.ref == "superheat" ||
|
|
501
|
+
measurement.ref == "subcooling" ||
|
|
502
|
+
measurement.ref == "compression_ratio" ||
|
|
503
|
+
measurement.ref == "airflow_estimated"
|
|
504
|
+
)
|
|
505
|
+
toolIcon = embeddedIcons.iconCalculator;
|
|
506
|
+
else
|
|
507
|
+
toolIcon = util.getToolIcon(
|
|
508
|
+
test,
|
|
509
|
+
measurement.ref,
|
|
510
|
+
embeddedIcons
|
|
511
|
+
);
|
|
188
512
|
|
|
189
513
|
let benchmarkIcon = embeddedIcons.iconThumbprintRed;
|
|
190
|
-
if (measurement.value == "Yes, under duress")
|
|
191
|
-
|
|
514
|
+
if (measurement.value == "Yes, under duress")
|
|
515
|
+
benchmarkIcon = embeddedIcons.iconThumbprintYellow;
|
|
516
|
+
else if (measurement.value == "Yes")
|
|
517
|
+
benchmarkIcon = embeddedIcons.iconThumbprintGreen;
|
|
192
518
|
|
|
193
|
-
toolIcon =
|
|
194
|
-
|
|
519
|
+
toolIcon =
|
|
520
|
+
measurement.ref == "benchmark" ? benchmarkIcon : toolIcon;
|
|
521
|
+
if (toolIcon)
|
|
522
|
+
form
|
|
523
|
+
.getButton(`Block${blockNum}-Row${rowNum}-Col4`)
|
|
524
|
+
.setImage(toolIcon);
|
|
195
525
|
}
|
|
196
526
|
} else break;
|
|
197
527
|
}
|
|
@@ -204,7 +534,10 @@ export async function getReport(payload) {
|
|
|
204
534
|
const [secondPage] = await pdfDocPg1.copyPages(pdfDocPg2, [0]);
|
|
205
535
|
pdfDocPg1.insertPage(1, secondPage);
|
|
206
536
|
}
|
|
207
|
-
return {
|
|
537
|
+
return {
|
|
538
|
+
status: 200,
|
|
539
|
+
data: await pdfDocPg1.saveAsBase64({ dataUri: true }),
|
|
540
|
+
};
|
|
208
541
|
} catch (error) {
|
|
209
542
|
return { status: 400, data: error };
|
|
210
543
|
}
|
|
@@ -350,6 +350,7 @@ export async function getReport(payload, _test) {
|
|
|
350
350
|
specialCaseIcon = iconRangeRed;
|
|
351
351
|
}
|
|
352
352
|
safeSetImage(form, `ImageAge${specialCasePlacement}`, specialCaseIcon);
|
|
353
|
+
safeSetText(form, `Age`, age.toString());
|
|
353
354
|
|
|
354
355
|
specialCasePlacement = "Low";
|
|
355
356
|
let efficiency = test.testInfo.data.efficiency
|
|
@@ -337,6 +337,7 @@ export async function getReport(payload, _test) {
|
|
|
337
337
|
specialCaseIcon = iconRangeRed;
|
|
338
338
|
}
|
|
339
339
|
safeSetImage(form, `ImageAge${specialCasePlacement}`, specialCaseIcon);
|
|
340
|
+
safeSetText(form, `Age`, age.toString());
|
|
340
341
|
|
|
341
342
|
specialCaseIcon = iconRangeRed;
|
|
342
343
|
specialCasePlacement = "Mid";
|