add indicator for percent of sucessfully updated subscription to topic details
[websub-hub] / src / template / admin-topic-details-html.js
index df13f210f7af70c2686b3955ee3d744f4b2b43db..1d0add005079f356545eae03db8448548af61134 100644 (file)
@@ -14,7 +14,7 @@ const th = require('./template-helper');
  */
 module.exports = (ctx, options) => {
   const pageTitle = `${options.manager.pageTitle} - Topic Details`;
-  const headElements = [];
+  const logoUrl = options.manager.logoUrl;
   const navLinks = [
     {
       href: '..',
@@ -25,20 +25,39 @@ module.exports = (ctx, options) => {
   if (!ctx.subscriptions) {
     ctx.subscriptions = [];
   }
-  return th.htmlTemplate(2, pageTitle, headElements, navLinks, [
+
+  const htmlOptions = {
+    pageTitle,
+    logoUrl,
+    navLinks,
+    footerEntries,
+  };
+
+  const content = [
     `      <section class="topics">
         <table>
           <thead>`,
     th.renderTopicRowHeader(),
     `          </thead>
         <tbody>`,
-    ...(ctx.topic && [ th.renderTopicRow(ctx.topic, ctx.subscriptions, false) ]),
+    ...(ctx.topic && [ th.renderTopicRow(ctx.topic, ctx.subscriptions, false) ] || []),
     `        </tbody>
         </table>
       </section>`,
+    `      <section class="history">
+        <p>Topic Publish History &mdash; ${ctx.publishCount} updates in the last ${ctx.publishSpan} days</p>
+        <img title="Topic Publish History" src="${ctx.params.topicId}/history.svg">
+      </section>`,
     `      <section class="subscriptions">
-        <p>${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'}</p>
-        <table>
+        <p>${ctx.subscriptions.length ? ctx.subscriptions.length : 'no'} subscription${(ctx.subscriptions.length === 1) ? '' : 's'}</p>`,
+    ...(ctx.subscriptions.length && [`
+        <label for="subscriptions-delivered">
+          Successful Deliveries of Latest Content
+        </label>
+        <progress id="subscriptions-delivered" max="${ctx.subscriptions.length}" value="${ctx.subscriptionsDelivered}">
+          ${ctx.subscriptionsDelivered} of ${ctx.subscriptions.length} (${Math.ceil(100 * ctx.subscriptions.length / ctx.subscriptionsDelivered)}%)
+        </progress>`] || []),
+    `        <table>
           <thead>`,
     th.renderSubscriptionRowHeader(),
     `          </thead>
@@ -47,5 +66,7 @@ module.exports = (ctx, options) => {
     `          </tbody>
         </table>
       </section>`,
-  ], footerEntries);
+  ];
+
+  return th.htmlPage(2, ctx, htmlOptions, content);
 };
\ No newline at end of file