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 `
+\tAlmanac
+\t
+\t\t
+\t\t\tEvent |
+\t\t\tDate |
+\t\t
+\t\t
+${almanac.map((entry) => renderAlmanacRow(entry)).join('\n')}
+\t\t
+\t
+`;
+}
+
+function renderChoreRow(choreName, choreDetails) {
+ const { intervalMs, nextSchedule } = choreDetails;
+ return `
+\t${choreName} |
+\t${th.secondsToPeriod(Math.ceil(intervalMs / 1000))} |
+\t${th.timeElement(nextSchedule)} |
+
`;
+}
+
+function choresSection(chores) {
+ return `
+\tChores
+\t
+\t\t
+\t\t\tChore |
+\t\t\tFrequency |
+\t\t\tNext Run |
+\t\t
+\t\t
+${Object.entries(chores).map((chore) => renderChoreRow(...chore)).join('\n')}
+\t\t
+\t
+`;
+}
+
+/**
+ *
+ * @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