-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/fe/infrastructure details connect to be #1172
Changes from all commits
90acb72
afee715
d12420e
e239a72
a0694d4
3053d63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ const Field = forwardRef( | |
return ( | ||
<Stack | ||
gap={theme.spacing(2)} | ||
className={`${className ?? `field field-${type}`}`} | ||
className={`field field-${type} ${className}`} | ||
sx={{ | ||
"& fieldset": { | ||
borderColor: theme.palette.border.dark, | ||
|
@@ -186,11 +186,11 @@ const Field = forwardRef( | |
), | ||
}} | ||
/> | ||
{ error && ( | ||
{error && ( | ||
<Typography | ||
component="span" | ||
className="input-error" | ||
hidden={className? true: false} | ||
hidden={className ? true : false} | ||
Comment on lines
+189
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mom's spaghetti moment: Error visibility logic needs rethinking! Using Consider one of these approaches:
- hidden={className ? true : false}
+ {/* Remove this prop and handle error visibility at the parent level */}
🧰 Tools🪛 Biome[error] 193-193: Unnecessary use of boolean literals in conditional expression. Simplify your code by directly assigning the result without using a ternary operator. (lint/complexity/noUselessTernary) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jennifer-gan I addressed this in my PR as well 👍 |
||
color={theme.palette.error.main} | ||
mt={theme.spacing(2)} | ||
sx={{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,11 @@ import { Stack, Box, Typography } from "@mui/material"; | |
import { useTheme } from "@emotion/react"; | ||
import CustomGauge from "../../../Components/Charts/CustomGauge"; | ||
import AreaChart from "../../../Components/Charts/AreaChart"; | ||
import { useSelector } from "react-redux"; | ||
import { networkService } from "../../../main"; | ||
import PulseDot from "../../../Components/Animated/PulseDot"; | ||
import useUtils from "../../Monitors/utils"; | ||
import { formatDurationRounded, formatDurationSplit } from "../../../Utils/timeUtils"; | ||
import axios from "axios"; | ||
import { | ||
TzTick, | ||
PercentTick, | ||
|
@@ -167,6 +168,8 @@ const InfrastructureDetails = () => { | |
{ name: "details", path: `/infrastructure/${monitorId}` }, | ||
]; | ||
const [monitor, setMonitor] = useState(null); | ||
const { authToken } = useSelector((state) => state.auth); | ||
const [dateRange, setDateRange] = useState("day"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Heads up about that dateRange state, buddy! 🤔 The dateRange is hardcoded to "day" but there's no UI component to modify it. Consider adding a date range selector to give users more control over the data visualization. Example implementation: const dateRangeOptions = ["day", "week", "month"];
<Select
value={dateRange}
onChange={(e) => setDateRange(e.target.value)}
>
{dateRangeOptions.map(option => (
<MenuItem key={option} value={option}>
{option.charAt(0).toUpperCase() + option.slice(1)}
</MenuItem>
))}
</Select> |
||
const { statusColor, determineState } = useUtils(); | ||
// These calculations are needed because ResponsiveContainer | ||
// doesn't take padding of parent/siblings into account | ||
|
@@ -183,11 +186,14 @@ const InfrastructureDetails = () => { | |
useEffect(() => { | ||
const fetchData = async () => { | ||
try { | ||
const response = await axios.get("http://localhost:5000/api/v1/dummy-data", { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Cache-Control": "no-cache", | ||
}, | ||
const response = await networkService.getStatsByMonitorId({ | ||
authToken: authToken, | ||
monitorId: monitorId, | ||
sortOrder: null, | ||
limit: null, | ||
dateRange: dateRange, | ||
numToDisplay: 50, | ||
normalize: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to normalize results here, normalizing the data is used when we are displaying response time in a chart. Response time has an unbounded range so we need to normalize the data to have a reasonable visual representation. Since we're not diplaying response time here this can safely be set to false. |
||
}); | ||
setMonitor(response.data.data); | ||
} catch (error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jennifer-gan I'm really glad to see you picked up on this issue too! I just submitted a PR that does basically this, could you remove this from this PR so that this one is focused on the details page please? One feature or fix per PR 😄