@measurequick/measurequick-report-generator 1.1.1 → 1.1.2
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
package/scripts/mq-standard.js
CHANGED
|
@@ -5,16 +5,16 @@ import * as pdf from '../templates/base-64/mq-standard.js';
|
|
|
5
5
|
/***************************************************
|
|
6
6
|
[Page # || Page Index ]: Purpose
|
|
7
7
|
============================================
|
|
8
|
-
[1 || 0]:
|
|
9
|
-
[2 || 1]:
|
|
10
|
-
[3 || 2:
|
|
11
|
-
[4 || 3]:
|
|
12
|
-
[5 || 4]:
|
|
13
|
-
[6 || 5]:
|
|
14
|
-
[7 || 6]:
|
|
15
|
-
[8 || 7]:
|
|
16
|
-
[9 || 8]:
|
|
17
|
-
[10 || 9]:
|
|
8
|
+
[1 || 0]: Cover Sheet
|
|
9
|
+
[2 || 1]: A/C Vitals Measurements
|
|
10
|
+
[3 || 2]: A/C Vitals Score Breakdown
|
|
11
|
+
[4 || 3]: A/C Vitals Information
|
|
12
|
+
[5 || 4]: Heating Vitals Measurements
|
|
13
|
+
[6 || 5]: Heating Vitals Score Breakdown
|
|
14
|
+
[7 || 6]: Heating Vitals Information
|
|
15
|
+
[8 || 7]: Equipment Information
|
|
16
|
+
[9 || 8]: System Review
|
|
17
|
+
[10 || 9]: 2-Column Measurement Details
|
|
18
18
|
[11 || 10]: 3-Column Measurement Details
|
|
19
19
|
[12 || 11]: 4-Column Measurement Details
|
|
20
20
|
[13 || 12]: Understanding A/C Subsystems
|
|
@@ -44,7 +44,7 @@ export async function generateReport(payload) { console.log(payload);
|
|
|
44
44
|
else if (payload.meta.number_of_measurement_columns === 4) { pdfDoc.removePage(10); pdfDoc.removePage(9); }
|
|
45
45
|
|
|
46
46
|
// Remove System Review Page (If Chosen)
|
|
47
|
-
if (!payload.meta.
|
|
47
|
+
if (!payload.meta.include_system_review) pdfDoc.removePage(8);
|
|
48
48
|
|
|
49
49
|
// Remove Equipment Info Page (If Chosen)
|
|
50
50
|
if (!payload.meta.include_equipment_info) pdfDoc.removePage(7);
|
|
@@ -57,6 +57,11 @@ export async function generateReport(payload) { console.log(payload);
|
|
|
57
57
|
if (!payload.meta.include_cover_sheet) pdfDoc.removePage(0);
|
|
58
58
|
|
|
59
59
|
// Fetch & Load Image Resources
|
|
60
|
+
let geolocationMap, profilePicture, companyLogo;
|
|
61
|
+
if (payload.photos.map_image_base64) geolocationMap = await pdfDoc.embedPng(_base64ToArrayBuffer(payload.photos.map_image_base64));
|
|
62
|
+
if (payload.photos.profile_image_base64) profilePicture = await pdfDoc.embedPng(_base64ToArrayBuffer(payload.photos.profile_image_base64));
|
|
63
|
+
if (payload.photos.company_logo_base64) companyLogo = await pdfDoc.embedPng(_base64ToArrayBuffer(payload.photos.company_logo_base64));
|
|
64
|
+
|
|
60
65
|
const iconRangeGreen = await pdfDoc.embedPng(_base64ToArrayBuffer(base64.iconRangeGreen));
|
|
61
66
|
const iconRangeRed = await pdfDoc.embedPng(_base64ToArrayBuffer(base64.iconRangeRed));
|
|
62
67
|
const iconFlagBlack = await pdfDoc.embedPng(_base64ToArrayBuffer(base64.iconFlagBlack));
|
|
@@ -75,6 +80,9 @@ export async function generateReport(payload) { console.log(payload);
|
|
|
75
80
|
form.getTextField("Technician Name").setText(payload.meta.technician_name);
|
|
76
81
|
form.getTextField("Date of Service Cover").setText(payload.meta.date_of_service);
|
|
77
82
|
form.getTextField("Time of Service Cover").setText(payload.meta.time_of_service);
|
|
83
|
+
if (companyLogo) form.getButton("Company Logo").setImage(companyLogo);
|
|
84
|
+
if (profilePicture) form.getButton("Profile Picture").setImage(profilePicture);
|
|
85
|
+
if (geolocationMap) form.getButton("Photo Equipment").setImage(geolocationMap);
|
|
78
86
|
|
|
79
87
|
// Populate Vitals Measurements
|
|
80
88
|
if (payload.diagnostics) {
|
|
@@ -186,9 +194,9 @@ export async function generateReport(payload) { console.log(payload);
|
|
|
186
194
|
}
|
|
187
195
|
|
|
188
196
|
// Populate Equipment Info Page
|
|
189
|
-
form.getTextField(`EI Title 1`).setText();
|
|
190
|
-
form.getTextField(`EI Title 2`).setText();
|
|
191
|
-
form.getTextField(`EI Title 3`).setText();
|
|
197
|
+
form.getTextField(`EI Title 1`).setText(payload.equipment_information.title1);
|
|
198
|
+
form.getTextField(`EI Title 2`).setText(payload.equipment_information.title2);
|
|
199
|
+
form.getTextField(`EI Title 3`).setText(payload.equipment_information.title3);
|
|
192
200
|
for (let fieldNum = 1; fieldNum <= 41; fieldNum++) {
|
|
193
201
|
form.getTextField(`Equip_Info-Field ${fieldNum}a`).setText();
|
|
194
202
|
form.getTextField(`Equip_Info-Field ${fieldNum}b`).setText();
|
|
@@ -197,31 +205,72 @@ export async function generateReport(payload) { console.log(payload);
|
|
|
197
205
|
// Populate System Review Page
|
|
198
206
|
for (let catNum = 1; catNum <= 10; catNum++) {
|
|
199
207
|
for (let fieldNum = 1; fieldNum <= 5; fieldNum++) {
|
|
200
|
-
form.getTextField(`SR Title ${catNum}`).setText();
|
|
208
|
+
form.getTextField(`SR Title ${catNum}`).setText(payload.system_review[`title${catNum}`]);
|
|
201
209
|
form.getTextField(`Category ${catNum} Field ${fieldNum}a`).setText();
|
|
202
210
|
form.getTextField(`Category ${catNum} Field ${fieldNum}b`).setText();
|
|
203
211
|
}
|
|
204
212
|
}
|
|
205
213
|
|
|
206
214
|
// Populate Measurement Details Page
|
|
215
|
+
let rowPrinting = 1;
|
|
216
|
+
let cNums = payload.meta.number_of_measurement_columns;
|
|
217
|
+
form.getTextField(`MD${cNums} Title 1`).setText(payload.measurement_details.title1);
|
|
218
|
+
form.getTextField(`MD${cNums} Title 2`).setText(payload.measurement_details.title2);
|
|
219
|
+
if (cNums >= 3) form.getTextField(`MD${cNums} Title 3`).setText(payload.measurement_details.title3);
|
|
220
|
+
if (cNums == 4) form.getTextField(`MD${cNums} Title 4`).setText(payload.measurement_details.title4);
|
|
221
|
+
|
|
222
|
+
// TODO: Add Section Header
|
|
223
|
+
|
|
207
224
|
for (let rowNum = 0; rowNum < payload.measurement_details.outdoor_measurements.length; rowNum++) {
|
|
208
225
|
let measurement = payload.measurement_details.outdoor_measurements[rowNum];
|
|
209
|
-
form.getTextField(`
|
|
210
|
-
form.getTextField(`
|
|
211
|
-
form.getTextField(`
|
|
212
|
-
form.getTextField(`
|
|
226
|
+
form.getTextField(`MD${cNums} ${rowPrinting}1`).setText(`${measurement.label} (${measurement.units})`);
|
|
227
|
+
form.getTextField(`MD${cNums} ${rowPrinting}2`).setText(measurement.testInValue);
|
|
228
|
+
if (cNums >= 3) form.getTextField(`MD${cNums} ${rowPrinting}3`).setText(measurement.testOutValue);
|
|
229
|
+
if (cNums == 4) form.getTextField(`MD${cNums} ${rowPrinting}4`).setText(measurement.referenceKey);
|
|
230
|
+
rowPrinting++;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// TODO: Add Section Header
|
|
234
|
+
|
|
235
|
+
// TODO: Add Line Break
|
|
236
|
+
|
|
237
|
+
for (let rowNum = 0; rowNum < payload.measurement_details.weather_data.length; rowNum++) {
|
|
238
|
+
let measurement = payload.measurement_details.weather_data[rowNum];
|
|
239
|
+
form.getTextField(`MD${cNums} ${rowPrinting}1`).setText(`${measurement.label} (${measurement.units})`);
|
|
240
|
+
form.getTextField(`MD${cNums} ${rowPrinting}2`).setText(measurement.testInValue);
|
|
241
|
+
if (cNums >= 3) form.getTextField(`MD${cNums} ${rowPrinting}3`).setText(measurement.testOutValue);
|
|
242
|
+
if (cNums == 4) form.getTextField(`MD${cNums} ${rowPrinting}4`).setText(measurement.referenceKey);
|
|
243
|
+
rowPrinting++;
|
|
213
244
|
}
|
|
214
245
|
|
|
246
|
+
// TODO: Add Section Header
|
|
247
|
+
|
|
248
|
+
// TODO: Add Line Break
|
|
249
|
+
|
|
250
|
+
for (let rowNum = 0; rowNum < payload.measurement_details.indoor_measurements.length; rowNum++) {
|
|
251
|
+
let measurement = payload.measurement_details.indoor_measurements[rowNum];
|
|
252
|
+
form.getTextField(`MD${cNums} ${rowPrinting}1`).setText(`${measurement.label} (${measurement.units})`);
|
|
253
|
+
form.getTextField(`MD${cNums} ${rowPrinting}2`).setText(measurement.testInValue);
|
|
254
|
+
if (cNums >= 3) form.getTextField(`MD${cNums} ${rowPrinting}3`).setText(measurement.testOutValue);
|
|
255
|
+
if (cNums == 4) form.getTextField(`MD${cNums} ${rowPrinting}4`).setText(measurement.referenceKey);
|
|
256
|
+
rowPrinting++;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// TODO: Duplicate Active Measurement Details Page
|
|
260
|
+
|
|
261
|
+
// TODO: Populate Performance Calculations
|
|
262
|
+
|
|
215
263
|
// Populate Photo Page(s)
|
|
216
264
|
|
|
265
|
+
// TODO: Duplicate Active Photo Page As Needed
|
|
217
266
|
|
|
218
267
|
// Flatten Form, Convert & Return PDF as Base64
|
|
219
268
|
form.flatten();
|
|
220
269
|
const pdfBase64 = await pdfDoc.saveAsBase64({ dataUri: true });
|
|
270
|
+
console.log(pdfBase64);
|
|
221
271
|
return pdfBase64;
|
|
222
272
|
}
|
|
223
273
|
|
|
224
|
-
|
|
225
274
|
function getGradeFromScore(score) {
|
|
226
275
|
let grade = "F";
|
|
227
276
|
if (score == 100) return "A+";
|