2021-01-31 09:53:00 +03:00
|
|
|
import React, { useContext, useState, useEffect } from 'react';
|
2021-01-31 12:38:20 +03:00
|
|
|
import { Typography, Slider } from 'antd';
|
2021-02-07 06:38:58 +03:00
|
|
|
import { ServerStatusContext } from '../../utils/server-status-context';
|
2021-01-31 09:53:00 +03:00
|
|
|
|
|
|
|
const { Title } = Typography;
|
|
|
|
|
|
|
|
const SLIDER_MARKS = {
|
|
|
|
1: 'lowest',
|
|
|
|
2: '',
|
|
|
|
3: '',
|
|
|
|
4: '',
|
|
|
|
5: 'highest',
|
|
|
|
};
|
|
|
|
|
2021-02-03 21:26:46 +03:00
|
|
|
const TOOLTIPS = {
|
|
|
|
1: 'lowest',
|
|
|
|
2: 'low',
|
|
|
|
3: 'medium',
|
|
|
|
4: 'high',
|
|
|
|
5: 'highest',
|
|
|
|
};
|
|
|
|
|
2021-01-31 12:38:20 +03:00
|
|
|
export default function CPUUsageSelector({ defaultValue, onChange }) {
|
2021-01-31 09:53:00 +03:00
|
|
|
const [selectedOption, setSelectedOption] = useState(null);
|
|
|
|
|
|
|
|
const serverStatusData = useContext(ServerStatusContext);
|
|
|
|
const { serverConfig } = serverStatusData || {};
|
|
|
|
const { videoSettings } = serverConfig || {};
|
|
|
|
|
|
|
|
if (!videoSettings) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setSelectedOption(defaultValue);
|
|
|
|
}, [videoSettings]);
|
2021-01-31 12:38:20 +03:00
|
|
|
|
2021-01-31 09:53:00 +03:00
|
|
|
const handleChange = value => {
|
2021-01-31 12:38:20 +03:00
|
|
|
setSelectedOption(value);
|
|
|
|
onChange(value);
|
2021-01-31 09:53:00 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2021-02-04 19:04:00 +03:00
|
|
|
<div className="config-video-segements-conatiner">
|
2021-01-31 09:53:00 +03:00
|
|
|
<Title level={3}>CPU Usage</Title>
|
2021-01-31 12:38:20 +03:00
|
|
|
<p>There are trade-offs when considering CPU usage blah blah more wording here.</p>
|
|
|
|
<br />
|
|
|
|
<br />
|
2021-02-04 19:04:00 +03:00
|
|
|
<div className="segment-slider-container">
|
2021-01-31 12:38:20 +03:00
|
|
|
<Slider
|
2021-02-04 19:04:00 +03:00
|
|
|
tipFormatter={value => TOOLTIPS[value]}
|
2021-01-31 09:53:00 +03:00
|
|
|
onChange={handleChange}
|
|
|
|
min={1}
|
|
|
|
max={Object.keys(SLIDER_MARKS).length}
|
|
|
|
marks={SLIDER_MARKS}
|
|
|
|
defaultValue={selectedOption}
|
|
|
|
value={selectedOption}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2021-01-31 12:38:20 +03:00
|
|
|
}
|