diff --git a/interface/src/app/main/Dashboard.tsx b/interface/src/app/main/Dashboard.tsx index cc9dff0bf..a66acced7 100644 --- a/interface/src/app/main/Dashboard.tsx +++ b/interface/src/app/main/Dashboard.tsx @@ -6,15 +6,7 @@ import UnfoldLessIcon from '@mui/icons-material/UnfoldLess'; import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore'; import { Box, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material'; -import { - Body, - Cell, - Header, - HeaderCell, - HeaderRow, - Row, - Table -} from '@table-library/react-table-library/table'; +import { Body, Cell, Row, Table } from '@table-library/react-table-library/table'; import { useTheme } from '@table-library/react-table-library/theme'; import { CellTree, useTree } from '@table-library/react-table-library/tree'; import { useAutoRequest } from 'alova/client'; @@ -52,19 +44,10 @@ const Dashboard = () => { height: 32px; } `, - HeaderRow: ` - text-transform: uppercase; - background-color: black; - color: #90CAF9; - .th { - border-bottom: 1px solid #565656; - height: 36px; - } - `, Row: ` background-color: #1e1e1e; - position: relative; - cursor: pointer; + // position: relative; + // cursor: pointer; .td { height: 24px; } @@ -107,9 +90,10 @@ const Dashboard = () => { if (di.id < 100) { if (di.nodes?.length) { return ( -
- {di.n} ({di.nodes?.length}) -
+ + {di.n} +  ({di.nodes?.length}) + ); } return
{di.n}
; @@ -133,13 +117,22 @@ const Dashboard = () => { return ; } + if (data.length === 0) { + return ( + + {/* TODO translate */} + No entities found. + + ); + } + return ( <> - - - Use Customizations to mark your favorite EMS entities - - + + The dashboard shows all EMS entities that are marked as favorite, and the + sensors. + + { - - {(tableList: DashboardItem[]) => ( - <> -
- - Name - Value - -
+
+ {(tableList: DashboardItem[]) => ( {tableList.map((di: DashboardItem) => ( @@ -180,9 +177,9 @@ const Dashboard = () => { ))} - - )} -
+ )} + + ); }; diff --git a/mock-api/rest_server.ts b/mock-api/rest_server.ts index b57af9db4..9837ed0b8 100644 --- a/mock-api/rest_server.ts +++ b/mock-api/rest_server.ts @@ -4327,71 +4327,78 @@ router .get(EMSESP_DASHBOARD_DATA_ENDPOINT, () => { let dashboard_data = []; let dashboard_object = {}; + let fake = false; + // let fake = true; - // pick EMS devices from coredata - for (const element of emsesp_coredata.devices) { - const id = element.id; + if (!fake) { + // pick EMS devices from coredata + for (const element of emsesp_coredata.devices) { + const id = element.id; + + dashboard_object = { + id: id, + n: element.n, + nodes: getDashboardEntityData(id) + }; + + // only add to dashboard if we have values + if (dashboard_object.nodes.length > 0) { + dashboard_data.push(dashboard_object); + } + } + + // add the custom entity data + dashboard_object = { + id: 99, + n: 'Custom Entities', + nodes: getDashboardEntityData(99) + }; + // only add to dashboard if we have values + if (dashboard_object.nodes.length > 0) { + dashboard_data.push(dashboard_object); + } + + // add temperature sensor data + let sensor_data = {}; + sensor_data = emsesp_sensordata.ts.map((item, index) => ({ + id: 980 + index, + n: item.n ? item.n : item.id, // name may not be set + v: item.t ? item.t : undefined, // can have no value + u: item.u + })); + dashboard_object = { + id: 98, + n: 'Temperature Sensors', + nodes: sensor_data + }; + // only add to dashboard if we have values + if (dashboard_object.nodes.length > 0) { + dashboard_data.push(dashboard_object); + } + + // add analog sensor data + // remove disabled sensors (t = 0) + sensor_data = emsesp_sensordata.as.filter((item) => item.t !== 0); + + sensor_data = sensor_data.map((item, index) => ({ + id: 970 + index, + n: item.n, + v: item.v, + u: item.u + })); dashboard_object = { - id: id, - n: element.n, - nodes: getDashboardEntityData(id) + id: 97, + n: 'Analog Sensors', + nodes: sensor_data }; - // only add to dashboard if we have values if (dashboard_object.nodes.length > 0) { dashboard_data.push(dashboard_object); } } - // add the custom entity data - dashboard_object = { - id: 99, - n: 'Custom Entities', - nodes: getDashboardEntityData(99) - }; - // only add to dashboard if we have values - if (dashboard_object.nodes.length > 0) { - dashboard_data.push(dashboard_object); - } - - // add temperature sensor data - let sensor_data = {}; - sensor_data = emsesp_sensordata.ts.map((item, index) => ({ - id: 980 + index, - n: item.n ? item.n : item.id, // name may not be set - v: item.t ? item.t : undefined, // can have no value - u: item.u - })); - dashboard_object = { - id: 98, - n: 'Temperature Sensors', - nodes: sensor_data - }; - // only add to dashboard if we have values - if (dashboard_object.nodes.length > 0) { - dashboard_data.push(dashboard_object); - } - - // add analog sensor data - sensor_data = emsesp_sensordata.as.map((item, index) => ({ - id: 970 + index, - n: item.n, - v: item.v, - u: item.u - })); - dashboard_object = { - id: 97, - n: 'Analog Sensors', - nodes: sensor_data - }; - // only add to dashboard if we have values - if (dashboard_object.nodes.length > 0) { - dashboard_data.push(dashboard_object); - } - // console.log('dashboard_data: ', dashboard_data); - return new Response(encoder.encode(dashboard_data), { headers }); // msgpack it })