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

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

Loading…
Cancel
Save