proddy
2025-01-28 22:33:23 +01:00
parent 0ab7eb42e4
commit 3df2d36453
17 changed files with 245 additions and 218 deletions

View File

@@ -45,9 +45,9 @@
"@eslint/js": "^9.19.0", "@eslint/js": "^9.19.0",
"@preact/compat": "^18.3.1", "@preact/compat": "^18.3.1",
"@preact/preset-vite": "^2.10.0", "@preact/preset-vite": "^2.10.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.1", "@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/formidable": "^3", "@types/formidable": "^3",
"@types/node": "^22.10.10", "@types/node": "^22.12.0",
"@types/react": "^19.0.8", "@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3", "@types/react-dom": "^19.0.3",
"concurrently": "^9.1.2", "concurrently": "^9.1.2",
@@ -57,7 +57,7 @@
"prettier": "^3.4.2", "prettier": "^3.4.2",
"rollup-plugin-visualizer": "^5.14.0", "rollup-plugin-visualizer": "^5.14.0",
"terser": "^5.37.0", "terser": "^5.37.0",
"typescript-eslint": "8.21.0", "typescript-eslint": "8.22.0",
"vite": "^6.0.11", "vite": "^6.0.11",
"vite-plugin-imagemin": "^0.6.1", "vite-plugin-imagemin": "^0.6.1",
"vite-tsconfig-paths": "^5.1.4" "vite-tsconfig-paths": "^5.1.4"

View File

@@ -5,7 +5,7 @@ import type {
Action, Action,
Activity, Activity,
CoreData, CoreData,
DashboardItem, DashboardData,
DeviceData, DeviceData,
DeviceEntity, DeviceEntity,
Entities, Entities,
@@ -22,7 +22,7 @@ import type {
// Dashboard // Dashboard
export const readDashboard = () => export const readDashboard = () =>
alovaInstance.Get<DashboardItem[]>('/rest/dashboardData', { alovaInstance.Get<DashboardData>('/rest/dashboardData', {
responseType: 'arraybuffer' // uses msgpack responseType: 'arraybuffer' // uses msgpack
}); });

View File

@@ -6,11 +6,11 @@ import { toast } from 'react-toastify';
import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import EditIcon from '@mui/icons-material/Edit'; import EditIcon from '@mui/icons-material/Edit';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
import UnfoldLessIcon from '@mui/icons-material/UnfoldLess'; import UnfoldLessIcon from '@mui/icons-material/UnfoldLess';
import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore'; import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore';
import { import {
Box, Box,
Grid2 as Grid,
IconButton, IconButton,
ToggleButton, ToggleButton,
ToggleButtonGroup, ToggleButtonGroup,
@@ -58,10 +58,10 @@ const Dashboard = () => {
error, error,
loading loading
} = useRequest(readDashboard, { } = useRequest(readDashboard, {
initialData: [] initialData: { connected: false, nodes: [] }
}).onSuccess((event) => { }).onSuccess((event) => {
if (event.data.length !== parentNodes) { if (event.data.nodes.length !== parentNodes) {
setParentNodes(event.data.length); // count number of parents/devices setParentNodes(event.data.nodes.length); // count number of parents/devices
} }
}); });
@@ -121,7 +121,7 @@ const Dashboard = () => {
}); });
const tree = useTree( const tree = useTree(
{ nodes: data }, { nodes: data.nodes },
{ {
onChange: undefined // not used but needed onChange: undefined // not used but needed
}, },
@@ -154,7 +154,7 @@ const Dashboard = () => {
useEffect(() => { useEffect(() => {
showAll showAll
? tree.fns.onAddAll(data.map((item: DashboardItem) => item.id)) // expand tree ? tree.fns.onAddAll(data.nodes.map((item: DashboardItem) => item.id)) // expand tree
: tree.fns.onRemoveAll(); // collapse tree : tree.fns.onRemoveAll(); // collapse tree
}, [parentNodes]); }, [parentNodes]);
@@ -224,47 +224,22 @@ const Dashboard = () => {
return <FormLoader onRetry={fetchDashboard} errorMessage={error?.message} />; return <FormLoader onRetry={fetchDashboard} errorMessage={error?.message} />;
} }
const hasFavEntities = data.filter( if (loading) {
return;
}
const hasFavEntities = data.nodes.filter(
(item: DashboardItem) => item.id <= 90 (item: DashboardItem) => item.id <= 90
).length; ).length;
return ( return (
<> <>
<Box {!data.connected && (
sx={{ <MessageBox mb={2} level="error" message={LL.EMS_BUS_WARNING()} />
backgroundColor: 'black', )}
pt: 1,
pl: 2
}}
>
<Grid container spacing={0} justifyContent="flex-start">
<Grid size={11}>
<Typography mb={2} variant="body1" color="warning">
{LL.DASHBOARD_1()}
</Typography>
</Grid>
<Grid size={1} alignItems="end"> {data.connected && !hasFavEntities && (
<ToggleButtonGroup <MessageBox mb={2} level="warning">
color="primary"
size="small"
value={showAll}
exclusive
onChange={handleShowAll}
>
<ToggleButton value={true}>
<UnfoldMoreIcon sx={{ fontSize: 18 }} />
</ToggleButton>
<ToggleButton value={false}>
<UnfoldLessIcon sx={{ fontSize: 18 }} />
</ToggleButton>
</ToggleButtonGroup>
</Grid>
</Grid>
</Box>
{!loading && !hasFavEntities && (
<MessageBox my={1} level="info">
<Typography> <Typography>
{LL.NO_DATA_1()}&nbsp; {LL.NO_DATA_1()}&nbsp;
<Link to="/customizations" style={{ color: 'white' }}> <Link to="/customizations" style={{ color: 'white' }}>
@@ -280,80 +255,107 @@ const Dashboard = () => {
</MessageBox> </MessageBox>
)} )}
{data.length > 0 && ( {data.nodes.length > 0 && (
<Box <>
padding={1} <ToggleButtonGroup
justifyContent="center" color="primary"
flexDirection="column" size="small"
sx={{ value={showAll}
borderRadius: 1, exclusive
border: '1px solid grey' onChange={handleShowAll}
}} >
> <Tooltip placement="top" title={LL.ALLVALUES()} arrow>
<IconContext.Provider <ToggleButton value={true}>
value={{ <UnfoldMoreIcon sx={{ fontSize: 18 }} />
color: 'lightblue', </ToggleButton>
size: '18', </Tooltip>
style: { verticalAlign: 'middle' } <Tooltip placement="top" title={LL.COMPACT()} arrow>
<ToggleButton value={false}>
<UnfoldLessIcon sx={{ fontSize: 18 }} />
</ToggleButton>
</Tooltip>
</ToggleButtonGroup>
<Tooltip placement="top" title={LL.DASHBOARD_1()} arrow>
<HelpOutlineIcon color="primary" sx={{ ml: 1, fontSize: 20 }} />
</Tooltip>
<Box
padding={1}
justifyContent="center"
flexDirection="column"
sx={{
borderRadius: 1,
border: '1px solid grey'
}} }}
> >
<Table <IconContext.Provider
data={{ nodes: data }} value={{
theme={dashboard_theme} color: 'lightblue',
layout={{ custom: true }} size: '18',
tree={tree} style: { verticalAlign: 'middle' }
}}
> >
{(tableList: DashboardItem[]) => ( <Table
<Body> data={{ nodes: data.nodes }}
{tableList.map((di: DashboardItem) => ( theme={dashboard_theme}
<Row layout={{ custom: true }}
key={di.id} tree={tree}
item={di} >
onClick={() => editDashboardValue(di)} {(tableList: DashboardItem[]) => (
> <Body>
{di.id > 99 ? ( {tableList.map((di: DashboardItem) => (
<> <Row
<Cell>{showName(di)}</Cell> key={di.id}
<Cell> item={di}
<Tooltip onClick={() => editDashboardValue(di)}
placement="left" >
title={formatValue(LL, di.dv?.v, di.dv?.u)} {di.id > 99 ? (
arrow <>
> <Cell>{showName(di)}</Cell>
<span>{formatValue(LL, di.dv?.v, di.dv?.u)}</span> <Cell>
</Tooltip> <Tooltip
</Cell> placement="left"
title={formatValue(LL, di.dv?.v, di.dv?.u)}
arrow
>
<span>{formatValue(LL, di.dv?.v, di.dv?.u)}</span>
</Tooltip>
</Cell>
<Cell> <Cell>
{me.admin && {me.admin &&
di.dv?.c && di.dv?.c &&
!hasMask(di.dv.id, DeviceEntityMask.DV_READONLY) && ( !hasMask(
<IconButton di.dv.id,
size="small" DeviceEntityMask.DV_READONLY
onClick={() => editDashboardValue(di)} ) && (
> <IconButton
<EditIcon size="small"
color="primary" onClick={() => editDashboardValue(di)}
sx={{ fontSize: 16 }} >
/> <EditIcon
</IconButton> color="primary"
)} sx={{ fontSize: 16 }}
</Cell> />
</> </IconButton>
) : ( )}
<> </Cell>
<CellTree item={di}>{showName(di)}</CellTree> </>
<Cell /> ) : (
<Cell /> <>
</> <CellTree item={di}>{showName(di)}</CellTree>
)} <Cell />
</Row> <Cell />
))} </>
</Body> )}
)} </Row>
</Table> ))}
</IconContext.Provider> </Body>
</Box> )}
</Table>
</IconContext.Provider>
</Box>
</>
)} )}
</> </>
); );

View File

@@ -124,6 +124,11 @@ export interface DashboardItem {
nodes?: DashboardItem[]; // children nodes, optional nodes?: DashboardItem[]; // children nodes, optional
} }
export interface DashboardData {
connected: boolean; // true if connected to EMS bus
nodes: DashboardItem[];
}
export interface DeviceValue { export interface DeviceValue {
id: string; // index, contains mask+name id: string; // index, contains mask+name
v?: unknown; // value, Number, String or Boolean - can be undefined v?: unknown; // value, Number, String or Boolean - can be undefined

View File

@@ -344,7 +344,7 @@ const cz: Translation = {
DUPLICATE: 'Duplikát', DUPLICATE: 'Duplikát',
UPGRADE: 'Upgrade', UPGRADE: 'Upgrade',
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate
NO_DATA_1: 'No favourite EMS entities found. Use the', // TODO translate NO_DATA_1: 'No favourite EMS entities found yet. Use the', // TODO translate
NO_DATA_2: 'module to mark them.', // TODO translate NO_DATA_2: 'module to mark them.', // TODO translate
NO_DATA_3: 'To see all available entities go to' // TODO translate NO_DATA_3: 'To see all available entities go to' // TODO translate
}; };

View File

@@ -344,7 +344,7 @@ const en: Translation = {
DEVELOPER_MODE: 'Developer Mode', DEVELOPER_MODE: 'Developer Mode',
DUPLICATE: 'Duplicate', DUPLICATE: 'Duplicate',
UPGRADE: 'Upgrade', UPGRADE: 'Upgrade',
NO_DATA_1: 'No favourite EMS entities found! Use the', NO_DATA_1: 'No favourite EMS entities found yet. Use the',
NO_DATA_2: 'module to mark them.', NO_DATA_2: 'module to mark them.',
NO_DATA_3: 'To see all available entities go to' NO_DATA_3: 'To see all available entities go to'
}; };

View File

@@ -344,7 +344,7 @@ const fr: Translation = {
DUPLICATE: 'Duplicate', // TODO translate DUPLICATE: 'Duplicate', // TODO translate
UPGRADE: 'Upgrade', // TODO translate UPGRADE: 'Upgrade', // TODO translate
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate
NO_DATA_1: 'No favourite EMS entities found. Use the', // TODO translate NO_DATA_1: 'No favourite EMS entities found yet. Use the', // TODO translate
NO_DATA_2: 'module to mark them.', // TODO translate NO_DATA_2: 'module to mark them.', // TODO translate
NO_DATA_3: 'To see all available entities go to' // TODO translate NO_DATA_3: 'To see all available entities go to' // TODO translate
}; };

View File

@@ -344,7 +344,7 @@ const it: Translation = {
DUPLICATE: 'Duplicate', // TODO translate DUPLICATE: 'Duplicate', // TODO translate
UPGRADE: 'Upgrade', // TODO translate UPGRADE: 'Upgrade', // TODO translate
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate
NO_DATA_1: 'No favourite EMS entities found. Use the', // TODO translate NO_DATA_1: 'No favourite EMS entities found yet. Use the', // TODO translate
NO_DATA_2: 'module to mark them.', // TODO translate NO_DATA_2: 'module to mark them.', // TODO translate
NO_DATA_3: 'To see all available entities go to' // TODO translate NO_DATA_3: 'To see all available entities go to' // TODO translate
}; };

View File

@@ -344,7 +344,7 @@ const nl: Translation = {
DUPLICATE: 'Duplicaat', DUPLICATE: 'Duplicaat',
UPGRADE: 'Upgraden', UPGRADE: 'Upgraden',
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate
NO_DATA_1: 'No favourite EMS entities found. Use the', // TODO translate NO_DATA_1: 'No favourite EMS entities found yet. Use the', // TODO translate
NO_DATA_2: 'module to mark them.', // TODO translate NO_DATA_2: 'module to mark them.', // TODO translate
NO_DATA_3: 'To see all available entities go to' // TODO translate NO_DATA_3: 'To see all available entities go to' // TODO translate
}; };

View File

@@ -344,7 +344,7 @@ const no: Translation = {
DUPLICATE: 'Duplicate', // TODO translate DUPLICATE: 'Duplicate', // TODO translate
UPGRADE: 'Upgrade', // TODO translate UPGRADE: 'Upgrade', // TODO translate
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate
NO_DATA_1: 'No favourite EMS entities found. Use the', // TODO translate NO_DATA_1: 'No favourite EMS entities found yet. Use the', // TODO translate
NO_DATA_2: 'module to mark them.', // TODO translate NO_DATA_2: 'module to mark them.', // TODO translate
NO_DATA_3: 'To see all available entities go to' // TODO translate NO_DATA_3: 'To see all available entities go to' // TODO translate
}; };

View File

@@ -344,7 +344,7 @@ const pl: BaseTranslation = {
DUPLICATE: 'Duplicate', // TODO translate DUPLICATE: 'Duplicate', // TODO translate
UPGRADE: 'Upgrade', // TODO translate UPGRADE: 'Upgrade', // TODO translate
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate
NO_DATA_1: 'No favourite EMS entities found. Use the', // TODO translate NO_DATA_1: 'No favourite EMS entities found yet. Use the', // TODO translate
NO_DATA_2: 'module to mark them.', // TODO translate NO_DATA_2: 'module to mark them.', // TODO translate
NO_DATA_3: 'To see all available entities go to' // TODO translate NO_DATA_3: 'To see all available entities go to' // TODO translate
}; };

View File

@@ -344,7 +344,7 @@ const sv: Translation = {
DUPLICATE: 'Dublett', DUPLICATE: 'Dublett',
UPGRADE: 'Uppgradera', UPGRADE: 'Uppgradera',
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate
NO_DATA_1: 'No favourite EMS entities found. Use the', // TODO translate NO_DATA_1: 'No favourite EMS entities found yet. Use the', // TODO translate
NO_DATA_2: 'module to mark them.', // TODO translate NO_DATA_2: 'module to mark them.', // TODO translate
NO_DATA_3: 'To see all available entities go to' // TODO translate NO_DATA_3: 'To see all available entities go to' // TODO translate
}; };

View File

@@ -344,7 +344,7 @@ const tr: Translation = {
DUPLICATE: 'Duplicate', // TODO translate DUPLICATE: 'Duplicate', // TODO translate
UPGRADE: 'Upgrade', // TODO translate UPGRADE: 'Upgrade', // TODO translate
DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate DASHBOARD_1: 'All EMS entities that are active and marked as Favorite, plus all Custom Entities, Schedules and external Sensors data are displayed below.', // TODO translate
NO_DATA_1: 'No favourite EMS entities found. Use the', // TODO translate NO_DATA_1: 'No favourite EMS entities found yet. Use the', // TODO translate
NO_DATA_2: 'module to mark them.', // TODO translate NO_DATA_2: 'module to mark them.', // TODO translate
NO_DATA_3: 'To see all available entities go to' // TODO translate NO_DATA_3: 'To see all available entities go to' // TODO translate
}; };

View File

@@ -74,7 +74,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@babel/generator@npm:^7.26.2, @babel/generator@npm:^7.26.5": "@babel/generator@npm:^7.26.5":
version: 7.26.5 version: 7.26.5
resolution: "@babel/generator@npm:7.26.5" resolution: "@babel/generator@npm:7.26.5"
dependencies: dependencies:
@@ -170,7 +170,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@babel/parser@npm:^7.25.9, @babel/parser@npm:^7.26.2, @babel/parser@npm:^7.26.5, @babel/parser@npm:^7.26.7": "@babel/parser@npm:^7.25.9, @babel/parser@npm:^7.26.5, @babel/parser@npm:^7.26.7":
version: 7.26.7 version: 7.26.7
resolution: "@babel/parser@npm:7.26.7" resolution: "@babel/parser@npm:7.26.7"
dependencies: dependencies:
@@ -253,7 +253,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@babel/types@npm:^7.25.9, @babel/types@npm:^7.26.0, @babel/types@npm:^7.26.5, @babel/types@npm:^7.26.7": "@babel/types@npm:^7.25.9, @babel/types@npm:^7.26.5, @babel/types@npm:^7.26.7":
version: 7.26.7 version: 7.26.7
resolution: "@babel/types@npm:7.26.7" resolution: "@babel/types@npm:7.26.7"
dependencies: dependencies:
@@ -1237,14 +1237,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@trivago/prettier-plugin-sort-imports@npm:^5.2.1": "@trivago/prettier-plugin-sort-imports@npm:^5.2.2":
version: 5.2.1 version: 5.2.2
resolution: "@trivago/prettier-plugin-sort-imports@npm:5.2.1" resolution: "@trivago/prettier-plugin-sort-imports@npm:5.2.2"
dependencies: dependencies:
"@babel/generator": "npm:^7.26.2" "@babel/generator": "npm:^7.26.5"
"@babel/parser": "npm:^7.26.2" "@babel/parser": "npm:^7.26.7"
"@babel/traverse": "npm:^7.25.9" "@babel/traverse": "npm:^7.26.7"
"@babel/types": "npm:^7.26.0" "@babel/types": "npm:^7.26.7"
javascript-natural-sort: "npm:^0.7.1" javascript-natural-sort: "npm:^0.7.1"
lodash: "npm:^4.17.21" lodash: "npm:^4.17.21"
peerDependencies: peerDependencies:
@@ -1259,7 +1259,7 @@ __metadata:
optional: true optional: true
svelte: svelte:
optional: true optional: true
checksum: 10c0/fd782f84d44c61159dce099775a86ebb5082b5e5eea205ec71d6fede3cf079aafb8f9a9979d5742ff0126598a37098cf679d5bad268320907513f2984df3d501 checksum: 10c0/2a4f0464f1f5a294bcd34558fb053f8263f0c62c4a7fcdd3ce40c9822a68ac8b4d951700ab6d01eb3919efe0ed44e4191997edd494d59679b22db1c0db00474e
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1399,7 +1399,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:*, @types/node@npm:^22.10.10": "@types/node@npm:*":
version: 22.10.10 version: 22.10.10
resolution: "@types/node@npm:22.10.10" resolution: "@types/node@npm:22.10.10"
dependencies: dependencies:
@@ -1408,6 +1408,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:^22.12.0":
version: 22.12.0
resolution: "@types/node@npm:22.12.0"
dependencies:
undici-types: "npm:~6.20.0"
checksum: 10c0/be220706732d95db2ed1c441c1e64cab90bf9a47519ce6f4c79cc5a9ec9d5c517131a149a9ac30afac1a30103e67e3a00d453ba7c1b0141608a3a7ba6397c303
languageName: node
linkType: hard
"@types/parse-json@npm:^4.0.0": "@types/parse-json@npm:^4.0.0":
version: 4.0.2 version: 4.0.2
resolution: "@types/parse-json@npm:4.0.2" resolution: "@types/parse-json@npm:4.0.2"
@@ -1467,15 +1476,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/eslint-plugin@npm:8.21.0": "@typescript-eslint/eslint-plugin@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "@typescript-eslint/eslint-plugin@npm:8.21.0" resolution: "@typescript-eslint/eslint-plugin@npm:8.22.0"
dependencies: dependencies:
"@eslint-community/regexpp": "npm:^4.10.0" "@eslint-community/regexpp": "npm:^4.10.0"
"@typescript-eslint/scope-manager": "npm:8.21.0" "@typescript-eslint/scope-manager": "npm:8.22.0"
"@typescript-eslint/type-utils": "npm:8.21.0" "@typescript-eslint/type-utils": "npm:8.22.0"
"@typescript-eslint/utils": "npm:8.21.0" "@typescript-eslint/utils": "npm:8.22.0"
"@typescript-eslint/visitor-keys": "npm:8.21.0" "@typescript-eslint/visitor-keys": "npm:8.22.0"
graphemer: "npm:^1.4.0" graphemer: "npm:^1.4.0"
ignore: "npm:^5.3.1" ignore: "npm:^5.3.1"
natural-compare: "npm:^1.4.0" natural-compare: "npm:^1.4.0"
@@ -1484,64 +1493,64 @@ __metadata:
"@typescript-eslint/parser": ^8.0.0 || ^8.0.0-alpha.0 "@typescript-eslint/parser": ^8.0.0 || ^8.0.0-alpha.0
eslint: ^8.57.0 || ^9.0.0 eslint: ^8.57.0 || ^9.0.0
typescript: ">=4.8.4 <5.8.0" typescript: ">=4.8.4 <5.8.0"
checksum: 10c0/4601d21ec35b9fa5cfc1ad0330733ab40d6c6822c7fc15c3584a16f678c9a72e077a1725a950823fe0f499a15f3981795b1ea5d1e7a1be5c7b8296ea9ae6327c checksum: 10c0/eecc23e05287cc99a43855d64c0f0898f690ee14b8c31b60ba92ce9732443f6b0c9695514b276fb2ecd27e64c15d4c38cd28b570779115525b4dfdbba60e81ca
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/parser@npm:8.21.0": "@typescript-eslint/parser@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "@typescript-eslint/parser@npm:8.21.0" resolution: "@typescript-eslint/parser@npm:8.22.0"
dependencies: dependencies:
"@typescript-eslint/scope-manager": "npm:8.21.0" "@typescript-eslint/scope-manager": "npm:8.22.0"
"@typescript-eslint/types": "npm:8.21.0" "@typescript-eslint/types": "npm:8.22.0"
"@typescript-eslint/typescript-estree": "npm:8.21.0" "@typescript-eslint/typescript-estree": "npm:8.22.0"
"@typescript-eslint/visitor-keys": "npm:8.21.0" "@typescript-eslint/visitor-keys": "npm:8.22.0"
debug: "npm:^4.3.4" debug: "npm:^4.3.4"
peerDependencies: peerDependencies:
eslint: ^8.57.0 || ^9.0.0 eslint: ^8.57.0 || ^9.0.0
typescript: ">=4.8.4 <5.8.0" typescript: ">=4.8.4 <5.8.0"
checksum: 10c0/aadebd50ca7aa2d61ad85d890c0d7010f2c293ec4d50a7833ef9674f232f0bc7118faa93a898771fbea50f02d542d687cf3569421b23f72fe6fed6895d5506fc checksum: 10c0/6575684d4724aa908b0d6a29db5d5054b9277804844ee4179c77371f8b8b84534b9b7e4df0e282c5f39729ae6f0019208a6b83f0ca5d0f06f9da5a06d8ddb4fd
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/scope-manager@npm:8.21.0": "@typescript-eslint/scope-manager@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "@typescript-eslint/scope-manager@npm:8.21.0" resolution: "@typescript-eslint/scope-manager@npm:8.22.0"
dependencies: dependencies:
"@typescript-eslint/types": "npm:8.21.0" "@typescript-eslint/types": "npm:8.22.0"
"@typescript-eslint/visitor-keys": "npm:8.21.0" "@typescript-eslint/visitor-keys": "npm:8.22.0"
checksum: 10c0/ea405e79dc884ea1c76465604db52f9b0941d6cbb0bde6bce1af689ef212f782e214de69d46503c7c47bfc180d763369b7433f1965e3be3c442b417e8c9f8f75 checksum: 10c0/f393ab32086f4b095fcd77169abb5200ad94f282860944d164cec8c9b70090c36235f49b066ba24dfd953201b7730e48200a254e5950a9a3565acdacbbc0fd64
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/type-utils@npm:8.21.0": "@typescript-eslint/type-utils@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "@typescript-eslint/type-utils@npm:8.21.0" resolution: "@typescript-eslint/type-utils@npm:8.22.0"
dependencies: dependencies:
"@typescript-eslint/typescript-estree": "npm:8.21.0" "@typescript-eslint/typescript-estree": "npm:8.22.0"
"@typescript-eslint/utils": "npm:8.21.0" "@typescript-eslint/utils": "npm:8.22.0"
debug: "npm:^4.3.4" debug: "npm:^4.3.4"
ts-api-utils: "npm:^2.0.0" ts-api-utils: "npm:^2.0.0"
peerDependencies: peerDependencies:
eslint: ^8.57.0 || ^9.0.0 eslint: ^8.57.0 || ^9.0.0
typescript: ">=4.8.4 <5.8.0" typescript: ">=4.8.4 <5.8.0"
checksum: 10c0/617f5dfe83fd9a7c722b27fa4e7f0c84f29baa94f75a4e8e5ccfd5b0a373437f65724e21b9642870fb0960f204b1a7f516a038200a12f8118f21b1bf86315bf3 checksum: 10c0/dc457d9184dc2156eda225c63de03b1052d75464d6393edaf0f1728eecf64170f73e19bc9b9d4a4a029870ce25015b59bd6705e1e18b731ca4fcecac4398bfb7
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/types@npm:8.21.0": "@typescript-eslint/types@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "@typescript-eslint/types@npm:8.21.0" resolution: "@typescript-eslint/types@npm:8.22.0"
checksum: 10c0/67dfd300cc614d7b02e94d0dacfb228a7f4c3fd4eede29c43adb9e9fcc16365ae3df8d6165018da3c123dce65545bef03e3e8183f35e9b3a911ffc727e3274c2 checksum: 10c0/6357d0937e2b84ddb00763d05053fe50f2270fa428aa11f1ad6a1293827cf54da7e6d4d20b00b9d4f633b6982a2eb0e494f05285daa1279d8a3493f0d8abae18
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/typescript-estree@npm:8.21.0": "@typescript-eslint/typescript-estree@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "@typescript-eslint/typescript-estree@npm:8.21.0" resolution: "@typescript-eslint/typescript-estree@npm:8.22.0"
dependencies: dependencies:
"@typescript-eslint/types": "npm:8.21.0" "@typescript-eslint/types": "npm:8.22.0"
"@typescript-eslint/visitor-keys": "npm:8.21.0" "@typescript-eslint/visitor-keys": "npm:8.22.0"
debug: "npm:^4.3.4" debug: "npm:^4.3.4"
fast-glob: "npm:^3.3.2" fast-glob: "npm:^3.3.2"
is-glob: "npm:^4.0.3" is-glob: "npm:^4.0.3"
@@ -1550,32 +1559,32 @@ __metadata:
ts-api-utils: "npm:^2.0.0" ts-api-utils: "npm:^2.0.0"
peerDependencies: peerDependencies:
typescript: ">=4.8.4 <5.8.0" typescript: ">=4.8.4 <5.8.0"
checksum: 10c0/0cf5b0382524f4af54fb5ec71ca7e939ec922711f2d77b383740b28dd4b21407b0ab5dded62df6819d01c12c0b354e95667e3c7025a5d27d05b805161ab94855 checksum: 10c0/0a9d77fbadfb1e54c06abde424e461103576595c70e50ae8a15a3d7c07f125f253f505208e1ea5cc483b9073d95fc10ce0c4ddfe0fe08ec2aceda6314c341e0d
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/utils@npm:8.21.0": "@typescript-eslint/utils@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "@typescript-eslint/utils@npm:8.21.0" resolution: "@typescript-eslint/utils@npm:8.22.0"
dependencies: dependencies:
"@eslint-community/eslint-utils": "npm:^4.4.0" "@eslint-community/eslint-utils": "npm:^4.4.0"
"@typescript-eslint/scope-manager": "npm:8.21.0" "@typescript-eslint/scope-manager": "npm:8.22.0"
"@typescript-eslint/types": "npm:8.21.0" "@typescript-eslint/types": "npm:8.22.0"
"@typescript-eslint/typescript-estree": "npm:8.21.0" "@typescript-eslint/typescript-estree": "npm:8.22.0"
peerDependencies: peerDependencies:
eslint: ^8.57.0 || ^9.0.0 eslint: ^8.57.0 || ^9.0.0
typescript: ">=4.8.4 <5.8.0" typescript: ">=4.8.4 <5.8.0"
checksum: 10c0/d8347dbe9176417220aa62902cfc1b2007a9246bb7a8cccdf8590120903eb50ca14cb668efaab4646d086277f2367559985b62230e43ebd8b0723d237eeaa2f2 checksum: 10c0/6f1e3f9c0fb865c8cef4fdca04679cea7357ed011338b54d80550e9ad5369a3f24cbe4b0985d293192fe351fa133e5f4ea401f47af90bb46c21903bfe087b398
languageName: node languageName: node
linkType: hard linkType: hard
"@typescript-eslint/visitor-keys@npm:8.21.0": "@typescript-eslint/visitor-keys@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "@typescript-eslint/visitor-keys@npm:8.21.0" resolution: "@typescript-eslint/visitor-keys@npm:8.22.0"
dependencies: dependencies:
"@typescript-eslint/types": "npm:8.21.0" "@typescript-eslint/types": "npm:8.22.0"
eslint-visitor-keys: "npm:^4.2.0" eslint-visitor-keys: "npm:^4.2.0"
checksum: 10c0/b3f1412f550e35c0d7ae0410db616951116b365167539f9b85710d8bc2b36b322c5e637caee84cc1ae5df8f1d961880250d52ffdef352b31e5bdbef74ba6fea9 checksum: 10c0/fd83d2feadaf79950427fbbc3d23ca01cf4646ce7e0dd515a9c881d31ec1cc768e7b8898d3af065e31df39452501a3345092581cbfccac89e89d293519540557
languageName: node languageName: node
linkType: hard linkType: hard
@@ -1593,9 +1602,9 @@ __metadata:
"@preact/compat": "npm:^18.3.1" "@preact/compat": "npm:^18.3.1"
"@preact/preset-vite": "npm:^2.10.0" "@preact/preset-vite": "npm:^2.10.0"
"@table-library/react-table-library": "npm:4.1.7" "@table-library/react-table-library": "npm:4.1.7"
"@trivago/prettier-plugin-sort-imports": "npm:^5.2.1" "@trivago/prettier-plugin-sort-imports": "npm:^5.2.2"
"@types/formidable": "npm:^3" "@types/formidable": "npm:^3"
"@types/node": "npm:^22.10.10" "@types/node": "npm:^22.12.0"
"@types/react": "npm:^19.0.8" "@types/react": "npm:^19.0.8"
"@types/react-dom": "npm:^19.0.3" "@types/react-dom": "npm:^19.0.3"
alova: "npm:3.2.8" alova: "npm:3.2.8"
@@ -1617,7 +1626,7 @@ __metadata:
terser: "npm:^5.37.0" terser: "npm:^5.37.0"
typesafe-i18n: "npm:^5.26.2" typesafe-i18n: "npm:^5.26.2"
typescript: "npm:^5.7.3" typescript: "npm:^5.7.3"
typescript-eslint: "npm:8.21.0" typescript-eslint: "npm:8.22.0"
vite: "npm:^6.0.11" vite: "npm:^6.0.11"
vite-plugin-imagemin: "npm:^0.6.1" vite-plugin-imagemin: "npm:^0.6.1"
vite-tsconfig-paths: "npm:^5.1.4" vite-tsconfig-paths: "npm:^5.1.4"
@@ -6646,17 +6655,17 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"typescript-eslint@npm:8.21.0": "typescript-eslint@npm:8.22.0":
version: 8.21.0 version: 8.22.0
resolution: "typescript-eslint@npm:8.21.0" resolution: "typescript-eslint@npm:8.22.0"
dependencies: dependencies:
"@typescript-eslint/eslint-plugin": "npm:8.21.0" "@typescript-eslint/eslint-plugin": "npm:8.22.0"
"@typescript-eslint/parser": "npm:8.21.0" "@typescript-eslint/parser": "npm:8.22.0"
"@typescript-eslint/utils": "npm:8.21.0" "@typescript-eslint/utils": "npm:8.22.0"
peerDependencies: peerDependencies:
eslint: ^8.57.0 || ^9.0.0 eslint: ^8.57.0 || ^9.0.0
typescript: ">=4.8.4 <5.8.0" typescript: ">=4.8.4 <5.8.0"
checksum: 10c0/44e5c341ad7f0b41dce3b4ca7a4c0a399ebe51a5323d930750db1e308367b4813a620f4c2332a5774a1dccd0047ebbaf993a8b7effd67389e9069b29b5701520 checksum: 10c0/d7a5ec4a08d0eb0a7cc0bf81919f0305a9fbb091b187cef6d3fa220c1673414dcb46e6cd5c9325050d3df2bbb283756399c1b2720eb4eadaab0bdc3cc8302405
languageName: node languageName: node
linkType: hard linkType: hard

View File

@@ -4500,14 +4500,14 @@ router
params.id ? deviceEntities(Number(params.id)) : status(404) params.id ? deviceEntities(Number(params.id)) : status(404)
) )
.get(EMSESP_DASHBOARD_DATA_ENDPOINT, () => { .get(EMSESP_DASHBOARD_DATA_ENDPOINT, () => {
let dashboard_data: { id?: number; n?: string; t?: number; nodes?: any[] }[] = let dashboard_nodes: { id?: number; n?: string; t?: number; nodes?: any[] }[] =
[]; [];
let dashboard_object: { id?: number; n?: string; t?: number; nodes?: any[] } = let dashboard_object: { id?: number; n?: string; t?: number; nodes?: any[] } =
{}; {};
let fake = false; let fake = false;
fake = true; // for testing, shows a subset of data // fake = true; // for testing, shows a subset of data
if (!fake) { if (!fake) {
// pick EMS devices from coredata // pick EMS devices from coredata
@@ -4522,7 +4522,7 @@ router
}; };
// only add to dashboard if we have values // only add to dashboard if we have values
if ((dashboard_object.nodes ?? []).length > 0) { if ((dashboard_object.nodes ?? []).length > 0) {
dashboard_data.push(dashboard_object); dashboard_nodes.push(dashboard_object);
} }
} }
@@ -4534,7 +4534,7 @@ router
}; };
// only add to dashboard if we have values // only add to dashboard if we have values
if ((dashboard_object.nodes ?? []).length > 0) { if ((dashboard_object.nodes ?? []).length > 0) {
dashboard_data.push(dashboard_object); dashboard_nodes.push(dashboard_object);
} }
// add temperature sensor data. no command c // add temperature sensor data. no command c
@@ -4554,7 +4554,7 @@ router
}; };
// only add to dashboard if we have values // only add to dashboard if we have values
if ((dashboard_object.nodes ?? []).length > 0) { if ((dashboard_object.nodes ?? []).length > 0) {
dashboard_data.push(dashboard_object); dashboard_nodes.push(dashboard_object);
} }
// add analog sensor data. no command c // add analog sensor data. no command c
@@ -4575,7 +4575,7 @@ router
}; };
// only add to dashboard if we have values // only add to dashboard if we have values
if ((dashboard_object.nodes ?? []).length > 0) { if ((dashboard_object.nodes ?? []).length > 0) {
dashboard_data.push(dashboard_object); dashboard_nodes.push(dashboard_object);
} }
// add the scheduler data // add the scheduler data
@@ -4597,7 +4597,7 @@ router
}; };
// only add to dashboard if we have values // only add to dashboard if we have values
if ((dashboard_object.nodes ?? []).length > 0) { if ((dashboard_object.nodes ?? []).length > 0) {
dashboard_data.push(dashboard_object); dashboard_nodes.push(dashboard_object);
} }
} else { } else {
// for testing only // for testing only
@@ -4609,7 +4609,7 @@ router
nodes: getDashboardEntityData(DeviceTypeUniqueID.CUSTOM_UID) nodes: getDashboardEntityData(DeviceTypeUniqueID.CUSTOM_UID)
}; };
if ((dashboard_object.nodes ?? []).length > 0) { if ((dashboard_object.nodes ?? []).length > 0) {
dashboard_data.push(dashboard_object); dashboard_nodes.push(dashboard_object);
} }
// add the scheduler data // add the scheduler data
@@ -4633,10 +4633,15 @@ router
// } // }
} }
// console.log('dashboard_data: ', dashboard_data); const dashboardData = {
// connect: false,
connected: true,
nodes: dashboard_nodes
};
// console.log('dashboardData: ', dashboardData);
// return dashboard_data; // if not using msgpack // return dashboard_data; // if not using msgpack
return new Response(encoder.encode(dashboard_data), { headers }); // msgpack it return new Response(encoder.encode(dashboardData), { headers }); // msgpack it
}) })
// Customizations // Customizations

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.7.2-dev.16" #define EMSESP_APP_VERSION "3.7.2-dev.17"

View File

@@ -352,19 +352,25 @@ void WebDataService::write_analog_sensor(AsyncWebServerRequest * request, JsonVa
// this is used in the dashboard and contains all ems device information // this is used in the dashboard and contains all ems device information
// /dashboardData endpoint // /dashboardData endpoint
void WebDataService::dashboard_data(AsyncWebServerRequest * request) { void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
auto * response = new AsyncMessagePackResponse(true); auto * response = new AsyncMessagePackResponse();
#if defined(EMSESP_STANDALONE) #if defined(EMSESP_STANDALONE)
JsonDocument doc; JsonDocument doc;
JsonArray root = doc.to<JsonArray>(); JsonObject root = doc.to<JsonObject>();
#else #else
JsonArray root = response->getRoot(); JsonObject root = response->getRoot();
#endif #endif
// first do all the recognized devices // add state of EMS bus
root["connected"] = EMSESP::bus_status() != 2;
// add all the data
JsonArray nodes = root["nodes"].to<JsonArray>();
// first fetch all the recognized devices
for (const auto & emsdevice : EMSESP::emsdevices) { for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice->count_entities_fav()) { if (emsdevice->count_entities_fav()) {
JsonObject obj = root.add<JsonObject>(); JsonObject obj = nodes.add<JsonObject>();
obj["id"] = emsdevice->unique_id(); // it's unique id obj["id"] = emsdevice->unique_id(); // it's unique id
obj["n"] = emsdevice->name(); // custom name obj["n"] = emsdevice->name(); // custom name
obj["t"] = emsdevice->device_type(); // device type number obj["t"] = emsdevice->device_type(); // device type number
@@ -374,15 +380,15 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
// add custom entities, if we have any // add custom entities, if we have any
if (EMSESP::webCustomEntityService.count_entities()) { if (EMSESP::webCustomEntityService.count_entities()) {
JsonObject obj = root.add<JsonObject>(); JsonObject obj = nodes.add<JsonObject>();
obj["id"] = EMSdevice::DeviceTypeUniqueID::CUSTOM_UID; // it's unique id obj["id"] = EMSdevice::DeviceTypeUniqueID::CUSTOM_UID; // it's unique id
obj["t"] = EMSdevice::DeviceType::CUSTOM; // device type number obj["t"] = EMSdevice::DeviceType::CUSTOM; // device type number
EMSESP::webCustomEntityService.generate_value_web(obj, true); EMSESP::webCustomEntityService.generate_value_web(obj, true);
} }
// add temperature sensors // add temperature sensors, if we have any
if (EMSESP::temperaturesensor_.have_sensors()) { if (EMSESP::temperaturesensor_.have_sensors()) {
JsonObject obj = root.add<JsonObject>(); JsonObject obj = nodes.add<JsonObject>();
obj["id"] = EMSdevice::DeviceTypeUniqueID::TEMPERATURESENSOR_UID; // it's unique id obj["id"] = EMSdevice::DeviceTypeUniqueID::TEMPERATURESENSOR_UID; // it's unique id
obj["t"] = EMSdevice::DeviceType::TEMPERATURESENSOR; // device type number obj["t"] = EMSdevice::DeviceType::TEMPERATURESENSOR; // device type number
JsonArray nodes = obj["nodes"].to<JsonArray>(); JsonArray nodes = obj["nodes"].to<JsonArray>();
@@ -409,7 +415,7 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
// add analog sensors, count excludes disabled entries // add analog sensors, count excludes disabled entries
if (EMSESP::analog_enabled() && EMSESP::analogsensor_.count_entities(false)) { if (EMSESP::analog_enabled() && EMSESP::analogsensor_.count_entities(false)) {
JsonObject obj = root.add<JsonObject>(); JsonObject obj = nodes.add<JsonObject>();
obj["id"] = EMSdevice::DeviceTypeUniqueID::ANALOGSENSOR_UID; // it's unique id obj["id"] = EMSdevice::DeviceTypeUniqueID::ANALOGSENSOR_UID; // it's unique id
obj["t"] = EMSdevice::DeviceType::ANALOGSENSOR; // device type number obj["t"] = EMSdevice::DeviceType::ANALOGSENSOR; // device type number
JsonArray nodes = obj["nodes"].to<JsonArray>(); JsonArray nodes = obj["nodes"].to<JsonArray>();
@@ -449,7 +455,7 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
// show scheduler, with name, on/off // show scheduler, with name, on/off
if (EMSESP::webSchedulerService.count_entities(true)) { if (EMSESP::webSchedulerService.count_entities(true)) {
JsonObject obj = root.add<JsonObject>(); JsonObject obj = nodes.add<JsonObject>();
obj["id"] = EMSdevice::DeviceTypeUniqueID::SCHEDULER_UID; // it's unique id obj["id"] = EMSdevice::DeviceTypeUniqueID::SCHEDULER_UID; // it's unique id
obj["t"] = EMSdevice::DeviceType::SCHEDULER; // device type number obj["t"] = EMSdevice::DeviceType::SCHEDULER; // device type number
JsonArray nodes = obj["nodes"].to<JsonArray>(); JsonArray nodes = obj["nodes"].to<JsonArray>();