e239e72612aafe41dc901cda2d9c670d2fe9c52f
3 const th
= require('./template-helper');
4 const { sessionNavLinks
} = require('@squeep/authentication-module');
7 * Show a topic with all of its subscribers.
8 * @param {object} ctx context
9 * @param {object} ctx.topic topic
10 * @param {object[]} ctx.subscriptions subscriptions
11 * @param {object} options options
12 * @param {object} options.manager manager options
13 * @param {string} options.manager.pageTitle page title
14 * @returns {string} html
16 module
.exports
= (ctx
, options
) => {
17 const pagePathLevel
= 2;
18 const pageTitle
= `${options.manager.pageTitle} - Topic Details`;
19 const logoUrl
= options
.manager
.logoUrl
;
23 text: '↑ All Topics',
26 const footerEntries
= options
.manager
.footerEntries
;
27 if (!ctx
.subscriptions
) {
28 ctx
.subscriptions
= [];
32 pageIdentifier: 'admin',
38 th
.navLinks(pagePathLevel
, ctx
, htmlOptions
);
39 sessionNavLinks(pagePathLevel
, ctx
, htmlOptions
);
42 ` <section class="topics">
45 th
.renderTopicRowHeader(),
48 ...(ctx
.topic
&& [ th
.renderTopicRow(ctx
.topic
, ctx
.subscriptions
, false) ] || []),
52 ` <section class="history">
53 <p>Topic Publish History — ${ctx.publishCount} updates in the last ${ctx.publishSpan} days</p>
54 <img title="Topic Publish History" src="${ctx.params.topicId}/history.svg" alt="histogram of publish history">
56 ` <section class="subscriptions">
57 <p>${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'}</p>`,
58 ...(ctx
.subscriptions
.length
&& [`
59 <label for="subscriptions-delivered">
60 Successful Deliveries of Latest Content
62 <progress id="subscriptions-delivered" max="${ctx.subscriptions.length}" value="${ctx.subscriptionsDelivered}">
63 ${ctx.subscriptionsDelivered} of ${ctx.subscriptions.length} (${Math.ceil(100 * ctx.subscriptions.length / ctx.subscriptionsDelivered)}%)
67 th
.renderSubscriptionRowHeader(),
70 ...((ctx
?.subscriptions
|| []).map(th
.renderSubscriptionRow
)),
76 return th
.htmlPage(pagePathLevel
, ctx
, htmlOptions
, content
);