diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 218b395..a4c6800 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -72,7 +72,8 @@
+ @toggle-expand="deviceExpanded[d.id] = !deviceExpanded[d.id]" + @edit="openDeviceForm" />
@@ -117,6 +118,10 @@ + + + + + diff --git a/frontend/src/components/DispositivoCard.vue b/frontend/src/components/DispositivoCard.vue index 8a68622..914d2f3 100644 --- a/frontend/src/components/DispositivoCard.vue +++ b/frontend/src/components/DispositivoCard.vue @@ -2,11 +2,17 @@
{{ device.nombre || device.mac }} - {{ device.mac }} + MAC: {{ device.mac }} + ID: {{ device.id }} Conectado +
+
+
Nombre: {{ device.nombre }}
+
Descripción: {{ device.descripcion }}
+
diff --git a/node-api/src/routes/api.js b/node-api/src/routes/api.js index 5e958ed..401b1b6 100644 --- a/node-api/src/routes/api.js +++ b/node-api/src/routes/api.js @@ -162,4 +162,18 @@ router.get('/devices', async (_req, res) => { } }); +router.patch('/devices/:id', async (req, res) => { + try { + const id = parseInt(String(req.params.id), 10); + if (!Number.isInteger(id) || id <= 0) return res.status(400).json({ ok: false, error: 'invalid_id' }); + const { nombre, descripcion } = req.body || {}; + const { rowCount } = await pool.query('UPDATE dispositivos SET nombre = $2, descripcion = $3, last_seen = NOW() WHERE id = $1', [id, nombre != null ? String(nombre) : null, descripcion != null ? String(descripcion) : null]); + if (rowCount === 0) return res.status(404).json({ ok: false, error: 'not_found' }); + res.json({ ok: true }); + } catch (e) { + console.error('PATCH /api/devices/:id error:', e?.message || e); + res.status(500).json({ ok: false, error: 'db_error' }); + } +}); + export default router;