I am trying to do an HTML Widget. This is a table where some cells will have a dropdownlist with dynamic data from our devices. Where one columns will be “Devices” (with a dynamic list of the devices that we have) and another column “Group Devices” (with a dynamic list of the group devices that we have). Example:
But my main problem is that I don’t know how acces to this information (the devices and the groups devices that we have). I am trying this in the “script” part of the HTML:
/*
<script>
// Realiza una solicitud a la API de Thinger.io para obtener datos dinámicos
var apiURL = 'https://api.thinger.io/v2/users/MYUSERNAME/devices?type=MYVIRTUALTYPEDEVICE';
var token = 'MYTOKEN';
fetch(apiURL, {
method: 'GET',
headers: {
'Authorization': 'Bearer ' + token
}
})
.then(response => response.json())
.then(data => {
// Extrae los datos relevantes para las columnas
var devices = data.map(Devices => Devices.properties.name);
var groups = data.map(device => device.grupo);
*/
My problem is here, in trhe last two command lines:
var devices = data.map(Devices => Devices.properties.name);
var groups = data.map(device => device.grupo);
var devices = data.map(Devices => Devices.name);
var groups = data.map(device => device.asset_group);
Also, that endpoint should be v1 instead of v2. You can find the available endpoints at: Swagger UI or for your private instance at: <host>/swagger/index.html
To get the response structures you may use the developer tools of your browser while loading the device page for example, as the frontend is built on top of the API.
I continue having the same problem. I would like to get the information placed on the “Devices” menu, specifically to the fields marked with a red square (like in the image). They are not in “properties devices”
I would like to create a dynamic data dropdown list in a dahsboard, which show in these options the devices availables by the name of the devices. Nevertheles, I don’t know how to get to that information (to the name). I know that we could get information about the properties of the device (or bucket), and we could put the “name” as a property of the device (like in the next image), but it is duplicate information, because the information of the name already exists.
For other hand, in this case, I couldn’t use a source switcher widget. The main objective is creating a table for showing which products are in X groups. A source switcher widget just let me show one device i one panel of a dashboard.