fix typo in ticket template causing extraneous navLink to be displayed
[squeep-indie-auther] / src / template / admin-maintenance-html.js
1 'use strict';
2
3 const th = require('./template-helper');
4 const { sessionNavLinks } = require('@squeep/authentication-module');
5
6 function renderAlmanacRow(entry) {
7 const { event, date } = entry;
8 return `<tr>
9 \t<td>${event}</td>
10 \t<td>${th.timeElement(date, { title: 'Occurred' })}</td>
11 </tr>`;
12 }
13
14 function almanacSection(almanac) {
15 return `<section>
16 \t<h2>Almanac</h2>
17 \t<table>
18 \t\t<thead>
19 \t\t\t\t<tr>
20 \t\t\t\t<th scope="col">Event</th>
21 \t\t\t\t<th scope="col">Date</th>
22 \t\t\t</tr>
23 \t\t</thead>
24 \t\t<tbody>
25 ${almanac.map((entry) => renderAlmanacRow(entry)).join('\n')}
26 \t\t</tbody>
27 \t</table>
28 </section>`;
29 }
30
31 function renderChoreRow(choreName, choreDetails) {
32 const { intervalMs, nextSchedule } = choreDetails;
33 return `<tr>
34 \t<td>${choreName}</td>
35 \t<td>${th.secondsToPeriod(Math.ceil(intervalMs / 1000))}</td>
36 \t<td>${th.timeElement(nextSchedule)}</td>
37 </tr>`;
38 }
39
40 function choresSection(chores) {
41 return `<section>
42 \t<h2>Chores</h2>
43 \t<table>
44 \t\t<thead>
45 \t\t\t<tr>
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>
49 \t\t\t</tr>
50 \t\t</thead>
51 \t\t<tbody>
52 ${Object.entries(chores).map((chore) => renderChoreRow(...chore)).join('\n')}
53 \t\t</tbody>
54 \t</table>
55 </section>`;
56 }
57
58 /**
59 *
60 * @param {Object} ctx
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
68 * @returns {String}
69 */
70 module.exports = (ctx, options) => {
71 const pagePathLevel = 1;
72 const htmlOptions = {
73 pageIdentifier: 'maintenance',
74 pageTitle: options.manager.pageTitle + ' - Maintenance',
75 logoUrl: options.manager.logoUrl,
76 footerEntries: options.manager.footerEntries,
77 };
78 th.navLinks(pagePathLevel, ctx, htmlOptions);
79 sessionNavLinks(pagePathLevel, ctx, htmlOptions);
80 const content = [
81 almanacSection(ctx.almanac || []),
82 choresSection(ctx.chores || {}),
83 ];
84 return th.htmlPage(pagePathLevel, ctx, htmlOptions, content);
85 };