Change color of percentage according to uptime of monitor.

This commit is contained in:
M M committed 2024-09-01 12:25:23 -07:00
1 parent 21fafa1705
commit d75b494d58
3 files changed
+17 -8

No files matched your search

+2 -2
View File
@@ -31,7 +31,7 @@ const icons = {
const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => { const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => {
const theme = useTheme(); const theme = useTheme();
const { text, light, border } = theme.palette[variant]; const { text, bg, border } = theme.palette[variant];
const icon = icons[variant]; const icon = icons[variant];
return ( return (
@@ -45,7 +45,7 @@ const Alert = ({ variant, title, body, isToast, hasIcon = true, onClick }) => {
padding: hasIcon padding: hasIcon
? theme.spacing(8) ? theme.spacing(8)
: `${theme.spacing(4)} ${theme.spacing(8)}`, : `${theme.spacing(4)} ${theme.spacing(8)}`,
backgroundColor: light, backgroundColor: bg,
border: `solid 1px ${border}`, border: `solid 1px ${border}`,
borderRadius: theme.shape.borderRadius, borderRadius: theme.shape.borderRadius,
}} }}
+14 -5
View File
@@ -32,21 +32,30 @@ export const buildData = (monitors, isAdmin, navigate) => {
data.rows = monitors.map((monitor, idx) => { data.rows = monitors.map((monitor, idx) => {
let uptimePercentage = ""; let uptimePercentage = "";
let percentageColor = theme.palette.success.main;
if (monitor.uptimePercentage !== undefined) { if (monitor.uptimePercentage !== undefined) {
uptimePercentage = uptimePercentage =
monitor.uptimePercentage === 0 monitor.uptimePercentage === 0
? "0" ? "0"
: (monitor.uptimePercentage * 100).toFixed(2); : (monitor.uptimePercentage * 100).toFixed(2);
}
if (monitor.uptimePercentage < 0.25) {
percentageColor = theme.palette.error.text;
} else if (monitor.uptimePercentage >= 0.25 && monitor.uptimePercentage < 0.5) {
percentageColor = theme.palette.warning.main;
} else if (monitor.uptimePercentage >= 0.5 && monitor.uptimePercentage < 0.75) {
percentageColor = theme.palette.warning.light;
} else if (monitor.uptimePercentage >= 0.75 && monitor.uptimePercentage <= 1) {
percentageColor = theme.palette.success.main;
}
}
const params = { const params = {
url: monitor.url, url: monitor.url,
title: monitor.name, title: monitor.name,
percentage: uptimePercentage, percentage: uptimePercentage,
percentageColor: percentageColor,
monitor.status === true
? theme.palette.success.main
: theme.palette.error.text,
status: monitor.status === true ? "up" : "down", status: monitor.status === true ? "up" : "down",
}; };
+1 -1
View File
@@ -53,7 +53,7 @@ const darkTheme = createTheme({
warning: { warning: {
text: "#e88c30", text: "#e88c30",
main: "#FF9F00", main: "#FF9F00",
light: "#27272a", light: "#ffd600",
bg: "#1E1E1E", bg: "#1E1E1E",
border: "#e88c30", border: "#e88c30",
}, },