Path: blob/trunk/javascript/grid-ui/src/components/NavBar/OverallConcurrency.tsx
2887 views
// Licensed to the Software Freedom Conservancy (SFC) under one1// or more contributor license agreements. See the NOTICE file2// distributed with this work for additional information3// regarding copyright ownership. The SFC licenses this file4// to you under the Apache License, Version 2.0 (the5// "License"); you may not use this file except in compliance6// with the License. You may obtain a copy of the License at7//8// http://www.apache.org/licenses/LICENSE-2.09//10// Unless required by applicable law or agreed to in writing,11// software distributed under the License is distributed on an12// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13// KIND, either express or implied. See the License for the14// specific language governing permissions and limitations15// under the License.1617import React from 'react'18import {19Box,20CircularProgress,21CircularProgressProps,22Typography23} from '@mui/material'2425function CircularProgressWithLabel (props: CircularProgressProps & { value: number }): JSX.Element {26return (27<Box position='relative' display='inline-flex'>28<CircularProgress variant='determinate' size={80} {...props} />29<Box30top={0}31left={0}32bottom={0}33right={0}34position='absolute'35display='flex'36alignItems='center'37justifyContent='center'38>39<Typography variant='h4' component='div' color='textSecondary'>40{`${Math.round(props.value)}%`}41</Typography>42</Box>43</Box>44)45}4647function OverallConcurrency (props) {48const { maxSession, sessionCount } = props49const currentLoad = Math.min(50((sessionCount / (maxSession === 0 ? 1 : maxSession)) * 100), 100)5152return (53<Box54p={2}55m={2}56data-testid='overall-concurrency'57>58<Typography59align='center'60gutterBottom61variant='h4'62>63Concurrency64</Typography>65<Box66display='flex'67justifyContent='center'68mt={2}69mb={2}70data-testid='concurrency-usage'71>72<CircularProgressWithLabel value={currentLoad} />73</Box>74<Typography75align='center'76variant='h4'77>78<Box display='inline' data-testid='session-count'>79{sessionCount}80</Box>81{' / '}82<Box display='inline' data-testid='max-session'>83{maxSession}84</Box>85</Typography>86</Box>87)88}8990export default OverallConcurrency919293