@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,608 +1,486 @@
|
|
|
1
|
-
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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 Promise from 'bluebird';
|
|
8
|
-
import { each, filter, find, groupBy, isEmpty, map, size, sortBy, sum, toString, trim } from 'lodash';
|
|
9
|
-
import moment, { duration } from 'moment-timezone';
|
|
10
|
-
import { getLocationReference, getTimezoneAbbr, getTimezoneDatetime } from '../../helpers';
|
|
11
|
-
import { launchIcon } from '../../images';
|
|
12
|
-
import { generateDefinition, horizontalLine, summaryFieldsTable, summaryStatTable, summaryWrapperTable, table, text, threeColumnTable, zebraFillColor } from '../helpers';
|
|
13
|
-
var LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
|
|
1
|
+
"use strict";
|
|
14
2
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
34
|
-
* @param {
|
|
35
|
-
* @param {
|
|
36
|
-
* @param {string}
|
|
37
|
-
* @param {array}
|
|
38
|
-
* @param {string}
|
|
39
|
-
* @param {string}
|
|
40
|
-
* @param {
|
|
41
|
-
* @param {
|
|
42
|
-
* @
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.buildShiftPdf = buildShiftPdf;
|
|
8
|
+
exports.getFineDuration = getFineDuration;
|
|
9
|
+
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
10
|
+
var _lodash = require("lodash");
|
|
11
|
+
var _momentTimezone = _interopRequireWildcard(require("moment-timezone"));
|
|
12
|
+
var _helpers = require("../../helpers");
|
|
13
|
+
var _images = require("../../images");
|
|
14
|
+
var _helpers2 = require("../helpers");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
+
const LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* buildActivityPdf
|
|
20
|
+
* @param {object} pdfOptions - the pdf options
|
|
21
|
+
* @param {string} pdfOptions.fileTitle - pdf file title
|
|
22
|
+
* @param {function} pdfOptions.footer - function executed to generate footer
|
|
23
|
+
* @param {function} pdfOptions.header - function executed to generate header
|
|
24
|
+
* @param {string} pdfOptions.logoUrl - pdf logo url
|
|
25
|
+
* @param {array} pdfOptions.pageMargins - pdf page margins
|
|
26
|
+
* @param {string} pdfOptions.pageOrientation - pdf page orientation
|
|
27
|
+
* @param {string} pdfOptions.pageSize - pdf page size
|
|
28
|
+
* @param {object} pdfOptions.styles - pdf styles
|
|
29
|
+
* @param {object} pdfOptions.title - pdf title
|
|
30
|
+
* @param {object} data - pdf data
|
|
31
|
+
* @param {array} data.audits - audit documents
|
|
32
|
+
* @param {array} data.events - event documents
|
|
33
|
+
* @param {array} data.locations - location documents
|
|
34
|
+
* @param {array} data.issues - issue documents
|
|
35
|
+
* @param {array} data.audits - audit documents
|
|
36
|
+
* @param {object} data.shift - shift document
|
|
37
|
+
* @param {object} data.settings - settings properties
|
|
38
|
+
* @param {string} data.settings.awsS3BaseUrl - aws S3 base url
|
|
39
|
+
* @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
|
|
40
|
+
* @param {array} data.tasks - task documents
|
|
41
|
+
* @param {string} data.timestamp - timestamp string
|
|
42
|
+
* @param {string} data.timezone - timezone string
|
|
43
|
+
* @param {array} data.zones - zone documents
|
|
44
|
+
* @param {array} data.user - user document
|
|
45
|
+
* @returns {Promise} returns pdfmake definition object
|
|
43
46
|
*/
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return _context.abrupt("return", generateDefinition(_objectSpread({
|
|
61
|
-
content: content,
|
|
62
|
-
fileTitle: title,
|
|
63
|
-
timestamp: timestamp,
|
|
64
|
-
timezone: timezone,
|
|
65
|
-
type: 'Shift Report'
|
|
66
|
-
}, pdfOptions)));
|
|
67
|
-
case 2:
|
|
68
|
-
case "end":
|
|
69
|
-
return _context.stop();
|
|
70
|
-
}
|
|
71
|
-
}, _callee);
|
|
72
|
-
}));
|
|
73
|
-
return _buildShiftPdf.apply(this, arguments);
|
|
74
|
-
}
|
|
75
|
-
function generateContent(_x3) {
|
|
76
|
-
return _generateContent.apply(this, arguments);
|
|
77
|
-
}
|
|
78
|
-
function _generateContent() {
|
|
79
|
-
_generateContent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
|
80
|
-
var activitySection, summarySection, titleTable;
|
|
81
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
82
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
83
|
-
case 0:
|
|
84
|
-
_context2.next = 1;
|
|
85
|
-
return buildActivitySection(data);
|
|
86
|
-
case 1:
|
|
87
|
-
activitySection = _context2.sent;
|
|
88
|
-
summarySection = buildSummarySection(data);
|
|
89
|
-
titleTable = buildTitleTable(data);
|
|
90
|
-
return _context2.abrupt("return", [titleTable, summarySection, activitySection]);
|
|
91
|
-
case 2:
|
|
92
|
-
case "end":
|
|
93
|
-
return _context2.stop();
|
|
94
|
-
}
|
|
95
|
-
}, _callee2);
|
|
96
|
-
}));
|
|
97
|
-
return _generateContent.apply(this, arguments);
|
|
48
|
+
async function buildShiftPdf(pdfOptions, data) {
|
|
49
|
+
const {
|
|
50
|
+
timestamp,
|
|
51
|
+
timezone
|
|
52
|
+
} = data;
|
|
53
|
+
const title = 'Daily Shift Report';
|
|
54
|
+
const content = await generateContent(data);
|
|
55
|
+
return (0, _helpers2.generateDefinition)({
|
|
56
|
+
content,
|
|
57
|
+
fileTitle: title,
|
|
58
|
+
timestamp,
|
|
59
|
+
timezone,
|
|
60
|
+
type: 'Shift Report',
|
|
61
|
+
...pdfOptions
|
|
62
|
+
});
|
|
98
63
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
64
|
+
async function generateContent(data) {
|
|
65
|
+
const activitySection = await buildActivitySection(data);
|
|
66
|
+
const summarySection = buildSummarySection(data);
|
|
67
|
+
const titleTable = buildTitleTable(data);
|
|
68
|
+
return [titleTable, summarySection, activitySection];
|
|
101
69
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
107
|
-
case 0:
|
|
108
|
-
_context3.next = 1;
|
|
109
|
-
return buildTimelineTable(data);
|
|
110
|
-
case 1:
|
|
111
|
-
timeline = _context3.sent;
|
|
112
|
-
_context3.next = 2;
|
|
113
|
-
return buildActivitySummarySection(data);
|
|
114
|
-
case 2:
|
|
115
|
-
activitySummary = _context3.sent;
|
|
116
|
-
return _context3.abrupt("return", [timeline, activitySummary]);
|
|
117
|
-
case 3:
|
|
118
|
-
case "end":
|
|
119
|
-
return _context3.stop();
|
|
120
|
-
}
|
|
121
|
-
}, _callee3);
|
|
122
|
-
}));
|
|
123
|
-
return _buildActivitySection.apply(this, arguments);
|
|
70
|
+
async function buildActivitySection(data) {
|
|
71
|
+
const timeline = await buildTimelineTable(data);
|
|
72
|
+
const activitySummary = await buildActivitySummarySection(data);
|
|
73
|
+
return [timeline, activitySummary];
|
|
124
74
|
}
|
|
125
75
|
function buildTitleTable(data) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
76
|
+
const {
|
|
77
|
+
shift,
|
|
78
|
+
timezone,
|
|
79
|
+
user
|
|
80
|
+
} = data;
|
|
81
|
+
const {
|
|
82
|
+
breaks,
|
|
83
|
+
duration,
|
|
84
|
+
end,
|
|
85
|
+
start
|
|
86
|
+
} = shift;
|
|
87
|
+
const headerTitle = (0, _helpers2.text)('Daily Shift Report', {
|
|
134
88
|
style: 'title'
|
|
135
89
|
});
|
|
136
|
-
|
|
137
|
-
|
|
90
|
+
const username = `${user.firstName} ${user.lastName}` || 'Unknown User';
|
|
91
|
+
const headerSubTitle = (0, _helpers2.text)(`${username}`, {
|
|
138
92
|
style: 'subTitle'
|
|
139
93
|
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
94
|
+
const mTimezoneStart = (0, _momentTimezone.default)(start.time).tz(timezone);
|
|
95
|
+
const mTimezoneEnd = (0, _momentTimezone.default)(end.time).tz(timezone);
|
|
96
|
+
const rangeStart = (0, _momentTimezone.default)(mTimezoneStart).format('MMM DD h:mma');
|
|
97
|
+
const rangeEnd = (0, _momentTimezone.default)(mTimezoneEnd).format('MMM DD h:mma');
|
|
98
|
+
const shiftDuration = getFineDuration(duration);
|
|
99
|
+
const breakDuration = getBreakDuration(breaks);
|
|
100
|
+
const header = !breakDuration ? `${rangeStart} - ${rangeEnd} | Duration: ${shiftDuration}` : `${rangeStart} - ${rangeEnd} | Duration: ${shiftDuration}, Break: ${breakDuration}`;
|
|
101
|
+
const headerRange = (0, _helpers2.text)(header, {
|
|
148
102
|
style: 'subTitle2'
|
|
149
103
|
});
|
|
150
|
-
return table({
|
|
104
|
+
return (0, _helpers2.table)({
|
|
151
105
|
body: [[headerTitle], [headerSubTitle], [headerRange]],
|
|
152
106
|
layout: 'noBorders',
|
|
153
107
|
style: 'titleTable'
|
|
154
108
|
});
|
|
155
109
|
}
|
|
156
110
|
function buildSummarySection(data) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
111
|
+
const {
|
|
112
|
+
audits,
|
|
113
|
+
events,
|
|
114
|
+
issues,
|
|
115
|
+
tasks
|
|
116
|
+
} = data;
|
|
117
|
+
const eventsByType = (0, _lodash.groupBy)(events, 'type');
|
|
118
|
+
const enterEventsCount = (0, _lodash.size)(eventsByType.enter);
|
|
119
|
+
const issuesCount = (0, _lodash.size)(issues);
|
|
120
|
+
const tasksCount = (0, _lodash.size)(tasks);
|
|
121
|
+
const auditsCount = (0, _lodash.size)(audits);
|
|
122
|
+
const scansText = (0, _helpers2.text)('SCANS', {
|
|
167
123
|
style: 'summaryText'
|
|
168
124
|
});
|
|
169
|
-
|
|
125
|
+
const issuesText = (0, _helpers2.text)('ISSUES', {
|
|
170
126
|
style: 'summaryText'
|
|
171
127
|
});
|
|
172
|
-
|
|
128
|
+
const tasksText = (0, _helpers2.text)('TASKS', {
|
|
173
129
|
style: 'summaryText'
|
|
174
130
|
});
|
|
175
|
-
|
|
131
|
+
const auditsText = (0, _helpers2.text)('AUDITS', {
|
|
176
132
|
style: 'summaryText'
|
|
177
133
|
});
|
|
178
|
-
|
|
134
|
+
const scansCountText = (0, _helpers2.text)((0, _lodash.toString)(enterEventsCount), {
|
|
179
135
|
style: 'summaryCount'
|
|
180
136
|
});
|
|
181
|
-
|
|
137
|
+
const issuesCountText = (0, _helpers2.text)((0, _lodash.toString)(issuesCount), {
|
|
182
138
|
style: 'summaryCount'
|
|
183
139
|
});
|
|
184
|
-
|
|
140
|
+
const tasksCountText = (0, _helpers2.text)((0, _lodash.toString)(tasksCount), {
|
|
185
141
|
style: 'summaryCount'
|
|
186
142
|
});
|
|
187
|
-
|
|
143
|
+
const auditsCountText = (0, _helpers2.text)((0, _lodash.toString)(auditsCount), {
|
|
188
144
|
style: 'summaryCount'
|
|
189
145
|
});
|
|
190
|
-
|
|
146
|
+
const scanTable = (0, _helpers2.summaryStatTable)({
|
|
191
147
|
body: [[scansText], [scansCountText]]
|
|
192
148
|
});
|
|
193
|
-
|
|
149
|
+
const issueTable = (0, _helpers2.summaryStatTable)({
|
|
194
150
|
body: [[issuesText], [issuesCountText]]
|
|
195
151
|
});
|
|
196
|
-
|
|
152
|
+
const taskTables = (0, _helpers2.summaryStatTable)({
|
|
197
153
|
body: [[tasksText], [tasksCountText]]
|
|
198
154
|
});
|
|
199
|
-
|
|
155
|
+
const auditTable = (0, _helpers2.summaryStatTable)({
|
|
200
156
|
body: [[auditsText], [auditsCountText]]
|
|
201
157
|
});
|
|
202
|
-
|
|
158
|
+
const wrapperTable = (0, _helpers2.summaryWrapperTable)({
|
|
203
159
|
body: [[scanTable, issueTable, taskTables, auditTable]]
|
|
204
160
|
});
|
|
205
161
|
return wrapperTable;
|
|
206
162
|
}
|
|
207
|
-
function buildActivitySummarySection(
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
timezone: timezone
|
|
240
|
-
});
|
|
241
|
-
case 1:
|
|
242
|
-
activityTable = _context4.sent;
|
|
243
|
-
activitySummarySection = [header, hLine, activityTable];
|
|
244
|
-
return _context4.abrupt("return", activitySummarySection);
|
|
245
|
-
case 2:
|
|
246
|
-
case "end":
|
|
247
|
-
return _context4.stop();
|
|
248
|
-
}
|
|
249
|
-
}, _callee4);
|
|
250
|
-
}));
|
|
251
|
-
return _buildActivitySummarySection.apply(this, arguments);
|
|
252
|
-
}
|
|
253
|
-
function buildActivityTable(_x6) {
|
|
254
|
-
return _buildActivityTable.apply(this, arguments);
|
|
163
|
+
async function buildActivitySummarySection(data) {
|
|
164
|
+
const {
|
|
165
|
+
audits,
|
|
166
|
+
events,
|
|
167
|
+
issues,
|
|
168
|
+
settings,
|
|
169
|
+
tasks,
|
|
170
|
+
timezone
|
|
171
|
+
} = data;
|
|
172
|
+
const enterEvents = (0, _lodash.filter)(events, event => event.type === 'enter');
|
|
173
|
+
const auditRows = (0, _lodash.map)(audits, getFormRowData('audits', data));
|
|
174
|
+
const issueRows = (0, _lodash.map)(issues, getFormRowData('issues', data));
|
|
175
|
+
const scanRows = (0, _lodash.map)(enterEvents, getScanRowData(data));
|
|
176
|
+
const taskRows = (0, _lodash.map)(tasks, getFormRowData('tasks', data));
|
|
177
|
+
const rows = [...auditRows, ...issueRows, ...scanRows, ...taskRows];
|
|
178
|
+
const sortedRows = (0, _lodash.sortBy)(rows, ['timestamp'], ['asc']);
|
|
179
|
+
const title = (0, _helpers2.text)('Activity Summary', {
|
|
180
|
+
style: 'summarySectionHeader'
|
|
181
|
+
});
|
|
182
|
+
const header = (0, _helpers2.table)({
|
|
183
|
+
body: [[title]],
|
|
184
|
+
layout: 'noBorders',
|
|
185
|
+
style: 'summaryHeaderTable'
|
|
186
|
+
});
|
|
187
|
+
const hLine = (0, _helpers2.horizontalLine)();
|
|
188
|
+
const activityTable = await buildActivityTable({
|
|
189
|
+
rows: sortedRows,
|
|
190
|
+
settings,
|
|
191
|
+
timezone
|
|
192
|
+
});
|
|
193
|
+
const activitySummarySection = [header, hLine, activityTable];
|
|
194
|
+
return activitySummarySection;
|
|
255
195
|
}
|
|
256
|
-
function
|
|
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
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
case 3:
|
|
348
|
-
case "end":
|
|
349
|
-
return _context5.stop();
|
|
350
|
-
}
|
|
351
|
-
}, _callee5);
|
|
352
|
-
}));
|
|
353
|
-
return function (_x8) {
|
|
354
|
-
return _ref6.apply(this, arguments);
|
|
355
|
-
};
|
|
356
|
-
}());
|
|
357
|
-
case 1:
|
|
358
|
-
activityTableRows = _context6.sent;
|
|
359
|
-
activityTableBody = isEmpty(activityTableRows) ? [[text('No other activity', {
|
|
360
|
-
colSpan: 4
|
|
361
|
-
})]] : activityTableRows;
|
|
362
|
-
activityTable = table({
|
|
363
|
-
body: [activityTableHeader].concat(_toConsumableArray(activityTableBody)),
|
|
364
|
-
dontBreakRows: true,
|
|
365
|
-
layout: {
|
|
366
|
-
hLineWidth: function hLineWidth() {
|
|
367
|
-
return 0;
|
|
368
|
-
},
|
|
369
|
-
fillColor: zebraFillColor,
|
|
370
|
-
paddingLeft: function paddingLeft() {
|
|
371
|
-
return 5;
|
|
372
|
-
},
|
|
373
|
-
paddingRight: function paddingRight() {
|
|
374
|
-
return 5;
|
|
375
|
-
},
|
|
376
|
-
paddingTop: function paddingTop() {
|
|
377
|
-
return 5;
|
|
378
|
-
},
|
|
379
|
-
paddingBottom: function paddingBottom() {
|
|
380
|
-
return 5;
|
|
381
|
-
},
|
|
382
|
-
vLineWidth: function vLineWidth() {
|
|
383
|
-
return 0;
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
widths: [110, 15, 230, 80, '*']
|
|
387
|
-
});
|
|
388
|
-
return _context6.abrupt("return", activityTable);
|
|
389
|
-
case 2:
|
|
390
|
-
case "end":
|
|
391
|
-
return _context6.stop();
|
|
392
|
-
}
|
|
393
|
-
}, _callee6);
|
|
394
|
-
}));
|
|
395
|
-
return _buildActivityTable.apply(this, arguments);
|
|
196
|
+
async function buildActivityTable({
|
|
197
|
+
rows,
|
|
198
|
+
settings,
|
|
199
|
+
timezone
|
|
200
|
+
}) {
|
|
201
|
+
const timezoneAbbr = (0, _helpers.getTimezoneAbbr)(timezone);
|
|
202
|
+
const activityTableHeader = [(0, _helpers2.text)('Activity', {
|
|
203
|
+
bold: true
|
|
204
|
+
}), {
|
|
205
|
+
text: ''
|
|
206
|
+
}, (0, _helpers2.text)('Location', {
|
|
207
|
+
bold: true
|
|
208
|
+
}), (0, _helpers2.text)(`Timestamp (${timezoneAbbr})`, {
|
|
209
|
+
alignment: 'right',
|
|
210
|
+
bold: true
|
|
211
|
+
})];
|
|
212
|
+
const activityTableRows = await _bluebird.default.map(rows, async function (data) {
|
|
213
|
+
const {
|
|
214
|
+
link,
|
|
215
|
+
location,
|
|
216
|
+
icon,
|
|
217
|
+
summaryFields,
|
|
218
|
+
timestamp,
|
|
219
|
+
title
|
|
220
|
+
} = data;
|
|
221
|
+
const timezoneHour = (0, _helpers.getTimezoneDatetime)({
|
|
222
|
+
format: 'ddd DD h:mm a',
|
|
223
|
+
showTzAbbr: false,
|
|
224
|
+
timestamp,
|
|
225
|
+
timezone
|
|
226
|
+
});
|
|
227
|
+
const iconCell = icon ? {
|
|
228
|
+
alignment: 'center',
|
|
229
|
+
fit: [8, 8],
|
|
230
|
+
image: icon,
|
|
231
|
+
link
|
|
232
|
+
} : {
|
|
233
|
+
text: ''
|
|
234
|
+
};
|
|
235
|
+
const rows = [[(0, _helpers2.text)(title, {
|
|
236
|
+
link
|
|
237
|
+
}), iconCell, (0, _helpers2.text)(location, {
|
|
238
|
+
link
|
|
239
|
+
}), (0, _helpers2.text)(timezoneHour, {
|
|
240
|
+
alignment: 'right',
|
|
241
|
+
link
|
|
242
|
+
})]];
|
|
243
|
+
const hasSummaryFields = !(0, _lodash.isEmpty)(summaryFields);
|
|
244
|
+
if (hasSummaryFields) {
|
|
245
|
+
const fieldsTable = await (0, _helpers2.summaryFieldsTable)({
|
|
246
|
+
fields: summaryFields,
|
|
247
|
+
settings,
|
|
248
|
+
timezone
|
|
249
|
+
});
|
|
250
|
+
rows.push([fieldsTable]);
|
|
251
|
+
}
|
|
252
|
+
const activityTableRow = [(0, _helpers2.table)({
|
|
253
|
+
body: [...rows],
|
|
254
|
+
colSpan: 5,
|
|
255
|
+
dontBreakRows: true,
|
|
256
|
+
headerRow: 0,
|
|
257
|
+
layout: {
|
|
258
|
+
hLineWidth: () => 0,
|
|
259
|
+
paddingLeft: () => 0,
|
|
260
|
+
paddingRight: () => 0,
|
|
261
|
+
paddingTop: () => 5,
|
|
262
|
+
paddingBottom: () => 5,
|
|
263
|
+
vLineWidth: () => 0
|
|
264
|
+
},
|
|
265
|
+
widths: [120, 25, 200, 110, '*']
|
|
266
|
+
})];
|
|
267
|
+
return activityTableRow;
|
|
268
|
+
});
|
|
269
|
+
const activityTableBody = (0, _lodash.isEmpty)(activityTableRows) ? [[(0, _helpers2.text)('No other activity', {
|
|
270
|
+
colSpan: 4
|
|
271
|
+
})]] : activityTableRows;
|
|
272
|
+
const activityTable = (0, _helpers2.table)({
|
|
273
|
+
body: [activityTableHeader, ...activityTableBody],
|
|
274
|
+
dontBreakRows: true,
|
|
275
|
+
layout: {
|
|
276
|
+
hLineWidth: () => 0,
|
|
277
|
+
fillColor: _helpers2.zebraFillColor,
|
|
278
|
+
paddingLeft: () => 5,
|
|
279
|
+
paddingRight: () => 5,
|
|
280
|
+
paddingTop: () => 5,
|
|
281
|
+
paddingBottom: () => 5,
|
|
282
|
+
vLineWidth: () => 0
|
|
283
|
+
},
|
|
284
|
+
widths: [110, 15, 230, 80, '*']
|
|
285
|
+
});
|
|
286
|
+
return activityTable;
|
|
396
287
|
}
|
|
397
|
-
function getFormRowData(collection,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
title =
|
|
407
|
-
|
|
288
|
+
function getFormRowData(collection, {
|
|
289
|
+
locations,
|
|
290
|
+
zones
|
|
291
|
+
}) {
|
|
292
|
+
return document => {
|
|
293
|
+
const {
|
|
294
|
+
_id,
|
|
295
|
+
createdAt,
|
|
296
|
+
entry = {},
|
|
297
|
+
title = 'Unknown'
|
|
298
|
+
} = document;
|
|
299
|
+
const location = (0, _helpers.getLocationReference)({
|
|
408
300
|
entity: document,
|
|
409
|
-
locations
|
|
410
|
-
zones
|
|
301
|
+
locations,
|
|
302
|
+
zones
|
|
411
303
|
});
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
304
|
+
const link = `${LIGHTHOUSE_BASE_URL}/reports/${collection}/${_id}`;
|
|
305
|
+
const timestamp = createdAt;
|
|
306
|
+
const summaryFields = entry.summaryFields || [];
|
|
415
307
|
return {
|
|
416
|
-
icon: launchIcon,
|
|
417
|
-
location
|
|
418
|
-
link
|
|
419
|
-
summaryFields
|
|
420
|
-
timestamp
|
|
421
|
-
title
|
|
308
|
+
icon: _images.launchIcon,
|
|
309
|
+
location,
|
|
310
|
+
link,
|
|
311
|
+
summaryFields,
|
|
312
|
+
timestamp,
|
|
313
|
+
title
|
|
422
314
|
};
|
|
423
315
|
};
|
|
424
316
|
}
|
|
425
|
-
function getScanRowData(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
317
|
+
function getScanRowData({
|
|
318
|
+
zones
|
|
319
|
+
}) {
|
|
320
|
+
return document => {
|
|
321
|
+
const {
|
|
322
|
+
timestamp,
|
|
323
|
+
zone = ''
|
|
324
|
+
} = document;
|
|
325
|
+
const zoneDoc = zone && (0, _lodash.find)(zones, doc => doc._id.toString() === zone.toString());
|
|
326
|
+
const zoneName = zoneDoc && zoneDoc.name;
|
|
327
|
+
const location = zoneName || 'Unknown Location';
|
|
328
|
+
const title = 'Location Scan';
|
|
437
329
|
return {
|
|
438
|
-
location
|
|
439
|
-
timestamp
|
|
440
|
-
title
|
|
330
|
+
location,
|
|
331
|
+
timestamp,
|
|
332
|
+
title
|
|
441
333
|
};
|
|
442
334
|
};
|
|
443
335
|
}
|
|
444
|
-
function buildTimelineTable(
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
bold: true
|
|
491
|
-
}), text("Timestamp (".concat(timezoneAbbr, ")"), {
|
|
492
|
-
alignment: 'right',
|
|
493
|
-
bold: true
|
|
494
|
-
})];
|
|
495
|
-
timelineTable = threeColumnTable({
|
|
496
|
-
body: [timelineHeaderRow].concat(_toConsumableArray(timeline))
|
|
497
|
-
});
|
|
498
|
-
title = text('Timeline', {
|
|
499
|
-
style: 'timelineTitle'
|
|
500
|
-
});
|
|
501
|
-
header = table({
|
|
502
|
-
body: [[title]],
|
|
503
|
-
layout: 'noBorders',
|
|
504
|
-
style: 'summaryHeaderTable'
|
|
505
|
-
});
|
|
506
|
-
hLine = horizontalLine();
|
|
507
|
-
timelineSection = [header, hLine, timelineTable];
|
|
508
|
-
return _context8.abrupt("return", timelineSection);
|
|
509
|
-
case 2:
|
|
510
|
-
case "end":
|
|
511
|
-
return _context8.stop();
|
|
512
|
-
}
|
|
513
|
-
}, _callee8);
|
|
514
|
-
}));
|
|
515
|
-
return _buildTimelineTable.apply(this, arguments);
|
|
336
|
+
async function buildTimelineTable(data) {
|
|
337
|
+
const {
|
|
338
|
+
timezone
|
|
339
|
+
} = data;
|
|
340
|
+
const timezoneAbbr = (0, _helpers.getTimezoneAbbr)(timezone);
|
|
341
|
+
const shiftRows = getShiftRowData(data);
|
|
342
|
+
const sortedRows = (0, _lodash.sortBy)(shiftRows, ['timestamp'], ['asc']);
|
|
343
|
+
const timeline = await _bluebird.default.map(sortedRows, async function (data) {
|
|
344
|
+
const {
|
|
345
|
+
location,
|
|
346
|
+
timestamp,
|
|
347
|
+
title
|
|
348
|
+
} = data;
|
|
349
|
+
const timezoneHour = (0, _helpers.getTimezoneDatetime)({
|
|
350
|
+
format: 'ddd DD h:mm a',
|
|
351
|
+
showTzAbbr: false,
|
|
352
|
+
timestamp,
|
|
353
|
+
timezone
|
|
354
|
+
});
|
|
355
|
+
const rows = [(0, _helpers2.text)(title), (0, _helpers2.text)(location), (0, _helpers2.text)(timezoneHour, {
|
|
356
|
+
alignment: 'right'
|
|
357
|
+
})];
|
|
358
|
+
return rows;
|
|
359
|
+
});
|
|
360
|
+
const timelineHeaderRow = [(0, _helpers2.text)('Activity', {
|
|
361
|
+
bold: true
|
|
362
|
+
}), (0, _helpers2.text)('Location', {
|
|
363
|
+
bold: true
|
|
364
|
+
}), (0, _helpers2.text)(`Timestamp (${timezoneAbbr})`, {
|
|
365
|
+
alignment: 'right',
|
|
366
|
+
bold: true
|
|
367
|
+
})];
|
|
368
|
+
const timelineTable = (0, _helpers2.threeColumnTable)({
|
|
369
|
+
body: [timelineHeaderRow, ...timeline]
|
|
370
|
+
});
|
|
371
|
+
const title = (0, _helpers2.text)('Timeline', {
|
|
372
|
+
style: 'timelineTitle'
|
|
373
|
+
});
|
|
374
|
+
const header = (0, _helpers2.table)({
|
|
375
|
+
body: [[title]],
|
|
376
|
+
layout: 'noBorders',
|
|
377
|
+
style: 'summaryHeaderTable'
|
|
378
|
+
});
|
|
379
|
+
const hLine = (0, _helpers2.horizontalLine)();
|
|
380
|
+
const timelineSection = [header, hLine, timelineTable];
|
|
381
|
+
return timelineSection;
|
|
516
382
|
}
|
|
517
|
-
function getShiftRowData(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
383
|
+
function getShiftRowData({
|
|
384
|
+
locations,
|
|
385
|
+
shift,
|
|
386
|
+
zones
|
|
387
|
+
}) {
|
|
388
|
+
const {
|
|
389
|
+
breaks,
|
|
390
|
+
end,
|
|
391
|
+
start
|
|
392
|
+
} = shift;
|
|
393
|
+
const startValues = getShiftValues(start, {
|
|
394
|
+
locations,
|
|
395
|
+
shift,
|
|
396
|
+
zones
|
|
528
397
|
});
|
|
529
|
-
|
|
530
|
-
title: 'Shift Started'
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
398
|
+
const startShift = {
|
|
399
|
+
title: 'Shift Started',
|
|
400
|
+
...startValues
|
|
401
|
+
};
|
|
402
|
+
const endValues = getShiftValues(end, {
|
|
403
|
+
locations,
|
|
404
|
+
shift,
|
|
405
|
+
zones
|
|
536
406
|
});
|
|
537
|
-
|
|
538
|
-
title: 'Shift Ended'
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
407
|
+
const endShift = {
|
|
408
|
+
title: 'Shift Ended',
|
|
409
|
+
...endValues
|
|
410
|
+
};
|
|
411
|
+
const shiftData = [startShift, endShift];
|
|
412
|
+
(0, _lodash.each)(breaks, function (data) {
|
|
413
|
+
const {
|
|
414
|
+
end,
|
|
415
|
+
start
|
|
416
|
+
} = data;
|
|
417
|
+
const startValues = getShiftValues(start, {
|
|
418
|
+
locations,
|
|
419
|
+
shift,
|
|
420
|
+
zones
|
|
548
421
|
});
|
|
549
|
-
|
|
550
|
-
title: 'Break Started'
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
422
|
+
const startBreak = {
|
|
423
|
+
title: 'Break Started',
|
|
424
|
+
...startValues
|
|
425
|
+
};
|
|
426
|
+
const endValues = getShiftValues(end, {
|
|
427
|
+
locations,
|
|
428
|
+
shift,
|
|
429
|
+
zones
|
|
556
430
|
});
|
|
557
|
-
|
|
558
|
-
title: 'Break Ended'
|
|
559
|
-
|
|
431
|
+
const endBreak = {
|
|
432
|
+
title: 'Break Ended',
|
|
433
|
+
...endValues
|
|
434
|
+
};
|
|
560
435
|
shiftData.push(startBreak);
|
|
561
436
|
shiftData.push(endBreak);
|
|
562
437
|
});
|
|
563
438
|
return shiftData;
|
|
564
439
|
}
|
|
565
|
-
function getShiftValues(value,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
440
|
+
function getShiftValues(value, {
|
|
441
|
+
locations,
|
|
442
|
+
shift,
|
|
443
|
+
zones
|
|
444
|
+
}) {
|
|
445
|
+
const locationName = (0, _helpers.getLocationReference)({
|
|
570
446
|
entity: value,
|
|
571
|
-
locations
|
|
572
|
-
zones
|
|
447
|
+
locations,
|
|
448
|
+
zones
|
|
573
449
|
});
|
|
574
|
-
|
|
450
|
+
const location = locationName === 'Unknown Location' ? (0, _helpers.getLocationReference)({
|
|
575
451
|
entity: shift,
|
|
576
|
-
locations
|
|
577
|
-
zones
|
|
452
|
+
locations,
|
|
453
|
+
zones
|
|
578
454
|
}) : locationName;
|
|
579
455
|
return {
|
|
580
456
|
timestamp: value.time,
|
|
581
|
-
location
|
|
457
|
+
location
|
|
582
458
|
};
|
|
583
459
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
460
|
+
function getFineDuration(durationValue) {
|
|
461
|
+
const measurement = 'milliseconds';
|
|
462
|
+
const durationByMeasurement = (0, _momentTimezone.duration)(durationValue, measurement);
|
|
463
|
+
const days = durationByMeasurement.get('days');
|
|
464
|
+
const hours = durationByMeasurement.get('hours');
|
|
465
|
+
const minutes = durationByMeasurement.get('minutes');
|
|
466
|
+
let fineDuration = '';
|
|
591
467
|
fineDuration += days !== 0 ? days + 'd ' : '';
|
|
592
468
|
fineDuration += hours !== 0 ? hours + 'h ' : '';
|
|
593
469
|
fineDuration += minutes !== 0 ? minutes + 'm' : '';
|
|
594
|
-
return trim(fineDuration);
|
|
470
|
+
return (0, _lodash.trim)(fineDuration);
|
|
595
471
|
}
|
|
596
472
|
function getBreakDuration(breaks) {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
473
|
+
const duration = (0, _lodash.sum)((0, _lodash.map)(breaks, function (data) {
|
|
474
|
+
const {
|
|
475
|
+
end,
|
|
476
|
+
start
|
|
477
|
+
} = data;
|
|
478
|
+
const endBreak = (0, _momentTimezone.default)(end.time);
|
|
479
|
+
const startBreak = (0, _momentTimezone.default)(start.time);
|
|
480
|
+
const breakDuration = endBreak.diff(startBreak);
|
|
603
481
|
return breakDuration;
|
|
604
482
|
}));
|
|
605
|
-
|
|
483
|
+
const breakDuration = getFineDuration(duration);
|
|
606
484
|
return breakDuration;
|
|
607
485
|
}
|
|
608
486
|
//# sourceMappingURL=index.js.map
|