0f4de44ce599fa62b745f1b63dab9d8ec90a2ca4
3 const th
= require('./template-helper');
4 const { sessionNavLinks
} = require('@squeep/authentication-module');
8 * @param {object} entry entry
11 function renderAlmanacRow(entry
) {
12 const { event
, date
} = entry
;
15 \t<td>${th.timeElement(date, { title: 'Occurred' })}</td>
21 * @param {object[]} almanac entries
22 * @returns {string} section
24 function almanacSection(almanac
) {
30 \t\t\t\t<th scope="col">Event</th>
31 \t\t\t\t<th scope="col">Date</th>
35 ${almanac.map((entry) => renderAlmanacRow(entry)).join('\n')}
43 * @param {string} choreName name
44 * @param {object} choreDetails details
45 * @returns {string} tr
47 function renderChoreRow(choreName
, choreDetails
) {
48 const { intervalMs
, nextSchedule
} = choreDetails
;
50 \t<td>${choreName}</td>
51 \t<td>${th.secondsToPeriod(Math.ceil(intervalMs / 1000))}</td>
52 \t<td>${th.timeElement(nextSchedule)}</td>
58 * @param {object} chores chores
59 * @returns {string} section
61 function choresSection(chores
) {
67 \t\t\t\t<th scope="col">Chore</th>
68 \t\t\t\t<th scope="col">Frequency</th>
69 \t\t\t\t<th scope="col">Next Run</th>
73 ${Object.entries(chores).map((chore) => renderChoreRow(...chore)).join('\n')}
81 * @param {object} ctx context
82 * @param {object[]} ctx.almanac entries
83 * @param {object} ctx.chores chores
84 * @param {object} options options
85 * @param {object} options.manager manager options
86 * @param {string} options.manager.pageTitle page title
87 * @param {string[]} options.manager.footerEntries footer entires
88 * @returns {string} page
90 module
.exports
= (ctx
, options
) => {
91 const pagePathLevel
= 1;
93 pageIdentifier: 'maintenance',
94 pageTitle: options
.manager
.pageTitle
+ ' - Maintenance',
95 logoUrl: options
.manager
.logoUrl
,
96 footerEntries: options
.manager
.footerEntries
,
98 th
.navLinks(pagePathLevel
, ctx
, htmlOptions
);
99 sessionNavLinks(pagePathLevel
, ctx
, htmlOptions
);
101 almanacSection(ctx
.almanac
|| []),
102 choresSection(ctx
.chores
|| {}),
104 return th
.htmlPage(pagePathLevel
, ctx
, htmlOptions
, content
);