Skip to content

Commit b5e5079

Browse files
committed
this will add metricProps type
1 parent 0b9e0c7 commit b5e5079

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/components/tabs/Metrics.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ import React from 'react';
44
import { Chart } from 'react-chartjs-2';
55
import LineChartDisplay from '../display/LineChartDisplay';
66
import { useSelector } from 'react-redux';
7-
import { ContainerProps, hostStats, containersList } from '../../../types';
8-
import { RootState, AppDispatch } from '../../renderer/store';
7+
import { MetricsProps } from '../../../types';
98

109
/**
1110
* Display general metrics
1211
*
1312
* @param {*} props
1413
*/
15-
const Metrics = (props : any) => {
14+
const Metrics = (props: MetricsProps) => {
1615
const fullRunningList = props.runningList;
1716
const hostStats = useSelector((state: any) => state.containersList.hostStats);
1817
const cpuData = 100 - hostStats.cpuPerc;

src/components/views/Admin.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const AdminView = () => {
5757
const runningList = useSelector((state: StateType) => state.containersList.runningList);
5858
const stoppedList = useSelector((state: StateType) => state.containersList.stoppedList);
5959
const imagesList = useSelector((state: StateType) => state.images.imagesList);
60+
const { mem_threshold, cpu_threshold } = useSelector((state: StateType) => state.session);
6061
// const networkList = useSelector((state: StateType) => state.networkList.networkList);
6162

6263
const arrayOfVolumeNames = useSelector(
@@ -249,7 +250,7 @@ const AdminView = () => {
249250
<Route
250251
path='/metrics'
251252
element={
252-
<Metrics runningList={runningList} />
253+
<Metrics runningList={runningList} threshold={[cpu_threshold, mem_threshold]}/>
253254
}
254255
/>
255256
<Route

src/components/views/UserView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const UserView = () => {
5656
const runningList = useSelector((state: StateType) => state.containersList.runningList);
5757
const stoppedList = useSelector((state: StateType) => state.containersList.stoppedList);
5858
const imagesList = useSelector((state: StateType) => state.images.imagesList);
59+
const { mem_threshold, cpu_threshold } = useSelector((state: StateType) => state.session);
5960
// const networkList = useSelector((state: StateType) => state.networkList.networkList);
6061
const arrayOfVolumeNames = useSelector((state: StateType) => state.volumeList.arrayOfVolumeNames);
6162
const volumeContainersList = useSelector((state: StateType) => state.volumeList.volumeContainersList);
@@ -237,7 +238,7 @@ const UserView = () => {
237238
<Route
238239
path='/metrics'
239240
element={
240-
<Metrics runningList={runningList} />
241+
<Metrics runningList={runningList} threshold={[cpu_threshold, mem_threshold]}/>
241242
}
242243
/>
243244

types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export type ContainerProps = {
4444
hostStats?: hostStats[];
4545
}
4646

47+
export type MetricsProps = {
48+
runningList: any[];
49+
threshold: any[];
50+
}
51+
4752
// Stopped containers have a Names key and running containers have a Name key
4853
export type ContainerType = {
4954
Name?: string;
@@ -251,7 +256,7 @@ interface session {
251256
export interface containersList {
252257
runningList: any[],
253258
stoppedList: any[],
254-
hostStats: any,
259+
hostStats: string[],
255260
}
256261

257262
interface imagesList {

0 commit comments

Comments
 (0)