@lighthouse/common 6.10.0 → 6.10.1-canary.0
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/.mise.toml +6 -6
- package/CHANGELOG.md +758 -758
- package/README.md +1 -1
- package/dist/errors/FetchImageError.js +3 -3
- package/dist/helpers/fetch-image-for-pdf-generator-service/index.js +7 -7
- package/dist/helpers/floatify/index.js +6 -6
- package/dist/helpers/get-audit-items-data/index.js +47 -36
- package/dist/helpers/validate-url/index.js +4 -4
- package/dist/pdf/activity-report/index.js +32 -32
- package/dist/pdf/audit/index.js +23 -23
- package/dist/pdf/helpers/fields/index.js +47 -27
- package/dist/pdf/issue/index.js +23 -23
- package/dist/pdf/job/index.js +22 -22
- package/dist/pdf/shift-report/index.js +28 -28
- package/dist/pdf/task/index.js +23 -23
- package/dist/scheduling/generators/occurrenceIntervalsGenerator.js +2 -2
- package/dist/scheduling/generators/scheduleIntervalsGenerator.js +2 -2
- package/dist/scheduling/generators/serviceIntervalsGenerator.js +2 -2
- package/dist/scheduling/helpers/convertToTimezone.js +6 -6
- package/dist/scheduling/helpers/generateNonRepeatingSchedule.js +2 -2
- package/dist/scheduling/helpers/generateRepeatingSchedule.js +2 -2
- package/dist/scheduling/helpers/generateScheduleEnd.js +2 -2
- package/dist/scheduling/helpers/hasValidStartAndEnd.js +5 -5
- package/dist/scheduling/helpers/intervalCovers.js +6 -6
- package/dist/scheduling/helpers/intervalIntersectsEnd.js +6 -6
- package/dist/scheduling/helpers/intervalIntersectsStart.js +6 -6
- package/dist/scheduling/helpers/intervalOnlyIntersectsEnd.js +6 -6
- package/dist/scheduling/helpers/intervalOnlyIntersectsStart.js +6 -6
- package/dist/scheduling/helpers/intervalOutside.js +6 -6
- package/dist/scheduling/helpers/intervalWithin.js +6 -6
- package/dist/scheduling/helpers/mergeIntervals.js +6 -6
- package/dist/scheduling/helpers/splitIntervals.js +6 -6
- package/dist/scheduling/strategies/getNext.js +2 -2
- package/dist/scheduling/strategies/getNextExactDateOfMonth.js +2 -2
- package/dist/scheduling/strategies/getNextLastDayOfMonth.js +2 -2
- package/dist/scheduling/strategies/getNextLastWeekdayOfMonth.js +2 -2
- package/dist/scheduling/strategies/getNextNoRepeat.js +2 -2
- package/dist/scheduling/strategies/getNextWeekday.js +2 -2
- package/dist/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +2 -2
- package/dist/service-hours/__helpers__/calculate-hours.js +4 -4
- package/dist/service-hours/__helpers__/isOpen.js +2 -2
- package/dist/service-hours/schema.js +4 -4
- package/lib/constants.js +12 -6
- package/lib/constants.js.map +1 -1
- package/lib/errors/DomainError.js +14 -21
- package/lib/errors/DomainError.js.map +1 -1
- package/lib/errors/FetchImageError.js +17 -24
- package/lib/errors/FetchImageError.js.map +1 -1
- package/lib/errors/ValidationError.js +30 -36
- package/lib/errors/ValidationError.js.map +1 -1
- package/lib/errors/index.js +23 -5
- package/lib/errors/index.js.map +1 -1
- package/lib/helpers/build-fetch-url/index.js +43 -47
- package/lib/helpers/build-fetch-url/index.js.map +1 -1
- package/lib/helpers/fetch-image/index.js +83 -82
- package/lib/helpers/fetch-image/index.js.map +1 -1
- package/lib/helpers/fetch-image-for-pdf-generator-service/index.js +168 -243
- package/lib/helpers/fetch-image-for-pdf-generator-service/index.js.map +1 -1
- package/lib/helpers/fetch-image-for-web/index.js +71 -94
- package/lib/helpers/fetch-image-for-web/index.js.map +1 -1
- package/lib/helpers/fetch-lighthouse-logo/index.js +36 -61
- package/lib/helpers/fetch-lighthouse-logo/index.js.map +1 -1
- package/lib/helpers/floatify/index.js +13 -7
- package/lib/helpers/floatify/index.js.map +1 -1
- package/lib/helpers/get-assignees-full-names/index.js +11 -7
- package/lib/helpers/get-assignees-full-names/index.js.map +1 -1
- package/lib/helpers/get-audit-entry-details/index.js +42 -32
- package/lib/helpers/get-audit-entry-details/index.js.map +1 -1
- package/lib/helpers/get-audit-items-data/index.js +104 -83
- package/lib/helpers/get-audit-items-data/index.js.map +1 -1
- package/lib/helpers/get-geometry-geocoded-string/index.js +10 -5
- package/lib/helpers/get-geometry-geocoded-string/index.js.map +1 -1
- package/lib/helpers/get-issue-details/index.js +53 -43
- package/lib/helpers/get-issue-details/index.js.map +1 -1
- package/lib/helpers/get-job-details/index.js +49 -41
- package/lib/helpers/get-job-details/index.js.map +1 -1
- package/lib/helpers/get-location-reference/index.js +32 -34
- package/lib/helpers/get-location-reference/index.js.map +1 -1
- package/lib/helpers/get-pretty-duration/index.js +16 -10
- package/lib/helpers/get-pretty-duration/index.js.map +1 -1
- package/lib/helpers/get-reference-details/index.js +20 -10
- package/lib/helpers/get-reference-details/index.js.map +1 -1
- package/lib/helpers/get-status-details/index.js +8 -2
- package/lib/helpers/get-status-details/index.js.map +1 -1
- package/lib/helpers/get-task-entry-details/index.js +32 -23
- package/lib/helpers/get-task-entry-details/index.js.map +1 -1
- package/lib/helpers/get-timezone-abbr/index.js +11 -4
- package/lib/helpers/get-timezone-abbr/index.js.map +1 -1
- package/lib/helpers/get-timezone-datetime/index.js +20 -13
- package/lib/helpers/get-timezone-datetime/index.js.map +1 -1
- package/lib/helpers/get-user-full-name/index.js +9 -3
- package/lib/helpers/get-user-full-name/index.js.map +1 -1
- package/lib/helpers/get-value-as-percentage/index.js +9 -4
- package/lib/helpers/get-value-as-percentage/index.js.map +1 -1
- package/lib/helpers/image-validators/index.js +18 -12
- package/lib/helpers/image-validators/index.js.map +1 -1
- package/lib/helpers/index.js +130 -18
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/validate-url/index.js +11 -5
- package/lib/helpers/validate-url/index.js.map +1 -1
- package/lib/images/index.js +10 -4
- package/lib/images/index.js.map +1 -1
- package/lib/index.js +66 -10
- package/lib/index.js.map +1 -1
- package/lib/pdf/activity-report/index.js +407 -537
- package/lib/pdf/activity-report/index.js.map +1 -1
- package/lib/pdf/audit/index.js +137 -134
- package/lib/pdf/audit/index.js.map +1 -1
- package/lib/pdf/fonts/index.js +4 -2
- package/lib/pdf/fonts/index.js.map +1 -1
- package/lib/pdf/helpers/build-audit-content/index.js +57 -51
- package/lib/pdf/helpers/build-audit-content/index.js.map +1 -1
- package/lib/pdf/helpers/build-audit-follow-ups/index.js +52 -50
- package/lib/pdf/helpers/build-audit-follow-ups/index.js.map +1 -1
- package/lib/pdf/helpers/build-location-scans-content/index.js +22 -16
- package/lib/pdf/helpers/build-location-scans-content/index.js.map +1 -1
- package/lib/pdf/helpers/build-template-content/index.js +52 -51
- package/lib/pdf/helpers/build-template-content/index.js.map +1 -1
- package/lib/pdf/helpers/default-footer/index.js +38 -35
- package/lib/pdf/helpers/default-footer/index.js.map +1 -1
- package/lib/pdf/helpers/default-header/index.js +40 -35
- package/lib/pdf/helpers/default-header/index.js.map +1 -1
- package/lib/pdf/helpers/default-styles/index.js +7 -1
- package/lib/pdf/helpers/default-styles/index.js.map +1 -1
- package/lib/pdf/helpers/fields/index.js +225 -214
- package/lib/pdf/helpers/fields/index.js.map +1 -1
- package/lib/pdf/helpers/format-location-address/index.js +14 -8
- package/lib/pdf/helpers/format-location-address/index.js.map +1 -1
- package/lib/pdf/helpers/generate-definition/index.js +60 -65
- package/lib/pdf/helpers/generate-definition/index.js.map +1 -1
- package/lib/pdf/helpers/horizontal-line/index.js +14 -14
- package/lib/pdf/helpers/horizontal-line/index.js.map +1 -1
- package/lib/pdf/helpers/html-transformer/index.js +45 -35
- package/lib/pdf/helpers/html-transformer/index.js.map +1 -1
- package/lib/pdf/helpers/index.js +194 -15
- package/lib/pdf/helpers/index.js.map +1 -1
- package/lib/pdf/helpers/parse-value/index.js +10 -4
- package/lib/pdf/helpers/parse-value/index.js.map +1 -1
- package/lib/pdf/helpers/table/index.js +136 -205
- package/lib/pdf/helpers/table/index.js.map +1 -1
- package/lib/pdf/helpers/text/index.js +11 -8
- package/lib/pdf/helpers/text/index.js.map +1 -1
- package/lib/pdf/icons/index.js +8 -2
- package/lib/pdf/icons/index.js.map +1 -1
- package/lib/pdf/index.js +47 -6
- package/lib/pdf/index.js.map +1 -1
- package/lib/pdf/issue/index.js +141 -135
- package/lib/pdf/issue/index.js.map +1 -1
- package/lib/pdf/job/index.js +95 -81
- package/lib/pdf/job/index.js.map +1 -1
- package/lib/pdf/shift-report/emptyFixtures.js +8 -2
- package/lib/pdf/shift-report/emptyFixtures.js.map +1 -1
- package/lib/pdf/shift-report/index.js +399 -521
- package/lib/pdf/shift-report/index.js.map +1 -1
- package/lib/pdf/task/index.js +89 -83
- package/lib/pdf/task/index.js.map +1 -1
- package/lib/scheduling/generators/index.js +38 -3
- package/lib/scheduling/generators/index.js.map +1 -1
- package/lib/scheduling/generators/occurrenceIntervalsGenerator.js +44 -37
- package/lib/scheduling/generators/occurrenceIntervalsGenerator.js.map +1 -1
- package/lib/scheduling/generators/scheduleIntervalsGenerator.js +20 -28
- package/lib/scheduling/generators/scheduleIntervalsGenerator.js.map +1 -1
- package/lib/scheduling/generators/serviceIntervalsGenerator.js +120 -150
- package/lib/scheduling/generators/serviceIntervalsGenerator.js.map +1 -1
- package/lib/scheduling/helpers/convertToTimezone.js +18 -11
- package/lib/scheduling/helpers/convertToTimezone.js.map +1 -1
- package/lib/scheduling/helpers/generateNonRepeatingSchedule.js +57 -95
- package/lib/scheduling/helpers/generateNonRepeatingSchedule.js.map +1 -1
- package/lib/scheduling/helpers/generateRepeatingSchedule.js +80 -119
- package/lib/scheduling/helpers/generateRepeatingSchedule.js.map +1 -1
- package/lib/scheduling/helpers/generateScheduleEnd.js +24 -14
- package/lib/scheduling/helpers/generateScheduleEnd.js.map +1 -1
- package/lib/scheduling/helpers/hasValidStartAndEnd.js +19 -11
- package/lib/scheduling/helpers/hasValidStartAndEnd.js.map +1 -1
- package/lib/scheduling/helpers/index.js +159 -14
- package/lib/scheduling/helpers/index.js.map +1 -1
- package/lib/scheduling/helpers/intervalCovers.js +13 -7
- package/lib/scheduling/helpers/intervalCovers.js.map +1 -1
- package/lib/scheduling/helpers/intervalIntersectsEnd.js +13 -7
- package/lib/scheduling/helpers/intervalIntersectsEnd.js.map +1 -1
- package/lib/scheduling/helpers/intervalIntersectsStart.js +13 -7
- package/lib/scheduling/helpers/intervalIntersectsStart.js.map +1 -1
- package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js +15 -10
- package/lib/scheduling/helpers/intervalOnlyIntersectsEnd.js.map +1 -1
- package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js +15 -10
- package/lib/scheduling/helpers/intervalOnlyIntersectsStart.js.map +1 -1
- package/lib/scheduling/helpers/intervalOutside.js +15 -9
- package/lib/scheduling/helpers/intervalOutside.js.map +1 -1
- package/lib/scheduling/helpers/intervalWithin.js +13 -7
- package/lib/scheduling/helpers/intervalWithin.js.map +1 -1
- package/lib/scheduling/helpers/mergeIntervals.js +21 -17
- package/lib/scheduling/helpers/mergeIntervals.js.map +1 -1
- package/lib/scheduling/helpers/splitIntervals.js +24 -23
- package/lib/scheduling/helpers/splitIntervals.js.map +1 -1
- package/lib/scheduling/index.js +38 -3
- package/lib/scheduling/index.js.map +1 -1
- package/lib/scheduling/scheduling.types.js +9 -3
- package/lib/scheduling/scheduling.types.js.map +1 -1
- package/lib/scheduling/strategies/getNext.js +57 -63
- package/lib/scheduling/strategies/getNext.js.map +1 -1
- package/lib/scheduling/strategies/getNextExactDateOfMonth.js +47 -56
- package/lib/scheduling/strategies/getNextExactDateOfMonth.js.map +1 -1
- package/lib/scheduling/strategies/getNextLastDayOfMonth.js +43 -51
- package/lib/scheduling/strategies/getNextLastDayOfMonth.js.map +1 -1
- package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js +49 -56
- package/lib/scheduling/strategies/getNextLastWeekdayOfMonth.js.map +1 -1
- package/lib/scheduling/strategies/getNextNoRepeat.js +25 -36
- package/lib/scheduling/strategies/getNextNoRepeat.js.map +1 -1
- package/lib/scheduling/strategies/getNextWeekday.js +47 -79
- package/lib/scheduling/strategies/getNextWeekday.js.map +1 -1
- package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js +52 -58
- package/lib/scheduling/strategies/getNextXDayOfXWeekOfMonth.js.map +1 -1
- package/lib/scheduling/strategies/index.js +82 -7
- package/lib/scheduling/strategies/index.js.map +1 -1
- package/lib/schema/index.js +16 -1
- package/lib/schema/index.js.map +1 -1
- package/lib/schema/schema.js +28 -34
- package/lib/schema/schema.js.map +1 -1
- package/lib/service-hours/__helpers__/calculate-hours.js +24 -22
- package/lib/service-hours/__helpers__/calculate-hours.js.map +1 -1
- package/lib/service-hours/__helpers__/isOpen.js +25 -24
- package/lib/service-hours/__helpers__/isOpen.js.map +1 -1
- package/lib/service-hours/index.js +27 -2
- package/lib/service-hours/index.js.map +1 -1
- package/lib/service-hours/schema.js +68 -55
- package/lib/service-hours/schema.js.map +1 -1
- package/package.json +86 -86
- package/vitest.config.ts +23 -23
- package/vitest.setup.js +7 -7
|
@@ -1,657 +1,527 @@
|
|
|
1
|
-
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
import { filter, find, groupBy, isEmpty, map, size, sortBy, take, toString, reduce } from 'lodash';
|
|
8
|
-
import moment from 'moment-timezone';
|
|
9
|
-
import Promise from 'bluebird';
|
|
10
|
-
import { generateDefinition, buildLocationScansContent, buildLocationScansBoundaries, horizontalLine, summaryStatTable, summaryWrapperTable, table, summaryFieldsTable, text, zebraFillColor } from '../helpers';
|
|
11
|
-
import { getLocationReference, getTimezoneAbbr, getTimezoneDatetime } from '../../helpers';
|
|
12
|
-
import { launchIcon } from '../../images';
|
|
13
|
-
var DEFAULT_MAX_SCANS = 200;
|
|
14
|
-
var MAX_ATTACHMENTS = 100;
|
|
15
|
-
var LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
|
|
1
|
+
"use strict";
|
|
16
2
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
38
|
-
* @param {
|
|
39
|
-
* @param {string}
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {string}
|
|
42
|
-
* @param {string}
|
|
43
|
-
* @param {
|
|
44
|
-
* @param {
|
|
45
|
-
* @param {
|
|
46
|
-
* @param {array} data.
|
|
47
|
-
* @param {
|
|
48
|
-
* @
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.buildActivityPdf = buildActivityPdf;
|
|
8
|
+
var _lodash = require("lodash");
|
|
9
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
10
|
+
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
11
|
+
var _helpers = require("../helpers");
|
|
12
|
+
var _helpers2 = require("../../helpers");
|
|
13
|
+
var _images = require("../../images");
|
|
14
|
+
const DEFAULT_MAX_SCANS = 200;
|
|
15
|
+
const MAX_ATTACHMENTS = 100;
|
|
16
|
+
const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* buildActivityPdf
|
|
20
|
+
*
|
|
21
|
+
* @param {object} pdfOptions - the pdf options
|
|
22
|
+
* @param {string} pdfOptions.fileTitle - pdf file title
|
|
23
|
+
* @param {function} pdfOptions.footer - function executed to generate footer
|
|
24
|
+
* @param {function} pdfOptions.header - function executed to generate header
|
|
25
|
+
* @param {string} pdfOptions.logoUrl - pdf logo url
|
|
26
|
+
* @param {array} pdfOptions.pageMargins - pdf page margins
|
|
27
|
+
* @param {string} pdfOptions.pageOrientation - pdf page orientation
|
|
28
|
+
* @param {string} pdfOptions.pageSize - pdf page size
|
|
29
|
+
* @param {object} pdfOptions.styles - pdf styles
|
|
30
|
+
* @param {object} pdfOptions.title - pdf title
|
|
31
|
+
* @param {object} data - pdf data
|
|
32
|
+
* @param {array} data.audits - audit documents
|
|
33
|
+
* @param {string} data.end - end datetime of summary report
|
|
34
|
+
* @param {array} data.events - event documents
|
|
35
|
+
* @param {object} data.location - location document
|
|
36
|
+
* @param {array} data.locations - location documents
|
|
37
|
+
* @param {array} data.issues - issue documents
|
|
38
|
+
* @param {bool} data.maxScans - max scans to include in standard report
|
|
39
|
+
* @param {bool} data.showAlternate - show alternate summary report
|
|
40
|
+
* @param {string} data.start - start datetime of summary report
|
|
41
|
+
* @param {object} data.settings - settings properties
|
|
42
|
+
* @param {string} data.settings.awsS3BaseUrl - aws S3 base url
|
|
43
|
+
* @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
|
|
44
|
+
* @param {array} data.tasks - task documents
|
|
45
|
+
* @param {string} data.timestamp - timestamp string
|
|
46
|
+
* @param {string} data.timezone - timezone string
|
|
47
|
+
* @param {array} data.zones - zone documents
|
|
48
|
+
* @param {array} data.users - user documents
|
|
49
|
+
* @returns {Promise} returns pdfmake definition object
|
|
49
50
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return _context.abrupt("return", generateDefinition(_objectSpread({
|
|
66
|
-
content: content,
|
|
67
|
-
fileTitle: title,
|
|
68
|
-
timestamp: timestamp,
|
|
69
|
-
timezone: timezone,
|
|
70
|
-
type: 'Activity Summary'
|
|
71
|
-
}, pdfOptions)));
|
|
72
|
-
case 2:
|
|
73
|
-
case "end":
|
|
74
|
-
return _context.stop();
|
|
75
|
-
}
|
|
76
|
-
}, _callee);
|
|
77
|
-
}));
|
|
78
|
-
return _buildActivityPdf.apply(this, arguments);
|
|
79
|
-
}
|
|
80
|
-
function generateContent(_x3) {
|
|
81
|
-
return _generateContent.apply(this, arguments);
|
|
82
|
-
}
|
|
83
|
-
function _generateContent() {
|
|
84
|
-
_generateContent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
85
|
-
var activitySection, summarySection, titleTable;
|
|
86
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
87
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
88
|
-
case 0:
|
|
89
|
-
_context2.next = 1;
|
|
90
|
-
return buildActivitySection(data);
|
|
91
|
-
case 1:
|
|
92
|
-
activitySection = _context2.sent;
|
|
93
|
-
summarySection = buildSummarySection(data);
|
|
94
|
-
titleTable = buildTitleTable(data);
|
|
95
|
-
return _context2.abrupt("return", [titleTable, summarySection, activitySection]);
|
|
96
|
-
case 2:
|
|
97
|
-
case "end":
|
|
98
|
-
return _context2.stop();
|
|
99
|
-
}
|
|
100
|
-
}, _callee2);
|
|
101
|
-
}));
|
|
102
|
-
return _generateContent.apply(this, arguments);
|
|
103
|
-
}
|
|
104
|
-
function buildActivitySection(_x4) {
|
|
105
|
-
return _buildActivitySection.apply(this, arguments);
|
|
106
|
-
}
|
|
107
|
-
function _buildActivitySection() {
|
|
108
|
-
_buildActivitySection = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
109
|
-
var _data$showAlternate, showAlternate, locationScans, otherActivity, activitySummary;
|
|
110
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
111
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
112
|
-
case 0:
|
|
113
|
-
_data$showAlternate = data.showAlternate, showAlternate = _data$showAlternate === void 0 ? false : _data$showAlternate;
|
|
114
|
-
if (!showAlternate) {
|
|
115
|
-
_context3.next = 2;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
locationScans = buildLocationScansSection(data);
|
|
119
|
-
_context3.next = 1;
|
|
120
|
-
return buildOtherActivitySection(data);
|
|
121
|
-
case 1:
|
|
122
|
-
otherActivity = _context3.sent;
|
|
123
|
-
return _context3.abrupt("return", [locationScans, otherActivity]);
|
|
124
|
-
case 2:
|
|
125
|
-
_context3.next = 3;
|
|
126
|
-
return buildActivitySummarySection(data);
|
|
127
|
-
case 3:
|
|
128
|
-
activitySummary = _context3.sent;
|
|
129
|
-
return _context3.abrupt("return", [activitySummary]);
|
|
130
|
-
case 4:
|
|
131
|
-
case "end":
|
|
132
|
-
return _context3.stop();
|
|
133
|
-
}
|
|
134
|
-
}, _callee3);
|
|
135
|
-
}));
|
|
136
|
-
return _buildActivitySection.apply(this, arguments);
|
|
51
|
+
async function buildActivityPdf(pdfOptions, data) {
|
|
52
|
+
const {
|
|
53
|
+
timestamp,
|
|
54
|
+
timezone
|
|
55
|
+
} = data;
|
|
56
|
+
const title = 'Daily Activity Report';
|
|
57
|
+
const content = await generateContent(data);
|
|
58
|
+
return (0, _helpers.generateDefinition)({
|
|
59
|
+
content,
|
|
60
|
+
fileTitle: title,
|
|
61
|
+
timestamp,
|
|
62
|
+
timezone,
|
|
63
|
+
type: 'Activity Summary',
|
|
64
|
+
...pdfOptions
|
|
65
|
+
});
|
|
137
66
|
}
|
|
138
|
-
function
|
|
139
|
-
|
|
67
|
+
async function generateContent(data) {
|
|
68
|
+
const activitySection = await buildActivitySection(data);
|
|
69
|
+
const summarySection = buildSummarySection(data);
|
|
70
|
+
const titleTable = buildTitleTable(data);
|
|
71
|
+
return [titleTable, summarySection, activitySection];
|
|
140
72
|
}
|
|
141
|
-
function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
scans = take(enterEvents, maxScans);
|
|
153
|
-
auditRows = map(audits, getFormRowData('audits', data));
|
|
154
|
-
issueRows = map(issues, getFormRowData('issues', data));
|
|
155
|
-
scanRows = map(scans, getScanRowData(data));
|
|
156
|
-
taskRows = map(tasks, getFormRowData('tasks', data));
|
|
157
|
-
formCount = size([].concat(_toConsumableArray(auditRows), _toConsumableArray(issueRows), _toConsumableArray(taskRows)));
|
|
158
|
-
exceedsMaxForms = formCount > MAX_ATTACHMENTS;
|
|
159
|
-
rows = [].concat(_toConsumableArray(auditRows), _toConsumableArray(issueRows), _toConsumableArray(scanRows), _toConsumableArray(taskRows));
|
|
160
|
-
sortedRows = sortBy(rows, ['timestamp'], ['asc']);
|
|
161
|
-
title = text('Activity Summary', {
|
|
162
|
-
style: 'summarySectionHeader'
|
|
163
|
-
});
|
|
164
|
-
header = table({
|
|
165
|
-
body: [[title]],
|
|
166
|
-
layout: 'noBorders',
|
|
167
|
-
style: 'summaryHeaderTable'
|
|
168
|
-
});
|
|
169
|
-
hLine = horizontalLine();
|
|
170
|
-
_context4.next = 1;
|
|
171
|
-
return buildActivityTable({
|
|
172
|
-
rows: sortedRows,
|
|
173
|
-
settings: settings,
|
|
174
|
-
timezone: timezone
|
|
175
|
-
});
|
|
176
|
-
case 1:
|
|
177
|
-
activityTable = _context4.sent;
|
|
178
|
-
activitySummarySection = [header, hLine, activityTable];
|
|
179
|
-
if (exceedsMaxScans) {
|
|
180
|
-
maxScansText = {
|
|
181
|
-
text: [text("Location Scans in the Daily Activity Report are limited to a total of ".concat(maxScans, ".")), text(' To view all Location Scans visit '), text('the Events Report', {
|
|
182
|
-
link: "".concat(LIGHTHOUSE_BASE_URL, "/reports/events")
|
|
183
|
-
}), text(' in the Lighthouse Management Console.')],
|
|
184
|
-
style: 'small',
|
|
185
|
-
margin: [0, 10, 0, 10]
|
|
186
|
-
};
|
|
187
|
-
activitySummarySection.push(maxScansText);
|
|
188
|
-
}
|
|
189
|
-
if (exceedsMaxForms) {
|
|
190
|
-
maxFormsText = {
|
|
191
|
-
text: [text("Detailed Form Submissions in the Daily Activity Report are limited to a total of ".concat(MAX_ATTACHMENTS, ". ")), text('To access individual Form Submissions, open the hyperlink next to the respective submission within the Activity Summary table. Alternatively, they may be accessed in the Lighthouse Management Console.')],
|
|
192
|
-
style: 'small',
|
|
193
|
-
margin: [0, 10, 0, 10]
|
|
194
|
-
};
|
|
195
|
-
activitySummarySection.push(maxFormsText);
|
|
196
|
-
}
|
|
197
|
-
return _context4.abrupt("return", activitySummarySection);
|
|
198
|
-
case 2:
|
|
199
|
-
case "end":
|
|
200
|
-
return _context4.stop();
|
|
201
|
-
}
|
|
202
|
-
}, _callee4);
|
|
203
|
-
}));
|
|
204
|
-
return _buildActivitySummarySection.apply(this, arguments);
|
|
73
|
+
async function buildActivitySection(data) {
|
|
74
|
+
const {
|
|
75
|
+
showAlternate = false
|
|
76
|
+
} = data;
|
|
77
|
+
if (showAlternate) {
|
|
78
|
+
const locationScans = buildLocationScansSection(data);
|
|
79
|
+
const otherActivity = await buildOtherActivitySection(data);
|
|
80
|
+
return [locationScans, otherActivity];
|
|
81
|
+
}
|
|
82
|
+
const activitySummary = await buildActivitySummarySection(data);
|
|
83
|
+
return [activitySummary];
|
|
205
84
|
}
|
|
206
|
-
function
|
|
207
|
-
|
|
85
|
+
async function buildActivitySummarySection(data) {
|
|
86
|
+
const {
|
|
87
|
+
audits,
|
|
88
|
+
events,
|
|
89
|
+
issues,
|
|
90
|
+
maxScans = DEFAULT_MAX_SCANS,
|
|
91
|
+
settings,
|
|
92
|
+
tasks,
|
|
93
|
+
timezone
|
|
94
|
+
} = data;
|
|
95
|
+
const enterEvents = (0, _lodash.filter)(events, event => event.type === 'enter');
|
|
96
|
+
const exceedsMaxScans = (0, _lodash.size)(enterEvents) > maxScans;
|
|
97
|
+
const scans = (0, _lodash.take)(enterEvents, maxScans);
|
|
98
|
+
const auditRows = (0, _lodash.map)(audits, getFormRowData('audits', data));
|
|
99
|
+
const issueRows = (0, _lodash.map)(issues, getFormRowData('issues', data));
|
|
100
|
+
const scanRows = (0, _lodash.map)(scans, getScanRowData(data));
|
|
101
|
+
const taskRows = (0, _lodash.map)(tasks, getFormRowData('tasks', data));
|
|
102
|
+
const formCount = (0, _lodash.size)([...auditRows, ...issueRows, ...taskRows]);
|
|
103
|
+
const exceedsMaxForms = formCount > MAX_ATTACHMENTS;
|
|
104
|
+
const rows = [...auditRows, ...issueRows, ...scanRows, ...taskRows];
|
|
105
|
+
const sortedRows = (0, _lodash.sortBy)(rows, ['timestamp'], ['asc']);
|
|
106
|
+
const title = (0, _helpers.text)('Activity Summary', {
|
|
107
|
+
style: 'summarySectionHeader'
|
|
108
|
+
});
|
|
109
|
+
const header = (0, _helpers.table)({
|
|
110
|
+
body: [[title]],
|
|
111
|
+
layout: 'noBorders',
|
|
112
|
+
style: 'summaryHeaderTable'
|
|
113
|
+
});
|
|
114
|
+
const hLine = (0, _helpers.horizontalLine)();
|
|
115
|
+
const activityTable = await buildActivityTable({
|
|
116
|
+
rows: sortedRows,
|
|
117
|
+
settings,
|
|
118
|
+
timezone
|
|
119
|
+
});
|
|
120
|
+
const activitySummarySection = [header, hLine, activityTable];
|
|
121
|
+
if (exceedsMaxScans) {
|
|
122
|
+
const maxScansText = {
|
|
123
|
+
text: [(0, _helpers.text)(`Location Scans in the Daily Activity Report are limited to a total of ${maxScans}.`), (0, _helpers.text)(' To view all Location Scans visit '), (0, _helpers.text)('the Events Report', {
|
|
124
|
+
link: `${LIGHTHOUSE_BASE_URL}/reports/events`
|
|
125
|
+
}), (0, _helpers.text)(' in the Lighthouse Management Console.')],
|
|
126
|
+
style: 'small',
|
|
127
|
+
margin: [0, 10, 0, 10]
|
|
128
|
+
};
|
|
129
|
+
activitySummarySection.push(maxScansText);
|
|
130
|
+
}
|
|
131
|
+
if (exceedsMaxForms) {
|
|
132
|
+
const maxFormsText = {
|
|
133
|
+
text: [(0, _helpers.text)(`Detailed Form Submissions in the Daily Activity Report are limited to a total of ${MAX_ATTACHMENTS}. `), (0, _helpers.text)('To access individual Form Submissions, open the hyperlink next to the respective submission within the Activity Summary table. Alternatively, they may be accessed in the Lighthouse Management Console.')],
|
|
134
|
+
style: 'small',
|
|
135
|
+
margin: [0, 10, 0, 10]
|
|
136
|
+
};
|
|
137
|
+
activitySummarySection.push(maxFormsText);
|
|
138
|
+
}
|
|
139
|
+
return activitySummarySection;
|
|
208
140
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
}, _callee5);
|
|
317
|
-
}));
|
|
318
|
-
return function (_x8) {
|
|
319
|
-
return _ref4.apply(this, arguments);
|
|
320
|
-
};
|
|
321
|
-
}());
|
|
322
|
-
case 1:
|
|
323
|
-
activityTableRows = _context6.sent;
|
|
324
|
-
activityTableBody = isEmpty(activityTableRows) ? [[text('No other activity', {
|
|
325
|
-
colSpan: 5
|
|
326
|
-
})]] : activityTableRows;
|
|
327
|
-
activityTable = table({
|
|
328
|
-
body: [activityTableHeader].concat(_toConsumableArray(activityTableBody)),
|
|
329
|
-
dontBreakRows: true,
|
|
330
|
-
layout: {
|
|
331
|
-
hLineWidth: function hLineWidth() {
|
|
332
|
-
return 0;
|
|
333
|
-
},
|
|
334
|
-
fillColor: zebraFillColor,
|
|
335
|
-
paddingLeft: function paddingLeft() {
|
|
336
|
-
return 5;
|
|
337
|
-
},
|
|
338
|
-
paddingRight: function paddingRight() {
|
|
339
|
-
return 5;
|
|
340
|
-
},
|
|
341
|
-
paddingTop: function paddingTop() {
|
|
342
|
-
return 5;
|
|
343
|
-
},
|
|
344
|
-
paddingBottom: function paddingBottom() {
|
|
345
|
-
return 5;
|
|
346
|
-
},
|
|
347
|
-
vLineWidth: function vLineWidth() {
|
|
348
|
-
return 0;
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
|
-
widths: [120, 15, 100, 100, '*']
|
|
352
|
-
});
|
|
353
|
-
return _context6.abrupt("return", activityTable);
|
|
354
|
-
case 2:
|
|
355
|
-
case "end":
|
|
356
|
-
return _context6.stop();
|
|
357
|
-
}
|
|
358
|
-
}, _callee6);
|
|
359
|
-
}));
|
|
360
|
-
return _buildActivityTable.apply(this, arguments);
|
|
141
|
+
async function buildActivityTable({
|
|
142
|
+
rows,
|
|
143
|
+
settings,
|
|
144
|
+
timezone
|
|
145
|
+
}) {
|
|
146
|
+
const timezoneAbbr = (0, _helpers2.getTimezoneAbbr)(timezone);
|
|
147
|
+
const activityTableHeader = [(0, _helpers.text)('Activity', {
|
|
148
|
+
bold: true
|
|
149
|
+
}), {
|
|
150
|
+
text: ''
|
|
151
|
+
},
|
|
152
|
+
// icon column
|
|
153
|
+
(0, _helpers.text)('Location', {
|
|
154
|
+
bold: true
|
|
155
|
+
}), (0, _helpers.text)('User', {
|
|
156
|
+
bold: true
|
|
157
|
+
}), (0, _helpers.text)(`Timestamp (${timezoneAbbr})`, {
|
|
158
|
+
alignment: 'right',
|
|
159
|
+
bold: true
|
|
160
|
+
})];
|
|
161
|
+
const activityTableRows = await _bluebird.default.map(rows, async function (data) {
|
|
162
|
+
const {
|
|
163
|
+
link,
|
|
164
|
+
location,
|
|
165
|
+
icon,
|
|
166
|
+
name,
|
|
167
|
+
summaryFields,
|
|
168
|
+
timestamp,
|
|
169
|
+
title
|
|
170
|
+
} = data;
|
|
171
|
+
const timezoneHour = (0, _helpers2.getTimezoneDatetime)({
|
|
172
|
+
format: 'ddd DD h:mm a',
|
|
173
|
+
showTzAbbr: false,
|
|
174
|
+
timestamp,
|
|
175
|
+
timezone
|
|
176
|
+
});
|
|
177
|
+
const iconCell = icon ? {
|
|
178
|
+
alignment: 'center',
|
|
179
|
+
fit: [8, 8],
|
|
180
|
+
image: icon,
|
|
181
|
+
link
|
|
182
|
+
} : {
|
|
183
|
+
text: ''
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// NOTE: pass link to each column as
|
|
187
|
+
// we can't wrap the entire table row
|
|
188
|
+
const rows = [[(0, _helpers.text)(title, {
|
|
189
|
+
link
|
|
190
|
+
}), iconCell, (0, _helpers.text)(location, {
|
|
191
|
+
link
|
|
192
|
+
}), (0, _helpers.text)(name, {
|
|
193
|
+
link
|
|
194
|
+
}), (0, _helpers.text)(timezoneHour, {
|
|
195
|
+
alignment: 'right',
|
|
196
|
+
link
|
|
197
|
+
})]];
|
|
198
|
+
const hasSummaryFields = !(0, _lodash.isEmpty)(summaryFields);
|
|
199
|
+
if (hasSummaryFields) {
|
|
200
|
+
const fieldsTable = await (0, _helpers.summaryFieldsTable)({
|
|
201
|
+
fields: summaryFields,
|
|
202
|
+
settings,
|
|
203
|
+
timezone
|
|
204
|
+
});
|
|
205
|
+
rows.push([fieldsTable]);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// NOTE: we return a table per row which includes the entry details and the
|
|
209
|
+
// summary fields if relevant
|
|
210
|
+
const activityTableRow = [(0, _helpers.table)({
|
|
211
|
+
body: [...rows],
|
|
212
|
+
colSpan: 5,
|
|
213
|
+
dontBreakRows: true,
|
|
214
|
+
headerRow: 0,
|
|
215
|
+
layout: {
|
|
216
|
+
hLineWidth: () => 0,
|
|
217
|
+
paddingLeft: () => 0,
|
|
218
|
+
paddingRight: () => 0,
|
|
219
|
+
paddingTop: () => 5,
|
|
220
|
+
paddingBottom: () => 5,
|
|
221
|
+
vLineWidth: () => 0
|
|
222
|
+
},
|
|
223
|
+
// NOTE: the timestamp must fill up the rest of the table space as
|
|
224
|
+
// otherwise the padding would be off between this table and the parent
|
|
225
|
+
// table that wraps it
|
|
226
|
+
widths: [130, 25, 110, 110, '*']
|
|
227
|
+
})];
|
|
228
|
+
return activityTableRow;
|
|
229
|
+
});
|
|
230
|
+
const activityTableBody = (0, _lodash.isEmpty)(activityTableRows) ? [[(0, _helpers.text)('No other activity', {
|
|
231
|
+
colSpan: 5
|
|
232
|
+
})]] : activityTableRows;
|
|
233
|
+
const activityTable = (0, _helpers.table)({
|
|
234
|
+
body: [activityTableHeader, ...activityTableBody],
|
|
235
|
+
dontBreakRows: true,
|
|
236
|
+
layout: {
|
|
237
|
+
hLineWidth: () => 0,
|
|
238
|
+
fillColor: _helpers.zebraFillColor,
|
|
239
|
+
paddingLeft: () => 5,
|
|
240
|
+
paddingRight: () => 5,
|
|
241
|
+
paddingTop: () => 5,
|
|
242
|
+
paddingBottom: () => 5,
|
|
243
|
+
vLineWidth: () => 0
|
|
244
|
+
},
|
|
245
|
+
widths: [120, 15, 100, 100, '*']
|
|
246
|
+
});
|
|
247
|
+
return activityTable;
|
|
361
248
|
}
|
|
362
249
|
function buildLocationScansSection(data) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
250
|
+
const {
|
|
251
|
+
events,
|
|
252
|
+
start,
|
|
253
|
+
timezone,
|
|
254
|
+
zones
|
|
255
|
+
} = data;
|
|
256
|
+
const title = (0, _helpers.text)('Location Scans', {
|
|
368
257
|
style: 'summarySectionHeader'
|
|
369
258
|
});
|
|
370
|
-
|
|
259
|
+
const header = (0, _helpers.table)({
|
|
371
260
|
body: [[title]],
|
|
372
261
|
layout: 'noBorders',
|
|
373
262
|
style: 'summaryHeaderTable'
|
|
374
263
|
});
|
|
375
264
|
|
|
376
265
|
// use start time and timezone to figure out the interval boundaries
|
|
377
|
-
|
|
266
|
+
const hourIntervalBoundaries = (0, _helpers.buildLocationScansBoundaries)(start, timezone);
|
|
378
267
|
|
|
379
268
|
// pair interval boundaries into column headers for the table
|
|
380
|
-
|
|
381
|
-
if (index < size(intervals) - 1)
|
|
269
|
+
const hourIntervalColumnHeaders = hourIntervalBoundaries.reduce((columns, interval, index, intervals) => {
|
|
270
|
+
if (index < (0, _lodash.size)(intervals) - 1)
|
|
382
271
|
// skip the final iteration as it's just the end of the last interval
|
|
383
|
-
columns.push(
|
|
272
|
+
columns.push((0, _helpers.text)(`${interval.format('h')}-${intervals[index + 1].format('hA')}`, {
|
|
384
273
|
alignment: 'center',
|
|
385
274
|
bold: true
|
|
386
275
|
}));
|
|
387
276
|
return columns;
|
|
388
277
|
}, []);
|
|
389
|
-
|
|
278
|
+
const scansTableHeader = [(0, _helpers.text)('Location', {
|
|
390
279
|
bold: true
|
|
391
|
-
})
|
|
280
|
+
}), ...hourIntervalColumnHeaders, (0, _helpers.text)('Total', {
|
|
392
281
|
alignment: 'right',
|
|
393
282
|
bold: true
|
|
394
|
-
})]
|
|
395
|
-
|
|
283
|
+
})];
|
|
284
|
+
const hLine = (0, _helpers.horizontalLine)();
|
|
396
285
|
|
|
397
286
|
// NOTE: only show the enter events within the summary table
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
var groupedEventsByZone = reduce(sortedZones, function (memo, zone) {
|
|
403
|
-
var zoneEvents = filter(enterEvents, function (event) {
|
|
404
|
-
return event.zone && event.zone.toString() === zone._id.toString();
|
|
405
|
-
});
|
|
287
|
+
const enterEvents = (0, _lodash.filter)(events, event => event.type === 'enter');
|
|
288
|
+
const sortedZones = (0, _lodash.sortBy)(zones, ['name']);
|
|
289
|
+
const groupedEventsByZone = (0, _lodash.reduce)(sortedZones, (memo, zone) => {
|
|
290
|
+
const zoneEvents = (0, _lodash.filter)(enterEvents, event => event.zone && event.zone.toString() === zone._id.toString());
|
|
406
291
|
memo[zone._id] = zoneEvents;
|
|
407
292
|
return memo;
|
|
408
293
|
}, {});
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
var sortedGroup = sortBy(events, ['timestamp'], ['asc']);
|
|
294
|
+
const scansTableRows = (0, _lodash.map)(groupedEventsByZone, (events, zone = '') => {
|
|
295
|
+
const sortedGroup = (0, _lodash.sortBy)(events, ['timestamp'], ['asc']);
|
|
412
296
|
|
|
413
297
|
// put events into interval buckets
|
|
414
|
-
|
|
298
|
+
const locationScansByInterval = (0, _helpers.buildLocationScansContent)(hourIntervalBoundaries, events);
|
|
415
299
|
// map the interval buckets to a format fit for the table
|
|
416
|
-
|
|
300
|
+
const locationScansByIntervalContent = locationScansByInterval.map(interval => {
|
|
417
301
|
return {
|
|
418
302
|
alignment: 'center',
|
|
419
|
-
text: size(interval)
|
|
303
|
+
text: (0, _lodash.size)(interval)
|
|
420
304
|
};
|
|
421
305
|
});
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
var zoneName = zoneDoc && zoneDoc.name || 'Unknown Location';
|
|
427
|
-
return [zoneName].concat(_toConsumableArray(locationScansByIntervalContent), [{
|
|
306
|
+
const totalEvents = (0, _lodash.size)(sortedGroup);
|
|
307
|
+
const zoneDoc = zone && (0, _lodash.find)(zones, doc => doc._id.toString() === zone.toString());
|
|
308
|
+
const zoneName = zoneDoc && zoneDoc.name || 'Unknown Location';
|
|
309
|
+
return [zoneName, ...locationScansByIntervalContent, {
|
|
428
310
|
alignment: 'right',
|
|
429
311
|
bold: true,
|
|
430
312
|
text: totalEvents
|
|
431
|
-
}]
|
|
313
|
+
}];
|
|
432
314
|
});
|
|
433
|
-
|
|
315
|
+
const scansTableBody = (0, _lodash.isEmpty)(scansTableRows) ? [[(0, _helpers.text)('No location scans', {
|
|
434
316
|
colSpan: 10
|
|
435
317
|
})]] : scansTableRows;
|
|
436
|
-
|
|
437
|
-
body: [scansTableHeader]
|
|
318
|
+
const scansTable = (0, _helpers.table)({
|
|
319
|
+
body: [scansTableHeader, ...scansTableBody],
|
|
438
320
|
widths: [100, '*', '*', '*', '*', '*', '*', '*', '*', '*']
|
|
439
321
|
});
|
|
440
322
|
return [header, hLine, scansTable];
|
|
441
323
|
}
|
|
442
324
|
function buildSummarySection(data) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
325
|
+
const {
|
|
326
|
+
audits,
|
|
327
|
+
events,
|
|
328
|
+
issues,
|
|
329
|
+
tasks
|
|
330
|
+
} = data;
|
|
447
331
|
|
|
448
332
|
//const userEvents = groupBy(events, 'user')
|
|
449
|
-
|
|
450
|
-
|
|
333
|
+
const eventsByType = (0, _lodash.groupBy)(events, 'type');
|
|
334
|
+
const enterEventsCount = (0, _lodash.size)(eventsByType.enter);
|
|
451
335
|
//const geoEventsCount = size(eventsByType.geo)
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
336
|
+
const issuesCount = (0, _lodash.size)(issues);
|
|
337
|
+
const tasksCount = (0, _lodash.size)(tasks);
|
|
338
|
+
const auditsCount = (0, _lodash.size)(audits);
|
|
455
339
|
//const uniqueUsers = size(userEvents)
|
|
456
340
|
|
|
457
|
-
|
|
341
|
+
const auditsText = (0, _helpers.text)('AUDITS', {
|
|
458
342
|
style: 'summaryText'
|
|
459
343
|
});
|
|
460
344
|
//const geoText = text('GPS', { style: 'summaryText' })
|
|
461
|
-
|
|
345
|
+
const issuesText = (0, _helpers.text)('ISSUES', {
|
|
462
346
|
style: 'summaryText'
|
|
463
347
|
});
|
|
464
348
|
//const peopleText = text('PEOPLE', { style: 'summaryText' })
|
|
465
|
-
|
|
349
|
+
const scansText = (0, _helpers.text)('SCANS', {
|
|
466
350
|
style: 'summaryText'
|
|
467
351
|
});
|
|
468
|
-
|
|
352
|
+
const tasksText = (0, _helpers.text)('TASKS', {
|
|
469
353
|
style: 'summaryText'
|
|
470
354
|
});
|
|
471
|
-
|
|
355
|
+
const auditsCountText = (0, _helpers.text)((0, _lodash.toString)(auditsCount), {
|
|
472
356
|
style: 'summaryCount'
|
|
473
357
|
});
|
|
474
358
|
//const peopleCountText = text(toString(uniqueUsers), { style: 'summaryCount' })
|
|
475
|
-
|
|
359
|
+
const scansCountText = (0, _helpers.text)((0, _lodash.toString)(enterEventsCount), {
|
|
476
360
|
style: 'summaryCount'
|
|
477
361
|
});
|
|
478
362
|
//const geoCountText = text(toString(geoEventsCount), { style: 'summaryCount' })
|
|
479
|
-
|
|
363
|
+
const issuesCountText = (0, _helpers.text)((0, _lodash.toString)(issuesCount), {
|
|
480
364
|
style: 'summaryCount'
|
|
481
365
|
});
|
|
482
|
-
|
|
366
|
+
const tasksCountText = (0, _helpers.text)((0, _lodash.toString)(tasksCount), {
|
|
483
367
|
style: 'summaryCount'
|
|
484
368
|
});
|
|
485
|
-
|
|
369
|
+
const auditTable = (0, _helpers.summaryStatTable)({
|
|
486
370
|
body: [[auditsText], [auditsCountText]]
|
|
487
371
|
});
|
|
488
372
|
//const peopleTable = summaryStatTable({
|
|
489
373
|
// body: [[peopleText], [peopleCountText]],
|
|
490
374
|
//})
|
|
491
375
|
//const gpsTable = summaryStatTable({ body: [[geoText], [geoCountText]] })
|
|
492
|
-
|
|
376
|
+
const scanTable = (0, _helpers.summaryStatTable)({
|
|
493
377
|
body: [[scansText], [scansCountText]]
|
|
494
378
|
});
|
|
495
|
-
|
|
379
|
+
const issueTable = (0, _helpers.summaryStatTable)({
|
|
496
380
|
body: [[issuesText], [issuesCountText]]
|
|
497
381
|
});
|
|
498
|
-
|
|
382
|
+
const taskTables = (0, _helpers.summaryStatTable)({
|
|
499
383
|
body: [[tasksText], [tasksCountText]]
|
|
500
384
|
});
|
|
501
|
-
|
|
385
|
+
const wrapperTable = (0, _helpers.summaryWrapperTable)({
|
|
502
386
|
body: [[/*peopleTable,*/
|
|
503
387
|
/*gpsTable,*/
|
|
504
388
|
scanTable, issueTable, taskTables, auditTable]]
|
|
505
389
|
});
|
|
506
390
|
return wrapperTable;
|
|
507
391
|
}
|
|
508
|
-
function buildOtherActivitySection(
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
margin: [0, 10, 0, 10]
|
|
548
|
-
};
|
|
549
|
-
otherActivitySummarySection.push(maxFormsText);
|
|
550
|
-
}
|
|
551
|
-
return _context7.abrupt("return", otherActivitySummarySection);
|
|
552
|
-
case 2:
|
|
553
|
-
case "end":
|
|
554
|
-
return _context7.stop();
|
|
555
|
-
}
|
|
556
|
-
}, _callee7);
|
|
557
|
-
}));
|
|
558
|
-
return _buildOtherActivitySection.apply(this, arguments);
|
|
392
|
+
async function buildOtherActivitySection(data) {
|
|
393
|
+
const {
|
|
394
|
+
audits,
|
|
395
|
+
issues,
|
|
396
|
+
tasks,
|
|
397
|
+
settings,
|
|
398
|
+
timezone
|
|
399
|
+
} = data;
|
|
400
|
+
const auditRows = (0, _lodash.map)(audits, getFormRowData('audits', data));
|
|
401
|
+
const issueRows = (0, _lodash.map)(issues, getFormRowData('issues', data));
|
|
402
|
+
const taskRows = (0, _lodash.map)(tasks, getFormRowData('tasks', data));
|
|
403
|
+
const rows = [...auditRows, ...issueRows, ...taskRows];
|
|
404
|
+
const sortedRows = (0, _lodash.sortBy)(rows, ['timestamp'], ['asc']);
|
|
405
|
+
const title = (0, _helpers.text)('Other Activity', {
|
|
406
|
+
style: 'summarySectionHeader'
|
|
407
|
+
});
|
|
408
|
+
const header = (0, _helpers.table)({
|
|
409
|
+
body: [[title]],
|
|
410
|
+
layout: 'noBorders',
|
|
411
|
+
style: 'summaryHeaderTable'
|
|
412
|
+
});
|
|
413
|
+
const hLine = (0, _helpers.horizontalLine)();
|
|
414
|
+
const activityTable = await buildActivityTable({
|
|
415
|
+
rows: sortedRows,
|
|
416
|
+
settings,
|
|
417
|
+
timezone
|
|
418
|
+
});
|
|
419
|
+
const otherActivitySummarySection = [header, hLine, activityTable];
|
|
420
|
+
const formCount = (0, _lodash.size)(rows);
|
|
421
|
+
const exceedsMaxForms = formCount > MAX_ATTACHMENTS;
|
|
422
|
+
if (exceedsMaxForms) {
|
|
423
|
+
const maxFormsText = {
|
|
424
|
+
text: [(0, _helpers.text)(`Detailed Form Submissions in the Daily Activity Report are limited to a total of ${MAX_ATTACHMENTS}. `), (0, _helpers.text)('To access individual Form Submissions, open the hyperlink next to the respective submission within the Other Activity table. Alternatively, they may be accessed in the Lighthouse Management Console.')],
|
|
425
|
+
style: 'small',
|
|
426
|
+
margin: [0, 10, 0, 10]
|
|
427
|
+
};
|
|
428
|
+
otherActivitySummarySection.push(maxFormsText);
|
|
429
|
+
}
|
|
430
|
+
return otherActivitySummarySection;
|
|
559
431
|
}
|
|
560
432
|
function buildTitleTable(data) {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
433
|
+
const {
|
|
434
|
+
location,
|
|
435
|
+
start,
|
|
436
|
+
end,
|
|
437
|
+
timezone
|
|
438
|
+
} = data;
|
|
439
|
+
const {
|
|
440
|
+
address = {}
|
|
441
|
+
} = location;
|
|
442
|
+
const headerTitle = (0, _helpers.text)('Daily Activity Report', {
|
|
568
443
|
style: 'title'
|
|
569
444
|
});
|
|
570
|
-
|
|
445
|
+
const headerSubTitle = (0, _helpers.text)(location.name, {
|
|
571
446
|
style: 'subTitle'
|
|
572
447
|
});
|
|
573
|
-
|
|
574
|
-
|
|
448
|
+
const addressText = !(0, _lodash.isEmpty)(address) ? `${address.street}, ${address.city || ''} ${address.state || ''} ${address.postalCode || ''}` : '';
|
|
449
|
+
const headerAddress = (0, _helpers.text)(addressText, {
|
|
575
450
|
style: 'small'
|
|
576
451
|
});
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
452
|
+
const mTimezoneStart = _momentTimezone.default.tz(start, timezone);
|
|
453
|
+
const mTimezoneEnd = _momentTimezone.default.tz(end, timezone);
|
|
454
|
+
const timezoneAbbr = (0, _helpers2.getTimezoneAbbr)(timezone);
|
|
455
|
+
const rangeStart = (0, _momentTimezone.default)(mTimezoneStart).format('MMM DD h:mma');
|
|
456
|
+
const rangeEnd = (0, _momentTimezone.default)(mTimezoneEnd).add(1, 'hour').startOf('hour').format('MMM DD h:mma');
|
|
457
|
+
const headerRange = (0, _helpers.text)(`${rangeStart} - ${rangeEnd} (${timezoneAbbr})`, {
|
|
583
458
|
style: 'subTitle2'
|
|
584
459
|
});
|
|
585
|
-
|
|
586
|
-
return table({
|
|
587
|
-
body
|
|
460
|
+
const body = !(0, _lodash.isEmpty)(address) ? [[headerTitle], [headerSubTitle], [headerAddress], [headerRange]] : [[headerTitle], [headerSubTitle], [headerRange]];
|
|
461
|
+
return (0, _helpers.table)({
|
|
462
|
+
body,
|
|
588
463
|
layout: 'noBorders',
|
|
589
464
|
style: 'titleTable'
|
|
590
465
|
});
|
|
591
466
|
}
|
|
592
|
-
function getFormRowData(collection,
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
title =
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
467
|
+
function getFormRowData(collection, {
|
|
468
|
+
locations,
|
|
469
|
+
users,
|
|
470
|
+
zones
|
|
471
|
+
}) {
|
|
472
|
+
return document => {
|
|
473
|
+
const {
|
|
474
|
+
_id,
|
|
475
|
+
createdAt,
|
|
476
|
+
entry = {},
|
|
477
|
+
title = 'Unknown',
|
|
478
|
+
user = ''
|
|
479
|
+
} = document;
|
|
480
|
+
const location = (0, _helpers2.getLocationReference)({
|
|
606
481
|
entity: document,
|
|
607
|
-
locations
|
|
608
|
-
zones
|
|
609
|
-
});
|
|
610
|
-
var link = "".concat(LIGHTHOUSE_BASE_URL, "/reports/").concat(collection, "/").concat(_id);
|
|
611
|
-
var timestamp = createdAt;
|
|
612
|
-
var userDoc = find(users, function (doc) {
|
|
613
|
-
return doc._id.toString() === user.toString();
|
|
482
|
+
locations,
|
|
483
|
+
zones
|
|
614
484
|
});
|
|
615
|
-
|
|
485
|
+
const link = `${LIGHTHOUSE_BASE_URL}/reports/${collection}/${_id}`;
|
|
486
|
+
const timestamp = createdAt;
|
|
487
|
+
const userDoc = (0, _lodash.find)(users, doc => doc._id.toString() === user.toString());
|
|
488
|
+
const name = userDoc && `${userDoc.firstName} ${userDoc.lastName}` || 'Unknown User';
|
|
616
489
|
|
|
617
490
|
// NOTE: currently only issues and tasks will return summary fields, audits
|
|
618
491
|
// aren't supported and will return an empty array here
|
|
619
|
-
|
|
492
|
+
const summaryFields = entry.summaryFields || [];
|
|
620
493
|
return {
|
|
621
|
-
icon: launchIcon,
|
|
622
|
-
location
|
|
623
|
-
link
|
|
624
|
-
name
|
|
625
|
-
summaryFields
|
|
626
|
-
timestamp
|
|
627
|
-
title
|
|
494
|
+
icon: _images.launchIcon,
|
|
495
|
+
location,
|
|
496
|
+
link,
|
|
497
|
+
name,
|
|
498
|
+
summaryFields,
|
|
499
|
+
timestamp,
|
|
500
|
+
title
|
|
628
501
|
};
|
|
629
502
|
};
|
|
630
503
|
}
|
|
631
|
-
function getScanRowData(
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
zone =
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
var location = zoneName || 'Unknown Location';
|
|
648
|
-
var name = userDoc && "".concat(userDoc.firstName, " ").concat(userDoc.lastName) || 'Unknown User';
|
|
649
|
-
var title = 'Location Scan';
|
|
504
|
+
function getScanRowData({
|
|
505
|
+
users,
|
|
506
|
+
zones
|
|
507
|
+
}) {
|
|
508
|
+
return document => {
|
|
509
|
+
const {
|
|
510
|
+
timestamp,
|
|
511
|
+
user = '',
|
|
512
|
+
zone = ''
|
|
513
|
+
} = document;
|
|
514
|
+
const userDoc = user && (0, _lodash.find)(users, doc => doc._id.toString() === user.toString());
|
|
515
|
+
const zoneDoc = zone && (0, _lodash.find)(zones, doc => doc._id.toString() === zone.toString());
|
|
516
|
+
const zoneName = zoneDoc && zoneDoc.name;
|
|
517
|
+
const location = zoneName || 'Unknown Location';
|
|
518
|
+
const name = userDoc && `${userDoc.firstName} ${userDoc.lastName}` || 'Unknown User';
|
|
519
|
+
const title = 'Location Scan';
|
|
650
520
|
return {
|
|
651
|
-
location
|
|
652
|
-
timestamp
|
|
653
|
-
name
|
|
654
|
-
title
|
|
521
|
+
location,
|
|
522
|
+
timestamp,
|
|
523
|
+
name,
|
|
524
|
+
title
|
|
655
525
|
};
|
|
656
526
|
};
|
|
657
527
|
}
|