@measurequick/measurequick-report-generator 1.2.34 → 1.2.35
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 +1 -1
- package/report-gen-scripts/corrective-measures.js +1 -1
- package/report-gen-scripts/measurement-details.js +1 -1
- package/report-gen-scripts/photos-report.js +45 -44
- package/report-gen-scripts/vitals-cooling-report.js +1 -1
- package/report-gen-scripts/vitals-heating-report.js +1 -1
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@ export async function getReport(payload) {
|
|
|
50
50
|
else form.getButton("FullWidthLogo").setImage(mqLogo);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
let systemScorePercentage = +payload.tests[0].testInfo.data.vitals_score.toFixed(0);
|
|
53
|
+
let systemScorePercentage = payload.tests[0].testInfo.data.vitals_score ? +payload.tests[0].testInfo.data.vitals_score.toFixed(0) : 0;
|
|
54
54
|
let systemScoreGrade = util.getGradeFromScore(systemScorePercentage);
|
|
55
55
|
let systemScoreColor = util.getColorFromGrade(systemScoreGrade);
|
|
56
56
|
if (!payload.tests[0].testInfo.canScoreVitals) {
|
|
@@ -116,7 +116,7 @@ export async function getReport(payload) {
|
|
|
116
116
|
form.getTextField('Time of Service').setText(payload.tests[t].created_time_string);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
let systemScorePercentage = +payload.tests[t].testInfo.data.vitals_score.toFixed(0);
|
|
119
|
+
let systemScorePercentage = payload.tests[t].testInfo.data.vitals_score ? +payload.tests[t].testInfo.data.vitals_score.toFixed(0) : 0;
|
|
120
120
|
let systemScoreGrade = util.getGradeFromScore(systemScorePercentage);
|
|
121
121
|
let systemScoreColor = util.getColorFromGrade(systemScoreGrade);
|
|
122
122
|
if (!payload.tests[0].testInfo.canScoreVitals) {
|
|
@@ -21,51 +21,52 @@ export async function getReport(payload) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Process All Photos
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
24
|
+
let previousPhotoSectionName;
|
|
25
|
+
let photoCollectionNames = ["project", "equipment", "site", "customer"];
|
|
26
|
+
let docIndex = 0;
|
|
27
|
+
for (let pcnIndex = 0; pcnIndex < photoCollectionNames.length; pcnIndex++) { // Iterate over all 4 photo photo collections
|
|
28
|
+
let photoCollectionName = photoCollectionNames[pcnIndex];
|
|
29
|
+
let photoCollection = payload.photos[photoCollectionName];
|
|
30
|
+
let photoSectionKeys = Object.keys(photoCollection);
|
|
31
|
+
if (!photoSectionKeys || photoSectionKeys.length == 0) break;
|
|
32
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
33
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
34
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
35
|
+
forms[docIndex].getTextField("Header").setText(`${util.capitalizeFirstLetter(photoCollectionName)} Photos`);
|
|
36
|
+
let photoPosition = 1;
|
|
37
|
+
for (let pskIndex = 0; pskIndex < photoSectionKeys.length; pskIndex++) { // Iterate over X user-defined photo sections within each photo collection
|
|
38
|
+
let photoSectionKey = photoSectionKeys[pskIndex];
|
|
39
|
+
let photoSection = photoCollection[photoSectionKey];
|
|
40
|
+
let photoSectionName = photoSection.name;
|
|
41
|
+
console.log(`Starting Section ${photoSectionName}`);
|
|
42
|
+
let photos = photoSection.photos;
|
|
43
|
+
if (!photos || photos.length == 0) break;
|
|
44
|
+
for (let pIndex = 1; pIndex <= photos.length; pIndex++) { // Iterate over X user-defined photos within each photo section
|
|
45
|
+
let photo = photos[pIndex-1];
|
|
46
|
+
if (photoPosition > maxPhotosPerPage) { // Need a new page
|
|
47
|
+
photoPosition = 1;
|
|
48
|
+
docIndex++;
|
|
49
|
+
docs[docIndex] = await PDFDocument.load(util._base64ToArrayBuffer(page.base64));
|
|
50
|
+
forms[docIndex] = docs[docIndex].getForm();
|
|
51
|
+
forms[docIndex].getButton("FullWidthLogo").setImage(await docs[docIndex].embedPng(mqLogoBytes));
|
|
52
|
+
forms[docIndex].getTextField("Header").setText(`${util.capitalizeFirstLetter(photoCollectionName)} Photos`);
|
|
53
|
+
}
|
|
54
|
+
let imageToSet;
|
|
55
|
+
if (photo.base64.includes("image/jpeg")) imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
56
|
+
else if (photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
57
|
+
if (imageToSet) {
|
|
58
|
+
console.log(`Printing ${photo.tag} in Position #${photoPosition} on Page #${docIndex+1}`);
|
|
59
|
+
forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
60
|
+
}
|
|
61
|
+
let photoSubText = photoSection.name;
|
|
62
|
+
let isFirstPhotoOfSection = previousPhotoSectionName !== photoSectionName;
|
|
63
|
+
if (isFirstPhotoOfSection && photoSection.hasNotes && photoSection.notes) photoSubText += `: ${photoSection.notes}`;
|
|
64
|
+
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(`${photoSubText}`);
|
|
65
|
+
photoPosition++;
|
|
66
|
+
previousPhotoSectionName = photoCollectionName;
|
|
67
|
+
}
|
|
52
68
|
}
|
|
53
|
-
|
|
54
|
-
if (photo.base64.includes("image/jpeg")) imageToSet = await docs[docIndex].embedJpg(util._base64ToArrayBuffer(photo.base64));
|
|
55
|
-
else if (photo.base64.includes("image/png")) imageToSet = await docs[docIndex].embedPng(util._base64ToArrayBuffer(photo.base64));
|
|
56
|
-
if (imageToSet) {
|
|
57
|
-
console.log(`Printing ${photo.tag} in Position #${photoPosition} on Page #${docIndex+1}`);
|
|
58
|
-
forms[docIndex].getButton(`photo${pSize}${photoPosition}`).setImage(imageToSet);
|
|
59
|
-
}
|
|
60
|
-
let photoSubText = photoSection.name;
|
|
61
|
-
let isFirstPhotoOfSection = previousPhotoCollectionName !== photoCollectionName;
|
|
62
|
-
if (isFirstPhotoOfSection && photoSection.hasNotes && photoSection.notes) photoSubText += `: ${photoSection.notes}`;
|
|
63
|
-
forms[docIndex].getTextField(`Notes${photoPosition}`).setText(`${photoSubText}`);
|
|
64
|
-
photoPosition++;
|
|
65
|
-
previousPhotoCollectionName = photoCollectionName;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
docIndex++;
|
|
69
|
+
docIndex++;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
// Prepare Deliverable
|
|
@@ -123,7 +123,7 @@ export async function getReport(payload, _test) { console.log(payload);
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
console.log();
|
|
126
|
-
let systemScorePercentage = +payload.tests[0].testInfo.data.vitals_score.toFixed(0);
|
|
126
|
+
let systemScorePercentage = payload.tests[0].testInfo.data.vitals_score ? +payload.tests[0].testInfo.data.vitals_score.toFixed(0) : 0;
|
|
127
127
|
let systemScoreGrade = util.getGradeFromScore(systemScorePercentage);
|
|
128
128
|
let systemScoreColor = util.getColorFromGrade(systemScoreGrade);
|
|
129
129
|
if (!payload.tests[0].testInfo.canScoreVitals) {
|
|
@@ -101,7 +101,7 @@ export async function getReport(payload, _test) { console.log("Vitals Heating Re
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
let systemScorePercentage = +payload.tests[0].testInfo.data.vitals_score.toFixed(0);
|
|
104
|
+
let systemScorePercentage = payload.tests[0].testInfo.data.vitals_score ? +payload.tests[0].testInfo.data.vitals_score.toFixed(0) : 0;
|
|
105
105
|
let systemScoreGrade = util.getGradeFromScore(systemScorePercentage);
|
|
106
106
|
let systemScoreColor = util.getColorFromGrade(systemScoreGrade);
|
|
107
107
|
if (!payload.tests[0].testInfo.canScoreVitals) {
|