|
|
|
@ -4,24 +4,6 @@ import Container from "components/services/widget/container";
|
|
|
|
|
import Block from "components/services/widget/block";
|
|
|
|
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
|
|
|
|
|
|
|
|
|
function secondsToDhms(seconds) {
|
|
|
|
|
const d = Math.floor(seconds / (3600 * 24));
|
|
|
|
|
const h = Math.floor((seconds % (3600 * 24)) / 3600);
|
|
|
|
|
const m = Math.floor((seconds % 3600) / 60);
|
|
|
|
|
const s = Math.floor(seconds % 60);
|
|
|
|
|
|
|
|
|
|
const dDisplay = d > 0 ? d + (d === 1 ? " day, " : " days, ") : "";
|
|
|
|
|
const hDisplay = h > 0 ? h + (h === 1 ? " hr, " : " hrs, ") : "";
|
|
|
|
|
let mDisplay = m > 0 && d === 0 ? m + (m === 1 ? " min" : " mins") : "";
|
|
|
|
|
let sDisplay = "";
|
|
|
|
|
|
|
|
|
|
if (d === 0 && h === 0) {
|
|
|
|
|
mDisplay = m > 0 ? m + (m === 1 ? " min, " : " mins, ") : "";
|
|
|
|
|
sDisplay = s > 0 ? s + (s === 1 ? " sec" : " secs") : "";
|
|
|
|
|
}
|
|
|
|
|
return (dDisplay + hDisplay + mDisplay + sDisplay).replace(/,\s*$/, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function Component({ service }) {
|
|
|
|
|
const { widget } = service;
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
@ -68,7 +50,7 @@ export default function Component({ service }) {
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
status = t("uptimerobot.up");
|
|
|
|
|
uptime = secondsToDhms(monitor.logs[0].duration);
|
|
|
|
|
uptime = t("common.uptime", { value: monitor.logs[0].duration });
|
|
|
|
|
logIndex = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
@ -83,7 +65,7 @@ export default function Component({ service }) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const lastDown = new Date(monitor.logs[logIndex].datetime * 1000).toLocaleString();
|
|
|
|
|
const downDuration = secondsToDhms(monitor.logs[logIndex].duration);
|
|
|
|
|
const downDuration = t("common.uptime", { value: monitor.logs[logIndex].duration });
|
|
|
|
|
const hideDown = logIndex === 1 && monitor.logs[logIndex].type !== 1;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|