ADD: added possibility to drag marker and get the new position for updating a entity

This commit is contained in:
hwinkel
2023-10-01 10:22:37 +02:00
parent 3a3901fbec
commit 229a4d7906
4 changed files with 91 additions and 21 deletions

View File

@@ -4,7 +4,7 @@ import './controls.css'
import Tracklist from './Tracklist'
import EntityControl from './EntityControl';
import {w3cwebsocket as W3CWebSocket} from "websocket"
// import {w3cwebsocket as W3CWebSocket} from "websocket"
// const config = {
@@ -16,7 +16,10 @@ import {w3cwebsocket as W3CWebSocket} from "websocket"
// const client = new W3CWebSocket("ws://"+config.apiUrl+":"+config.apiProt+"/");
const round = (n, dp) => {
const h = +('1'.padEnd(dp + 1, '0')) // 10 or 100 or 1000 or etc
return Math.round(n * h) / h
}
class Controls extends React.Component
{
@@ -41,17 +44,28 @@ state = {
render() {
function getEntityFromID(Entities, SelectedKey)
function getEntityFromID(Entities, SelectedEntity)
{
let tmp = [];
Entities.map((val,index) => {
if(val.id === SelectedKey)
if(SelectedEntity !== undefined)
{
tmp = val
let tmp = [];
Entities.map((val) => {
if(val.id === SelectedEntity.Name)
{
tmp = val
if(SelectedEntity.NewPos !== undefined)
{
tmp.OldPos = val.Position;
tmp.Position[0] = round(SelectedEntity.NewPos[0],3);
tmp.Position[1] = round(SelectedEntity.NewPos[1],3);
}
tmp.NewPos = SelectedEntity.NewPos;
}
})
return tmp;
}
})
return tmp;
}