X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=src%2Ftemplate%2Fadmin-maintenance-html.js;fp=src%2Ftemplate%2Fadmin-maintenance-html.js;h=031eb30c18527602aed4c9a30ae1897432997e39;hp=0000000000000000000000000000000000000000;hb=b0103b0d496262c438b40bc20304081dbfe41e73;hpb=8ed81748bce7cea7904cac7225b20a60cafdfc16 diff --git a/src/template/admin-maintenance-html.js b/src/template/admin-maintenance-html.js new file mode 100644 index 0000000..031eb30 --- /dev/null +++ b/src/template/admin-maintenance-html.js @@ -0,0 +1,86 @@ +'use strict'; + +const th = require('./template-helper'); + +function renderAlmanacRow(entry) { + const { event, date } = entry; + return ` +\t${event} +\t${th.timeElement(date, { title: 'Occurred' })} +`; +} + +function almanacSection(almanac) { + return `
+\t

Almanac

+\t +\t\t +\t\t\t +\t\t\t +\t\t +\t\t +${almanac.map((entry) => renderAlmanacRow(entry)).join('\n')} +\t\t +\t
EventDate
+`; +} + +function renderChoreRow(choreName, choreDetails) { + const { intervalMs, nextSchedule } = choreDetails; + return ` +\t +\t +\t +`; +} + +function choresSection(chores) { + return `
+\t

Chores

+\t
${choreName}${th.secondsToPeriod(Math.ceil(intervalMs / 1000))}${th.timeElement(nextSchedule)}
+\t\t +\t\t\t +\t\t\t +\t\t\t +\t\t +\t\t +${Object.entries(chores).map((chore) => renderChoreRow(...chore)).join('\n')} +\t\t +\t
ChoreFrequencyNext Run
+`; +} + +/** + * + * @param {Object} ctx + * @param {Object[]} ctx.almanac + * @param {Object} ctx.chores + * @param {Object} options + * @param {Object} options.manager + * @param {String} options.manager.pageTitle + * @param {String[]} options.manager.footerEntries + * @param {String} options.adminContactHTML + * @returns {String} + */ +module.exports = (ctx, options) => { + const htmlOptions = { + pageTitle: options.manager.pageTitle + ' - Maintenance', + logoUrl: options.manager.logoUrl, + footerEntries: options.manager.footerEntries, + navLinks: [ + { + text: 'Admin', + href: '.', + }, + { + text: 'Ticket', + href: './ticket', + }, + ], + }; + const content = [ + almanacSection(ctx.almanac || []), + choresSection(ctx.chores || {}), + ]; + return th.htmlPage(1, ctx, htmlOptions, content); +}; \ No newline at end of file