chore(frontend): add modal to edit parameter
This commit is contained in:
parent
88fca6dbad
commit
214151c7ce
|
|
@ -7,6 +7,14 @@ import {
|
||||||
List,
|
List,
|
||||||
ListItem,
|
ListItem,
|
||||||
ListItemText,
|
ListItemText,
|
||||||
|
Box,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogContentText,
|
||||||
|
DialogTitle,
|
||||||
|
TextField,
|
||||||
|
Button
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import CircularProgress from '@mui/material/CircularProgress';
|
import CircularProgress from '@mui/material/CircularProgress';
|
||||||
import PlusCircleIcon from '@heroicons/react/24/outline/PlusCircleIcon';
|
import PlusCircleIcon from '@heroicons/react/24/outline/PlusCircleIcon';
|
||||||
|
|
@ -20,8 +28,19 @@ const AccessType = {
|
||||||
WriteOnly: 2,
|
WriteOnly: 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShowParamsWithValues({x, deviceParametersValue}) {
|
function ShowParamsWithValues({x, deviceParametersValue, setOpen, setParameter, setParameterValue}) {
|
||||||
let paths = x.supported_obj_path.split(".")
|
let paths = x.supported_obj_path.split(".")
|
||||||
|
|
||||||
|
const showDialog = (param, paramvalue) => {
|
||||||
|
setParameter(param);
|
||||||
|
if (paramvalue == "\"\"") {
|
||||||
|
setParameterValue("")
|
||||||
|
}else{
|
||||||
|
setParameterValue(paramvalue);
|
||||||
|
}
|
||||||
|
setOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
if(paths[paths.length -2] == "{i}"){
|
if(paths[paths.length -2] == "{i}"){
|
||||||
return Object.keys(deviceParametersValue).map((paramKey, h)=>{
|
return Object.keys(deviceParametersValue).map((paramKey, h)=>{
|
||||||
return (
|
return (
|
||||||
|
|
@ -57,7 +76,13 @@ function ShowParamsWithValues({x, deviceParametersValue}) {
|
||||||
<div>
|
<div>
|
||||||
{Object.values(param)[0].value}
|
{Object.values(param)[0].value}
|
||||||
{Object.values(param)[0].access > 0 && <IconButton>
|
{Object.values(param)[0].access > 0 && <IconButton>
|
||||||
<SvgIcon sx={{width:'20px'}}>
|
<SvgIcon sx={{width:'20px'}}
|
||||||
|
onClick={()=>{
|
||||||
|
showDialog(
|
||||||
|
paramKey+Object.keys(param)[0],
|
||||||
|
Object.values(param)[0].value)
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
|
||||||
<Pencil></Pencil>
|
<Pencil></Pencil>
|
||||||
|
|
||||||
|
|
@ -96,7 +121,13 @@ function ShowParamsWithValues({x, deviceParametersValue}) {
|
||||||
<div>
|
<div>
|
||||||
{deviceParametersValue[y.param_name].value}
|
{deviceParametersValue[y.param_name].value}
|
||||||
{deviceParametersValue[y.param_name].access > 0 && <IconButton>
|
{deviceParametersValue[y.param_name].access > 0 && <IconButton>
|
||||||
<SvgIcon sx={{width:'20px'}}>
|
<SvgIcon sx={{width:'20px'}}
|
||||||
|
onClick={()=>{
|
||||||
|
showDialog(
|
||||||
|
x.supported_obj_path + y.param_name,
|
||||||
|
deviceParametersValue[y.param_name].value)
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
|
||||||
<Pencil></Pencil>
|
<Pencil></Pencil>
|
||||||
|
|
||||||
|
|
@ -119,7 +150,10 @@ export const DevicesDiscovery = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const [deviceParameters, setDeviceParameters] = useState(null)
|
const [deviceParameters, setDeviceParameters] = useState(null)
|
||||||
|
const [parameter, setParameter] = useState(null)
|
||||||
|
const [parameterValue, setParameterValue] = useState(null)
|
||||||
const [deviceParametersValue, setDeviceParametersValue] = useState({})
|
const [deviceParametersValue, setDeviceParametersValue] = useState({})
|
||||||
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
const initialize = async (raw) => {
|
const initialize = async (raw) => {
|
||||||
let content = await getDeviceParameters(raw)
|
let content = await getDeviceParameters(raw)
|
||||||
|
|
@ -497,7 +531,13 @@ const getDeviceParameterInstances = async (raw) =>{
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
{ x.supported_params &&
|
{ x.supported_params &&
|
||||||
<ShowParamsWithValues x={x} deviceParametersValue={deviceParametersValue}/>
|
<ShowParamsWithValues
|
||||||
|
x={x}
|
||||||
|
deviceParametersValue={deviceParametersValue}
|
||||||
|
setOpen={setOpen}
|
||||||
|
setParameter={setParameter}
|
||||||
|
setParameterValue={setParameterValue}
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
{ x.supported_commands &&
|
{ x.supported_commands &&
|
||||||
x.supported_commands.map((y)=>{
|
x.supported_commands.map((y)=>{
|
||||||
|
|
@ -555,6 +595,27 @@ const getDeviceParameterInstances = async (raw) =>{
|
||||||
<CardContent>
|
<CardContent>
|
||||||
{showParameters()}
|
{showParameters()}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
<Dialog open={open}
|
||||||
|
slotProps={{ backdrop: { style: { backgroundColor: 'rgba(255,255,255,0.5)' } } }}
|
||||||
|
>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText>
|
||||||
|
{parameter}
|
||||||
|
</DialogContentText>
|
||||||
|
<TextField
|
||||||
|
autoFocus
|
||||||
|
margin="dense"
|
||||||
|
id="parameterValue"
|
||||||
|
fullWidth
|
||||||
|
variant="standard"
|
||||||
|
defaultValue={parameterValue}
|
||||||
|
/>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button onClick={()=>{setOpen(false)}}>Cancel</Button>
|
||||||
|
<Button onClick={()=>{setOpen(false)}}>Apply</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
</Card>
|
</Card>
|
||||||
:
|
:
|
||||||
<Box sx={{display:'flex',justifyContent:'center'}}>
|
<Box sx={{display:'flex',justifyContent:'center'}}>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user