Fix: Technitium widget percentage display (#3984)

---------

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
pull/3993/head
Bobby Driggs 2 months ago committed by GitHub
parent 68c2b04090
commit 295c6ea796
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -53,7 +53,7 @@ export default function Component({ service }) {
function toPercent(value, total) { function toPercent(value, total) {
return t("common.percent", { return t("common.percent", {
value: !Number.isNaN(value / total) ? value / total : 0, value: !Number.isNaN(value / total) ? 100 * (value / total) : 0,
maximumFractionDigits: 2, maximumFractionDigits: 2,
}); });
} }
@ -64,55 +64,64 @@ export default function Component({ service }) {
<Block <Block
label="technitium.totalNoError" label="technitium.totalNoError"
value={`${t("common.number", { value: statsData.totalNoError })} (${toPercent( value={`${t("common.number", { value: statsData.totalNoError })} (${toPercent(
statsData.totalNoError / statsData.totalQueries, statsData.totalNoError,
statsData.totalQueries,
)})`} )})`}
/> />
<Block <Block
label="technitium.totalServerFailure" label="technitium.totalServerFailure"
value={`${t("common.number", { value: statsData.totalServerFailure })} (${toPercent( value={`${t("common.number", { value: statsData.totalServerFailure })} (${toPercent(
statsData.totalServerFailure / statsData.totalQueries, statsData.totalServerFailure,
statsData.totalQueries,
)})`} )})`}
/> />
<Block <Block
label="technitium.totalNxDomain" label="technitium.totalNxDomain"
value={`${t("common.number", { value: statsData.totalNxDomain })} (${toPercent( value={`${t("common.number", { value: statsData.totalNxDomain })} (${toPercent(
statsData.totalNxDomain / statsData.totalQueries, statsData.totalNxDomain,
statsData.totalQueries,
)})`} )})`}
/> />
<Block <Block
label="technitium.totalRefused" label="technitium.totalRefused"
value={`${t("common.number", { value: statsData.totalRefused })} (${toPercent( value={`${t("common.number", { value: statsData.totalRefused })} (${toPercent(
statsData.totalRefused / statsData.totalQueries, statsData.totalRefused,
statsData.totalQueries,
)})`} )})`}
/> />
<Block <Block
label="technitium.totalAuthoritative" label="technitium.totalAuthoritative"
value={`${t("common.number", { value: statsData.totalAuthoritative })} (${toPercent( value={`${t("common.number", { value: statsData.totalAuthoritative })} (${toPercent(
statsData.totalAuthoritative / statsData.totalQueries, statsData.totalAuthoritative,
statsData.totalQueries,
)})`} )})`}
/> />
<Block <Block
label="technitium.totalRecursive" label="technitium.totalRecursive"
value={`${t("common.number", { value: statsData.totalRecursive })} (${toPercent( value={`${t("common.number", { value: statsData.totalRecursive })} (${toPercent(
statsData.totalRecursive / statsData.totalQueries, statsData.totalRecursive,
statsData.totalQueries,
)})`} )})`}
/> />
<Block <Block
label="technitium.totalCached" label="technitium.totalCached"
value={`${t("common.number", { value: statsData.totalCached })} (${toPercent( value={`${t("common.number", { value: statsData.totalCached })} (${toPercent(
statsData.totalCached / statsData.totalQueries, statsData.totalCached,
statsData.totalQueries,
)})`} )})`}
/> />
<Block <Block
label="technitium.totalBlocked" label="technitium.totalBlocked"
value={`${t("common.number", { value: statsData.totalBlocked })} (${toPercent( value={`${t("common.number", { value: statsData.totalBlocked })} (${toPercent(
statsData.totalBlocked / statsData.totalQueries, statsData.totalBlocked,
statsData.totalQueries,
)})`} )})`}
/> />
<Block <Block
label="technitium.totalDropped" label="technitium.totalDropped"
value={`${t("common.number", { value: statsData.totalDropped })} (${toPercent( value={`${t("common.number", { value: statsData.totalDropped })} (${toPercent(
statsData.totalDropped / statsData.totalQueries, statsData.totalDropped,
statsData.totalQueries,
)})`} )})`}
/> />
<Block label="technitium.totalClients" value={`${t("common.number", { value: statsData.totalClients })}`} /> <Block label="technitium.totalClients" value={`${t("common.number", { value: statsData.totalClients })}`} />

@ -9,7 +9,7 @@ const widget = {
endpoint: "dashboard/stats/get", endpoint: "dashboard/stats/get",
validate: ["response", "status"], validate: ["response", "status"],
params: ["type"], params: ["type"],
map: (data) => asJson(data).response.stats, map: (data) => asJson(data).response?.stats,
}, },
}, },
}; };

Loading…
Cancel
Save