|
|
|
@ -6,16 +6,28 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
|
|
|
|
|
|
|
|
|
|
export const fritzboxDefaultFields = ["connectionStatus", "uptime", "maxDown", "maxUp"];
|
|
|
|
|
|
|
|
|
|
const formatUptime = (timestamp) => {
|
|
|
|
|
const hours = Math.floor(timestamp / 3600);
|
|
|
|
|
const minutes = Math.floor((timestamp % 3600) / 60);
|
|
|
|
|
const seconds = timestamp % 60;
|
|
|
|
|
const formatUptime = (uptimeInSeconds) => {
|
|
|
|
|
const days = Math.floor(uptimeInSeconds / (3600 * 24));
|
|
|
|
|
const hours = Math.floor((uptimeInSeconds % (3600 * 24)) / 3600);
|
|
|
|
|
const minutes = Math.floor((uptimeInSeconds % 3600) / 60);
|
|
|
|
|
const seconds = Math.floor(uptimeInSeconds) % 60;
|
|
|
|
|
const format = (num) => String(num).padStart(2, "0");
|
|
|
|
|
|
|
|
|
|
const hourDuration = hours > 0 ? `${hours}h` : "00h";
|
|
|
|
|
const minDuration = minutes > 0 ? `${minutes}m` : "00m";
|
|
|
|
|
const secDuration = seconds > 0 ? `${seconds}s` : "00s";
|
|
|
|
|
let uptimeStr = "";
|
|
|
|
|
if (days) {
|
|
|
|
|
uptimeStr += `${days}d`;
|
|
|
|
|
}
|
|
|
|
|
if (uptimeInSeconds >= 3600) {
|
|
|
|
|
uptimeStr += `${format(hours)}h`;
|
|
|
|
|
}
|
|
|
|
|
if (uptimeInSeconds >= 60) {
|
|
|
|
|
uptimeStr += `${format(minutes)}m`;
|
|
|
|
|
}
|
|
|
|
|
if (!days) {
|
|
|
|
|
uptimeStr += `${format(seconds)}s `;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return hourDuration + minDuration + secDuration;
|
|
|
|
|
return uptimeStr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default function Component({ service }) {
|
|
|
|
|