ADD: rounded some numbers and changed that only strings are sended to the ws
This commit is contained in:
@@ -4,6 +4,7 @@ import { useForm, SubmitHandler } from "react-hook-form"
|
|||||||
import Form from 'react-bootstrap/Form';
|
import Form from 'react-bootstrap/Form';
|
||||||
import FloatingLabel from 'react-bootstrap/FloatingLabel';
|
import FloatingLabel from 'react-bootstrap/FloatingLabel';
|
||||||
import InputGroup from 'react-bootstrap/InputGroup';
|
import InputGroup from 'react-bootstrap/InputGroup';
|
||||||
|
import round from "../Utils";
|
||||||
|
|
||||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
|
|
||||||
@@ -14,7 +15,8 @@ import './controls.css'
|
|||||||
|
|
||||||
function EntityControl(props)
|
function EntityControl(props)
|
||||||
{
|
{
|
||||||
|
const RoundPrecision = 2;
|
||||||
|
const RoundPrecisionPosition = 4;
|
||||||
|
|
||||||
|
|
||||||
const [Entity, setEntity] = useState(undefined);
|
const [Entity, setEntity] = useState(undefined);
|
||||||
@@ -33,20 +35,20 @@ function EntityControl(props)
|
|||||||
|
|
||||||
if(props.Entity !== undefined)
|
if(props.Entity !== undefined)
|
||||||
{
|
{
|
||||||
console.log(props.Entity)
|
// console.log(props.Entity)
|
||||||
if(Entity === undefined)
|
if(Entity === undefined)
|
||||||
{
|
{
|
||||||
setEntity(props.Entity);
|
setEntity(props.Entity);
|
||||||
setFormData({name:props.Entity.Name,course:props.Entity.Course,speed:props.Entity.Speed,position:props.Entity.Position,height:props.Entity.Height })
|
setFormData({name:props.Entity.Name,course:props.Entity.Course,speed:props.Entity.Speed,position:props.Entity.Position,height:round(props.Entity.Height,RoundPrecision) })
|
||||||
|
|
||||||
}else if(Entity.id !== props.Entity.id)
|
}else if(Entity.id !== props.Entity.id)
|
||||||
{
|
{
|
||||||
setEntity(props.Entity);
|
setEntity(props.Entity);
|
||||||
setFormData({name:props.Entity.Name,course:props.Entity.Course,speed:props.Entity.Speed,position:props.Entity.Position,height:props.Entity.Height})
|
setFormData({name:props.Entity.Name,course:props.Entity.Course,speed:props.Entity.Speed,position:props.Entity.Position,height:round(props.Entity.Height,RoundPrecision)})
|
||||||
|
|
||||||
} else if(Entity.id === props.Entity.id && Entity.Position !== props.Entity.Position)
|
} else if(Entity.id === props.Entity.id && Entity.Position !== props.Entity.Position)
|
||||||
{
|
{
|
||||||
setFormData({...formData,position:props.Entity.Position,height:props.Entity.Height})
|
setFormData({...formData,position:props.Entity.Position,height:round(props.Entity.Height,RoundPrecision)})
|
||||||
setPositionDragged(true);
|
setPositionDragged(true);
|
||||||
|
|
||||||
|
|
||||||
@@ -235,8 +237,8 @@ const handleClick = (e) => {
|
|||||||
Name: formData.name,
|
Name: formData.name,
|
||||||
Speed: formData.speed.toString(),
|
Speed: formData.speed.toString(),
|
||||||
Course: formData.course.toString(),
|
Course: formData.course.toString(),
|
||||||
Position: formData.position,
|
Position: [formData.position[0].toString(),formData.position[1].toString()],
|
||||||
Height: formData.height,
|
Height: formData.height.toString(),
|
||||||
SetPosition: true
|
SetPosition: true
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -257,8 +259,8 @@ const handleClick = (e) => {
|
|||||||
ID: Entity.id,
|
ID: Entity.id,
|
||||||
Speed: formData.speed.toString(),
|
Speed: formData.speed.toString(),
|
||||||
Course: formData.course.toString(),
|
Course: formData.course.toString(),
|
||||||
Position: formData.position,
|
Position: [formData.position[0].toString(),formData.position[1].toString()],
|
||||||
Height: formData.height,
|
Height: formData.height.toString(),
|
||||||
SetPosition: setPos
|
SetPosition: setPos
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -353,14 +355,14 @@ const handleClick = (e) => {
|
|||||||
<div class="div7">
|
<div class="div7">
|
||||||
<div class="input-group mb-3 NumberInputsGroup">
|
<div class="input-group mb-3 NumberInputsGroup">
|
||||||
<span class="input-group-text">Lat</span>
|
<span class="input-group-text">Lat</span>
|
||||||
<input className="ControlInput NumberInputs" name="Lat" type="text" onChange={handleInput} value={formData.position[0]} />
|
<input className="ControlInput NumberInputs" name="Lat" type="text" onChange={handleInput} value={round(formData.position[0],RoundPrecisionPosition)} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="div8">
|
<div class="div8">
|
||||||
<div class="input-group mb-3 NumberInputsGroup" >
|
<div class="input-group mb-3 NumberInputsGroup" >
|
||||||
<span class="input-group-text">Lon</span>
|
<span class="input-group-text">Lon</span>
|
||||||
{/* <input className="ControlInput" name="Lat" readOnly={true} type="text" onClick={handleClick} value={formData.position[0]} /> */}
|
{/* <input className="ControlInput" name="Lat" readOnly={true} type="text" onClick={handleClick} value={formData.position[0]} /> */}
|
||||||
<input className="ControlInput NumberInputs" name="Lon" readOnly={true} type="text" onClick={handleClick} onChange={handleInput} value={formData.position[1]}/>
|
<input className="ControlInput NumberInputs" name="Lon" readOnly={true} type="text" onClick={handleClick} onChange={handleInput} value={round(formData.position[1],RoundPrecisionPosition)}/>
|
||||||
</div>
|
</div>
|
||||||
{/* <div className="flex">
|
{/* <div className="flex">
|
||||||
<div className="ControlHeader">Lon:</div>
|
<div className="ControlHeader">Lon:</div>
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class Tracklist extends React.Component
|
|||||||
<td >{val.Name}</td>
|
<td >{val.Name}</td>
|
||||||
<td className='TracklistCell'>{val.Course}</td>
|
<td className='TracklistCell'>{val.Course}</td>
|
||||||
<td className='TracklistCell'>{val.Speed}</td>
|
<td className='TracklistCell'>{val.Speed}</td>
|
||||||
<td className='TracklistCell'>{round(val.Position[0],3)}</td>
|
<td className='TracklistCell'>{round(val.Position[0],4)}</td>
|
||||||
<td className='TracklistCell'>{round(val.Position[1],3)}</td>
|
<td className='TracklistCell'>{round(val.Position[1],4)}</td>
|
||||||
<td className='TracklistCell'>{val.Type}</td>
|
<td className='TracklistCell'>{val.Type}</td>
|
||||||
<td className='TracklistCell'>{val.Side}</td>
|
<td className='TracklistCell'>{val.Side}</td>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user