X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftemplate%2Fadmin-topic-details-html.js;h=e239e72612aafe41dc901cda2d9c670d2fe9c52f;hb=e23bda592175ae5ed772f366069ccfd2f60e1f70;hp=df13f210f7af70c2686b3955ee3d744f4b2b43db;hpb=ed6dc5a66ce0eaf2dd61f9fb7a5ec048944c68ee;p=websub-hub diff --git a/src/template/admin-topic-details-html.js b/src/template/admin-topic-details-html.js index df13f21..e239e72 100644 --- a/src/template/admin-topic-details-html.js +++ b/src/template/admin-topic-details-html.js @@ -1,20 +1,22 @@ 'use strict'; const th = require('./template-helper'); +const { sessionNavLinks } = require('@squeep/authentication-module'); /** * Show a topic with all of its subscribers. - * @param {Object} ctx - * @param {Object} ctx.topic - * @param {Object[]} ctx.subscriptions - * @param {Object} options - * @param {Object} options.manager - * @param {String} options.manager.pageTitle - * @returns {String} + * @param {object} ctx context + * @param {object} ctx.topic topic + * @param {object[]} ctx.subscriptions subscriptions + * @param {object} options options + * @param {object} options.manager manager options + * @param {string} options.manager.pageTitle page title + * @returns {string} html */ module.exports = (ctx, options) => { + const pagePathLevel = 2; const pageTitle = `${options.manager.pageTitle} - Topic Details`; - const headElements = []; + const logoUrl = options.manager.logoUrl; const navLinks = [ { href: '..', @@ -25,27 +27,51 @@ module.exports = (ctx, options) => { if (!ctx.subscriptions) { ctx.subscriptions = []; } - return th.htmlTemplate(2, pageTitle, headElements, navLinks, [ + + const htmlOptions = { + pageIdentifier: 'admin', + pageTitle, + logoUrl, + navLinks, + footerEntries, + }; + th.navLinks(pagePathLevel, ctx, htmlOptions); + sessionNavLinks(pagePathLevel, ctx, htmlOptions); + + const content = [ ` `, th.renderTopicRowHeader(), ` `, - ...(ctx.topic && [ th.renderTopicRow(ctx.topic, ctx.subscriptions, false) ]), + ...(ctx.topic && [ th.renderTopicRow(ctx.topic, ctx.subscriptions, false) ] || []), ` `, + ` + Topic Publish History — ${ctx.publishCount} updates in the last ${ctx.publishSpan} days + + `, ` - ${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'} - + ${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'}`, + ...(ctx.subscriptions.length && [` + + Successful Deliveries of Latest Content + + + ${ctx.subscriptionsDelivered} of ${ctx.subscriptions.length} (${Math.ceil(100 * ctx.subscriptions.length / ctx.subscriptionsDelivered)}%) + `] || []), + ` `, th.renderSubscriptionRowHeader(), ` `, - ...(ctx.subscriptions && ctx.subscriptions.map(th.renderSubscriptionRow)), + ...((ctx?.subscriptions || []).map(th.renderSubscriptionRow)), ` `, - ], footerEntries); + ]; + + return th.htmlPage(pagePathLevel, ctx, htmlOptions, content); }; \ No newline at end of file
Topic Publish History — ${ctx.publishCount} updates in the last ${ctx.publishSpan} days
${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'}