3 const th
= require('./template-helper');
6 * Show a topic with all of its subscribers.
8 * @param {Object} ctx.topic
9 * @param {Object[]} ctx.subscriptions
10 * @param {Object} options
11 * @param {Object} options.manager
12 * @param {String} options.manager.pageTitle
15 module
.exports
= (ctx
, options
) => {
16 const pageTitle
= `${options.manager.pageTitle} - Topic Details`;
17 const logoUrl
= options
.manager
.logoUrl
;
21 text: '↑ All Topics',
24 const footerEntries
= options
.manager
.footerEntries
;
25 if (!ctx
.subscriptions
) {
26 ctx
.subscriptions
= [];
37 ` <section class="topics">
40 th
.renderTopicRowHeader(),
43 ...(ctx
.topic
&& [ th
.renderTopicRow(ctx
.topic
, ctx
.subscriptions
, false) ] || []),
47 ` <section class="history">
48 <p>Topic Publish History — ${ctx.publishCount} updates in the last ${ctx.publishSpan} days</p>
49 <img title="Topic Publish History" src="${ctx.params.topicId}/history.svg">
51 ` <section class="subscriptions">
52 <p>${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'}</p>`,
53 ...(ctx
.subscriptions
.length
&& [`
54 <label for="subscriptions-delivered">
55 Successful Deliveries of Latest Content
57 <progress id="subscriptions-delivered" max="${ctx.subscriptions.length}" value="${ctx.subscriptionsDelivered}">
58 ${ctx.subscriptionsDelivered} of ${ctx.subscriptions.length} (${Math.ceil(100 * ctx.subscriptions.length / ctx.subscriptionsDelivered)}%)
62 th
.renderSubscriptionRowHeader(),
65 ...(ctx
.subscriptions
&& ctx
.subscriptions
.map(th
.renderSubscriptionRow
)),
71 return th
.htmlPage(2, ctx
, htmlOptions
, content
);