@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["filter","find","groupBy","isEmpty","map","size","sortBy","take","toString","reduce","moment","Promise","generateDefinition","buildLocationScansContent","buildLocationScansBoundaries","horizontalLine","summaryStatTable","summaryWrapperTable","table","summaryFieldsTable","text","zebraFillColor","getLocationReference","getTimezoneAbbr","getTimezoneDatetime","launchIcon","DEFAULT_MAX_SCANS","MAX_ATTACHMENTS","LIGHTHOUSE_BASE_URL","buildActivityPdf","_x","_x2","_buildActivityPdf","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","pdfOptions","data","timestamp","timezone","title","content","wrap","_context","prev","next","generateContent","sent","abrupt","_objectSpread","fileTitle","type","stop","_x3","_generateContent","_callee2","activitySection","summarySection","titleTable","_context2","buildActivitySection","buildSummarySection","buildTitleTable","_x4","_buildActivitySection","_callee3","_data$showAlternate","showAlternate","locationScans","otherActivity","activitySummary","_context3","buildLocationScansSection","buildOtherActivitySection","buildActivitySummarySection","_x5","_buildActivitySummarySection","_callee4","audits","events","issues","_data$maxScans","maxScans","settings","tasks","enterEvents","exceedsMaxScans","scans","auditRows","issueRows","scanRows","taskRows","formCount","exceedsMaxForms","rows","sortedRows","header","hLine","activityTable","activitySummarySection","maxScansText","maxFormsText","_context4","event","getFormRowData","getScanRowData","concat","_toConsumableArray","style","body","layout","buildActivityTable","link","margin","push","_x6","_buildActivityTable","_callee6","_ref","timezoneAbbr","activityTableHeader","activityTableRows","activityTableBody","_context6","bold","alignment","_ref4","_callee5","location","icon","name","summaryFields","timezoneHour","iconCell","hasSummaryFields","fieldsTable","activityTableRow","_context5","format","showTzAbbr","fit","image","fields","colSpan","dontBreakRows","headerRow","hLineWidth","paddingLeft","paddingRight","paddingTop","paddingBottom","vLineWidth","widths","_x8","fillColor","start","zones","hourIntervalBoundaries","hourIntervalColumnHeaders","columns","interval","index","intervals","scansTableHeader","sortedZones","groupedEventsByZone","memo","zone","zoneEvents","_id","scansTableRows","length","undefined","sortedGroup","locationScansByInterval","locationScansByIntervalContent","totalEvents","zoneDoc","doc","zoneName","scansTableBody","scansTable","eventsByType","enterEventsCount","enter","issuesCount","tasksCount","auditsCount","auditsText","issuesText","scansText","tasksText","auditsCountText","scansCountText","issuesCountText","tasksCountText","auditTable","scanTable","issueTable","taskTables","wrapperTable","_x7","_buildOtherActivitySection","_callee7","otherActivitySummarySection","_context7","end","_location$address","address","headerTitle","headerSubTitle","addressText","street","city","state","postalCode","headerAddress","mTimezoneStart","tz","mTimezoneEnd","rangeStart","rangeEnd","add","startOf","headerRange","collection","_ref2","locations","users","document","createdAt","_document$entry","entry","_document$title","_document$user","user","entity","userDoc","firstName","lastName","_ref3","_document$user2","_document$zone"],"sources":["../../../src/pdf/activity-report/index.js"],"sourcesContent":["import {\n filter,\n find,\n groupBy,\n isEmpty,\n map,\n size,\n sortBy,\n take,\n toString,\n reduce,\n} from 'lodash'\n\nimport moment from 'moment-timezone'\nimport Promise from 'bluebird'\n\nimport {\n generateDefinition,\n buildLocationScansContent,\n buildLocationScansBoundaries,\n horizontalLine,\n summaryStatTable,\n summaryWrapperTable,\n table,\n summaryFieldsTable,\n text,\n zebraFillColor,\n} from '../helpers'\n\nimport {\n getLocationReference,\n getTimezoneAbbr,\n getTimezoneDatetime,\n} from '../../helpers'\nimport { launchIcon } from '../../images'\n\nconst DEFAULT_MAX_SCANS = 200\nconst MAX_ATTACHMENTS = 100\nconst LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io'\n\n/**\n * buildActivityPdf\n *\n * @param {object} pdfOptions - the pdf options\n * @param {string} pdfOptions.fileTitle - pdf file title\n * @param {function} pdfOptions.footer - function executed to generate footer\n * @param {function} pdfOptions.header - function executed to generate header\n * @param {string} pdfOptions.logoUrl - pdf logo url\n * @param {array} pdfOptions.pageMargins - pdf page margins\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\n * @param {string} pdfOptions.pageSize - pdf page size\n * @param {object} pdfOptions.styles - pdf styles\n * @param {object} pdfOptions.title - pdf title\n * @param {object} data - pdf data\n * @param {array} data.audits - audit documents\n * @param {string} data.end - end datetime of summary report\n * @param {array} data.events - event documents\n * @param {object} data.location - location document\n * @param {array} data.locations - location documents\n * @param {array} data.issues - issue documents\n * @param {bool} data.maxScans - max scans to include in standard report\n * @param {bool} data.showAlternate - show alternate summary report\n * @param {string} data.start - start datetime of summary report\n * @param {object} data.settings - settings properties\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\n * @param {string} data.settings.cloudfrontBaseUrl - cloudfront base url\n * @param {array} data.tasks - task documents\n * @param {string} data.timestamp - timestamp string\n * @param {string} data.timezone - timezone string\n * @param {array} data.zones - zone documents\n * @param {array} data.users - user documents\n * @returns {Promise} returns pdfmake definition object\n */\nexport async function buildActivityPdf(pdfOptions, data) {\n const { timestamp, timezone } = data\n\n const title = 'Daily Activity Report'\n const content = await generateContent(data)\n\n return generateDefinition({\n content,\n fileTitle: title,\n timestamp,\n timezone,\n type: 'Activity Summary',\n ...pdfOptions,\n })\n}\n\nasync function generateContent(data) {\n const activitySection = await buildActivitySection(data)\n const summarySection = buildSummarySection(data)\n const titleTable = buildTitleTable(data)\n\n return [titleTable, summarySection, activitySection]\n}\n\nasync function buildActivitySection(data) {\n const { showAlternate = false } = data\n\n if (showAlternate) {\n const locationScans = buildLocationScansSection(data)\n const otherActivity = await buildOtherActivitySection(data)\n\n return [locationScans, otherActivity]\n }\n\n const activitySummary = await buildActivitySummarySection(data)\n\n return [activitySummary]\n}\n\nasync function buildActivitySummarySection(data) {\n const {\n audits,\n events,\n issues,\n maxScans = DEFAULT_MAX_SCANS,\n settings,\n tasks,\n timezone,\n } = data\n\n const enterEvents = filter(events, (event) => event.type === 'enter')\n const exceedsMaxScans = size(enterEvents) > maxScans\n const scans = take(enterEvents, maxScans)\n\n const auditRows = map(audits, getFormRowData('audits', data))\n const issueRows = map(issues, getFormRowData('issues', data))\n const scanRows = map(scans, getScanRowData(data))\n const taskRows = map(tasks, getFormRowData('tasks', data))\n\n const formCount = size([...auditRows, ...issueRows, ...taskRows])\n const exceedsMaxForms = formCount > MAX_ATTACHMENTS\n\n const rows = [...auditRows, ...issueRows, ...scanRows, ...taskRows]\n const sortedRows = sortBy(rows, ['timestamp'], ['asc'])\n const title = text('Activity Summary', { style: 'summarySectionHeader' })\n\n const header = table({\n body: [[title]],\n layout: 'noBorders',\n style: 'summaryHeaderTable',\n })\n\n const hLine = horizontalLine()\n const activityTable = await buildActivityTable({\n rows: sortedRows,\n settings,\n timezone,\n })\n const activitySummarySection = [header, hLine, activityTable]\n\n if (exceedsMaxScans) {\n const maxScansText = {\n text: [\n text(\n `Location Scans in the Daily Activity Report are limited to a total of ${maxScans}.`\n ),\n text(' To view all Location Scans visit '),\n text('the Events Report', {\n link: `${LIGHTHOUSE_BASE_URL}/reports/events`,\n }),\n text(' in the Lighthouse Management Console.'),\n ],\n style: 'small',\n margin: [0, 10, 0, 10],\n }\n\n activitySummarySection.push(maxScansText)\n }\n\n if (exceedsMaxForms) {\n const maxFormsText = {\n text: [\n text(\n `Detailed Form Submissions in the Daily Activity Report are limited to a total of ${MAX_ATTACHMENTS}. `\n ),\n text(\n '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.'\n ),\n ],\n style: 'small',\n margin: [0, 10, 0, 10],\n }\n activitySummarySection.push(maxFormsText)\n }\n\n return activitySummarySection\n}\n\nasync function buildActivityTable({ rows, settings, timezone }) {\n const timezoneAbbr = getTimezoneAbbr(timezone)\n\n const activityTableHeader = [\n text('Activity', { bold: true }),\n { text: '' }, // icon column\n text('Location', { bold: true }),\n text('User', { bold: true }),\n text(`Timestamp (${timezoneAbbr})`, { alignment: 'right', bold: true }),\n ]\n\n const activityTableRows = await Promise.map(rows, async function (data) {\n const { link, location, icon, name, summaryFields, timestamp, title } = data\n\n const timezoneHour = getTimezoneDatetime({\n format: 'ddd DD h:mm a',\n showTzAbbr: false,\n timestamp,\n timezone,\n })\n\n const iconCell = icon\n ? { alignment: 'center', fit: [8, 8], image: icon, link }\n : { text: '' }\n\n // NOTE: pass link to each column as\n // we can't wrap the entire table row\n const rows = [\n [\n text(title, { link }),\n iconCell,\n text(location, { link }),\n text(name, { link }),\n text(timezoneHour, { alignment: 'right', link }),\n ],\n ]\n\n const hasSummaryFields = !isEmpty(summaryFields)\n\n if (hasSummaryFields) {\n const fieldsTable = await summaryFieldsTable({\n fields: summaryFields,\n settings,\n timezone,\n })\n rows.push([fieldsTable])\n }\n\n // NOTE: we return a table per row which includes the entry details and the\n // summary fields if relevant\n const activityTableRow = [\n table({\n body: [...rows],\n colSpan: 5,\n dontBreakRows: true,\n headerRow: 0,\n layout: {\n hLineWidth: () => 0,\n paddingLeft: () => 0,\n paddingRight: () => 0,\n paddingTop: () => 5,\n paddingBottom: () => 5,\n vLineWidth: () => 0,\n },\n // NOTE: the timestamp must fill up the rest of the table space as\n // otherwise the padding would be off between this table and the parent\n // table that wraps it\n widths: [130, 25, 110, 110, '*'],\n }),\n ]\n\n return activityTableRow\n })\n\n const activityTableBody = isEmpty(activityTableRows)\n ? [[text('No other activity', { colSpan: 5 })]]\n : activityTableRows\n\n const activityTable = table({\n body: [activityTableHeader, ...activityTableBody],\n dontBreakRows: true,\n layout: {\n hLineWidth: () => 0,\n fillColor: zebraFillColor,\n paddingLeft: () => 5,\n paddingRight: () => 5,\n paddingTop: () => 5,\n paddingBottom: () => 5,\n vLineWidth: () => 0,\n },\n widths: [120, 15, 100, 100, '*'],\n })\n\n return activityTable\n}\n\nfunction buildLocationScansSection(data) {\n const { events, start, timezone, zones } = data\n\n const title = text('Location Scans', { style: 'summarySectionHeader' })\n\n const header = table({\n body: [[title]],\n layout: 'noBorders',\n style: 'summaryHeaderTable',\n })\n\n // use start time and timezone to figure out the interval boundaries\n const hourIntervalBoundaries = buildLocationScansBoundaries(start, timezone)\n\n // pair interval boundaries into column headers for the table\n const hourIntervalColumnHeaders = hourIntervalBoundaries.reduce(\n (columns, interval, index, intervals) => {\n if (index < size(intervals) - 1)\n // skip the final iteration as it's just the end of the last interval\n columns.push(\n text(`${interval.format('h')}-${intervals[index + 1].format('hA')}`, {\n alignment: 'center',\n bold: true,\n })\n )\n return columns\n },\n []\n )\n\n const scansTableHeader = [\n text('Location', { bold: true }),\n ...hourIntervalColumnHeaders,\n text('Total', { alignment: 'right', bold: true }),\n ]\n\n const hLine = horizontalLine()\n\n // NOTE: only show the enter events within the summary table\n const enterEvents = filter(events, (event) => event.type === 'enter')\n const sortedZones = sortBy(zones, ['name'])\n\n const groupedEventsByZone = reduce(\n sortedZones,\n (memo, zone) => {\n const zoneEvents = filter(\n enterEvents,\n (event) => event.zone && event.zone.toString() === zone._id.toString()\n )\n memo[zone._id] = zoneEvents\n return memo\n },\n {}\n )\n\n const scansTableRows = map(groupedEventsByZone, (events, zone = '') => {\n const sortedGroup = sortBy(events, ['timestamp'], ['asc'])\n\n // put events into interval buckets\n const locationScansByInterval = buildLocationScansContent(\n hourIntervalBoundaries,\n events\n )\n // map the interval buckets to a format fit for the table\n const locationScansByIntervalContent = locationScansByInterval.map(\n (interval) => {\n return { alignment: 'center', text: size(interval) }\n }\n )\n\n const totalEvents = size(sortedGroup)\n\n const zoneDoc =\n zone && find(zones, (doc) => doc._id.toString() === zone.toString())\n const zoneName = (zoneDoc && zoneDoc.name) || 'Unknown Location'\n\n return [\n zoneName,\n ...locationScansByIntervalContent,\n { alignment: 'right', bold: true, text: totalEvents },\n ]\n })\n\n const scansTableBody = isEmpty(scansTableRows)\n ? [[text('No location scans', { colSpan: 10 })]]\n : scansTableRows\n\n const scansTable = table({\n body: [scansTableHeader, ...scansTableBody],\n widths: [100, '*', '*', '*', '*', '*', '*', '*', '*', '*'],\n })\n\n return [header, hLine, scansTable]\n}\n\nfunction buildSummarySection(data) {\n const { audits, events, issues, tasks } = data\n\n //const userEvents = groupBy(events, 'user')\n const eventsByType = groupBy(events, 'type')\n\n const enterEventsCount = size(eventsByType.enter)\n //const geoEventsCount = size(eventsByType.geo)\n const issuesCount = size(issues)\n const tasksCount = size(tasks)\n const auditsCount = size(audits)\n //const uniqueUsers = size(userEvents)\n\n const auditsText = text('AUDITS', { style: 'summaryText' })\n //const geoText = text('GPS', { style: 'summaryText' })\n const issuesText = text('ISSUES', { style: 'summaryText' })\n //const peopleText = text('PEOPLE', { style: 'summaryText' })\n const scansText = text('SCANS', { style: 'summaryText' })\n const tasksText = text('TASKS', { style: 'summaryText' })\n\n const auditsCountText = text(toString(auditsCount), { style: 'summaryCount' })\n //const peopleCountText = text(toString(uniqueUsers), { style: 'summaryCount' })\n const scansCountText = text(toString(enterEventsCount), {\n style: 'summaryCount',\n })\n //const geoCountText = text(toString(geoEventsCount), { style: 'summaryCount' })\n const issuesCountText = text(toString(issuesCount), { style: 'summaryCount' })\n const tasksCountText = text(toString(tasksCount), { style: 'summaryCount' })\n\n const auditTable = summaryStatTable({\n body: [[auditsText], [auditsCountText]],\n })\n //const peopleTable = summaryStatTable({\n // body: [[peopleText], [peopleCountText]],\n //})\n //const gpsTable = summaryStatTable({ body: [[geoText], [geoCountText]] })\n const scanTable = summaryStatTable({ body: [[scansText], [scansCountText]] })\n const issueTable = summaryStatTable({\n body: [[issuesText], [issuesCountText]],\n })\n const taskTables = summaryStatTable({ body: [[tasksText], [tasksCountText]] })\n\n const wrapperTable = summaryWrapperTable({\n body: [\n [\n /*peopleTable,*/\n /*gpsTable,*/\n scanTable,\n issueTable,\n taskTables,\n auditTable,\n ],\n ],\n })\n\n return wrapperTable\n}\n\nasync function buildOtherActivitySection(data) {\n const { audits, issues, tasks, settings, timezone } = data\n\n const auditRows = map(audits, getFormRowData('audits', data))\n const issueRows = map(issues, getFormRowData('issues', data))\n const taskRows = map(tasks, getFormRowData('tasks', data))\n\n const rows = [...auditRows, ...issueRows, ...taskRows]\n const sortedRows = sortBy(rows, ['timestamp'], ['asc'])\n const title = text('Other Activity', { style: 'summarySectionHeader' })\n\n const header = table({\n body: [[title]],\n layout: 'noBorders',\n style: 'summaryHeaderTable',\n })\n\n const hLine = horizontalLine()\n const activityTable = await buildActivityTable({\n rows: sortedRows,\n settings,\n timezone,\n })\n\n const otherActivitySummarySection = [header, hLine, activityTable]\n\n const formCount = size(rows)\n const exceedsMaxForms = formCount > MAX_ATTACHMENTS\n\n if (exceedsMaxForms) {\n const maxFormsText = {\n text: [\n text(\n `Detailed Form Submissions in the Daily Activity Report are limited to a total of ${MAX_ATTACHMENTS}. `\n ),\n text(\n '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.'\n ),\n ],\n style: 'small',\n margin: [0, 10, 0, 10],\n }\n otherActivitySummarySection.push(maxFormsText)\n }\n\n return otherActivitySummarySection\n}\n\nfunction buildTitleTable(data) {\n const { location, start, end, timezone } = data\n const { address = {} } = location\n\n const headerTitle = text('Daily Activity Report', { style: 'title' })\n const headerSubTitle = text(location.name, { style: 'subTitle' })\n const addressText = !isEmpty(address)\n ? `${address.street}, ${address.city || ''} ${\n address.state || ''\n } ${address.postalCode || ''}`\n : ''\n const headerAddress = text(addressText, { style: 'small' })\n\n const mTimezoneStart = moment.tz(start, timezone)\n const mTimezoneEnd = moment.tz(end, timezone)\n const timezoneAbbr = getTimezoneAbbr(timezone)\n\n const rangeStart = moment(mTimezoneStart).format('MMM DD h:mma')\n\n const rangeEnd = moment(mTimezoneEnd)\n .add(1, 'hour')\n .startOf('hour')\n .format('MMM DD h:mma')\n\n const headerRange = text(`${rangeStart} - ${rangeEnd} (${timezoneAbbr})`, {\n style: 'subTitle2',\n })\n\n const body = !isEmpty(address)\n ? [[headerTitle], [headerSubTitle], [headerAddress], [headerRange]]\n : [[headerTitle], [headerSubTitle], [headerRange]]\n\n return table({\n body,\n layout: 'noBorders',\n style: 'titleTable',\n })\n}\n\nfunction getFormRowData(collection, { locations, users, zones }) {\n return (document) => {\n const {\n _id,\n createdAt,\n entry = {},\n title = 'Unknown',\n user = '',\n } = document\n\n const location = getLocationReference({\n entity: document,\n locations,\n zones,\n })\n\n const link = `${LIGHTHOUSE_BASE_URL}/reports/${collection}/${_id}`\n const timestamp = createdAt\n const userDoc = find(users, (doc) => doc._id.toString() === user.toString())\n const name =\n (userDoc && `${userDoc.firstName} ${userDoc.lastName}`) || 'Unknown User'\n\n // NOTE: currently only issues and tasks will return summary fields, audits\n // aren't supported and will return an empty array here\n const summaryFields = entry.summaryFields || []\n\n return {\n icon: launchIcon,\n location,\n link,\n name,\n summaryFields,\n timestamp,\n title,\n }\n }\n}\n\nfunction getScanRowData({ users, zones }) {\n return (document) => {\n const { timestamp, user = '', zone = '' } = document\n\n const userDoc =\n user && find(users, (doc) => doc._id.toString() === user.toString())\n const zoneDoc =\n zone && find(zones, (doc) => doc._id.toString() === zone.toString())\n\n const zoneName = zoneDoc && zoneDoc.name\n const location = zoneName || 'Unknown Location'\n\n const name =\n (userDoc && `${userDoc.firstName} ${userDoc.lastName}`) || 'Unknown User'\n\n const title = 'Location Scan'\n\n return {\n location,\n timestamp,\n name,\n title,\n }\n }\n}\n"],"mappings":";;;;;;AAAA,SACEA,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,OAAO,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ACP2G,OAAO,OAAAnI,MAAA,CAAOmI,OAAO,CAACC,SAAS,OAAApI,MAAA,CAAImI,OAAO,CAACE,QAAQ,CAAE,IAAK,cAAc;IAE3E,IAAMvM,KAAK,GAAG,eAAe;IAE7B,OAAO;MACLwF,QAAQ,EAARA,QAAQ;MACR1F,SAAS,EAATA,SAAS;MACT4F,IAAI,EAAJA,IAAI;MACJ1F,KAAK,EAALA;IACF,CAAC;EACH,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_lodash","require","_momentTimezone","_interopRequireDefault","_bluebird","_helpers","_helpers2","_images","DEFAULT_MAX_SCANS","MAX_ATTACHMENTS","LIGHTHOUSE_BASE_URL","buildActivityPdf","pdfOptions","data","timestamp","timezone","title","content","generateContent","generateDefinition","fileTitle","type","activitySection","buildActivitySection","summarySection","buildSummarySection","titleTable","buildTitleTable","showAlternate","locationScans","buildLocationScansSection","otherActivity","buildOtherActivitySection","activitySummary","buildActivitySummarySection","audits","events","issues","maxScans","settings","tasks","enterEvents","filter","event","exceedsMaxScans","size","scans","take","auditRows","map","getFormRowData","issueRows","scanRows","getScanRowData","taskRows","formCount","exceedsMaxForms","rows","sortedRows","sortBy","text","style","header","table","body","layout","hLine","horizontalLine","activityTable","buildActivityTable","activitySummarySection","maxScansText","link","margin","push","maxFormsText","timezoneAbbr","getTimezoneAbbr","activityTableHeader","bold","alignment","activityTableRows","Promise","location","icon","name","summaryFields","timezoneHour","getTimezoneDatetime","format","showTzAbbr","iconCell","fit","image","hasSummaryFields","isEmpty","fieldsTable","summaryFieldsTable","fields","activityTableRow","colSpan","dontBreakRows","headerRow","hLineWidth","paddingLeft","paddingRight","paddingTop","paddingBottom","vLineWidth","widths","activityTableBody","fillColor","zebraFillColor","start","zones","hourIntervalBoundaries","buildLocationScansBoundaries","hourIntervalColumnHeaders","reduce","columns","interval","index","intervals","scansTableHeader","sortedZones","groupedEventsByZone","memo","zone","zoneEvents","toString","_id","scansTableRows","sortedGroup","locationScansByInterval","buildLocationScansContent","locationScansByIntervalContent","totalEvents","zoneDoc","find","doc","zoneName","scansTableBody","scansTable","eventsByType","groupBy","enterEventsCount","enter","issuesCount","tasksCount","auditsCount","auditsText","issuesText","scansText","tasksText","auditsCountText","scansCountText","issuesCountText","tasksCountText","auditTable","summaryStatTable","scanTable","issueTable","taskTables","wrapperTable","summaryWrapperTable","otherActivitySummarySection","end","address","headerTitle","headerSubTitle","addressText","street","city","state","postalCode","headerAddress","mTimezoneStart","moment","tz","mTimezoneEnd","rangeStart","rangeEnd","add","startOf","headerRange","collection","locations","users","document","createdAt","entry","user","getLocationReference","entity","userDoc","firstName","lastName","launchIcon"],"sources":["../../../src/pdf/activity-report/index.js"],"sourcesContent":["import {\r\n filter,\r\n find,\r\n groupBy,\r\n isEmpty,\r\n map,\r\n size,\r\n sortBy,\r\n take,\r\n toString,\r\n reduce,\r\n} from 'lodash'\r\n\r\nimport moment from 'moment-timezone'\r\nimport Promise from 'bluebird'\r\n\r\nimport {\r\n generateDefinition,\r\n buildLocationScansContent,\r\n buildLocationScansBoundaries,\r\n horizontalLine,\r\n summaryStatTable,\r\n summaryWrapperTable,\r\n table,\r\n summaryFieldsTable,\r\n text,\r\n zebraFillColor,\r\n} from '../helpers'\r\n\r\nimport {\r\n getLocationReference,\r\n getTimezoneAbbr,\r\n getTimezoneDatetime,\r\n} from '../../helpers'\r\nimport { launchIcon } from '../../images'\r\n\r\nconst DEFAULT_MAX_SCANS = 200\r\nconst MAX_ATTACHMENTS = 100\r\nconst LIGHTHOUSE_BASE_URL = 'https://app.lighthouse.io'\r\n\r\n/**\r\n * buildActivityPdf\r\n *\r\n * @param {object} pdfOptions - the pdf options\r\n * @param {string} pdfOptions.fileTitle - pdf file title\r\n * @param {function} pdfOptions.footer - function executed to generate footer\r\n * @param {function} pdfOptions.header - function executed to generate header\r\n * @param {string} pdfOptions.logoUrl - pdf logo url\r\n * @param {array} pdfOptions.pageMargins - pdf page margins\r\n * @param {string} pdfOptions.pageOrientation - pdf page orientation\r\n * @param {string} pdfOptions.pageSize - pdf page size\r\n * @param {object} pdfOptions.styles - pdf styles\r\n * @param {object} pdfOptions.title - pdf title\r\n * @param {object} data - pdf data\r\n * @param {array} data.audits - audit documents\r\n * @param {string} data.end - end datetime of summary report\r\n * @param {array} data.events - event documents\r\n * @param {object} data.location - location document\r\n * @param {array} data.locations - location documents\r\n * @param {array} data.issues - issue documents\r\n * @param {bool} data.maxScans - max scans to include in standard report\r\n * @param {bool} data.showAlternate - show alternate summary report\r\n * @param {string} data.start - start datetime of summary report\r\n * @param {object} data.settings - settings properties\r\n * @param {string} data.settings.awsS3BaseUrl - aws S3 base url\r\n * @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url\r\n * @param {array} data.tasks - task documents\r\n * @param {string} data.timestamp - timestamp string\r\n * @param {string} data.timezone - timezone string\r\n * @param {array} data.zones - zone documents\r\n * @param {array} data.users - user documents\r\n * @returns {Promise} returns pdfmake definition object\r\n */\r\nexport async function buildActivityPdf(pdfOptions, data) {\r\n const { timestamp, timezone } = data\r\n\r\n const title = 'Daily Activity Report'\r\n const content = await generateContent(data)\r\n\r\n return generateDefinition({\r\n content,\r\n fileTitle: title,\r\n timestamp,\r\n timezone,\r\n type: 'Activity Summary',\r\n ...pdfOptions,\r\n })\r\n}\r\n\r\nasync function generateContent(data) {\r\n const activitySection = await buildActivitySection(data)\r\n const summarySection = buildSummarySection(data)\r\n const titleTable = buildTitleTable(data)\r\n\r\n return [titleTable, summarySection, activitySection]\r\n}\r\n\r\nasync function buildActivitySection(data) {\r\n const { showAlternate = false } = data\r\n\r\n if (showAlternate) {\r\n const locationScans = buildLocationScansSection(data)\r\n const otherActivity = await buildOtherActivitySection(data)\r\n\r\n return [locationScans, otherActivity]\r\n }\r\n\r\n const activitySummary = await buildActivitySummarySection(data)\r\n\r\n return [activitySummary]\r\n}\r\n\r\nasync function buildActivitySummarySection(data) {\r\n const {\r\n audits,\r\n events,\r\n issues,\r\n maxScans = DEFAULT_MAX_SCANS,\r\n settings,\r\n tasks,\r\n timezone,\r\n } = data\r\n\r\n const enterEvents = filter(events, event => event.type === 'enter')\r\n const exceedsMaxScans = size(enterEvents) > maxScans\r\n const scans = take(enterEvents, maxScans)\r\n\r\n const auditRows = map(audits, getFormRowData('audits', data))\r\n const issueRows = map(issues, getFormRowData('issues', data))\r\n const scanRows = map(scans, getScanRowData(data))\r\n const taskRows = map(tasks, getFormRowData('tasks', data))\r\n\r\n const formCount = size([...auditRows, ...issueRows, ...taskRows])\r\n const exceedsMaxForms = formCount > MAX_ATTACHMENTS\r\n\r\n const rows = [...auditRows, ...issueRows, ...scanRows, ...taskRows]\r\n const sortedRows = sortBy(rows, ['timestamp'], ['asc'])\r\n const title = text('Activity Summary', { style: 'summarySectionHeader' })\r\n\r\n const header = table({\r\n body: [[title]],\r\n layout: 'noBorders',\r\n style: 'summaryHeaderTable',\r\n })\r\n\r\n const hLine = horizontalLine()\r\n const activityTable = await buildActivityTable({\r\n rows: sortedRows,\r\n settings,\r\n timezone,\r\n })\r\n const activitySummarySection = [header, hLine, activityTable]\r\n\r\n if (exceedsMaxScans) {\r\n const maxScansText = {\r\n text: [\r\n text(\r\n `Location Scans in the Daily Activity Report are limited to a total of ${maxScans}.`\r\n ),\r\n text(' To view all Location Scans visit '),\r\n text('the Events Report', {\r\n link: `${LIGHTHOUSE_BASE_URL}/reports/events`,\r\n }),\r\n text(' in the Lighthouse Management Console.'),\r\n ],\r\n style: 'small',\r\n margin: [0, 10, 0, 10],\r\n }\r\n\r\n activitySummarySection.push(maxScansText)\r\n }\r\n\r\n if (exceedsMaxForms) {\r\n const maxFormsText = {\r\n text: [\r\n text(\r\n `Detailed Form Submissions in the Daily Activity Report are limited to a total of ${MAX_ATTACHMENTS}. `\r\n ),\r\n text(\r\n '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.'\r\n ),\r\n ],\r\n style: 'small',\r\n margin: [0, 10, 0, 10],\r\n }\r\n activitySummarySection.push(maxFormsText)\r\n }\r\n\r\n return activitySummarySection\r\n}\r\n\r\nasync function buildActivityTable({ rows, settings, timezone }) {\r\n const timezoneAbbr = getTimezoneAbbr(timezone)\r\n\r\n const activityTableHeader = [\r\n text('Activity', { bold: true }),\r\n { text: '' }, // icon column\r\n text('Location', { bold: true }),\r\n text('User', { bold: true }),\r\n text(`Timestamp (${timezoneAbbr})`, { alignment: 'right', bold: true }),\r\n ]\r\n\r\n const activityTableRows = await Promise.map(rows, async function(data) {\r\n const { link, location, icon, name, summaryFields, timestamp, title } = data\r\n\r\n const timezoneHour = getTimezoneDatetime({\r\n format: 'ddd DD h:mm a',\r\n showTzAbbr: false,\r\n timestamp,\r\n timezone,\r\n })\r\n\r\n const iconCell = icon\r\n ? { alignment: 'center', fit: [8, 8], image: icon, link }\r\n : { text: '' }\r\n\r\n // NOTE: pass link to each column as\r\n // we can't wrap the entire table row\r\n const rows = [\r\n [\r\n text(title, { link }),\r\n iconCell,\r\n text(location, { link }),\r\n text(name, { link }),\r\n text(timezoneHour, { alignment: 'right', link }),\r\n ],\r\n ]\r\n\r\n const hasSummaryFields = !isEmpty(summaryFields)\r\n\r\n if (hasSummaryFields) {\r\n const fieldsTable = await summaryFieldsTable({\r\n fields: summaryFields,\r\n settings,\r\n timezone,\r\n })\r\n rows.push([fieldsTable])\r\n }\r\n\r\n // NOTE: we return a table per row which includes the entry details and the\r\n // summary fields if relevant\r\n const activityTableRow = [\r\n table({\r\n body: [...rows],\r\n colSpan: 5,\r\n dontBreakRows: true,\r\n headerRow: 0,\r\n layout: {\r\n hLineWidth: () => 0,\r\n paddingLeft: () => 0,\r\n paddingRight: () => 0,\r\n paddingTop: () => 5,\r\n paddingBottom: () => 5,\r\n vLineWidth: () => 0,\r\n },\r\n // NOTE: the timestamp must fill up the rest of the table space as\r\n // otherwise the padding would be off between this table and the parent\r\n // table that wraps it\r\n widths: [130, 25, 110, 110, '*'],\r\n }),\r\n ]\r\n\r\n return activityTableRow\r\n })\r\n\r\n const activityTableBody = isEmpty(activityTableRows)\r\n ? [[text('No other activity', { colSpan: 5 })]]\r\n : activityTableRows\r\n\r\n const activityTable = table({\r\n body: [activityTableHeader, ...activityTableBody],\r\n dontBreakRows: true,\r\n layout: {\r\n hLineWidth: () => 0,\r\n fillColor: zebraFillColor,\r\n paddingLeft: () => 5,\r\n paddingRight: () => 5,\r\n paddingTop: () => 5,\r\n paddingBottom: () => 5,\r\n vLineWidth: () => 0,\r\n },\r\n widths: [120, 15, 100, 100, '*'],\r\n })\r\n\r\n return activityTable\r\n}\r\n\r\nfunction buildLocationScansSection(data) {\r\n const { events, start, timezone, zones } = data\r\n\r\n const title = text('Location Scans', { style: 'summarySectionHeader' })\r\n\r\n const header = table({\r\n body: [[title]],\r\n layout: 'noBorders',\r\n style: 'summaryHeaderTable',\r\n })\r\n\r\n // use start time and timezone to figure out the interval boundaries\r\n const hourIntervalBoundaries = buildLocationScansBoundaries(start, timezone)\r\n\r\n // pair interval boundaries into column headers for the table\r\n const hourIntervalColumnHeaders = hourIntervalBoundaries.reduce(\r\n (columns, interval, index, intervals) => {\r\n if (index < size(intervals) - 1)\r\n // skip the final iteration as it's just the end of the last interval\r\n columns.push(\r\n text(`${interval.format('h')}-${intervals[index + 1].format('hA')}`, {\r\n alignment: 'center',\r\n bold: true,\r\n })\r\n )\r\n return columns\r\n },\r\n []\r\n )\r\n\r\n const scansTableHeader = [\r\n text('Location', { bold: true }),\r\n ...hourIntervalColumnHeaders,\r\n text('Total', { alignment: 'right', bold: true }),\r\n ]\r\n\r\n const hLine = horizontalLine()\r\n\r\n // NOTE: only show the enter events within the summary table\r\n const enterEvents = filter(events, event => event.type === 'enter')\r\n const sortedZones = sortBy(zones, ['name'])\r\n\r\n const groupedEventsByZone = reduce(\r\n sortedZones,\r\n (memo, zone) => {\r\n const zoneEvents = filter(\r\n enterEvents,\r\n event => event.zone && event.zone.toString() === zone._id.toString()\r\n )\r\n memo[zone._id] = zoneEvents\r\n return memo\r\n },\r\n {}\r\n )\r\n\r\n const scansTableRows = map(groupedEventsByZone, (events, zone = '') => {\r\n const sortedGroup = sortBy(events, ['timestamp'], ['asc'])\r\n\r\n // put events into interval buckets\r\n const locationScansByInterval = buildLocationScansContent(\r\n hourIntervalBoundaries,\r\n events\r\n )\r\n // map the interval buckets to a format fit for the table\r\n const locationScansByIntervalContent = locationScansByInterval.map(\r\n interval => {\r\n return { alignment: 'center', text: size(interval) }\r\n }\r\n )\r\n\r\n const totalEvents = size(sortedGroup)\r\n\r\n const zoneDoc =\r\n zone && find(zones, doc => doc._id.toString() === zone.toString())\r\n const zoneName = (zoneDoc && zoneDoc.name) || 'Unknown Location'\r\n\r\n return [\r\n zoneName,\r\n ...locationScansByIntervalContent,\r\n { alignment: 'right', bold: true, text: totalEvents },\r\n ]\r\n })\r\n\r\n const scansTableBody = isEmpty(scansTableRows)\r\n ? [[text('No location scans', { colSpan: 10 })]]\r\n : scansTableRows\r\n\r\n const scansTable = table({\r\n body: [scansTableHeader, ...scansTableBody],\r\n widths: [100, '*', '*', '*', '*', '*', '*', '*', '*', '*'],\r\n })\r\n\r\n return [header, hLine, scansTable]\r\n}\r\n\r\nfunction buildSummarySection(data) {\r\n const { audits, events, issues, tasks } = data\r\n\r\n //const userEvents = groupBy(events, 'user')\r\n const eventsByType = groupBy(events, 'type')\r\n\r\n const enterEventsCount = size(eventsByType.enter)\r\n //const geoEventsCount = size(eventsByType.geo)\r\n const issuesCount = size(issues)\r\n const tasksCount = size(tasks)\r\n const auditsCount = size(audits)\r\n //const uniqueUsers = size(userEvents)\r\n\r\n const auditsText = text('AUDITS', { style: 'summaryText' })\r\n //const geoText = text('GPS', { style: 'summaryText' })\r\n const issuesText = text('ISSUES', { style: 'summaryText' })\r\n //const peopleText = text('PEOPLE', { style: 'summaryText' })\r\n const scansText = text('SCANS', { style: 'summaryText' })\r\n const tasksText = text('TASKS', { style: 'summaryText' })\r\n\r\n const auditsCountText = text(toString(auditsCount), { style: 'summaryCount' })\r\n //const peopleCountText = text(toString(uniqueUsers), { style: 'summaryCount' })\r\n const scansCountText = text(toString(enterEventsCount), {\r\n style: 'summaryCount',\r\n })\r\n //const geoCountText = text(toString(geoEventsCount), { style: 'summaryCount' })\r\n const issuesCountText = text(toString(issuesCount), { style: 'summaryCount' })\r\n const tasksCountText = text(toString(tasksCount), { style: 'summaryCount' })\r\n\r\n const auditTable = summaryStatTable({\r\n body: [[auditsText], [auditsCountText]],\r\n })\r\n //const peopleTable = summaryStatTable({\r\n // body: [[peopleText], [peopleCountText]],\r\n //})\r\n //const gpsTable = summaryStatTable({ body: [[geoText], [geoCountText]] })\r\n const scanTable = summaryStatTable({ body: [[scansText], [scansCountText]] })\r\n const issueTable = summaryStatTable({\r\n body: [[issuesText], [issuesCountText]],\r\n })\r\n const taskTables = summaryStatTable({ body: [[tasksText], [tasksCountText]] })\r\n\r\n const wrapperTable = summaryWrapperTable({\r\n body: [\r\n [\r\n /*peopleTable,*/\r\n /*gpsTable,*/\r\n scanTable,\r\n issueTable,\r\n taskTables,\r\n auditTable,\r\n ],\r\n ],\r\n })\r\n\r\n return wrapperTable\r\n}\r\n\r\nasync function buildOtherActivitySection(data) {\r\n const { audits, issues, tasks, settings, timezone } = data\r\n\r\n const auditRows = map(audits, getFormRowData('audits', data))\r\n const issueRows = map(issues, getFormRowData('issues', data))\r\n const taskRows = map(tasks, getFormRowData('tasks', data))\r\n\r\n const rows = [...auditRows, ...issueRows, ...taskRows]\r\n const sortedRows = sortBy(rows, ['timestamp'], ['asc'])\r\n const title = text('Other Activity', { style: 'summarySectionHeader' })\r\n\r\n const header = table({\r\n body: [[title]],\r\n layout: 'noBorders',\r\n style: 'summaryHeaderTable',\r\n })\r\n\r\n const hLine = horizontalLine()\r\n const activityTable = await buildActivityTable({\r\n rows: sortedRows,\r\n settings,\r\n timezone,\r\n })\r\n\r\n const otherActivitySummarySection = [header, hLine, activityTable]\r\n\r\n const formCount = size(rows)\r\n const exceedsMaxForms = formCount > MAX_ATTACHMENTS\r\n\r\n if (exceedsMaxForms) {\r\n const maxFormsText = {\r\n text: [\r\n text(\r\n `Detailed Form Submissions in the Daily Activity Report are limited to a total of ${MAX_ATTACHMENTS}. `\r\n ),\r\n text(\r\n '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.'\r\n ),\r\n ],\r\n style: 'small',\r\n margin: [0, 10, 0, 10],\r\n }\r\n otherActivitySummarySection.push(maxFormsText)\r\n }\r\n\r\n return otherActivitySummarySection\r\n}\r\n\r\nfunction buildTitleTable(data) {\r\n const { location, start, end, timezone } = data\r\n const { address = {} } = location\r\n\r\n const headerTitle = text('Daily Activity Report', { style: 'title' })\r\n const headerSubTitle = text(location.name, { style: 'subTitle' })\r\n const addressText = !isEmpty(address)\r\n ? `${address.street}, ${address.city || ''} ${address.state ||\r\n ''} ${address.postalCode || ''}`\r\n : ''\r\n const headerAddress = text(addressText, { style: 'small' })\r\n\r\n const mTimezoneStart = moment.tz(start, timezone)\r\n const mTimezoneEnd = moment.tz(end, timezone)\r\n const timezoneAbbr = getTimezoneAbbr(timezone)\r\n\r\n const rangeStart = moment(mTimezoneStart).format('MMM DD h:mma')\r\n\r\n const rangeEnd = moment(mTimezoneEnd)\r\n .add(1, 'hour')\r\n .startOf('hour')\r\n .format('MMM DD h:mma')\r\n\r\n const headerRange = text(`${rangeStart} - ${rangeEnd} (${timezoneAbbr})`, {\r\n style: 'subTitle2',\r\n })\r\n\r\n const body = !isEmpty(address)\r\n ? [[headerTitle], [headerSubTitle], [headerAddress], [headerRange]]\r\n : [[headerTitle], [headerSubTitle], [headerRange]]\r\n\r\n return table({\r\n body,\r\n layout: 'noBorders',\r\n style: 'titleTable',\r\n })\r\n}\r\n\r\nfunction getFormRowData(collection, { locations, users, zones }) {\r\n return document => {\r\n const {\r\n _id,\r\n createdAt,\r\n entry = {},\r\n title = 'Unknown',\r\n user = '',\r\n } = document\r\n\r\n const location = getLocationReference({\r\n entity: document,\r\n locations,\r\n zones,\r\n })\r\n\r\n const link = `${LIGHTHOUSE_BASE_URL}/reports/${collection}/${_id}`\r\n const timestamp = createdAt\r\n const userDoc = find(users, doc => doc._id.toString() === user.toString())\r\n const name =\r\n (userDoc && `${userDoc.firstName} ${userDoc.lastName}`) || 'Unknown User'\r\n\r\n // NOTE: currently only issues and tasks will return summary fields, audits\r\n // aren't supported and will return an empty array here\r\n const summaryFields = entry.summaryFields || []\r\n\r\n return {\r\n icon: launchIcon,\r\n location,\r\n link,\r\n name,\r\n summaryFields,\r\n timestamp,\r\n title,\r\n }\r\n }\r\n}\r\n\r\nfunction getScanRowData({ users, zones }) {\r\n return document => {\r\n const { timestamp, user = '', zone = '' } = document\r\n\r\n const userDoc =\r\n user && find(users, doc => doc._id.toString() === user.toString())\r\n const zoneDoc =\r\n zone && find(zones, doc => doc._id.toString() === zone.toString())\r\n\r\n const zoneName = zoneDoc && zoneDoc.name\r\n const location = zoneName || 'Unknown Location'\r\n\r\n const name =\r\n (userDoc && `${userDoc.firstName} ${userDoc.lastName}`) || 'Unknown User'\r\n\r\n const title = 'Location Scan'\r\n\r\n return {\r\n location,\r\n timestamp,\r\n name,\r\n title,\r\n }\r\n }\r\n}\r\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAaA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAaA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,OAAA,GAAAN,OAAA;AAEA,MAAMO,iBAAiB,GAAG,GAAG;AAC7B,MAAMC,eAAe,GAAG,GAAG;AAC3B,MAAMC,mBAAmB,GAAG,2BAA2B;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AQ,EAAE,IAAK,cAAc;IAE3E,MAAMpL,KAAK,GAAG,eAAe;IAE7B,OAAO;MACLmE,QAAQ;MACRrE,SAAS;MACTuE,IAAI;MACJrE;IACF,CAAC;EACH,CAAC;AACH","ignoreList":[]}
|
package/lib/pdf/audit/index.js
CHANGED
|
@@ -1,215 +1,218 @@
|
|
|
1
|
-
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
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; }
|
|
4
|
-
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; }
|
|
5
|
-
import Promise from 'bluebird';
|
|
6
|
-
import { isEmpty, round } from 'lodash';
|
|
7
|
-
import moment from 'moment-timezone';
|
|
8
|
-
import { buildAuditContent, buildAuditFollowUps, buildTemplateContent, generateDefinition, getFormattedAddress, horizontalLine, text, twoColumnTable } from '../helpers';
|
|
9
|
-
import { getAuditEntryDetails } from '../../helpers';
|
|
1
|
+
"use strict";
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @param {object} pdfOptions
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {string}
|
|
31
|
-
* @param {string}
|
|
32
|
-
* @param {object}
|
|
33
|
-
* @
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.buildAuditPdf = buildAuditPdf;
|
|
8
|
+
var _bluebird = _interopRequireDefault(require("bluebird"));
|
|
9
|
+
var _lodash = require("lodash");
|
|
10
|
+
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
11
|
+
var _helpers = require("../helpers");
|
|
12
|
+
var _helpers2 = require("../../helpers");
|
|
13
|
+
/**
|
|
14
|
+
* buildAuditPdf
|
|
15
|
+
*
|
|
16
|
+
* @param {object} pdfOptions - the pdf options
|
|
17
|
+
* @param {string} pdfOptions.fileTitle - pdf file title
|
|
18
|
+
* @param {function} pdfOptions.footer - function executed to generate footer
|
|
19
|
+
* @param {function} pdfOptions.header - function executed to generate header
|
|
20
|
+
* @param {string} pdfOptions.logoUrl - pdf logo url
|
|
21
|
+
* @param {array} pdfOptions.pageMargins - pdf page margins
|
|
22
|
+
* @param {string} pdfOptions.pageOrientation - pdf page orientation
|
|
23
|
+
* @param {string} pdfOptions.pageSize - pdf page size
|
|
24
|
+
* @param {object} pdfOptions.styles - pdf styles
|
|
25
|
+
* @param {object} pdfOptions.title - pdf title
|
|
26
|
+
* @param {object} pdfOptions.flags - flags to conditionally render parts of the pdf
|
|
27
|
+
* @param {object} data - pdf data
|
|
28
|
+
* @param {object} data.entity - audit document
|
|
29
|
+
* @param {object} data.locations - locations documents
|
|
30
|
+
* @param {object} data.settings - settings properties
|
|
31
|
+
* @param {string} data.settings.awsS3BaseUrl - aws S3 base url
|
|
32
|
+
* @param {string} data.settings.cloudinaryBaseUrl - cloudinary base url
|
|
33
|
+
* @param {string} data.timezone - timezone string
|
|
34
|
+
* @param {object} data.users - application user documents
|
|
35
|
+
* @returns {Promise} returns pdfmake definition object
|
|
34
36
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
function buildAuditPdf(pdfOptions, data) {
|
|
38
|
+
const {
|
|
39
|
+
entity,
|
|
40
|
+
timezone
|
|
41
|
+
} = data;
|
|
42
|
+
const {
|
|
43
|
+
flags = {}
|
|
44
|
+
} = pdfOptions;
|
|
45
|
+
const sequenceId = entity.sequenceId;
|
|
46
|
+
const timestamp = entity.createdAt;
|
|
47
|
+
const title = entity.title || 'Unknown';
|
|
48
|
+
const fileTitle = `Audit Report - ${title}`;
|
|
49
|
+
return generateContent(data, flags).then(content => (0, _helpers.generateDefinition)({
|
|
50
|
+
content,
|
|
51
|
+
fileTitle,
|
|
52
|
+
sequenceId,
|
|
53
|
+
timestamp,
|
|
54
|
+
timezone,
|
|
55
|
+
type: 'Audit',
|
|
56
|
+
...pdfOptions
|
|
57
|
+
})).catch(err => {
|
|
58
|
+
throw new Error(`BuildAuditPdfError: ${err.message}`);
|
|
55
59
|
});
|
|
56
60
|
}
|
|
57
61
|
function generateContent(data) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
gps =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
62
|
+
const {
|
|
63
|
+
entity
|
|
64
|
+
} = data;
|
|
65
|
+
const {
|
|
66
|
+
followUps = [],
|
|
67
|
+
footerFields = {},
|
|
68
|
+
gps = {},
|
|
69
|
+
headerFields = {},
|
|
70
|
+
score = {},
|
|
71
|
+
title = 'Unknown'
|
|
72
|
+
} = entity;
|
|
73
|
+
const timezone = entity?.timezone || data?.timezone || 'UTC';
|
|
74
|
+
const entityDetails = (0, _helpers2.getAuditEntryDetails)(data);
|
|
75
|
+
const {
|
|
76
|
+
gpsText,
|
|
77
|
+
groupedData,
|
|
78
|
+
locationText,
|
|
79
|
+
referenceValue,
|
|
80
|
+
timezoneHourTime,
|
|
81
|
+
scoreText,
|
|
82
|
+
target,
|
|
83
|
+
targetServiceLevel
|
|
84
|
+
} = entityDetails;
|
|
85
|
+
const renderTargetFields = !!targetServiceLevel;
|
|
86
|
+
const headerTitle = (0, _helpers.text)(title, {
|
|
83
87
|
style: 'title'
|
|
84
88
|
});
|
|
85
|
-
|
|
89
|
+
const headerScore = (0, _helpers.text)(scoreText, {
|
|
86
90
|
alignment: 'right',
|
|
87
91
|
style: 'title'
|
|
88
92
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
const firstRow = [headerTitle, headerScore];
|
|
94
|
+
const subTitle = `${locationText || gpsText} - ${timezoneHourTime} by ${referenceValue}`;
|
|
95
|
+
let headerSubTitle = (0, _helpers.text)(subTitle, {
|
|
92
96
|
colSpan: 2,
|
|
93
97
|
style: 'subTitle'
|
|
94
98
|
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
let secondRow = [headerSubTitle];
|
|
100
|
+
const reverseGeocoded = gps.reverseGeocoded;
|
|
101
|
+
const address = !(0, _lodash.isEmpty)(reverseGeocoded) ? (0, _helpers.getFormattedAddress)(reverseGeocoded) : '';
|
|
102
|
+
const renderHeaderAddress = !(0, _lodash.isEmpty)(reverseGeocoded);
|
|
103
|
+
const dummyColumn = (0, _helpers.text)(' ', {
|
|
100
104
|
style: 'small'
|
|
101
105
|
});
|
|
102
|
-
|
|
106
|
+
let headerAddress = (0, _helpers.text)(address, {
|
|
103
107
|
colSpan: 2,
|
|
104
108
|
style: 'small'
|
|
105
109
|
});
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
const renderThirdRow = renderHeaderAddress || renderTargetFields;
|
|
111
|
+
let thirdRow = renderHeaderAddress ? [headerAddress] : [];
|
|
108
112
|
if (renderTargetFields) {
|
|
109
|
-
headerSubTitle = text(subTitle, {
|
|
113
|
+
headerSubTitle = (0, _helpers.text)(subTitle, {
|
|
110
114
|
style: 'subTitle'
|
|
111
115
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
const serviceLevelBelow = targetServiceLevel === 'below';
|
|
117
|
+
const serviceLevelText = targetServiceLevel === 'above' ? 'Above Target' : targetServiceLevel === 'on' ? 'On Target' : targetServiceLevel === 'below' ? 'Below Target' : '';
|
|
118
|
+
const scoreServiceLevelSubTitle = (0, _helpers.text)(serviceLevelText, {
|
|
115
119
|
alignment: 'right',
|
|
116
120
|
style: serviceLevelBelow ? 'serviceLevelBelow' : 'serviceLevelAboveOrOn'
|
|
117
121
|
});
|
|
118
122
|
secondRow = [headerSubTitle, scoreServiceLevelSubTitle];
|
|
119
|
-
headerAddress = text(address, {
|
|
123
|
+
headerAddress = (0, _helpers.text)(address, {
|
|
120
124
|
style: 'small'
|
|
121
125
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
const truncatedTargetPercent = (0, _lodash.round)(target, 2);
|
|
127
|
+
const scoreTargetText = `(Target - ${truncatedTargetPercent}%)`;
|
|
128
|
+
const scoreTargetSubTitle = (0, _helpers.text)(scoreTargetText, {
|
|
125
129
|
alignment: 'right',
|
|
126
130
|
style: 'subTitle'
|
|
127
131
|
});
|
|
128
132
|
thirdRow = renderHeaderAddress ? [headerAddress, scoreTargetSubTitle] : [dummyColumn, scoreTargetSubTitle];
|
|
129
133
|
}
|
|
130
|
-
|
|
134
|
+
const scoreBreakdown = (0, _helpers.text)(`${(0, _lodash.round)(score.actual, 2)} / ${(0, _lodash.round)(score.max, 2)}`, {
|
|
131
135
|
alignment: 'right',
|
|
132
136
|
style: 'totalScore'
|
|
133
137
|
});
|
|
134
|
-
|
|
138
|
+
const scorePercentage = (0, _helpers.text)(scoreText, {
|
|
135
139
|
alignment: 'right',
|
|
136
140
|
colSpan: 2,
|
|
137
141
|
style: 'totalAuditScore'
|
|
138
142
|
});
|
|
139
|
-
|
|
143
|
+
const scoreTitle = (0, _helpers.text)('Total Score', {
|
|
140
144
|
style: 'totalScore'
|
|
141
145
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
146
|
+
const body = renderThirdRow ? [firstRow, secondRow, thirdRow] : [firstRow, secondRow];
|
|
147
|
+
const submittedAtInTimezone = entity.submittedAt ? (0, _momentTimezone.default)(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
148
|
+
const submittedAt = (0, _helpers.text)(`Submitted: ${submittedAtInTimezone}`, {
|
|
145
149
|
colSpan: 2,
|
|
146
150
|
style: 'small'
|
|
147
151
|
});
|
|
148
152
|
if (entity.showSimplifiedDuration) {
|
|
149
153
|
body.push([submittedAt, dummyColumn]);
|
|
150
154
|
} else {
|
|
151
|
-
|
|
152
|
-
|
|
155
|
+
const startedAtInTimezone = entity.startedAt ? (0, _momentTimezone.default)(entity.startedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
156
|
+
const startedAt = (0, _helpers.text)(`Started: ${startedAtInTimezone}`, {
|
|
153
157
|
colSpan: 2,
|
|
154
158
|
style: 'small'
|
|
155
159
|
});
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
const submittedAtInTimezone = entity.submittedAt ? (0, _momentTimezone.default)(entity.submittedAt).tz(timezone).format('YYYY-MM-DD HH:mm:ss z') : 'Not recorded';
|
|
161
|
+
const submittedAt = (0, _helpers.text)(`Submitted: ${submittedAtInTimezone}`, {
|
|
158
162
|
colSpan: 2,
|
|
159
163
|
style: 'small'
|
|
160
164
|
});
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
const momentDuration = _momentTimezone.default.duration(Math.abs(entity.formDuration));
|
|
166
|
+
const days = Math.floor(momentDuration.asDays()).toString().padStart(2, '0');
|
|
167
|
+
const hours = Math.floor(momentDuration.hours()).toString().padStart(2, '0');
|
|
168
|
+
const minutes = momentDuration.minutes().toString().padStart(2, '0');
|
|
169
|
+
const seconds = momentDuration.seconds().toString().padStart(2, '0');
|
|
170
|
+
const formattedFormDuration = entity.formDuration ? `${entity.formDuration < 0 ? '-' : ''}${days}:${hours}:${minutes}:${seconds}` : 'Not recorded';
|
|
171
|
+
const formDuration = (0, _helpers.text)(`Form Duration (DD:HH:MM:SS): ${formattedFormDuration}`, {
|
|
168
172
|
colSpan: 2,
|
|
169
173
|
style: 'small'
|
|
170
174
|
});
|
|
171
175
|
body.push([startedAt, dummyColumn]);
|
|
172
|
-
body.push([
|
|
176
|
+
body.push([submittedAt, dummyColumn]);
|
|
173
177
|
body.push([formDuration, dummyColumn]);
|
|
174
178
|
}
|
|
175
|
-
|
|
176
|
-
body
|
|
179
|
+
const titleTable = (0, _helpers.twoColumnTable)({
|
|
180
|
+
body,
|
|
177
181
|
layout: 'noBorders',
|
|
178
182
|
style: 'titleTable',
|
|
179
183
|
widths: ['*', 100],
|
|
180
184
|
margin: [0, 0, 0, 30]
|
|
181
185
|
});
|
|
182
|
-
|
|
186
|
+
const totalScoreTable = (0, _helpers.twoColumnTable)({
|
|
183
187
|
body: [[scoreTitle, scoreBreakdown], [scorePercentage]],
|
|
184
188
|
layout: 'noBorders',
|
|
185
189
|
widths: ['*', 100]
|
|
186
190
|
});
|
|
187
|
-
|
|
191
|
+
const hLineTop = (0, _helpers.horizontalLine)({
|
|
188
192
|
margin: [0, 10, 0, 0]
|
|
189
193
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
timezone
|
|
194
|
+
const hLineBottom = (0, _helpers.horizontalLine)();
|
|
195
|
+
const followUpItems = (0, _helpers.buildAuditFollowUps)(followUps, {
|
|
196
|
+
timezone
|
|
193
197
|
});
|
|
194
|
-
|
|
195
|
-
entry: buildAuditContent(groupedData.items, data.settings),
|
|
196
|
-
footerTemplate: buildTemplateContent(footerFields.formGroups, data),
|
|
197
|
-
headerTemplate: buildTemplateContent(headerFields.formGroups, data)
|
|
198
|
+
const promises = {
|
|
199
|
+
entry: (0, _helpers.buildAuditContent)(groupedData.items, data.settings),
|
|
200
|
+
footerTemplate: (0, _helpers.buildTemplateContent)(footerFields.formGroups, data),
|
|
201
|
+
headerTemplate: (0, _helpers.buildTemplateContent)(headerFields.formGroups, data)
|
|
198
202
|
};
|
|
199
|
-
|
|
203
|
+
const auditItemsTitle = [{
|
|
200
204
|
text: 'Audit Items',
|
|
201
205
|
style: {
|
|
202
206
|
font: 'Gotham',
|
|
203
207
|
lineHeight: 1.1
|
|
204
208
|
}
|
|
205
209
|
}, hLineTop];
|
|
206
|
-
return
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
throw new Error("GenerateContentError: ".concat(err.message));
|
|
210
|
+
return _bluebird.default.props(promises).then(({
|
|
211
|
+
entry,
|
|
212
|
+
footerTemplate,
|
|
213
|
+
headerTemplate
|
|
214
|
+
}) => [titleTable, followUpItems, ...auditItemsTitle, ...headerTemplate, ...entry, hLineTop, totalScoreTable, hLineBottom, ...footerTemplate]).catch(err => {
|
|
215
|
+
throw new Error(`GenerateContentError: ${err.message}`);
|
|
213
216
|
});
|
|
214
217
|
}
|
|
215
218
|
//# sourceMappingURL=index.js.map
|