Refactor GCodePreview and GCodeLegend Components for Improved Rendering and Interaction
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Updated GCodePreview to conditionally render the GCodeLegend based on line type, enhancing the user interface for different modes. - Simplified the loading overlay in GCodePreview for better visibility and responsiveness during loading states. - Replaced InputNumber with InputNumberCal in GCodeLegend for improved functionality and user experience. - Adjusted styles and layout in both components to ensure consistent presentation and interaction across different scenarios.
This commit is contained in:
parent
0e9b6392c2
commit
6daba1cec8
@ -710,6 +710,22 @@ function GCodePreview(props) {
|
|||||||
const loadingLabel = loader.planning
|
const loadingLabel = loader.planning
|
||||||
? 'Calculating motion...'
|
? 'Calculating motion...'
|
||||||
: `Parsing G-code... ${segmentCount.toLocaleString()} moves`
|
: `Parsing G-code... ${segmentCount.toLocaleString()} moves`
|
||||||
|
const isLineType = mode.kind === 'category'
|
||||||
|
const legend =
|
||||||
|
model && (ready || segmentCount > 0) ? (
|
||||||
|
<GCodeLegend
|
||||||
|
mode={mode}
|
||||||
|
model={model}
|
||||||
|
isDarkMode={isDarkMode}
|
||||||
|
hiddenTypes={hiddenTypes}
|
||||||
|
onToggleType={toggleType}
|
||||||
|
showTravel={showTravel}
|
||||||
|
onToggleTravel={() => setShowTravel((prev) => !prev)}
|
||||||
|
range={displayRange}
|
||||||
|
autoRange={autoRange || displayRange}
|
||||||
|
onRangeChange={handleRangeChange}
|
||||||
|
/>
|
||||||
|
) : null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
@ -808,22 +824,14 @@ function GCodePreview(props) {
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
|
{legend && !isLineType ? (
|
||||||
|
<Flex align='center' style={{ marginLeft: 'auto', flex: '0 0 auto' }}>
|
||||||
|
{legend}
|
||||||
|
</Flex>
|
||||||
|
) : null}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
{model && (ready || segmentCount > 0) ? (
|
{legend && isLineType ? legend : null}
|
||||||
<GCodeLegend
|
|
||||||
mode={mode}
|
|
||||||
model={model}
|
|
||||||
isDarkMode={isDarkMode}
|
|
||||||
hiddenTypes={hiddenTypes}
|
|
||||||
onToggleType={toggleType}
|
|
||||||
showTravel={showTravel}
|
|
||||||
onToggleTravel={() => setShowTravel((prev) => !prev)}
|
|
||||||
range={displayRange}
|
|
||||||
autoRange={autoRange || displayRange}
|
|
||||||
onRangeChange={handleRangeChange}
|
|
||||||
/>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
ref={paneRef}
|
ref={paneRef}
|
||||||
@ -887,27 +895,26 @@ function GCodePreview(props) {
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{loader.status === 'loading' ? (
|
{loader.status === 'loading' ? (
|
||||||
<div
|
<div className='previewProgressOverlay visible'>
|
||||||
style={{
|
<Flex
|
||||||
position: 'absolute',
|
style={{ width: '100%', height: '100%' }}
|
||||||
top: 12,
|
align='center'
|
||||||
left: '50%',
|
justify='center'
|
||||||
transform: 'translateX(-50%)',
|
|
||||||
zIndex: 3,
|
|
||||||
width: 'min(320px, calc(100% - 24px))',
|
|
||||||
pointerEvents: 'none'
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Card
|
<Card
|
||||||
size='small'
|
style={{
|
||||||
className='previewZoomCard'
|
maxWidth: 360,
|
||||||
style={{ borderRadius: 12 }}
|
minWidth: 100,
|
||||||
styles={{ body: { padding: '8px 12px' } }}
|
width: '100%',
|
||||||
|
margin: 24
|
||||||
|
}}
|
||||||
|
styles={{ body: { padding: 18 } }}
|
||||||
>
|
>
|
||||||
<ProgressDisplay percent={loadingPercent} status='active'>
|
<ProgressDisplay percent={loadingPercent} status='active'>
|
||||||
{loadingLabel}
|
{loadingLabel}
|
||||||
</ProgressDisplay>
|
</ProgressDisplay>
|
||||||
</Card>
|
</Card>
|
||||||
|
</Flex>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Button, Flex, InputNumber, Typography } from 'antd'
|
import { Button, Flex, Typography } from 'antd'
|
||||||
import { FEATURE, FEATURE_INFO } from './featureTypes.js'
|
import { FEATURE, FEATURE_INFO } from './featureTypes.js'
|
||||||
import { TOOL_PALETTE, rampCss } from './colorModes.js'
|
import { TOOL_PALETTE, rampCss } from './colorModes.js'
|
||||||
|
import InputNumberCal from '../../../Dashboard/common/InputNumberCal.jsx'
|
||||||
|
|
||||||
const { Text } = Typography
|
const { Text } = Typography
|
||||||
|
|
||||||
@ -151,21 +152,19 @@ function GCodeLegend({
|
|||||||
autoRange != null &&
|
autoRange != null &&
|
||||||
(range.min !== autoRange.min || range.max !== autoRange.max)
|
(range.min !== autoRange.min || range.max !== autoRange.max)
|
||||||
const isDuration = mode.stat === 'layerTime'
|
const isDuration = mode.stat === 'layerTime'
|
||||||
|
const unitSuffix = mode.unit || undefined
|
||||||
return (
|
return (
|
||||||
<Flex gap='small' align='center' wrap='wrap' justify='center'>
|
<Flex gap='small' align='center' wrap='wrap' justify='center'>
|
||||||
<Text style={{ color: textColor, fontSize: 14, lineHeight: 1 }}>
|
|
||||||
{mode.label}
|
|
||||||
</Text>
|
|
||||||
{isDuration ? (
|
{isDuration ? (
|
||||||
<Text style={{ color: textColor, fontSize: 14 }}>{format(min)}</Text>
|
<Text style={{ color: textColor, fontSize: 14 }}>{format(min)}</Text>
|
||||||
) : (
|
) : (
|
||||||
<InputNumber
|
<InputNumberCal
|
||||||
size='small'
|
|
||||||
value={Number(min.toFixed(2))}
|
value={Number(min.toFixed(2))}
|
||||||
onChange={(value) =>
|
onChange={(value) =>
|
||||||
Number.isFinite(value) && onRangeChange({ min: value, max })
|
Number.isFinite(value) && onRangeChange({ min: value, max })
|
||||||
}
|
}
|
||||||
style={{ width: 80 }}
|
suffix={unitSuffix}
|
||||||
|
style={{ width: 100 }}
|
||||||
controls={false}
|
controls={false}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@ -180,21 +179,16 @@ function GCodeLegend({
|
|||||||
{isDuration ? (
|
{isDuration ? (
|
||||||
<Text style={{ color: textColor, fontSize: 14 }}>{format(max)}</Text>
|
<Text style={{ color: textColor, fontSize: 14 }}>{format(max)}</Text>
|
||||||
) : (
|
) : (
|
||||||
<InputNumber
|
<InputNumberCal
|
||||||
size='small'
|
|
||||||
value={Number(max.toFixed(2))}
|
value={Number(max.toFixed(2))}
|
||||||
onChange={(value) =>
|
onChange={(value) =>
|
||||||
Number.isFinite(value) && onRangeChange({ min, max: value })
|
Number.isFinite(value) && onRangeChange({ min, max: value })
|
||||||
}
|
}
|
||||||
style={{ width: 80 }}
|
suffix={unitSuffix}
|
||||||
|
style={{ width: 100 }}
|
||||||
controls={false}
|
controls={false}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{mode.unit ? (
|
|
||||||
<Text type='secondary' style={{ fontSize: 12 }}>
|
|
||||||
{mode.unit}
|
|
||||||
</Text>
|
|
||||||
) : null}
|
|
||||||
{overridden ? (
|
{overridden ? (
|
||||||
<Button size='small' type='link' onClick={() => onRangeChange(null)}>
|
<Button size='small' type='link' onClick={() => onRangeChange(null)}>
|
||||||
Reset range
|
Reset range
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user