From dc126a515783a2998aa40e7bee66b4f9846c9fe8 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Tue, 3 Jan 2023 19:28:13 -0600 Subject: Se arreglan comandos y se cambia cálculo de status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modern/src/CommandsPage.js | 7 +++---- modern/src/DevicesList.js | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/modern/src/CommandsPage.js b/modern/src/CommandsPage.js index 1458b43..3680a0d 100644 --- a/modern/src/CommandsPage.js +++ b/modern/src/CommandsPage.js @@ -66,13 +66,12 @@ const CommandsPage = () => { }, [id]); const handleSend = async () => { + const cmd = commands.find(c => c.id.toString() == selectedCommand); + cmd.deviceId = device.id; const response = await fetch(`/api/commands/send`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - 'id': selectedCommand, - 'deviceId': device.id, - }), + body: JSON.stringify(cmd), }); if (response.ok) { diff --git a/modern/src/DevicesList.js b/modern/src/DevicesList.js index 967ca82..1bc1fa7 100644 --- a/modern/src/DevicesList.js +++ b/modern/src/DevicesList.js @@ -96,7 +96,7 @@ const DeviceRow = ({ data, index, style }) => { const showIgnition = position?.attributes.hasOwnProperty('ignition') && position.attributes.ignition === true; const statusColor = () => { - if (position && position.speed >= 2) { + if (item.status == "online") { return 'primary'; } else { return 'error'; -- cgit v1.2.3