X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=src%2Ftemplate%2Fadmin-overview-html.js;h=1ec3d110275d2197f20f9a239a6a4776922b84b6;hb=HEAD;hp=a8efef3bb5c7d77cbe9cdd070e0a645008297414;hpb=afc5da271215282fa723e79a12562d3b86734326;p=websub-hub diff --git a/src/template/admin-overview-html.js b/src/template/admin-overview-html.js index a8efef3..948bdbb 100644 --- a/src/template/admin-overview-html.js +++ b/src/template/admin-overview-html.js @@ -1,25 +1,36 @@ 'use strict'; const th = require('./template-helper'); +const { sessionNavLinks } = require('@squeep/authentication-module'); /** * Show a summary of all topics. - * @param {Object} ctx - * @param {Object[]} ctx.topics - * @param {Object} options - * @param {Object} options.manager - * @param {String} options.manager.pageTitle - * @returns {String} + * @param {object} ctx context + * @param {object[]} ctx.topics topics + * @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 = 1; const pageTitle = `${options.manager.pageTitle} - Topics`; - const headElements = []; - const navLinks = []; + const logoUrl = options.manager.logoUrl; const footerEntries = options.manager.footerEntries; if (!ctx.topics) { ctx.topics = []; } - return th.htmlTemplate(ctx, 1, pageTitle, headElements, navLinks, [ + + const htmlOptions = { + pageIdentifier: 'admin', + pageTitle, + logoUrl, + footerEntries, + }; + th.navLinks(pagePathLevel, ctx, htmlOptions); + sessionNavLinks(pagePathLevel, ctx, htmlOptions); + + const content = [ `

${ctx.topics.length ? ctx.topics.length : 'no'} topic${(ctx.topics.length === 1) ? '' : 's'}

@@ -27,9 +38,11 @@ module.exports = (ctx, options) => { th.renderTopicRowHeader(), ` `, - ...(ctx.topics && ctx.topics.map((topic) => th.renderTopicRow(topic, { length: topic.subscribers }))), + ...((ctx?.topics || []).map((topic) => th.renderTopicRow(topic, { length: topic.subscribers }))), `
`, - ], footerEntries); + ]; + + return th.htmlPage(pagePathLevel, ctx, htmlOptions, content); }; \ No newline at end of file