diff --git a/frontend/src/sections/devices/devices-discovery.js b/frontend/src/sections/devices/devices-discovery.js
index 882b67c..cd93e42 100644
--- a/frontend/src/sections/devices/devices-discovery.js
+++ b/frontend/src/sections/devices/devices-discovery.js
@@ -8,18 +8,60 @@ import {
ListItem,
ListItemText,
Box,
+ Dialog,
+ DialogActions,
+ DialogContent,
+ DialogContentText,
+ DialogTitle,
+ TextField,
+ Button,
+ Backdrop,
} from '@mui/material';
import CircularProgress from '@mui/material/CircularProgress';
import PlusCircleIcon from '@heroicons/react/24/outline/PlusCircleIcon';
+import Pencil from "@heroicons/react/24/outline/PencilIcon"
import ArrowUturnLeftIcon from '@heroicons/react/24/outline/ArrowUturnLeftIcon'
+import XMarkIcon from '@heroicons/react/24/outline/XMarkIcon';
+
import { useRouter } from 'next/router';
-function ShowParamsWithValues({x, deviceParametersValue}) {
- console.log("estoy aqui")
+const AccessType = {
+ ReadOnly: 0,
+ ReadWrite: 1,
+ WriteOnly: 2,
+}
+
+const ParamValueType = {
+ Unknown: 0,
+ Base64: 1,
+ Boolean: 2,
+ DateTime: 3,
+ Decimal: 4,
+ HexBinary: 5,
+ Int: 6,
+ Long: 7,
+ String: 8,
+ UnisgnedInt: 9,
+ UnsignedLong: 10,
+}
+
+function ShowParamsWithValues({x, deviceParametersValue, setOpen, setParameter, setParameterValue}) {
+ console.log("HEY jow:", deviceParametersValue)
let paths = x.supported_obj_path.split(".")
- console.log(paths)
+ const showDialog = (param, paramvalue) => {
+ setParameter(param);
+ if (paramvalue == "\"\"") {
+ setParameterValue("")
+ }else{
+ setParameterValue(paramvalue);
+ }
+ setOpen(true);
+ }
+
if(paths[paths.length -2] == "{i}"){
return Object.keys(deviceParametersValue).map((paramKey, h)=>{
+ console.log(deviceParametersValue)
+ console.log(paramKey)
return (
- {deviceParametersValue[paramKey].map((param, i) => {
- console.log("opa")
+ {deviceParametersValue[paramKey].length > 0 ?
+ deviceParametersValue[paramKey].map((param, i) => {
return (
- {Object.values(param)[0]}
+ {Object.values(param)[0].value}
+ {Object.values(param)[0].access > AccessType.ReadOnly &&
+ {
+ showDialog(
+ paramKey+Object.keys(param)[0],
+ Object.values(param)[0].value)
+ }
+ }>
+
+
+
+
+ }
}
>
@@ -62,7 +117,7 @@ function ShowParamsWithValues({x, deviceParametersValue}) {
)
- })}
+ }):<>>}
)
})
@@ -84,7 +139,20 @@ function ShowParamsWithValues({x, deviceParametersValue}) {
}}
secondaryAction={
- {deviceParametersValue[y.param_name]}
+ {deviceParametersValue[y.param_name].value}
+ {deviceParametersValue[y.param_name].access > AccessType.ReadOnly &&
+ {
+ showDialog(
+ x.supported_obj_path + y.param_name,
+ deviceParametersValue[y.param_name].value)
+ }
+ }>
+
+
+
+
+ }
}
>
@@ -102,7 +170,14 @@ export const DevicesDiscovery = () => {
const router = useRouter()
const [deviceParameters, setDeviceParameters] = useState(null)
+const [parameter, setParameter] = useState(null)
+const [parameterValue, setParameterValue] = useState(null)
+const [parameterValueChange, setParameterValueChange] = useState(null)
const [deviceParametersValue, setDeviceParametersValue] = useState({})
+const [open, setOpen] = useState(false)
+const [errorModal, setErrorModal] = useState(false)
+const [errorModalText, setErrorModalText] = useState("")
+const [showLoading, setShowLoading] = useState(false)
const initialize = async (raw) => {
let content = await getDeviceParameters(raw)
@@ -286,12 +361,34 @@ const getDeviceParameterInstances = async (raw) =>{
console.log("content:",content)
+ let paramsInfo = {}
+
let supportedParams = content.req_obj_results[0].supported_objs[0].supported_params
let parametersToFetch = () => {
let paramsToFetch = []
for (let i =0; i < supportedParams.length ;i++){
+
let supported_obj_path = content.req_obj_results[0].supported_objs[0].supported_obj_path.replaceAll("{i}","*")
- paramsToFetch.push(supported_obj_path+supportedParams[i].param_name)
+ let param = supportedParams[i]
+
+ paramsToFetch.push(supported_obj_path+param.param_name)
+
+ let paths = supported_obj_path.split(".")
+ if (paths[paths.length -2] !== "*"){
+ paramsInfo[param.param_name] = {
+ "value_change":param["value_change"],
+ "value_type":param["value_type"],
+ "access": param["access"],
+ "value": "-",
+ }
+ }else{
+ paramsInfo[param.param_name] = {
+ "value_change":param["value_change"],
+ "value_type":param["value_type"],
+ "access": param["access"],
+ "value":"-",
+ }
+ }
}
return paramsToFetch
}
@@ -307,58 +404,55 @@ const getDeviceParameterInstances = async (raw) =>{
let result = await getDeviceParametersValue(raw)
console.log("result:", result)
-
+ console.log("/-------------------------------------------------------/")
let values = {}
- // let setvalues = () => {resultValues.req_path_results.map((x)=>{
- // // let path = x.requested_path.split(".")
- // // let param = path[path.length -1]
- // if (!x.resolved_path_results){
- // return
- // }
-
- // Object.keys(x.resolved_path_results[0].result_params).forEach((key, index) =>{
- // values[key] = x.resolved_path_results[0].result_params[key]
- // })
- // return values
- // })}
- // setvalues()
-
- let setvalues = () => {result.req_path_results.map((x)=>{
+ console.log("VALUES:",values)
+ result.req_path_results.map((x)=>{
if (!x.resolved_path_results){
+ values[x.requested_path] = {}
+ setDeviceParametersValue(values)
return
}
let paths = x.requested_path.split(".")
if(paths[paths.length -2] == "*"){
x.resolved_path_results.map(y=>{
- if (values[y.resolved_path]){
- values[y.resolved_path].push(y.result_params)
- }else{
+ console.log(y.result_params)
+ console.log(y.resolved_path)
+ let key = Object.keys(y.result_params)[0]
+ console.log(key)
+ console.log(paramsInfo[key].value)
+ console.log(paramsInfo[key])
+ console.log(y.result_params[key])
+ console.log({[key]:paramsInfo[key]})
+ console.log("Take a look here mate: ",{...paramsInfo[key], value: y.result_params[key]})
+ if (!values[y.resolved_path]){
values[y.resolved_path] = []
- values[y.resolved_path].push(y.result_params)
}
- // Object.keys(y.result_params).forEach((key, index) =>{
- // if (values[y.resolved_path]){
- // values[y.resolved_path].push(y.result_params)
- // }else{
- // values[y.resolved_path] = []
- // values[y.resolved_path].push(y.result_params)
- // }
- // })
+ if (y.result_params[key] == ""){
+ y.result_params[key] = "\"\""
+ }
+ values[y.resolved_path].push({[key]:{...paramsInfo[key], value: y.result_params[key]}})
})
}else{
Object.keys(x.resolved_path_results[0].result_params).forEach((key, index) =>{
- values[key] = x.resolved_path_results[0].result_params[key]
+ if (x.resolved_path_results[0].result_params[key] != ""){
+ paramsInfo[key].value = x.resolved_path_results[0].result_params[key]
+ }else{
+ paramsInfo[key].value = "\"\""
+ }
+ values = paramsInfo
})
}
- return values
- })}
- setvalues()
- console.log(values)
- setDeviceParametersValue(values)
+ console.log(values)
+ setDeviceParametersValue(values)
+ })
+
+ console.log("/-------------------------------------------------------/")
setDeviceParameters(content)
}else{
+ console.log("fixme")
setDeviceParameters(content)
}
}
@@ -385,6 +479,10 @@ const getDeviceParameterInstances = async (raw) =>{
}
+ function isInteger(value) {
+ return /^\d+$/.test(value);
+ }
+
const showParameters = () => {
return deviceParameters.req_obj_results.map((a,b)=>{
return a.supported_objs.map((x,i)=> {
@@ -468,8 +566,14 @@ const getDeviceParameterInstances = async (raw) =>{
sx={{fontWeight:'bold'}}
/>
- { x.supported_params &&
-
+ { x.supported_params && deviceParametersValue &&
+
}
{ x.supported_commands &&
x.supported_commands.map((y)=>{
@@ -527,6 +631,158 @@ const getDeviceParameterInstances = async (raw) =>{
{showParameters()}
+
+
+ theme.zIndex.drawer + 1,
+ overflow: 'hidden'
+ }}
+ open={showLoading}
+ >
+
+
: