curl --location --request POST 'https://test.your-api-server.com/api/dashboards/507f1f77bcf86cd799439011/widgets' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Producción Total",
"type": "kpi",
"description": "Unidades producidas en tiempo real",
"config": {
"title": "Unidades Producidas",
"dataSource": "mqtt",
"useAutoTopic": false,
"mqttTopic": "nodered/produccion/total",
"icon": "trending-up",
"prefix": "",
"suffix": " units",
"decimals": 0,
"animated": true,
"showSparkline": true,
"dataExtraction": {
"type": "single-value",
"valuePath": "count",
"correctionFactor": 1
}
}
}'{
"msg": "Widget creado exitosamente",
"widget": {
"_id": "string",
"dashboardId": "string",
"name": "string",
"type": "line-chart",
"description": "string",
"config": {
"title": "string",
"dataSource": "mqtt",
"topicMode": "auto",
"useAutoTopic": true,
"autoGeneratedTopic": "miobox/507f1f77bcf86cd799439011/607f1f77bcf86cd799439012",
"mqttTopic": "nodered/produccion/linea1",
"selectedPlcTag": {},
"useMultipleTopics": false,
"mqttTopics": [
{
"topic": "string",
"label": "string",
"color": "string"
}
],
"mqttBroker": {
"host": "string",
"port": 0,
"protocol": "ws",
"username": "string",
"password": "string",
"useCustomBroker": true
},
"dataExtraction": {
"type": "single-value",
"valuePath": "value",
"expectedFields": [
"string"
],
"correctionFactor": 1,
"timestampPath": "string",
"categoryPath": "string",
"aggregation": "none",
"keepHistory": 50
},
"showLegend": true,
"showGrid": true,
"colors": [
"string"
],
"icon": "string",
"prefix": "string",
"suffix": "string",
"decimals": 0,
"thresholds": [
{
"max": 0,
"color": "string"
}
],
"columns": [
{
"field": "string",
"label": "string",
"width": "string",
"sortable": true
}
]
},
"metadata": {
"lastDataReceived": "2019-08-24T14:15:22.123Z",
"lastError": "string",
"messageCount": 0,
"connectionStatus": "connected"
},
"status": true,
"createdAt": "2019-08-24T14:15:22.123Z",
"updatedAt": "2019-08-24T14:15:22.123Z"
}
}