X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=src%2Ftemplate%2Fadmin-html.js;h=f72102f27f8bf09883b930b2eeed054d4f5f6735;hb=f0bf29c75b0fd405ff92fa76f058e61162b87e43;hp=3b16a2834411a431fe1d2c661af9847b17dd3572;hpb=52aff9fa0269a628c115f58f0f62faff3f8fc4a4;p=squeep-indie-auther
diff --git a/src/template/admin-html.js b/src/template/admin-html.js
index 3b16a28..f72102f 100644
--- a/src/template/admin-html.js
+++ b/src/template/admin-html.js
@@ -10,11 +10,23 @@ const th = require('./template-helper');
const { sessionNavLinks } = require('@squeep/authentication-module');
+/**
+ *
+ * @param {string} profile profile
+ * @returns {string} li
+ */
function renderProfileLI(profile) {
return `\t
${profile}`;
}
+/**
+ *
+ * @param {string} profile profile
+ * @param {string} scope scope
+ * @param {boolean} selected is selected
+ * @returns {string} td
+ */
function renderProfileScopeIndicator(profile, scope, selected) {
const checked = selected ? ' checked' : '';
return `\t\t
@@ -22,6 +34,13 @@ function renderProfileScopeIndicator(profile, scope, selected) {
\t\t | `;
}
+/**
+ *
+ * @param {string} scope scope
+ * @param {object} details details
+ * @param {string[]} profiles profiles
+ * @returns {string} tr
+ */
function renderScopeRow(scope, details, profiles) {
return `\t
${(profiles || []).map((profile) => renderProfileScopeIndicator(profile, scope, details.profiles.includes(profile))).join('\n')}
@@ -37,6 +56,11 @@ ${(profiles || []).map((profile) => renderProfileScopeIndicator(profile, scope,
}
+/**
+ *
+ * @param {string} profile profile
+ * @returns {string} th
+ */
function renderProfileHeader(profile) {
return `
\t\t${profile}
@@ -44,6 +68,12 @@ function renderProfileHeader(profile) {
}
+/**
+ *
+ * @param {object} scopeIndex scopes
+ * @param {string[]} profiles profiles
+ * @returns {string} table
+ */
function scopeIndexTable(scopeIndex, profiles) {
return `
@@ -61,6 +91,11 @@ ${Object.entries(scopeIndex).sort(th.scopeCompare).map(([scope, details]) => ren
`;
}
+/**
+ *
+ * @param {object} token token
+ * @returns {string} type
+ */
function _tokenType(token) {
if (token.resource) {
return 'ticket-token';
@@ -71,6 +106,11 @@ function _tokenType(token) {
return 'token';
}
+/**
+ *
+ * @param {object} token token
+ * @returns {string} tr
+ */
function renderTokenRow(token) {
const createdTitle = token.refreshed ? 'Refreshed At' : 'Created At';
const createdDate = token.refreshed ? token.refreshed : token.created;
@@ -91,12 +131,20 @@ function renderTokenRow(token) {
\t\t |
`;
}
+/**
+ * @returns {string} tr
+ */
function noTokensRows() {
return [`\t\t
\t\t\t(No active or recent tokens.) |
\t\t
`];
}
+/**
+ *
+ * @param {object} tokens tokens
+ * @returns {string} table
+ */
function tokenTable(tokens) {
const tokenRows = tokens?.length ? tokens.map((token) => renderTokenRow(token)) : noTokensRows();
const formOpen = tokens?.length ? '