fix: add code adjustments
This commit is contained in:
7 files changed
+25
-16
No files matched your search
@@ -27,11 +27,11 @@ export const getMenu = (t: Function) => {
|
|||||||
{
|
{
|
||||||
group: t("components.sidebar.menu.groups.monitoring"),
|
group: t("components.sidebar.menu.groups.monitoring"),
|
||||||
items: [
|
items: [
|
||||||
{
|
// {
|
||||||
name: t("components.sidebar.menu.dashboard"),
|
// name: t("components.sidebar.menu.dashboard"),
|
||||||
path: "dashboard",
|
// path: "dashboard",
|
||||||
icon: <Icon icon={LayoutDashboard} />,
|
// icon: <Icon icon={LayoutDashboard} />,
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
name: t("components.sidebar.menu.uptime"),
|
name: t("components.sidebar.menu.uptime"),
|
||||||
path: "uptime",
|
path: "uptime",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Stack from "@mui/material/Stack";
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { typographyLevels } from "@/Utils/Theme/Palette";
|
import { typographyLevels } from "@/Utils/Theme/Palette";
|
||||||
import { SPACING } from "@/Utils/Theme/constants";
|
import { LAYOUT, SPACING } from "@/Utils/Theme/constants";
|
||||||
|
|
||||||
interface BarRowProps {
|
interface BarRowProps {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -38,15 +38,15 @@ export const BarRow = ({ label, value, fillRatio, valueColor }: BarRowProps) =>
|
|||||||
</Typography>
|
</Typography>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Box
|
<Box
|
||||||
height={4}
|
height={theme.spacing(LAYOUT.XS)}
|
||||||
borderRadius={2}
|
borderRadius={theme.shape.borderRadius}
|
||||||
bgcolor={theme.palette.action.disabledBackground}
|
bgcolor={theme.palette.action.disabledBackground}
|
||||||
overflow="hidden"
|
overflow="hidden"
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
height="100%"
|
height="100%"
|
||||||
width={`${clampedRatio * 100}%`}
|
width={`${clampedRatio * 100}%`}
|
||||||
borderRadius={2}
|
borderRadius={theme.shape.borderRadius}
|
||||||
bgcolor={theme.palette.primary.main}
|
bgcolor={theme.palette.primary.main}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { BarRow } from "@/Pages/Dashboard/components/cards/BarRow";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import type { DashboardTypeCount } from "@/Pages/Dashboard/types";
|
import type { DashboardTypeCount } from "@/Pages/Dashboard/types";
|
||||||
|
import { getMonitorTypeLabel } from "@/Types/Monitor";
|
||||||
import { LAYOUT } from "@/Utils/Theme/constants";
|
import { LAYOUT } from "@/Utils/Theme/constants";
|
||||||
|
|
||||||
interface MonitorsByTypeCardProps {
|
interface MonitorsByTypeCardProps {
|
||||||
@@ -18,11 +19,11 @@ export const MonitorsByTypeCard = ({ monitorsByType }: MonitorsByTypeCardProps)
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardCard title={t("pages.dashboard.cards.monitorsByType")}>
|
<DashboardCard title={t("pages.dashboard.cards.monitorsByType")}>
|
||||||
<Stack gap={LAYOUT.SM}>
|
<Stack gap={theme.spacing(LAYOUT.SM)}>
|
||||||
{monitorsByType.map(({ type, count }) => (
|
{monitorsByType.map(({ type, count }) => (
|
||||||
<BarRow
|
<BarRow
|
||||||
key={type}
|
key={type}
|
||||||
label={type}
|
label={getMonitorTypeLabel(type, t)}
|
||||||
value={String(count)}
|
value={String(count)}
|
||||||
fillRatio={count / maxCount}
|
fillRatio={count / maxCount}
|
||||||
valueColor={theme.palette.text.primary}
|
valueColor={theme.palette.text.primary}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
||||||
|
|
||||||
import { BasePage } from "@/Components/design-elements/BasePage";
|
import { BasePage } from "@/Components/design-elements/BasePage";
|
||||||
import { LAYOUT } from "@/Utils/Theme/constants";
|
import { LAYOUT } from "@/Utils/Theme/constants";
|
||||||
@@ -28,13 +27,12 @@ const MOCK_MONITORS_BY_TYPE: DashboardTypeCount[] = [
|
|||||||
|
|
||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage headerKey="dashboard">
|
<BasePage headerKey="dashboard">
|
||||||
<Box
|
<Box
|
||||||
display="grid"
|
display="grid"
|
||||||
gridTemplateColumns={isSmall ? "1fr" : "1fr 1fr"}
|
gridTemplateColumns={{ xs: "1fr", md: "1fr 1fr" }}
|
||||||
gap={theme.spacing(LAYOUT.MD)}
|
gap={theme.spacing(LAYOUT.MD)}
|
||||||
>
|
>
|
||||||
<MonitorStatusCard summary={MOCK_SUMMARY} />
|
<MonitorStatusCard summary={MOCK_SUMMARY} />
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import type { MonitorType } from "@/Types/Monitor";
|
||||||
|
|
||||||
export interface DashboardTypeCount {
|
export interface DashboardTypeCount {
|
||||||
type: string;
|
type: MonitorType;
|
||||||
count: number;
|
count: number;
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ const Routes = () => {
|
|||||||
>
|
>
|
||||||
<Route
|
<Route
|
||||||
path="/"
|
path="/"
|
||||||
element={<Navigate to="/dashboard" />}
|
element={<Navigate to="/uptime" />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="dashboard"
|
path="dashboard"
|
||||||
|
|||||||
@@ -60,6 +60,14 @@ export const monitorTypeLabelKey: Record<SelectableMonitorType, string> &
|
|||||||
pagespeed: "optionPagespeed",
|
pagespeed: "optionPagespeed",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getMonitorTypeLabel = (
|
||||||
|
type: MonitorType,
|
||||||
|
t: (key: string) => string
|
||||||
|
): string => {
|
||||||
|
const monitorLabel = monitorTypeLabelKey[type];
|
||||||
|
return monitorLabel ? t(`pages.common.monitors.monitorTypes.${monitorLabel}`) : type;
|
||||||
|
};
|
||||||
|
|
||||||
export const MonitorIntervalOptions = [
|
export const MonitorIntervalOptions = [
|
||||||
{ value: 15000, labelKey: "fifteenSeconds" },
|
{ value: 15000, labelKey: "fifteenSeconds" },
|
||||||
{ value: 30000, labelKey: "thirtySeconds" },
|
{ value: 30000, labelKey: "thirtySeconds" },
|
||||||
|
|||||||
Reference in new issue
Block a user