3 const th
= require('./template-helper');
4 const { sessionNavLinks
} = require('@squeep/authentication-module');
6 function renderAlmanacRow(entry
) {
7 const { event
, date
} = entry
;
10 \t<td>${th.timeElement(date, { title: 'Occurred' })}</td>
14 function almanacSection(almanac
) {
20 \t\t\t\t<th scope="col">Event</th>
21 \t\t\t\t<th scope="col">Date</th>
25 ${almanac.map((entry) => renderAlmanacRow(entry)).join('\n')}
31 function renderChoreRow(choreName
, choreDetails
) {
32 const { intervalMs
, nextSchedule
} = choreDetails
;
34 \t<td>${choreName}</td>
35 \t<td>${th.secondsToPeriod(Math.ceil(intervalMs / 1000))}</td>
36 \t<td>${th.timeElement(nextSchedule)}</td>
40 function choresSection(chores
) {
46 \t\t\t\t<th scope="col">Chore</th>
47 \t\t\t\t<th scope="col">Frequency</th>
48 \t\t\t\t<th scope="col">Next Run</th>
52 ${Object.entries(chores).map((chore) => renderChoreRow(...chore)).join('\n')}
61 * @param {Object[]} ctx.almanac
62 * @param {Object} ctx.chores
63 * @param {Object} options
64 * @param {Object} options.manager
65 * @param {String} options.manager.pageTitle
66 * @param {String[]} options.manager.footerEntries
67 * @param {String} options.adminContactHTML
70 module
.exports
= (ctx
, options
) => {
71 const pagePathLevel
= 1;
73 pageIdentifier: 'maintenance',
74 pageTitle: options
.manager
.pageTitle
+ ' - Maintenance',
75 logoUrl: options
.manager
.logoUrl
,
76 footerEntries: options
.manager
.footerEntries
,
78 th
.navLinks(pagePathLevel
, ctx
, htmlOptions
);
79 sessionNavLinks(pagePathLevel
, ctx
, htmlOptions
);
81 almanacSection(ctx
.almanac
|| []),
82 choresSection(ctx
.chores
|| {}),
84 return th
.htmlPage(pagePathLevel
, ctx
, htmlOptions
, content
);