diff --git a/source/app/metrics/index.mjs b/source/app/metrics/index.mjs index 9d5fb53b..a66df761 100644 --- a/source/app/metrics/index.mjs +++ b/source/app/metrics/index.mjs @@ -4,7 +4,7 @@ import util from "util" import * as utils from "./utils.mjs" //Setup -export default async function metrics({login, q}, {graphql, rest, plugins, conf, die = false, verify = false, convert = null, callbacks = null}, {Plugins, Templates}) { +export default async function metrics({login, q}, {graphql, rest, plugins, conf, die = false, verify = false, convert = null, callbacks = null, warnings = []}, {Plugins, Templates}) { //Compute rendering try { //Debug @@ -39,7 +39,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf, : null), } const extras = {css: imports.metadata.plugins.core.extras("extras_css", {...conf.settings, error: false}) ? q["extras.css"] ?? "" : "", js: imports.metadata.plugins.core.extras("extras_js", {...conf.settings, error: false}) ? q["extras.js"] ?? "" : ""} - const data = {q, animated: true, large: false, base: {}, config: {}, errors: [], plugins: {}, computed: {}, extras, postscripts: []} + const data = {q, animated: true, large: false, base: {}, config: {}, errors: [], warnings, plugins: {}, computed: {}, extras, postscripts: []} const experimental = new Set(decodeURIComponent(q["experimental.features"] ?? "").split(" ").map(x => x.trim().toLocaleLowerCase()).filter(x => x)) if (conf.settings["debug.headless"]) imports.puppeteer.headless = false @@ -139,8 +139,14 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf, q.config_animations = false } q = Object.fromEntries([...Object.entries(q).map(([key, value]) => [key.replace(/^plugin_/, "").replace(/_/g, "."), value]), ["base", false]]) + //Check users errors + const warnings = [] + if ((!Object.keys(Plugins).filter(key => q[key]).length)&&(!parts.length)) + warnings.push({warning:{message:"No plugin were selected"}}) + const ineffective = Object.keys(q).filter(key => (key.includes(".")) && (key.split(".").at(0) !== "base") && (key.split(".").at(0) in Plugins)).filter(key => !q[key.split(".").at(0)]) + warnings.push(...ineffective.map(key => ({warning:{message:`"${key}" has no effect because "${key.split(".").at(0)}: true" is not set`}}))) //Compute rendering - const {rendered} = await metrics({login, q}, {...arguments[1], convert: ["svg", "png", "jpeg"].includes(q["config.output"]) ? q["config.output"] : null}, arguments[2]) + const {rendered} = await metrics({login, q}, {...arguments[1], convert: ["svg", "png", "jpeg"].includes(q["config.output"]) ? q["config.output"] : null, warnings}, arguments[2]) console.debug(`metrics/compute/${login}/embed > ${name} > success >>>>>>>>>>>>>>>>>>>>>>`) return `` } diff --git a/source/templates/classic/image.svg b/source/templates/classic/image.svg index 5982dab2..7ccad904 100644 --- a/source/templates/classic/image.svg +++ b/source/templates/classic/image.svg @@ -6,6 +6,17 @@
+ <% if (warnings.length) { %> +
+
+
+ + <%= warnings.map(({warning}) => warning.message).join(", ") %> +
+
+
+ <% } %> + <% for (const partial of [...partials]) { %> <%- await include(`partials/${partial}.ejs`) %> <% } %> diff --git a/source/templates/classic/style.css b/source/templates/classic/style.css index 361a9348..57ef1ff4 100644 --- a/source/templates/classic/style.css +++ b/source/templates/classic/style.css @@ -103,6 +103,12 @@ .field.error svg { fill: #cb2431; } + .field.warning { + color: #D79533; + } + .field.warning svg { + fill: #D79533; + } /* Displays */ .row { diff --git a/source/templates/repository/image.svg b/source/templates/repository/image.svg index a8ac7fa3..2a44e630 100644 --- a/source/templates/repository/image.svg +++ b/source/templates/repository/image.svg @@ -7,6 +7,16 @@
+ <% if (warnings.length) { %> +
+
+
+ + <%= warnings.map(({warning}) => warning.message).join(", ") %> +
+
+
+ <% } %> <% if (errors.length) { %>
diff --git a/source/templates/terminal/image.svg b/source/templates/terminal/image.svg index ac064701..28918752 100644 --- a/source/templates/terminal/image.svg +++ b/source/templates/terminal/image.svg @@ -51,6 +51,7 @@ WARRANTY, to the extent permitted by applicable law. Last generated: <%= meta.generated %>
<% } -%> +<% if (warnings.length) { %>
<%- warnings.map(({warning}) => `WARN: ${warning.message}`).join("
") %>
<% } %><%# -%> <% for (const partial of [...partials]) { %><%- await include(`partials/${partial}.ejs`) %><% } -%> <% if (base.metadata) { -%> diff --git a/source/templates/terminal/style.css b/source/templates/terminal/style.css index d2e60a55..3492118e 100644 --- a/source/templates/terminal/style.css +++ b/source/templates/terminal/style.css @@ -62,6 +62,10 @@ .banner, footer { color: #AE9DA7; } + .warnings { + color: #D79533; + white-space: normal; + } /* Isocalendar */ .isocalendar svg {