add web page for modules

This commit is contained in:
proddy
2024-05-29 22:23:01 +02:00
parent 3fa42be6d4
commit fb6b8813c7
8 changed files with 625 additions and 92 deletions

View File

@@ -26,12 +26,12 @@
"@alova/scene-react": "^1.5.0",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "^5.15.18",
"@mui/material": "^5.15.18",
"@mui/icons-material": "^5.15.19",
"@mui/material": "^5.15.19",
"@table-library/react-table-library": "4.1.7",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.12.12",
"@types/react": "^18.3.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"alova": "^2.20.5",
@@ -50,7 +50,7 @@
"typescript": "^5.4.5"
},
"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/core": "^7.24.6",
"@eslint/js": "^9.3.0",
"@preact/compat": "^17.1.2",
"@preact/preset-vite": "^2.8.2",
@@ -63,8 +63,8 @@
"prettier": "^3.2.5",
"rollup-plugin-visualizer": "^5.12.0",
"terser": "^5.31.0",
"typescript-eslint": "^7.9.0",
"vite": "^5.2.11",
"typescript-eslint": "^7.11.0",
"vite": "^5.2.12",
"vite-plugin-imagemin": "^0.6.1",
"vite-tsconfig-paths": "^4.3.2"
},

View File

@@ -16,6 +16,7 @@ import ApplicationSettings from 'project/ApplicationSettings';
import CustomEntities from 'project/CustomEntities';
import Customization from 'project/Customization';
import Devices from 'project/Devices';
import Modules from 'project/Modules';
import Scheduler from 'project/Scheduler';
import Sensors from 'project/Sensors';
@@ -43,6 +44,7 @@ const AuthenticatedRouting: FC = () => {
<Route path="/settings/ntp/*" element={<NetworkTime />} />
<Route path="/settings/mqtt/*" element={<Mqtt />} />
<Route path="/settings/security/*" element={<Security />} />
<Route path="/settings/modules/*" element={<Modules />} />
<Route path="/system/espsystemstatus/*" element={<ESPSystemStatus />} />
<Route path="/settings/upload/*" element={<UploadDownload />} />
</>

View File

@@ -9,6 +9,7 @@ import SettingsBackupRestoreIcon from '@mui/icons-material/SettingsBackupRestore
import SettingsEthernetIcon from '@mui/icons-material/SettingsEthernet';
import SettingsInputAntennaIcon from '@mui/icons-material/SettingsInputAntenna';
import TuneIcon from '@mui/icons-material/Tune';
import ViewModuleIcon from '@mui/icons-material/ViewModule';
import {
Box,
Button,
@@ -122,6 +123,14 @@ const Settings: FC = () => {
to="security"
/>
<ListMenuItem
icon={ViewModuleIcon}
bgcolor="#efc34b"
label="Modules"
text="Activate or deactivate external modules"
to="modules"
/>
<Divider />
<ListMenuItem

View File

@@ -0,0 +1,228 @@
import { useState } from 'react';
import type { FC } from 'react';
import { useBlocker } from 'react-router-dom';
import { toast } from 'react-toastify';
import CancelIcon from '@mui/icons-material/Cancel';
import CircleIcon from '@mui/icons-material/Circle';
import WarningIcon from '@mui/icons-material/Warning';
import { Box, Button, Typography } from '@mui/material';
import {
Body,
Cell,
Header,
HeaderCell,
HeaderRow,
Row,
Table
} from '@table-library/react-table-library/table';
import { useTheme } from '@table-library/react-table-library/theme';
import { updateState, useRequest } from 'alova';
import {
BlockNavigation,
ButtonRow,
FormLoader,
SectionContent,
useLayoutTitle
} from 'components';
import { useI18nContext } from 'i18n/i18n-react';
import * as EMSESP from './api';
import type { ModuleItem, Modules } from './types';
const Modules: FC = () => {
const { LL } = useI18nContext();
const [numChanges, setNumChanges] = useState<number>(0);
const blocker = useBlocker(numChanges !== 0);
const {
data: modules,
send: fetchModules,
error
} = useRequest(EMSESP.readModules, {
initialData: [],
force: true
});
const { send: writeModules } = useRequest(
(data: Modules) => EMSESP.writeModules(data),
{
immediate: false
}
);
const modules_theme = useTheme({
Table: `
--data-table-library_grid-template-columns: 48px 180px 120px 100px repeat(1, minmax(160px, 1fr));
`,
BaseRow: `
font-size: 14px;
.td {
height: 32px;
}
`,
BaseCell: `
&:nth-of-type(1) {
text-align: center;
}
`,
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;
.td {
border-top: 1px solid #565656;
border-bottom: 1px solid #565656;
}
&:hover .td {
border-top: 1px solid #177ac9;
border-bottom: 1px solid #177ac9;
}
&:nth-of-type(odd) .td {
background-color: #303030;
}
`
});
const onCancel = async () => {
await fetchModules().then(() => {
setNumChanges(0);
});
};
function hasModulesChanged(mi: ModuleItem) {
return mi.enabled !== mi.o_enabled;
}
const selectModule = (updatedItem: ModuleItem) => {
updatedItem.enabled = !updatedItem.enabled;
updateState('modules', (data: ModuleItem[]) => {
const new_data = data.map((mi) =>
mi.id === updatedItem.id ? { ...mi, ...updatedItem } : mi
);
setNumChanges(new_data.filter((mi) => hasModulesChanged(mi)).length);
return new_data;
});
};
const saveModules = async () => {
await writeModules({
modules: modules.map((condensed_mi) => ({
name: condensed_mi.name,
enabled: condensed_mi.enabled
}))
})
.then(() => {
toast.success('Modules saved');
})
.catch((error: Error) => {
toast.error(error.message);
})
.finally(async () => {
await fetchModules();
setNumChanges(0);
});
};
const renderModules = () => {
if (!modules) {
return <FormLoader onRetry={fetchModules} errorMessage={error?.message} />;
}
useLayoutTitle('Modules');
return (
<Table
data={{ nodes: modules }}
theme={modules_theme}
layout={{ custom: true }}
>
{(tableList: ModuleItem[]) => (
<>
<Header>
<HeaderRow>
<HeaderCell />
<HeaderCell stiff>{LL.NAME(0)}</HeaderCell>
<HeaderCell stiff>Author</HeaderCell>
<HeaderCell stiff>{LL.VERSION()}</HeaderCell>
<HeaderCell stiff>{LL.STATUS_OF('')}</HeaderCell>
</HeaderRow>
</Header>
<Body>
{tableList.map((mi: ModuleItem) => (
<Row key={mi.id} item={mi} onClick={() => selectModule(mi)}>
<Cell stiff>
{mi.enabled ? (
<CircleIcon
color="success"
sx={{ fontSize: 16, verticalAlign: 'middle' }}
/>
) : (
<CircleIcon
color="error"
sx={{ fontSize: 16, verticalAlign: 'middle' }}
/>
)}
</Cell>
<Cell>{mi.name}</Cell>
<Cell>{mi.author}</Cell>
<Cell>{mi.version}</Cell>
<Cell>{mi.status}</Cell>
</Row>
))}
</Body>
</>
)}
</Table>
);
};
return (
<SectionContent>
{blocker ? <BlockNavigation blocker={blocker} /> : null}
<Box mb={2} color="warning.main">
<Typography variant="body2">
Activate or de-activate EMS-ESP library modules (** experimental **)
</Typography>
</Box>
{renderModules()}
<Box mt={1} display="flex" flexWrap="wrap">
<Box flexGrow={1}>
{numChanges !== 0 && (
<ButtonRow>
<Button
startIcon={<CancelIcon />}
variant="outlined"
onClick={onCancel}
color="secondary"
>
{LL.CANCEL()}
</Button>
<Button
startIcon={<WarningIcon color="warning" />}
variant="contained"
color="info"
onClick={saveModules}
>
{LL.APPLY_CHANGES(numChanges)}
</Button>
</ButtonRow>
)}
</Box>
</Box>
</SectionContent>
);
};
export default Modules;

View File

@@ -9,6 +9,8 @@ import type {
Devices,
Entities,
EntityItem,
ModuleItem,
Modules,
Schedule,
ScheduleItem,
SensorData,
@@ -104,6 +106,20 @@ export const readSchedule = () =>
export const writeSchedule = (data: Schedule) =>
alovaInstance.Post('/rest/schedule', data);
// Modules
export const readModules = () =>
alovaInstance.Get<ModuleItem[]>('/rest/modules', {
name: 'modules',
transformData(data) {
return (data as Modules).modules.map((mi: ModuleItem) => ({
...mi,
o_enabled: mi.enabled
}));
}
});
export const writeModules = (data: Modules) =>
alovaInstance.Post('/rest/modules', data);
// SettingsEntities
export const readCustomEntities = () =>
alovaInstance.Get<EntityItem[]>('/rest/customEntities', {

View File

@@ -308,6 +308,20 @@ export interface Schedule {
schedule: ScheduleItem[];
}
export interface ModuleItem {
id: number; // unique index
name: string;
author: string;
version: string;
status: string;
enabled: boolean;
o_enabled?: boolean;
}
export interface Modules {
modules: ModuleItem[];
}
export enum ScheduleFlag {
SCHEDULE_SUN = 1,
SCHEDULE_MON = 2,

View File

@@ -39,6 +39,16 @@ __metadata:
languageName: node
linkType: hard
"@babel/code-frame@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/code-frame@npm:7.24.6"
dependencies:
"@babel/highlight": "npm:^7.24.6"
picocolors: "npm:^1.0.0"
checksum: 10c0/c93c6d1763530f415218c31d07359364397f19b70026abdff766164c21ed352a931cf07f3102c5fb9e04792de319e332d68bcb1f7debef601a02197f90f9ba24
languageName: node
linkType: hard
"@babel/compat-data@npm:^7.23.5":
version: 7.24.4
resolution: "@babel/compat-data@npm:7.24.4"
@@ -46,7 +56,14 @@ __metadata:
languageName: node
linkType: hard
"@babel/core@npm:^7.22.1, @babel/core@npm:^7.24.5":
"@babel/compat-data@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/compat-data@npm:7.24.6"
checksum: 10c0/f50abbd4008eb2a5d12139c578809cebbeaeb8e660fb12d546eb2e7c2108ae1836ab8339184a5f5ce0e95bf81bb91e18edce86b387c59db937b01693ec0bc774
languageName: node
linkType: hard
"@babel/core@npm:^7.22.1":
version: 7.24.5
resolution: "@babel/core@npm:7.24.5"
dependencies:
@@ -69,6 +86,29 @@ __metadata:
languageName: node
linkType: hard
"@babel/core@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/core@npm:7.24.6"
dependencies:
"@ampproject/remapping": "npm:^2.2.0"
"@babel/code-frame": "npm:^7.24.6"
"@babel/generator": "npm:^7.24.6"
"@babel/helper-compilation-targets": "npm:^7.24.6"
"@babel/helper-module-transforms": "npm:^7.24.6"
"@babel/helpers": "npm:^7.24.6"
"@babel/parser": "npm:^7.24.6"
"@babel/template": "npm:^7.24.6"
"@babel/traverse": "npm:^7.24.6"
"@babel/types": "npm:^7.24.6"
convert-source-map: "npm:^2.0.0"
debug: "npm:^4.1.0"
gensync: "npm:^1.0.0-beta.2"
json5: "npm:^2.2.3"
semver: "npm:^6.3.1"
checksum: 10c0/e0762a8daef7f417494d555929418cfacd6848c7fc3310ec00e6dd8cecac20b7f590e760bfc9365d2af07874a3f5599832f9c9ff7f1a9d126a168f77ba67945a
languageName: node
linkType: hard
"@babel/generator@npm:7.17.7":
version: 7.17.7
resolution: "@babel/generator@npm:7.17.7"
@@ -92,6 +132,18 @@ __metadata:
languageName: node
linkType: hard
"@babel/generator@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/generator@npm:7.24.6"
dependencies:
"@babel/types": "npm:^7.24.6"
"@jridgewell/gen-mapping": "npm:^0.3.5"
"@jridgewell/trace-mapping": "npm:^0.3.25"
jsesc: "npm:^2.5.1"
checksum: 10c0/8d71a17b386536582354afba53cc784396458a88cc9f05f0c6de0ec99475f6f539943b3566b2e733820c4928236952473831765e483c25d68cc007a6e604d782
languageName: node
linkType: hard
"@babel/helper-annotate-as-pure@npm:^7.22.5":
version: 7.22.5
resolution: "@babel/helper-annotate-as-pure@npm:7.22.5"
@@ -114,6 +166,19 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-compilation-targets@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-compilation-targets@npm:7.24.6"
dependencies:
"@babel/compat-data": "npm:^7.24.6"
"@babel/helper-validator-option": "npm:^7.24.6"
browserslist: "npm:^4.22.2"
lru-cache: "npm:^5.1.1"
semver: "npm:^6.3.1"
checksum: 10c0/4d41150086959f5f4d72d27bae29204192e943537ecb71df1711d1f5d8791358a44f3a5882ed3c8238ba0c874b0b55213af43767e14771765f13b8d15b262432
languageName: node
linkType: hard
"@babel/helper-environment-visitor@npm:^7.22.20":
version: 7.22.20
resolution: "@babel/helper-environment-visitor@npm:7.22.20"
@@ -121,6 +186,13 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-environment-visitor@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-environment-visitor@npm:7.24.6"
checksum: 10c0/fdcd18ac505ed71f40c05cc992b648a4495b0aa5310a774492a0f74d8dcf3579691102f516561a651d3de6c3a44fe64bfb3049d11c14c5857634ef1823ea409a
languageName: node
linkType: hard
"@babel/helper-function-name@npm:^7.23.0":
version: 7.23.0
resolution: "@babel/helper-function-name@npm:7.23.0"
@@ -131,6 +203,16 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-function-name@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-function-name@npm:7.24.6"
dependencies:
"@babel/template": "npm:^7.24.6"
"@babel/types": "npm:^7.24.6"
checksum: 10c0/5ba2f8db789b3f5a2b2239300a217aa212e303cd7bfad9c8b90563807f49215e8c679e8f8f177b6aaca2038038e29bc702b83839e1f7b4896d79c44a75cac97a
languageName: node
linkType: hard
"@babel/helper-hoist-variables@npm:^7.22.5":
version: 7.22.5
resolution: "@babel/helper-hoist-variables@npm:7.22.5"
@@ -140,6 +222,15 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-hoist-variables@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-hoist-variables@npm:7.24.6"
dependencies:
"@babel/types": "npm:^7.24.6"
checksum: 10c0/e10ec6b864aaa419ec4934f5fcb5d0cfcc9d0657584a1b6c3c42ada949d44ca6bffcdab433a90ada4396c747e551cca31ba0e565ea005ab3f50964e3817bf6cf
languageName: node
linkType: hard
"@babel/helper-module-imports@npm:^7.16.7, @babel/helper-module-imports@npm:^7.22.15, @babel/helper-module-imports@npm:^7.24.3":
version: 7.24.3
resolution: "@babel/helper-module-imports@npm:7.24.3"
@@ -149,6 +240,15 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-module-imports@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-module-imports@npm:7.24.6"
dependencies:
"@babel/types": "npm:^7.24.6"
checksum: 10c0/e0db3fbfcd963d138f0792ff626f940a576fcf212d02b8fe6478dccf3421bd1c2a76f8e69c7450c049985e7b63b30be309a24eeeb6ad7c2137a31b676a095a84
languageName: node
linkType: hard
"@babel/helper-module-transforms@npm:^7.24.5":
version: 7.24.5
resolution: "@babel/helper-module-transforms@npm:7.24.5"
@@ -164,6 +264,21 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-module-transforms@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-module-transforms@npm:7.24.6"
dependencies:
"@babel/helper-environment-visitor": "npm:^7.24.6"
"@babel/helper-module-imports": "npm:^7.24.6"
"@babel/helper-simple-access": "npm:^7.24.6"
"@babel/helper-split-export-declaration": "npm:^7.24.6"
"@babel/helper-validator-identifier": "npm:^7.24.6"
peerDependencies:
"@babel/core": ^7.0.0
checksum: 10c0/9e2e3d0ddb397b36b9e8c7d94e175a36be8cb888ef370cefef2cdfd53ae1f87d567b268bd90ed9a6c706485a8de3da19cac577657613e9cd17210b91cbdfb00b
languageName: node
linkType: hard
"@babel/helper-plugin-utils@npm:^7.22.5, @babel/helper-plugin-utils@npm:^7.24.0":
version: 7.24.5
resolution: "@babel/helper-plugin-utils@npm:7.24.5"
@@ -180,6 +295,15 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-simple-access@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-simple-access@npm:7.24.6"
dependencies:
"@babel/types": "npm:^7.24.6"
checksum: 10c0/b17e404dd6c9787fc7d558aea5222471a77e29596705f0d10b4c2a58b9d71ff7eae915094204848cc1af99b771553caa69337a768b9abdd82b54a0050ba83eb9
languageName: node
linkType: hard
"@babel/helper-split-export-declaration@npm:^7.22.6, @babel/helper-split-export-declaration@npm:^7.24.5":
version: 7.24.5
resolution: "@babel/helper-split-export-declaration@npm:7.24.5"
@@ -189,6 +313,15 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-split-export-declaration@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-split-export-declaration@npm:7.24.6"
dependencies:
"@babel/types": "npm:^7.24.6"
checksum: 10c0/53a5dd8691fdffc89cc7fcf5aed0ad1d8bc39796a5782a3d170dcbf249eb5c15cc8a290e8d09615711d18798ad04a7d0694ab5195d35fa651abbc1b9c885d6a8
languageName: node
linkType: hard
"@babel/helper-string-parser@npm:^7.24.1":
version: 7.24.1
resolution: "@babel/helper-string-parser@npm:7.24.1"
@@ -196,6 +329,13 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-string-parser@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-string-parser@npm:7.24.6"
checksum: 10c0/95115bf676e92c4e99166395649108d97447e6cabef1fabaec8cdbc53a43f27b5df2268ff6534439d405bc1bd06685b163eb3b470455bd49f69159dada414145
languageName: node
linkType: hard
"@babel/helper-validator-identifier@npm:^7.16.7, @babel/helper-validator-identifier@npm:^7.24.5":
version: 7.24.5
resolution: "@babel/helper-validator-identifier@npm:7.24.5"
@@ -203,6 +343,13 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-validator-identifier@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-validator-identifier@npm:7.24.6"
checksum: 10c0/d29d2e3fca66c31867a009014169b93f7bc21c8fc1dd7d0b9d85d7a4000670526ff2222d966febb75a6e12f9859a31d1e75b558984e28ecb69651314dd0a6fd1
languageName: node
linkType: hard
"@babel/helper-validator-option@npm:^7.23.5":
version: 7.23.5
resolution: "@babel/helper-validator-option@npm:7.23.5"
@@ -210,6 +357,13 @@ __metadata:
languageName: node
linkType: hard
"@babel/helper-validator-option@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helper-validator-option@npm:7.24.6"
checksum: 10c0/787268dff5cf77f3b704454b96ab7b58aa4f43b2808247e51859a103a1c28a9c252100f830433f4b37a73f4a61ba745bbeef4cdccbab48c1e9adf037f4ca3491
languageName: node
linkType: hard
"@babel/helpers@npm:^7.24.5":
version: 7.24.5
resolution: "@babel/helpers@npm:7.24.5"
@@ -221,6 +375,16 @@ __metadata:
languageName: node
linkType: hard
"@babel/helpers@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/helpers@npm:7.24.6"
dependencies:
"@babel/template": "npm:^7.24.6"
"@babel/types": "npm:^7.24.6"
checksum: 10c0/e5b5c0919fd6fa56ae11c15a72962d8de0ac19db524849554af28cf08ac32f9ae5aee49a43146eb150f54418cefb8e890fa2b2f33d029434dc7777dbcdfd5bac
languageName: node
linkType: hard
"@babel/highlight@npm:^7.24.2":
version: 7.24.5
resolution: "@babel/highlight@npm:7.24.5"
@@ -233,6 +397,18 @@ __metadata:
languageName: node
linkType: hard
"@babel/highlight@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/highlight@npm:7.24.6"
dependencies:
"@babel/helper-validator-identifier": "npm:^7.24.6"
chalk: "npm:^2.4.2"
js-tokens: "npm:^4.0.0"
picocolors: "npm:^1.0.0"
checksum: 10c0/5bbc31695e5d44e97feb267f7aaf4c52908560d184ffeb2e2e57aae058d40125592931883889413e19def3326895ddb41ff45e090fa90b459d8c294b4ffc238c
languageName: node
linkType: hard
"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.20.5, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.23.0, @babel/parser@npm:^7.24.0, @babel/parser@npm:^7.24.5":
version: 7.24.5
resolution: "@babel/parser@npm:7.24.5"
@@ -242,6 +418,15 @@ __metadata:
languageName: node
linkType: hard
"@babel/parser@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/parser@npm:7.24.6"
bin:
parser: ./bin/babel-parser.js
checksum: 10c0/cbef70923078a20fe163b03f4a6482be65ed99d409a57f3091a23ce3a575ee75716c30e7ea9f40b692ac5660f34055f4cbeb66a354fad15a6cf1fca35c3496c5
languageName: node
linkType: hard
"@babel/plugin-syntax-jsx@npm:^7.23.3":
version: 7.24.1
resolution: "@babel/plugin-syntax-jsx@npm:7.24.1"
@@ -299,6 +484,17 @@ __metadata:
languageName: node
linkType: hard
"@babel/template@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/template@npm:7.24.6"
dependencies:
"@babel/code-frame": "npm:^7.24.6"
"@babel/parser": "npm:^7.24.6"
"@babel/types": "npm:^7.24.6"
checksum: 10c0/a4d5805770de908b445f7cdcebfcb6eaa07b1ec9c7b78fd3f375a911b1522c249bddae6b96bc4aac24247cc603e3e6cffcf2fe50b4c929dfeb22de289b517525
languageName: node
linkType: hard
"@babel/traverse@npm:7.23.2":
version: 7.23.2
resolution: "@babel/traverse@npm:7.23.2"
@@ -335,6 +531,24 @@ __metadata:
languageName: node
linkType: hard
"@babel/traverse@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/traverse@npm:7.24.6"
dependencies:
"@babel/code-frame": "npm:^7.24.6"
"@babel/generator": "npm:^7.24.6"
"@babel/helper-environment-visitor": "npm:^7.24.6"
"@babel/helper-function-name": "npm:^7.24.6"
"@babel/helper-hoist-variables": "npm:^7.24.6"
"@babel/helper-split-export-declaration": "npm:^7.24.6"
"@babel/parser": "npm:^7.24.6"
"@babel/types": "npm:^7.24.6"
debug: "npm:^4.3.1"
globals: "npm:^11.1.0"
checksum: 10c0/39027d5fc7a241c6b71bb5872c2bdcec53743cd7ef3c151bbe6fd7cf874d15f4bc09e5d7e19e2f534b0eb2c115f5368553885fa4253aa1bc9441c6e5bf9efdaf
languageName: node
linkType: hard
"@babel/types@npm:7.17.0":
version: 7.17.0
resolution: "@babel/types@npm:7.17.0"
@@ -356,6 +570,17 @@ __metadata:
languageName: node
linkType: hard
"@babel/types@npm:^7.24.6":
version: 7.24.6
resolution: "@babel/types@npm:7.24.6"
dependencies:
"@babel/helper-string-parser": "npm:^7.24.6"
"@babel/helper-validator-identifier": "npm:^7.24.6"
to-fast-properties: "npm:^2.0.0"
checksum: 10c0/1d94d92d97ef49030ad7f9e14cfccfeb70b1706dabcaa69037e659ec9d2c3178fb005d2088cce40d88dfc1306153d9157fe038a79ea2be92e5e6b99a59ef80cc
languageName: node
linkType: hard
"@emotion/babel-plugin@npm:^11.11.0":
version: 11.11.0
resolution: "@emotion/babel-plugin@npm:11.11.0"
@@ -870,16 +1095,16 @@ __metadata:
languageName: node
linkType: hard
"@mui/core-downloads-tracker@npm:^5.15.18":
version: 5.15.18
resolution: "@mui/core-downloads-tracker@npm:5.15.18"
checksum: 10c0/7899df3ce5192f2b876b8e5e645b03701512b9edaf386be07aa81d0d940404fa966776ef3e5e7654f312949f669db60438b864e14f7cece3eec7b5979a7349aa
"@mui/core-downloads-tracker@npm:^5.15.19":
version: 5.15.19
resolution: "@mui/core-downloads-tracker@npm:5.15.19"
checksum: 10c0/90cd3eb95399326f60140618b43c91de133a7192fd122c379278e30e09b921a6109786189b1a78e45b3b6ef6104d0f0e2f29209e48f64c978ec28ef91c5bce2b
languageName: node
linkType: hard
"@mui/icons-material@npm:^5.15.18":
version: 5.15.18
resolution: "@mui/icons-material@npm:5.15.18"
"@mui/icons-material@npm:^5.15.19":
version: 5.15.19
resolution: "@mui/icons-material@npm:5.15.19"
dependencies:
"@babel/runtime": "npm:^7.23.9"
peerDependencies:
@@ -889,17 +1114,17 @@ __metadata:
peerDependenciesMeta:
"@types/react":
optional: true
checksum: 10c0/8990f48060cb9f52a898c3b53d602913129bd37c811528dbc3988a62b1ef84b12dd9e263be76200a429455e5552706d1395c8f2b1fe56c04b37543784864d43c
checksum: 10c0/f2a4381b6a0f955d74aa5ac88bb8d38fee384fdff9a8e82c7fb9e596fbc61ccff97883a6c1a3cfbab3253f4d53c3fef21a3b438dfe45de365e842577bc892c08
languageName: node
linkType: hard
"@mui/material@npm:^5.15.18":
version: 5.15.18
resolution: "@mui/material@npm:5.15.18"
"@mui/material@npm:^5.15.19":
version: 5.15.19
resolution: "@mui/material@npm:5.15.19"
dependencies:
"@babel/runtime": "npm:^7.23.9"
"@mui/base": "npm:5.0.0-beta.40"
"@mui/core-downloads-tracker": "npm:^5.15.18"
"@mui/core-downloads-tracker": "npm:^5.15.19"
"@mui/system": "npm:^5.15.15"
"@mui/types": "npm:^7.2.14"
"@mui/utils": "npm:^5.15.14"
@@ -922,7 +1147,7 @@ __metadata:
optional: true
"@types/react":
optional: true
checksum: 10c0/0ae6ec5cb806b8095f16c542be5e0ae059e5e4adccf1cc463865acd0429b7c9b8fc12ce56c12a15ac787f29c173d118ff06af56e1e4c46a040212cd7d203c15d
checksum: 10c0/388eb14bedea7453dde7e5cbdcf9e51bec20567978d9405aa4affb9df69d25c9696427820ebff927215a8e8cd79a873ce9ac4207989a1c6b859d26394031382e
languageName: node
linkType: hard
@@ -1585,13 +1810,13 @@ __metadata:
languageName: node
linkType: hard
"@types/react@npm:^18.3.2":
version: 18.3.2
resolution: "@types/react@npm:18.3.2"
"@types/react@npm:^18.3.3":
version: 18.3.3
resolution: "@types/react@npm:18.3.3"
dependencies:
"@types/prop-types": "npm:*"
csstype: "npm:^3.0.2"
checksum: 10c0/9fb2f1fcf7e889ee4ea7c3c5978df595c66e770e5fd3a245dbdd2589b9b911524c11dab25a6275d8af4e336e4cb5fa850d447884b84c335a187a338c89df99ba
checksum: 10c0/fe455f805c5da13b89964c3d68060cebd43e73ec15001a68b34634604a78140e6fc202f3f61679b9d809dde6d7a7c2cb3ed51e0fd1462557911db09879b55114
languageName: node
linkType: hard
@@ -1613,15 +1838,15 @@ __metadata:
languageName: node
linkType: hard
"@typescript-eslint/eslint-plugin@npm:7.9.0":
version: 7.9.0
resolution: "@typescript-eslint/eslint-plugin@npm:7.9.0"
"@typescript-eslint/eslint-plugin@npm:7.11.0":
version: 7.11.0
resolution: "@typescript-eslint/eslint-plugin@npm:7.11.0"
dependencies:
"@eslint-community/regexpp": "npm:^4.10.0"
"@typescript-eslint/scope-manager": "npm:7.9.0"
"@typescript-eslint/type-utils": "npm:7.9.0"
"@typescript-eslint/utils": "npm:7.9.0"
"@typescript-eslint/visitor-keys": "npm:7.9.0"
"@typescript-eslint/scope-manager": "npm:7.11.0"
"@typescript-eslint/type-utils": "npm:7.11.0"
"@typescript-eslint/utils": "npm:7.11.0"
"@typescript-eslint/visitor-keys": "npm:7.11.0"
graphemer: "npm:^1.4.0"
ignore: "npm:^5.3.1"
natural-compare: "npm:^1.4.0"
@@ -1632,44 +1857,44 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 10c0/5c0ded9cb2210c141d236075f01a86447bf497a5061773c3c64a90756264776b4c4df100f7588e36d34f727eca55afd52fe6696a3cbe2d1f131250934254603a
checksum: 10c0/50fedf832e4de9546569106eab1d10716204ceebc5cc7d62299112c881212270d0f7857e3d6452c07db031d40b58cf27c4d1b1a36043e8e700fc3496e377b54a
languageName: node
linkType: hard
"@typescript-eslint/parser@npm:7.9.0":
version: 7.9.0
resolution: "@typescript-eslint/parser@npm:7.9.0"
"@typescript-eslint/parser@npm:7.11.0":
version: 7.11.0
resolution: "@typescript-eslint/parser@npm:7.11.0"
dependencies:
"@typescript-eslint/scope-manager": "npm:7.9.0"
"@typescript-eslint/types": "npm:7.9.0"
"@typescript-eslint/typescript-estree": "npm:7.9.0"
"@typescript-eslint/visitor-keys": "npm:7.9.0"
"@typescript-eslint/scope-manager": "npm:7.11.0"
"@typescript-eslint/types": "npm:7.11.0"
"@typescript-eslint/typescript-estree": "npm:7.11.0"
"@typescript-eslint/visitor-keys": "npm:7.11.0"
debug: "npm:^4.3.4"
peerDependencies:
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10c0/16ca04645429436d9b7986cddda979ef4d088f4223f4a69e04a369e0fd4852dd5ff3d4b99da2e43cddaa2b421b24ff42f275d87bd110ae2356bdd0e81c2534e7
checksum: 10c0/f5d1343fae90ccd91aea8adf194e22ed3eb4b2ea79d03d8a9ca6e7b669a6db306e93138ec64f7020c5b3128619d50304dea1f06043eaff6b015071822cad4972
languageName: node
linkType: hard
"@typescript-eslint/scope-manager@npm:7.9.0":
version: 7.9.0
resolution: "@typescript-eslint/scope-manager@npm:7.9.0"
"@typescript-eslint/scope-manager@npm:7.11.0":
version: 7.11.0
resolution: "@typescript-eslint/scope-manager@npm:7.11.0"
dependencies:
"@typescript-eslint/types": "npm:7.9.0"
"@typescript-eslint/visitor-keys": "npm:7.9.0"
checksum: 10c0/1ba6fc559a42a9b54e38c3ac2b6669efcff1a30292fb4e5fc8739c890a6c0f37d1a6aee1d115198f57c88e4f1776e95c1d7143de5cb5b970d5eb3023e97789dd
"@typescript-eslint/types": "npm:7.11.0"
"@typescript-eslint/visitor-keys": "npm:7.11.0"
checksum: 10c0/35f9d88f38f2366017b15c9ee752f2605afa8009fa1eaf81c8b2b71fc22ddd2a33fff794a02015c8991a5fa99f315c3d6d76a5957d3fad1ccbb4cd46735c98b5
languageName: node
linkType: hard
"@typescript-eslint/type-utils@npm:7.9.0":
version: 7.9.0
resolution: "@typescript-eslint/type-utils@npm:7.9.0"
"@typescript-eslint/type-utils@npm:7.11.0":
version: 7.11.0
resolution: "@typescript-eslint/type-utils@npm:7.11.0"
dependencies:
"@typescript-eslint/typescript-estree": "npm:7.9.0"
"@typescript-eslint/utils": "npm:7.9.0"
"@typescript-eslint/typescript-estree": "npm:7.11.0"
"@typescript-eslint/utils": "npm:7.11.0"
debug: "npm:^4.3.4"
ts-api-utils: "npm:^1.3.0"
peerDependencies:
@@ -1677,23 +1902,23 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 10c0/775280fb179268f8bacd60e684d9d5a1c6a379646b082c7244bf2dfb7dd693053bd9efa473b71e10a86db69322b0a2cecf5598d019684930df50000bf3d70af0
checksum: 10c0/637395cb0f4c424c610e751906a31dcfedcdbd8c479012da6e81f9be6b930f32317bfe170ccb758d93a411b2bd9c4e7e5d18892094466099c6f9c3dceda81a72
languageName: node
linkType: hard
"@typescript-eslint/types@npm:7.9.0":
version: 7.9.0
resolution: "@typescript-eslint/types@npm:7.9.0"
checksum: 10c0/d5f4a547dba4865ee2391bf06f2b3f8e8592a561976d2be35bb61ce340c7d1b7b4b25ac6ab5b9941813b465b9420bebb7b2179b1d71f6a83069feeb000b3558d
"@typescript-eslint/types@npm:7.11.0":
version: 7.11.0
resolution: "@typescript-eslint/types@npm:7.11.0"
checksum: 10c0/c5d6c517124017eb44aa180c8ea1fad26ec8e47502f92fd12245ba3141560e69d7f7e35b8aa160ddd5df63a2952af407e2f62cc58b663c86e1f778ffb5b01789
languageName: node
linkType: hard
"@typescript-eslint/typescript-estree@npm:7.9.0":
version: 7.9.0
resolution: "@typescript-eslint/typescript-estree@npm:7.9.0"
"@typescript-eslint/typescript-estree@npm:7.11.0":
version: 7.11.0
resolution: "@typescript-eslint/typescript-estree@npm:7.11.0"
dependencies:
"@typescript-eslint/types": "npm:7.9.0"
"@typescript-eslint/visitor-keys": "npm:7.9.0"
"@typescript-eslint/types": "npm:7.11.0"
"@typescript-eslint/visitor-keys": "npm:7.11.0"
debug: "npm:^4.3.4"
globby: "npm:^11.1.0"
is-glob: "npm:^4.0.3"
@@ -1703,31 +1928,31 @@ __metadata:
peerDependenciesMeta:
typescript:
optional: true
checksum: 10c0/cfc3d2b7a5433c9a2989c7289bc72b49786993782801ad8ca5a07c651df457a67fbce13b120c86c34c03d56570a90e5cf4f3b8806349f103a3658f2366ec28ea
checksum: 10c0/a4eda43f352d20edebae0c1c221c4fd9de0673a94988cf1ae3f5e4917ef9cdb9ead8d3673ea8dd6e80d9cf3523a47c295be1326a3fae017b277233f4c4b4026b
languageName: node
linkType: hard
"@typescript-eslint/utils@npm:7.9.0":
version: 7.9.0
resolution: "@typescript-eslint/utils@npm:7.9.0"
"@typescript-eslint/utils@npm:7.11.0":
version: 7.11.0
resolution: "@typescript-eslint/utils@npm:7.11.0"
dependencies:
"@eslint-community/eslint-utils": "npm:^4.4.0"
"@typescript-eslint/scope-manager": "npm:7.9.0"
"@typescript-eslint/types": "npm:7.9.0"
"@typescript-eslint/typescript-estree": "npm:7.9.0"
"@typescript-eslint/scope-manager": "npm:7.11.0"
"@typescript-eslint/types": "npm:7.11.0"
"@typescript-eslint/typescript-estree": "npm:7.11.0"
peerDependencies:
eslint: ^8.56.0
checksum: 10c0/cb99d6a950e7da0319bc7b923a82c52c0798a14e837afee51b2295cfbde02e0a2ac8e0b5904cd7bd01d1b376c7a6ad3739101b486feaf2517c8640024deb88c7
checksum: 10c0/539a7ff8b825ad810fc59a80269094748df1a397a42cdbb212c493fc2486711c7d8fd6d75d4cd8a067822b8e6a11f42c50441977d51c183eec47992506d1cdf8
languageName: node
linkType: hard
"@typescript-eslint/visitor-keys@npm:7.9.0":
version: 7.9.0
resolution: "@typescript-eslint/visitor-keys@npm:7.9.0"
"@typescript-eslint/visitor-keys@npm:7.11.0":
version: 7.11.0
resolution: "@typescript-eslint/visitor-keys@npm:7.11.0"
dependencies:
"@typescript-eslint/types": "npm:7.9.0"
"@typescript-eslint/types": "npm:7.11.0"
eslint-visitor-keys: "npm:^3.4.3"
checksum: 10c0/19181d8b9d2d7bc43d5c8884661cd9a86ac316392b8e590187cc507442093a1ba2bef0cc22181b8298d5dc9f455abb73cffa4663451bdf32b1b7fe12160c5c99
checksum: 10c0/664e558d9645896484b7ffc9381837f0d52443bf8d121a5586d02d42ca4d17dc35faf526768c4b1beb52c57c43fae555898eb087651eb1c7a3d60f1085effea1
languageName: node
linkType: hard
@@ -1737,12 +1962,12 @@ __metadata:
dependencies:
"@alova/adapter-xhr": "npm:^1.0.6"
"@alova/scene-react": "npm:^1.5.0"
"@babel/core": "npm:^7.24.5"
"@babel/core": "npm:^7.24.6"
"@emotion/react": "npm:^11.11.4"
"@emotion/styled": "npm:^11.11.5"
"@eslint/js": "npm:^9.3.0"
"@mui/icons-material": "npm:^5.15.18"
"@mui/material": "npm:^5.15.18"
"@mui/icons-material": "npm:^5.15.19"
"@mui/material": "npm:^5.15.19"
"@preact/compat": "npm:^17.1.2"
"@preact/preset-vite": "npm:^2.8.2"
"@table-library/react-table-library": "npm:4.1.7"
@@ -1750,7 +1975,7 @@ __metadata:
"@types/babel__core": "npm:^7"
"@types/lodash-es": "npm:^4.17.12"
"@types/node": "npm:^20.12.12"
"@types/react": "npm:^18.3.2"
"@types/react": "npm:^18.3.3"
"@types/react-dom": "npm:^18.3.0"
"@types/react-router-dom": "npm:^5.3.3"
alova: "npm:^2.20.5"
@@ -1774,8 +1999,8 @@ __metadata:
terser: "npm:^5.31.0"
typesafe-i18n: "npm:^5.26.2"
typescript: "npm:^5.4.5"
typescript-eslint: "npm:^7.9.0"
vite: "npm:^5.2.11"
typescript-eslint: "npm:^7.11.0"
vite: "npm:^5.2.12"
vite-plugin-imagemin: "npm:^0.6.1"
vite-tsconfig-paths: "npm:^4.3.2"
languageName: unknown
@@ -6892,19 +7117,19 @@ __metadata:
languageName: node
linkType: hard
"typescript-eslint@npm:^7.9.0":
version: 7.9.0
resolution: "typescript-eslint@npm:7.9.0"
"typescript-eslint@npm:^7.11.0":
version: 7.11.0
resolution: "typescript-eslint@npm:7.11.0"
dependencies:
"@typescript-eslint/eslint-plugin": "npm:7.9.0"
"@typescript-eslint/parser": "npm:7.9.0"
"@typescript-eslint/utils": "npm:7.9.0"
"@typescript-eslint/eslint-plugin": "npm:7.11.0"
"@typescript-eslint/parser": "npm:7.11.0"
"@typescript-eslint/utils": "npm:7.11.0"
peerDependencies:
eslint: ^8.56.0
peerDependenciesMeta:
typescript:
optional: true
checksum: 10c0/dacdd8b278d519eea1d980c71dd301a0b68fe1100aa8eaa9e3b80acd7089765ef50bdf369b7c11ddc5f4be6ac6d90cc9283db549003c3df8cfabbe4f44a36b53
checksum: 10c0/11dbbf4f317abe687733614f85a255e5ebad0d45d2a1f8c4922918bf74b902c8b20fd3be50f58cd6e7645a2cb34e99cb068ac97bca50ff96c931cfa9572855c0
languageName: node
linkType: hard
@@ -7093,9 +7318,9 @@ __metadata:
languageName: node
linkType: hard
"vite@npm:^5.2.11":
version: 5.2.11
resolution: "vite@npm:5.2.11"
"vite@npm:^5.2.12":
version: 5.2.12
resolution: "vite@npm:5.2.12"
dependencies:
esbuild: "npm:^0.20.1"
fsevents: "npm:~2.3.3"
@@ -7129,7 +7354,7 @@ __metadata:
optional: true
bin:
vite: bin/vite.js
checksum: 10c0/664b8d68e4f5152ae16bd2041af1bbaf11c43630ac461835bc31ff7d019913b33e465386e09f66dc1037d7aeefbb06939e0173787c063319bc2bd30c3b9ad8e4
checksum: 10c0/f03fdfc320adea3397df3e327029fd875f8220779f679ab183a3a994e8788b4ce531fee28f830361fb274f3cf08ed9adb9429496ecefdc3faf535b38da7ea8b1
languageName: node
linkType: hard

View File

@@ -428,10 +428,11 @@ const EMSESP_WRITE_TEMPSENSOR_ENDPOINT = REST_ENDPOINT_ROOT + 'writeTemperatureS
const EMSESP_WRITE_ANALOGSENSOR_ENDPOINT = REST_ENDPOINT_ROOT + 'writeAnalogSensor';
const EMSESP_CUSTOMIZATION_ENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'customizationEntities';
const EMSESP_RESET_CUSTOMIZATIONS_ENDPOINT = REST_ENDPOINT_ROOT + 'resetCustomizations';
const EMSESP_SCHEDULE_ENDPOINT = REST_ENDPOINT_ROOT + 'schedule';
const EMSESP_CUSTOMENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'customEntities';
const EMSESP_MODULES_ENDPOINT = REST_ENDPOINT_ROOT + 'modules';
// these are used in the API calls only
const EMSESP_GET_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'getSettings';
const EMSESP_GET_CUSTOMIZATIONS_ENDPOINT = REST_ENDPOINT_ROOT + 'getCustomizations';
const EMSESP_GET_ENTITIES_ENDPOINT = REST_ENDPOINT_ROOT + 'getEntities';
@@ -2127,6 +2128,28 @@ let emsesp_schedule = {
]
};
// SCHEDULE
let emsesp_modules = {
"modules": [
{
id: 1,
"name": "ModuleTest1",
"author": "proddy",
"version": "1.0.0",
"enabled": true,
"status": "active"
},
{
id: 2,
"name": "ModuleTest2",
"author": "proddy",
"version": "1.0.0",
"enabled": true,
"status": "active"
}
]
}
// CUSTOMIZATION
const emsesp_deviceentities_1 = [{ v: 'dummy value', n: 'dummy name', id: 'dummy', m: 0, w: false }];
const emsesp_deviceentities_3 = [{ v: 'dummy value', n: 'dummy name', id: 'dummy', m: 0, w: false }];
@@ -2485,6 +2508,22 @@ router
})
.get(EMSESP_SCHEDULE_ENDPOINT, () => emsesp_schedule)
// Modules
.post(EMSESP_MODULES_ENDPOINT, async (request: any) => {
const content = await request.json();
// TODO find the one and toggle it
console.log('modules saved', emsesp_modules);
/*
const dd_objIndex = dd.data.findIndex((obj: any) => obj.id.slice(2) === fullname);
if (dd_objIndex !== -1) {
let changed = new Boolean(false);
emsesp_modules = content;
*/
return status(200);
})
.get(EMSESP_MODULES_ENDPOINT, () => emsesp_modules)
// Custom Entities
.post(EMSESP_CUSTOMENTITIES_ENDPOINT, async (request: any) => {
const content = await request.json();