Skip to content

Commit 6eecd00

Browse files
committed
[grid] Adding an overall Grid status to the UI
1 parent 80bd262 commit 6eecd00

File tree

6 files changed

+69
-10
lines changed

6 files changed

+69
-10
lines changed

java/server/src/org/openqa/selenium/grid/graphql/Grid.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ public int getTotalSlots() {
113113
.sum();
114114
}
115115

116-
public int getUsedSlots() {
117-
return getSessionCount();
116+
public int getMaxSession() {
117+
return distributorStatus.get().getNodes().stream()
118+
.mapToInt(NodeStatus::getMaxSessionCount)
119+
.sum();
118120
}
119121

120122
public int getSessionQueueSize() {

java/server/src/org/openqa/selenium/grid/graphql/selenium-grid-schema.graphqls

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type GridQuery {
6565
type Grid {
6666
uri: Uri!
6767
totalSlots: Int!
68-
usedSlots: Int!
68+
maxSession: Int!
6969
sessionCount: Int!
7070
version: String!
7171
sessionQueueSize: Int!

javascript/grid-ui/src/components/NavBar/NavBar.tsx

+56-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import DashboardIcon from "@material-ui/icons/Dashboard";
1111
import AssessmentIcon from '@material-ui/icons/Assessment';
1212
import clsx from 'clsx';
1313
import * as React from 'react';
14+
import {Box, CircularProgress, CircularProgressProps, Typography} from "@material-ui/core";
1415

1516
const drawerWidth = 240;
1617

@@ -48,15 +49,41 @@ const useStyles = makeStyles((theme) => ({
4849
width: theme.spacing(9),
4950
},
5051
},
52+
concurrencyBackground: {
53+
backgroundColor: theme.palette.secondary.main,
54+
},
5155
}));
5256

5357
function ListItemLink(props) {
5458
return <ListItem button component="a" {...props} />;
5559
}
5660

61+
function CircularProgressWithLabel(props: CircularProgressProps & { value: number }) {
62+
return (
63+
<Box position="relative" display="inline-flex">
64+
<CircularProgress variant="determinate" size={80} {...props} />
65+
<Box
66+
top={0}
67+
left={0}
68+
bottom={0}
69+
right={0}
70+
position="absolute"
71+
display="flex"
72+
alignItems="center"
73+
justifyContent="center"
74+
>
75+
<Typography variant="h4" component="div" color="textSecondary">{`${Math.round(
76+
props.value,
77+
)}%`}</Typography>
78+
</Box>
79+
</Box>
80+
);
81+
}
82+
5783
export default function NavBar(props) {
5884
const classes = useStyles();
59-
const open = props.open;
85+
const {open, maxSession, sessionCount} = props;
86+
const currentLoad = Math.min(((sessionCount / maxSession) * 100), 100);
6087

6188
return (
6289
<Drawer
@@ -88,8 +115,34 @@ export default function NavBar(props) {
88115
</ListItemLink>
89116
</div>
90117
</List>
91-
{/*<Divider/>*/}
92-
{/*<List>{secondaryListItems}</List>*/}
118+
<Box flexGrow={1}/>
119+
<Box
120+
p={2}
121+
m={2}
122+
className={classes.concurrencyBackground}
123+
>
124+
<Typography
125+
align="center"
126+
gutterBottom
127+
variant="h4"
128+
>
129+
Concurrency
130+
</Typography>
131+
<Box
132+
display="flex"
133+
justifyContent="center"
134+
mt={2}
135+
mb={2}
136+
>
137+
<CircularProgressWithLabel value={currentLoad}/>
138+
</Box>
139+
<Typography
140+
align="center"
141+
variant="h4"
142+
>
143+
{sessionCount} / {maxSession}
144+
</Typography>
145+
</Box>
93146
</Drawer>
94147
);
95148
}

javascript/grid-ui/src/components/Node/Node.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default function Node(props) {
148148
</Typography>
149149
</DialogContent>
150150
<DialogActions>
151-
<Button onClick={handleDialogClose} color="primary" variant="outlined">
151+
<Button onClick={handleDialogClose} color="primary" variant="contained">
152152
Close
153153
</Button>
154154
</DialogActions>
@@ -242,7 +242,7 @@ export default function Node(props) {
242242
</Grid>
243243
<Grid item xs={12}
244244
>
245-
<LinearProgressWithLabel value={currentLoad as any}/>
245+
<LinearProgressWithLabel value={currentLoad as number}/>
246246
</Grid>
247247
</Grid>
248248
</Grid>

javascript/grid-ui/src/components/TopBar/TopBar.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export default function TopBar() {
7171
if (error) return <p>`Error! ${error.message}`</p>;
7272

7373
const gridVersion = data.grid.version;
74+
const maxSession = data.grid.maxSession;
75+
const sessionCount = data.grid.sessionCount ?? 0;
7476

7577
return (
7678
<div className={classes.root}>
@@ -121,7 +123,7 @@ export default function TopBar() {
121123
</Box>
122124
</Toolbar>
123125
</AppBar>
124-
<NavBar open={open}/>
126+
<NavBar open={open} maxSession={maxSession} sessionCount={sessionCount}/>
125127
</div>
126128
);
127129
}

javascript/grid-ui/src/graphql/grid.gql

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ query Summary {
22
grid {
33
uri
44
totalSlots
5-
usedSlots
5+
maxSession
6+
sessionCount
7+
sessionQueueSize
68
version
79
}
810
}

0 commit comments

Comments
 (0)