Skip to content

Commit

Permalink
ui/nodes: Add flow typing for Node Metrics
Browse files Browse the repository at this point in the history
Refs: #2925
  • Loading branch information
alexis-ld committed Feb 3, 2021
1 parent a546bf9 commit 1894b77
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
16 changes: 13 additions & 3 deletions ui/src/containers/NodePageMetricsTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { useHistory } from 'react-router';
import styled from 'styled-components';
import { padding, fontSize } from '@scality/core-ui/dist/style/theme';
import { LineChart, Loader, Dropdown, Button, Toggle } from '@scality/core-ui';
import { updateNodeStatsFetchArgumentAction } from '../ducks/app/monitoring';
import {
updateNodeStatsFetchArgumentAction,
MonitoringMetrics,
} from '../ducks/app/monitoring';
import {
yAxisUsage,
yAxis,
Expand Down Expand Up @@ -63,8 +66,15 @@ const CheckboxContainer = styled.div`
}
`;

const NodePageMetricsTab = (props) => {
const { nodeStats, instanceIP, avgStats } = props;
const NodePageMetricsTab = ({
nodeStats,
instanceIP,
avgStats,
}: {
nodeStats: MonitoringMetrics,
instanceIP: string,
avgStats: MonitoringMetrics,
}) => {
const dispatch = useDispatch();
const theme = useSelector((state) => state.config.theme);
const history = useHistory();
Expand Down
33 changes: 21 additions & 12 deletions ui/src/ducks/app/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ const defaultState = {
unameInfo: [],
};

type MonitoringMetricValue = [number, string];
type MonitoringMetric = {
metric: any,
values: MonitoringMetricValue,
};
export type MonitoringMetrics = {
cpuUsage: MonitoringMetric,
systemLoad: MonitoringMetric,
memory: MonitoringMetric,
iopsRead: MonitoringMetric,
iopsWrite: MonitoringMetric,
controlPlaneNetworkBandwidthIn: MonitoringMetric,
controlPlaneNetworkBandwidthOut: MonitoringMetric,
workloadPlaneNetworkBandwidthIn: MonitoringMetric,
workloadPlaneNetworkBandwidthOut: MonitoringMetric,
queryStartingTime: number,
};

export type MonitoringState = {
alert: {
list: any[], // todo, type alert
Expand Down Expand Up @@ -182,18 +200,9 @@ export type MonitoringState = {
instanceIP: string,
controlPlaneInterface: string,
workloadPlaneInterface: string,
metrics: {
cpuUsage: any[], // todo, identify this type
systemLoad: any[], // todo, identify this type
memory: any[], // todo, identify this type
iopsRead: any[], // todo, identify this type
iopsWrite: any[], // todo, identify this type
controlPlaneNetworkBandwidthIn: any[], // todo, identify this type
controlPlaneNetworkBandwidthOut: any[], // todo, identify this type
workloadPlaneNetworkBandwidthIn: any[], // todo, identify this type
workloadPlaneNetworkBandwidthOut: any[], // todo, identify this type
queryStartingTime: number,
},
metrics: MonitoringMetrics,
metricsAvg: MonitoringMetrics,
showAvg: boolean,
isRefreshing: boolean,
},
unameInfo: any[], // todo, identify this type
Expand Down

0 comments on commit 1894b77

Please sign in to comment.