mirror of
https://github.com/gethomepage/homepage.git
synced 2026-01-11 11:32:09 +08:00
Run pre-commit hooks over existing codebase
Co-Authored-By: Ben Phelps <ben@phelps.io>
This commit is contained in:
@@ -6,7 +6,7 @@ import Resource from "../widget/resource";
|
||||
import Error from "../widget/error";
|
||||
|
||||
function convertToFahrenheit(t) {
|
||||
return t * 9/5 + 32
|
||||
return (t * 9) / 5 + 32;
|
||||
}
|
||||
|
||||
export default function CpuTemp({ expanded, units, refresh = 1500 }) {
|
||||
@@ -17,18 +17,20 @@ export default function CpuTemp({ expanded, units, refresh = 1500 }) {
|
||||
});
|
||||
|
||||
if (error || data?.error) {
|
||||
return <Error />
|
||||
return <Error />;
|
||||
}
|
||||
|
||||
if (!data || !data.cputemp) {
|
||||
return <Resource
|
||||
icon={FaThermometerHalf}
|
||||
value="-"
|
||||
label={t("resources.temp")}
|
||||
expandedValue="-"
|
||||
expandedLabel={t("resources.max")}
|
||||
expanded={expanded}
|
||||
/>;
|
||||
return (
|
||||
<Resource
|
||||
icon={FaThermometerHalf}
|
||||
value="-"
|
||||
label={t("resources.temp")}
|
||||
expandedValue="-"
|
||||
expandedLabel={t("resources.max")}
|
||||
expanded={expanded}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
let mainTemp = data.cputemp.main;
|
||||
@@ -36,26 +38,28 @@ export default function CpuTemp({ expanded, units, refresh = 1500 }) {
|
||||
mainTemp = data.cputemp.cores.reduce((a, b) => a + b) / data.cputemp.cores.length;
|
||||
}
|
||||
const unit = units === "imperial" ? "fahrenheit" : "celsius";
|
||||
mainTemp = (unit === "celsius") ? mainTemp : convertToFahrenheit(mainTemp);
|
||||
const maxTemp = (unit === "celsius") ? data.cputemp.max : convertToFahrenheit(data.cputemp.max);
|
||||
mainTemp = unit === "celsius" ? mainTemp : convertToFahrenheit(mainTemp);
|
||||
const maxTemp = unit === "celsius" ? data.cputemp.max : convertToFahrenheit(data.cputemp.max);
|
||||
|
||||
return <Resource
|
||||
icon={FaThermometerHalf}
|
||||
value={t("common.number", {
|
||||
value: mainTemp,
|
||||
maximumFractionDigits: 1,
|
||||
style: "unit",
|
||||
unit
|
||||
})}
|
||||
label={t("resources.temp")}
|
||||
expandedValue={t("common.number", {
|
||||
value: maxTemp,
|
||||
maximumFractionDigits: 1,
|
||||
style: "unit",
|
||||
unit
|
||||
})}
|
||||
expandedLabel={t("resources.max")}
|
||||
percentage={Math.round((mainTemp / maxTemp) * 100)}
|
||||
expanded={expanded}
|
||||
/>;
|
||||
return (
|
||||
<Resource
|
||||
icon={FaThermometerHalf}
|
||||
value={t("common.number", {
|
||||
value: mainTemp,
|
||||
maximumFractionDigits: 1,
|
||||
style: "unit",
|
||||
unit,
|
||||
})}
|
||||
label={t("resources.temp")}
|
||||
expandedValue={t("common.number", {
|
||||
value: maxTemp,
|
||||
maximumFractionDigits: 1,
|
||||
style: "unit",
|
||||
unit,
|
||||
})}
|
||||
expandedLabel={t("resources.max")}
|
||||
percentage={Math.round((mainTemp / maxTemp) * 100)}
|
||||
expanded={expanded}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user