diff --git a/.gitignore b/.gitignore index e1c4ecc90..f680ef353 100644 --- a/.gitignore +++ b/.gitignore @@ -37,7 +37,7 @@ stats.html !.yarn/sdks !.yarn/versions yarn.lock -interface/analyse.html +analyse.html interface/vite.config.ts.timestamp* # scripts diff --git a/interface/package.json b/interface/package.json index 9d12cdd96..9e9c0c46c 100644 --- a/interface/package.json +++ b/interface/package.json @@ -23,15 +23,15 @@ }, "dependencies": { "@alova/adapter-xhr": "^1.0.3", - "@babel/core": "^7.24.0", + "@babel/core": "^7.24.1", "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.0", - "@mui/icons-material": "^5.15.13", - "@mui/material": "^5.15.13", + "@mui/icons-material": "^5.15.14", + "@mui/material": "^5.15.14", "@table-library/react-table-library": "4.1.7", "@types/imagemin": "^8.0.5", "@types/lodash-es": "^4.17.12", - "@types/node": "^20.11.28", + "@types/node": "^20.11.30", "@types/react": "^18.2.67", "@types/react-dom": "^18.2.22", "@types/react-router-dom": "^5.3.3", @@ -54,8 +54,8 @@ "devDependencies": { "@preact/compat": "^17.1.2", "@preact/preset-vite": "^2.8.2", - "@typescript-eslint/eslint-plugin": "^7.3.0", - "@typescript-eslint/parser": "^7.3.0", + "@typescript-eslint/eslint-plugin": "^7.3.1", + "@typescript-eslint/parser": "^7.3.1", "concurrently": "^8.2.2", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", diff --git a/interface/src/AuthenticatedRouting.tsx b/interface/src/AuthenticatedRouting.tsx index 689a325c2..7ba75209f 100644 --- a/interface/src/AuthenticatedRouting.tsx +++ b/interface/src/AuthenticatedRouting.tsx @@ -10,6 +10,7 @@ import NetworkConnection from 'framework/network/NetworkConnection'; import NetworkTime from 'framework/ntp/NetworkTime'; import OTASettingsForm from 'framework/ota/OTASettingsForm'; import Security from 'framework/security/Security'; +import ESPSystemStatus from 'framework/system/ESPSystemStatus'; import Status from 'framework/system/Status'; import UploadDownload from 'framework/system/UploadDownload'; import ApplicationSettings from 'project/ApplicationSettings'; @@ -42,6 +43,7 @@ const AuthenticatedRouting: FC = () => { } /> } /> } /> + } /> } /> )} diff --git a/interface/src/api/system.ts b/interface/src/api/system.ts index 8b3cb72fa..447866037 100644 --- a/interface/src/api/system.ts +++ b/interface/src/api/system.ts @@ -1,7 +1,10 @@ import { alovaInstance, alovaInstanceGH } from './endpoints'; -import type { OTASettings, SystemStatus, LogSettings } from 'types'; +import type { OTASettings, SystemStatus, LogSettings, ESPSystemStatus } from 'types'; -// SystemStatus - also used to ping in Restart monitor for pinging +// ESPSystemStatus - also used to ping in Restart monitor for pinging +export const readESPSystemStatus = () => alovaInstance.Get('/rest/ESPSystemStatus'); + +// SystemStatus export const readSystemStatus = () => alovaInstance.Get('/rest/systemStatus'); // commands diff --git a/interface/src/framework/Settings.tsx b/interface/src/framework/Settings.tsx index 1515b7417..ce84066a1 100644 --- a/interface/src/framework/Settings.tsx +++ b/interface/src/framework/Settings.tsx @@ -4,6 +4,7 @@ import CastIcon from '@mui/icons-material/Cast'; import DeviceHubIcon from '@mui/icons-material/DeviceHub'; import ImportExportIcon from '@mui/icons-material/ImportExport'; import LockIcon from '@mui/icons-material/Lock'; +import MemoryIcon from '@mui/icons-material/Memory'; import NavigateNextIcon from '@mui/icons-material/NavigateNext'; import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew'; import SettingsBackupRestoreIcon from '@mui/icons-material/SettingsBackupRestore'; @@ -24,7 +25,8 @@ import { DialogActions, DialogContent, DialogTitle, - Box + Box, + Divider } from '@mui/material'; import { useRequest } from 'alova'; import { useState, type FC } from 'react'; @@ -294,6 +296,26 @@ const Settings: FC = () => { + + + + + + } + > + + + + + + + + + + { + {renderRestartDialog()} {renderFactoryResetDialog()} + diff --git a/interface/src/framework/ap/APSettingsForm.tsx b/interface/src/framework/ap/APSettingsForm.tsx index bb0ea3541..95acbc36f 100644 --- a/interface/src/framework/ap/APSettingsForm.tsx +++ b/interface/src/framework/ap/APSettingsForm.tsx @@ -205,7 +205,7 @@ const APSettingsForm: FC = () => { }; return ( - + {blocker ? : null} {content()} diff --git a/interface/src/framework/ap/APStatusForm.tsx b/interface/src/framework/ap/APStatusForm.tsx index 0a05e0f22..af66de784 100644 --- a/interface/src/framework/ap/APStatusForm.tsx +++ b/interface/src/framework/ap/APStatusForm.tsx @@ -99,7 +99,7 @@ const APStatusForm: FC = () => { ); }; - return {content()}; + return {content()}; }; export default APStatusForm; diff --git a/interface/src/framework/mqtt/MqttSettingsForm.tsx b/interface/src/framework/mqtt/MqttSettingsForm.tsx index e7e0f4e70..2a5b774ad 100644 --- a/interface/src/framework/mqtt/MqttSettingsForm.tsx +++ b/interface/src/framework/mqtt/MqttSettingsForm.tsx @@ -449,7 +449,7 @@ const MqttSettingsForm: FC = () => { }; return ( - + {blocker ? : null} {content()} diff --git a/interface/src/framework/mqtt/MqttStatusForm.tsx b/interface/src/framework/mqtt/MqttStatusForm.tsx index 872a8a79b..25cf86ef0 100644 --- a/interface/src/framework/mqtt/MqttStatusForm.tsx +++ b/interface/src/framework/mqtt/MqttStatusForm.tsx @@ -146,7 +146,7 @@ const MqttStatusForm: FC = () => { ); }; - return {content()}; + return {content()}; }; export default MqttStatusForm; diff --git a/interface/src/framework/network/NetworkSettingsForm.tsx b/interface/src/framework/network/NetworkSettingsForm.tsx index 34c5af798..39786f087 100644 --- a/interface/src/framework/network/NetworkSettingsForm.tsx +++ b/interface/src/framework/network/NetworkSettingsForm.tsx @@ -360,7 +360,7 @@ const WiFiSettingsForm: FC = () => { }; return ( - + {blocker ? : null} {restarting ? : content()} diff --git a/interface/src/framework/network/NetworkStatusForm.tsx b/interface/src/framework/network/NetworkStatusForm.tsx index 37a3efe88..a84f97df8 100644 --- a/interface/src/framework/network/NetworkStatusForm.tsx +++ b/interface/src/framework/network/NetworkStatusForm.tsx @@ -193,7 +193,7 @@ const NetworkStatusForm: FC = () => { ); }; - return {content()}; + return {content()}; }; export default NetworkStatusForm; diff --git a/interface/src/framework/network/WiFiNetworkScanner.tsx b/interface/src/framework/network/WiFiNetworkScanner.tsx index f7d227104..ecc5eb034 100644 --- a/interface/src/framework/network/WiFiNetworkScanner.tsx +++ b/interface/src/framework/network/WiFiNetworkScanner.tsx @@ -56,7 +56,7 @@ const WiFiNetworkScanner: FC = () => { }; return ( - + {renderNetworkScanner()} + + + + ); + + const content = () => { + if (!data) { + return ; + } + + return ( + <> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {me.admin && ( + + )} + + + + + + {renderScanDialog()} + + + + + + ); + }; + + return {content()}; +}; + +export default SystemStatus; diff --git a/interface/src/framework/system/UploadDownload.tsx b/interface/src/framework/system/UploadDownload.tsx index b1091e1ce..a9b012310 100644 --- a/interface/src/framework/system/UploadDownload.tsx +++ b/interface/src/framework/system/UploadDownload.tsx @@ -32,12 +32,13 @@ const UploadDownload: FC = () => { immediate: false }); - const { data: data, send: loadData, error } = useRequest(SystemApi.readSystemStatus, { force: true }); + const { data: data, send: loadData, error } = useRequest(SystemApi.readESPSystemStatus, { force: true }); const { data: latestVersion } = useRequest(SystemApi.getStableVersion, { immediate: true, force: true }); + const { data: latestDevVersion } = useRequest(SystemApi.getDevVersion, { immediate: true, force: true diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index 7af60142d..77c3e0685 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -80,7 +80,6 @@ const de: Translation = { FAIL: 'FEHLER', QUALITY: 'QUALITÄT', SCAN_DEVICES: 'Nach neuen Geräten suchen', - EMS_BUS_STATUS_TITLE: 'EMS-Bus- und Aktivitätsstatus', SCAN: 'Suche', STATUS_NAMES: [ 'EMS-Telegramme empfangen (Rx)', @@ -322,7 +321,9 @@ const de: Translation = { ACTIVEHIGH: 'Aktiv Positiv', ACTIVELOW: 'Aktiv Negativ', UNCHANGED: 'Unverändert', - ALWAYS: 'Immer' + ALWAYS: 'Immer', + ACTIVITY: 'Activity' // TODO translate + }; export default de; diff --git a/interface/src/i18n/en/index.ts b/interface/src/i18n/en/index.ts index 465637f39..d1ecd25aa 100644 --- a/interface/src/i18n/en/index.ts +++ b/interface/src/i18n/en/index.ts @@ -80,7 +80,6 @@ const en: Translation = { FAIL: 'FAIL', QUALITY: 'QUALITY', SCAN_DEVICES: 'Scan for new devices', - EMS_BUS_STATUS_TITLE: 'EMS Bus & Activity Status', SCAN: 'Scan', STATUS_NAMES: [ 'EMS Telegrams Received (Rx)', @@ -164,7 +163,7 @@ const en: Translation = { HELP_INFORMATION_1: 'Visit the online wiki to get instructions on how to configure EMS-ESP', HELP_INFORMATION_2: 'For live community chat join our Discord server', HELP_INFORMATION_3: 'To request a feature or report a bug', - HELP_INFORMATION_4: 'Remember to download and attach your support information for a faster response when reporting an issue', + HELP_INFORMATION_4: 'Download and attach your support information for a faster response when reporting an issue', HELP_INFORMATION_5: 'EMS-ESP is a free and open-source project. Please support its future development by giving it a star on Github!', UPLOAD: 'Upload', DOWNLOAD: '{{D|d|d}}ownload', @@ -187,7 +186,6 @@ const en: Translation = { RELEASE_IS: 'release is', RELEASE_NOTES: 'release notes', EMS_ESP_VER: 'EMS-ESP Version', - PLATFORM: 'Device (Platform / SDK)', UPTIME: 'System Uptime', HEAP: 'Heap (Free / Max Alloc)', PSRAM: 'PSRAM (Size / Free)', @@ -323,7 +321,8 @@ const en: Translation = { ACTIVEHIGH: 'Active High', ACTIVELOW: 'Active Low', UNCHANGED: 'Unchanged', - ALWAYS: 'Always' + ALWAYS: 'Always', + ACTIVITY: 'Activity' }; export default en; diff --git a/interface/src/i18n/fr/index.ts b/interface/src/i18n/fr/index.ts index 744c064c7..8187f0dea 100644 --- a/interface/src/i18n/fr/index.ts +++ b/interface/src/i18n/fr/index.ts @@ -80,7 +80,6 @@ const fr: Translation = { FAIL: 'ÉCHEC', QUALITY: 'QUALITÉ', SCAN_DEVICES: 'Rechercher de nouveaux appareils', - EMS_BUS_STATUS_TITLE: 'Statut du bus et de l\'activité EMS', SCAN: 'Scan', STATUS_NAMES: [ 'Télégrammes EMS reçus (Rx)', @@ -322,7 +321,8 @@ const fr: Translation = { ACTIVEHIGH: 'Active High', // TODO translate ACTIVELOW: 'Active Low', // TODO translate UNCHANGED: 'Unchanged', // TODO translate - ALWAYS: 'Always' // TODO translate + ALWAYS: 'Always', // TODO translate + ACTIVITY: 'Activity' // TODO translate }; export default fr; diff --git a/interface/src/i18n/it/index.ts b/interface/src/i18n/it/index.ts index fc320c453..85e1c806c 100644 --- a/interface/src/i18n/it/index.ts +++ b/interface/src/i18n/it/index.ts @@ -48,7 +48,6 @@ const it: Translation = { REMOVE: 'Elimina', PROBLEM_UPDATING: 'Problema aggiornamento', PROBLEM_LOADING: 'Problema caricamento', - ACCESS_DENIED: 'Accesso Negato', ANALOG_SENSOR: 'Sensore Analogico', ANALOG_SENSORS: 'Sensori Analogici', SETTINGS: 'Settings', @@ -68,7 +67,6 @@ const it: Translation = { TEMP_SENSOR: 'Sensore Temperatura', TEMP_SENSORS: 'Sensori Temperatura', WRITE_CMD_SENT: 'Scrittura comando inviata', - WRITE_CMD_FAILED: 'Scittura comando fallita', EMS_BUS_WARNING: 'EMS bus disconnesso. Se questo avvertimento persiste dopo alcuni secondi prego verificare impostazioni scheda', EMS_BUS_SCANNING: 'Scansione dispositivi EMS ...', CONNECTED: 'Connesso', @@ -82,7 +80,6 @@ const it: Translation = { FAIL: 'FALLITO', QUALITY: 'QUALITÂ', SCAN_DEVICES: 'Scansione per nuovi dispositivi', - EMS_BUS_STATUS_TITLE: 'Bus EMS & Stato Attività', SCAN: 'Scansione', STATUS_NAMES: [ 'Telegrammi EMS Ricevuti (Rx)', @@ -324,7 +321,8 @@ const it: Translation = { ACTIVEHIGH: 'Active High', // TODO translate ACTIVELOW: 'Active Low', // TODO translate UNCHANGED: 'Unchanged', // TODO translate - ALWAYS: 'Always' // TODO translate + ALWAYS: 'Always', // TODO translate + ACTIVITY: 'Activity' // TODO translate }; export default it; diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index 78d8218ca..55f1651c5 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -80,7 +80,6 @@ const nl: Translation = { FAIL: 'MISLUKT', QUALITY: 'QUALITEIT', SCAN_DEVICES: 'Scannen naar nieuwe apparaten', - EMS_BUS_STATUS_TITLE: 'EMS Bus & Activiteitenstatus', SCAN: 'Scan', STATUS_NAMES: [ 'EMS Telegrammen ontvangen (Rx)', @@ -322,7 +321,8 @@ const nl: Translation = { ACTIVEHIGH: 'Active High', // TODO translate ACTIVELOW: 'Active Low', // TODO translate UNCHANGED: 'Unchanged', // TODO translate - ALWAYS: 'Always' // TODO translate + ALWAYS: 'Always', // TODO translate + ACTIVITY: 'Activity' // TODO translate }; export default nl; diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index 974bfa17c..533ac2713 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -80,7 +80,6 @@ const no: Translation = { FAIL: 'MISLYKKET', QUALITY: 'KVALITET', SCAN_DEVICES: 'Søk etter nye enheter', - EMS_BUS_STATUS_TITLE: 'EMS Buss & Aktivitet Status', SCAN: 'Søk', STATUS_NAMES: [ 'EMS Telegrammer Mottatt (Rx)', @@ -322,7 +321,8 @@ const no: Translation = { ACTIVEHIGH: 'Active High', // TODO translate ACTIVELOW: 'Active Low', // TODO translate UNCHANGED: 'Unchanged', // TODO translate - ALWAYS: 'Always' // TODO translate + ALWAYS: 'Always', // TODO translate + ACTIVITY: 'Activity' // TODO translate }; export default no; diff --git a/interface/src/i18n/pl/index.ts b/interface/src/i18n/pl/index.ts index 38b54f927..fd2f641b8 100644 --- a/interface/src/i18n/pl/index.ts +++ b/interface/src/i18n/pl/index.ts @@ -80,7 +80,6 @@ const pl: BaseTranslation = { FAIL: 'Nieudane', QUALITY: 'Jakość', SCAN_DEVICES: 'Wyszukiwanie nowych urządzeń', - EMS_BUS_STATUS_TITLE: 'Aktywność', SCAN: 'Skanuj', STATUS_NAMES: [ 'EMS, telegramy odebrane (Rx)', @@ -322,7 +321,8 @@ const pl: BaseTranslation = { ACTIVEHIGH: 'Wyzwalany stanem wysokim', ACTIVELOW: 'Wyzwalany stanem niskim', UNCHANGED: 'Zachowaj stan', - ALWAYS: 'Zawsze' + ALWAYS: 'Zawsze', + ACTIVITY: 'Activity' // TODO translate }; export default pl; diff --git a/interface/src/i18n/sk/index.ts b/interface/src/i18n/sk/index.ts index ef6adc0e0..2b0399ba3 100644 --- a/interface/src/i18n/sk/index.ts +++ b/interface/src/i18n/sk/index.ts @@ -80,7 +80,6 @@ const sk: Translation = { FAIL: 'ZLYHANIE', QUALITY: 'KVALITA', SCAN_DEVICES: 'Scan pre nové zariadenia', - EMS_BUS_STATUS_TITLE: 'EMS zbernica & stav aktivity', SCAN: 'Scan', STATUS_NAMES: [ 'EMS Telegramy prijaté (Rx)', @@ -322,7 +321,8 @@ const sk: Translation = { ACTIVEHIGH: 'Aktívny Vysoký', ACTIVELOW: 'Aktívny Nízky', UNCHANGED: 'Nezmenené', - ALWAYS: 'Vždy' + ALWAYS: 'Vždy', + ACTIVITY: 'Activity' // TODO translate }; export default sk; diff --git a/interface/src/i18n/sv/index.ts b/interface/src/i18n/sv/index.ts index 588b86462..13f2d86b0 100644 --- a/interface/src/i18n/sv/index.ts +++ b/interface/src/i18n/sv/index.ts @@ -80,7 +80,6 @@ const sv: Translation = { FAIL: 'Misslyckades', QUALITY: 'Kvalitet', SCAN_DEVICES: 'Sök efter nya enheter', - EMS_BUS_STATUS_TITLE: 'EMS-buss & aktivitetsstatus', SCAN: 'Sök', STATUS_NAMES: [ 'EMS-telegram (Rx)', @@ -322,7 +321,8 @@ const sv: Translation = { ACTIVEHIGH: 'Active High', // TODO translate ACTIVELOW: 'Active Low', // TODO translate UNCHANGED: 'Unchanged', // TODO translate - ALWAYS: 'Always' // TODO translate + ALWAYS: 'Always', // TODO translate + ACTIVITY: 'Activity' // TODO translate }; export default sv; diff --git a/interface/src/i18n/tr/index.ts b/interface/src/i18n/tr/index.ts index e229331b5..f6c84fece 100644 --- a/interface/src/i18n/tr/index.ts +++ b/interface/src/i18n/tr/index.ts @@ -80,7 +80,6 @@ const tr: Translation = { FAIL: 'HATA', QUALITY: 'KALİTE', SCAN_DEVICES: 'Yeni cihaz taraması', - EMS_BUS_STATUS_TITLE: 'EMS Hattı ve Aktivite Durumu', SCAN: 'Tara', STATUS_NAMES: [ 'EMS Telegramlar Alındı (Rx)', @@ -322,7 +321,8 @@ const tr: Translation = { ACTIVEHIGH: 'Active High', // TODO translate ACTIVELOW: 'Active Low', // TODO translate UNCHANGED: 'Unchanged', // TODO translate - ALWAYS: 'Always' // TODO translate + ALWAYS: 'Always', // TODO translate + ACTIVITY: 'Activity' // TODO translate }; export default tr; diff --git a/interface/src/project/Activity.tsx b/interface/src/project/Activity.tsx new file mode 100644 index 000000000..7320270cc --- /dev/null +++ b/interface/src/project/Activity.tsx @@ -0,0 +1,128 @@ +import RefreshIcon from '@mui/icons-material/Refresh'; +import { Box, Button } from '@mui/material'; +import { Body, Cell, Header, HeaderCell, HeaderRow, Row, Table } from '@table-library/react-table-library/table'; +import { useTheme as tableTheme } from '@table-library/react-table-library/theme'; +import { useRequest } from 'alova'; +import { useEffect } from 'react'; + +import * as EMSESP from './api'; +import type { Stat } from './types'; + +import type { Translation } from 'i18n/i18n-types'; +import type { FC } from 'react'; +import { FormLoader, SectionContent } from 'components'; +import { useI18nContext } from 'i18n/i18n-react'; + +const Activity: FC = () => { + const { data: data, send: loadData, error } = useRequest(EMSESP.readActivity); + + const { LL } = useI18nContext(); + + const stats_theme = tableTheme({ + Table: ` + --data-table-library_grid-template-columns: repeat(1, minmax(0, 1fr)) 90px 90px 80px; + `, + BaseRow: ` + font-size: 14px; + `, + HeaderRow: ` + text-transform: uppercase; + background-color: black; + color: #90CAF9; + + .th { + height: 36px; + border-bottom: 1px solid #565656; + } + `, + Row: ` + .td { + padding: 8px; + border-top: 1px solid #565656; + border-bottom: 1px solid #565656; + } + + &:nth-of-type(odd) .td { + background-color: #303030; + } + &:nth-of-type(even) .td { + background-color: #1e1e1e; + } + `, + BaseCell: ` + &:not(:first-of-type) { + text-align: center; + } + ` + }); + + useEffect(() => { + const timer = setInterval(() => loadData(), 30000); + return () => { + clearInterval(timer); + }; + }); + + const showName = (id: any) => { + const name: keyof Translation['STATUS_NAMES'] = id; + return LL.STATUS_NAMES[name](); + }; + + const showQuality = (stat: Stat) => { + if (stat.q === 0 || stat.s + stat.f === 0) { + return; + } + if (stat.q === 100) { + return
{stat.q}%
; + } + if (stat.q >= 95) { + return
{stat.q}%
; + } else { + return
{stat.q}%
; + } + }; + + const content = () => { + if (!data) { + return ; + } + + return ( + <> + + {(tableList: any) => ( + <> +
+ + + {LL.SUCCESS()} + {LL.FAIL()} + {LL.QUALITY()} + +
+ + {tableList.map((stat: Stat) => ( + + {showName(stat.id)} + {Intl.NumberFormat().format(stat.s)} + {Intl.NumberFormat().format(stat.f)} + {showQuality(stat)} + + ))} + + + )} +
+ + + + + ); + }; + + return {content()}; +}; + +export default Activity; diff --git a/interface/src/project/EMSStatus.tsx b/interface/src/project/EMSStatus.tsx deleted file mode 100644 index 4bfc70bcf..000000000 --- a/interface/src/project/EMSStatus.tsx +++ /dev/null @@ -1,279 +0,0 @@ -import CancelIcon from '@mui/icons-material/Cancel'; -import DeviceHubIcon from '@mui/icons-material/DeviceHub'; -import DirectionsBusIcon from '@mui/icons-material/DirectionsBus'; -import PermScanWifiIcon from '@mui/icons-material/PermScanWifi'; -import RefreshIcon from '@mui/icons-material/Refresh'; -import { - Avatar, - Box, - Button, - Dialog, - DialogActions, - DialogContent, - DialogTitle, - List, - ListItem, - ListItemAvatar, - ListItemText, - useTheme -} from '@mui/material'; -import { Body, Cell, Header, HeaderCell, HeaderRow, Row, Table } from '@table-library/react-table-library/table'; -import { useTheme as tableTheme } from '@table-library/react-table-library/theme'; -import { useRequest } from 'alova'; -import { useContext, useEffect, useState } from 'react'; -import { toast } from 'react-toastify'; - -import * as EMSESP from './api'; -import { busConnectionStatus } from './types'; -import type { Stat, Status } from './types'; -import type { Theme } from '@mui/material'; - -import type { Translation } from 'i18n/i18n-types'; -import type { FC } from 'react'; -import { dialogStyle } from 'CustomTheme'; -import { ButtonRow, FormLoader, SectionContent } from 'components'; -import { AuthenticatedContext } from 'contexts/authentication'; -import { useI18nContext } from 'i18n/i18n-react'; - -export const isConnected = ({ status }: Status) => status !== busConnectionStatus.BUS_STATUS_OFFLINE; - -const busStatusHighlight = ({ status }: Status, theme: Theme) => { - switch (status) { - case busConnectionStatus.BUS_STATUS_TX_ERRORS: - return theme.palette.warning.main; - case busConnectionStatus.BUS_STATUS_CONNECTED: - return theme.palette.success.main; - case busConnectionStatus.BUS_STATUS_OFFLINE: - return theme.palette.error.main; - default: - return theme.palette.warning.main; - } -}; - -const showQuality = (stat: Stat) => { - if (stat.q === 0 || stat.s + stat.f === 0) { - return; - } - if (stat.q === 100) { - return
{stat.q}%
; - } - if (stat.q >= 95) { - return
{stat.q}%
; - } else { - return
{stat.q}%
; - } -}; - -const EMSStatus: FC = () => { - const { data: data, send: loadData, error } = useRequest(EMSESP.readStatus); - - const { LL } = useI18nContext(); - - const theme = useTheme(); - const [confirmScan, setConfirmScan] = useState(false); - - const { me } = useContext(AuthenticatedContext); - - const { send: scanDevices } = useRequest(EMSESP.scanDevices, { - immediate: false - }); - - const stats_theme = tableTheme({ - Table: ` - --data-table-library_grid-template-columns: repeat(1, minmax(0, 1fr)) 90px 90px 80px; - `, - BaseRow: ` - font-size: 14px; - `, - HeaderRow: ` - text-transform: uppercase; - background-color: black; - color: #90CAF9; - - .th { - height: 36px; - border-bottom: 1px solid #565656; - } - `, - Row: ` - .td { - padding: 8px; - border-top: 1px solid #565656; - border-bottom: 1px solid #565656; - } - - &:nth-of-type(odd) .td { - background-color: #303030; - } - &:nth-of-type(even) .td { - background-color: #1e1e1e; - } - `, - BaseCell: ` - &:not(:first-of-type) { - text-align: center; - } - ` - }); - - useEffect(() => { - const timer = setInterval(() => loadData(), 30000); - return () => { - clearInterval(timer); - }; - }); - - const showName = (id: any) => { - const name: keyof Translation['STATUS_NAMES'] = id; - return LL.STATUS_NAMES[name](); - }; - - const formatDurationSec = (duration_sec: number) => { - const days = Math.trunc((duration_sec * 1000) / 86400000); - const hours = Math.trunc((duration_sec * 1000) / 3600000) % 24; - const minutes = Math.trunc((duration_sec * 1000) / 60000) % 60; - const seconds = Math.trunc((duration_sec * 1000) / 1000) % 60; - - let formatted = ''; - if (days) { - formatted += LL.NUM_DAYS({ num: days }) + ' '; - } - if (hours) { - formatted += LL.NUM_HOURS({ num: hours }) + ' '; - } - if (minutes) { - formatted += LL.NUM_MINUTES({ num: minutes }) + ' '; - } - formatted += LL.NUM_SECONDS({ num: seconds }); - return formatted; - }; - - const busStatus = () => { - if (data) { - switch (data.status) { - case busConnectionStatus.BUS_STATUS_CONNECTED: - return LL.CONNECTED(0) + ' (' + formatDurationSec(data.uptime) + ')'; - case busConnectionStatus.BUS_STATUS_TX_ERRORS: - return LL.TX_ISSUES(); - case busConnectionStatus.BUS_STATUS_OFFLINE: - return LL.DISCONNECTED(); - } - } - return 'Unknown'; - }; - - const scan = async () => { - await scanDevices() - .then(() => { - toast.info(LL.SCANNING() + '...'); - }) - .catch((err) => { - toast.error(err.message); - }); - setConfirmScan(false); - }; - - const renderScanDialog = () => ( - setConfirmScan(false)}> - {LL.SCAN_DEVICES()} - {LL.EMS_SCAN()} - - - - - - ); - - const content = () => { - if (!data) { - return ; - } - - return ( - <> - - - - - - - - - - - - - - - - - - - - {(tableList: any) => ( - <> -
- - - {LL.SUCCESS()} - {LL.FAIL()} - {LL.QUALITY()} - -
- - {tableList.map((stat: Stat) => ( - - {showName(stat.id)} - {Intl.NumberFormat().format(stat.s)} - {Intl.NumberFormat().format(stat.f)} - {showQuality(stat)} - - ))} - - - )} -
-
- {renderScanDialog()} - - - - - {me.admin && ( - - - - - - )} - - - ); - }; - - return {content()}; -}; - -export default EMSStatus; diff --git a/interface/src/project/api.ts b/interface/src/project/api.ts index 1475c4779..16cf7184e 100644 --- a/interface/src/project/api.ts +++ b/interface/src/project/api.ts @@ -1,7 +1,7 @@ import type { APIcall, Settings, - Status, + Activity, CoreData, Devices, DeviceEntity, @@ -25,7 +25,7 @@ export const readDeviceData = (id: number) => }); export const writeDeviceValue = (data: any) => alovaInstance.Post('/rest/writeDeviceValue', data); -// SettingsApplication +// Application Settings export const readSettings = () => alovaInstance.Get('/rest/settings'); export const writeSettings = (data: any) => alovaInstance.Post('/rest/settings', data); export const getBoardProfile = (boardProfile: string) => @@ -33,17 +33,18 @@ export const getBoardProfile = (boardProfile: string) => params: { boardProfile } }); -// DashboardSensors +// Sensors export const readSensorData = () => alovaInstance.Get('/rest/sensorData'); export const writeTemperatureSensor = (ts: WriteTemperatureSensor) => alovaInstance.Post('/rest/writeTemperatureSensor', ts); export const writeAnalogSensor = (as: WriteAnalogSensor) => alovaInstance.Post('/rest/writeAnalogSensor', as); -// DashboardStatus -export const readStatus = () => alovaInstance.Get('/rest/status'); +// Activity +export const readActivity = () => alovaInstance.Get('/rest/activity'); + export const scanDevices = () => alovaInstance.Post('/rest/scanDevices'); -// HelpInformation +// API, used in HelpInformation export const API = (apiCall: APIcall) => alovaInstance.Post('/api', apiCall); // UploadFileForm diff --git a/interface/src/project/types.ts b/interface/src/project/types.ts index 47b1d9a31..9b55c1f0b 100644 --- a/interface/src/project/types.ts +++ b/interface/src/project/types.ts @@ -50,13 +50,7 @@ export interface Stat { q: number; // quality } -export interface Status { - status: busConnectionStatus; - tx_mode: number; - uptime: number; - num_devices: number; - num_sensors: number; - num_analogs: number; +export interface Activity { stats: Stat[]; } diff --git a/interface/src/types/system.ts b/interface/src/types/system.ts index 04eee0593..3a7721178 100644 --- a/interface/src/types/system.ts +++ b/interface/src/types/system.ts @@ -1,5 +1,6 @@ -export interface SystemStatus { - // TODO fix this next +import type { busConnectionStatus } from 'project/types'; + +export interface ESPSystemStatus { emsesp_version: string; esp_platform: string; max_alloc_heap: number; @@ -17,13 +18,23 @@ export interface SystemStatus { app_free: number; fs_used: number; fs_free: number; - uptime: string; free_mem: number; psram_size?: number; free_psram?: number; has_loader: boolean; } +export interface SystemStatus { + emsesp_version: string; + esp_platform: string; + status: busConnectionStatus; + tx_mode: number; + uptime: number; + num_devices: number; + num_sensors: number; + num_analogs: number; +} + export interface OTASettings { enabled: boolean; port: number; diff --git a/interface/vite.config.ts b/interface/vite.config.ts index b5b69c560..e55510a06 100644 --- a/interface/vite.config.ts +++ b/interface/vite.config.ts @@ -29,7 +29,7 @@ export default defineConfig(({ command, mode }) => { }; } - if (command === 'build' && mode === 'hosted') { + if (mode === 'hosted') { return { plugins: [preact(), viteTsconfigPaths()], build: { @@ -38,97 +38,94 @@ export default defineConfig(({ command, mode }) => { }; } - // production build, both for hosted and building the firmware - if (command === 'build') { - return { - plugins: [ - preact(), - viteTsconfigPaths(), - splitVendorChunkPlugin(), - { - ...viteImagemin({ - verbose: false, - gifsicle: { - optimizationLevel: 7, - interlaced: false - }, - optipng: { - optimizationLevel: 7 - }, - mozjpeg: { - quality: 20 - }, - pngquant: { - quality: [0.8, 0.9], - speed: 4 - }, - svgo: { - plugins: [ - { - name: 'removeViewBox' - }, - { - name: 'removeEmptyAttrs', - active: false - } - ] - } - }), - enforce: 'pre' - }, - visualizer({ - template: 'treemap', // or sunburst - open: false, - gzipSize: true, - brotliSize: true, - filename: 'analyse.html' // will be saved in project's root - }) - ], - - build: { - // target: 'es2022', - chunkSizeWarningLimit: 1024, - minify: 'terser', - terserOptions: { - compress: { - passes: 4, - arrows: true, - drop_console: true, - drop_debugger: true, - sequences: true + return { + plugins: [ + preact(), + viteTsconfigPaths(), + splitVendorChunkPlugin(), + { + ...viteImagemin({ + verbose: false, + gifsicle: { + optimizationLevel: 7, + interlaced: false }, - mangle: { - // toplevel: true - // module: true - // properties: { - // regex: /^_/ - // } + optipng: { + optimizationLevel: 7 }, - ecma: 5, - enclose: false, - keep_classnames: false, - keep_fnames: false, - ie8: false, - module: false, - nameCache: null, - safari10: false, - toplevel: false - }, - - rollupOptions: { - output: { - manualChunks(id: string) { - if (id.includes('node_modules')) { - // creating a chunk to react routes deps. Reducing the vendor chunk size - if (id.includes('react-router-dom') || id.includes('@remix-run') || id.includes('react-router')) { - return '@react-router'; - } - return 'vendor'; + mozjpeg: { + quality: 20 + }, + pngquant: { + quality: [0.8, 0.9], + speed: 4 + }, + svgo: { + plugins: [ + { + name: 'removeViewBox' + }, + { + name: 'removeEmptyAttrs', + active: false } + ] + } + }), + enforce: 'pre' + }, + visualizer({ + template: 'treemap', // or sunburst + open: false, + gzipSize: true, + brotliSize: true, + filename: '../analyse.html' // will be saved in project's root + }) + ], + + build: { + // target: 'es2022', + chunkSizeWarningLimit: 1024, + minify: 'terser', + terserOptions: { + compress: { + passes: 4, + arrows: true, + drop_console: true, + drop_debugger: true, + sequences: true + }, + mangle: { + // toplevel: true + // module: true + // properties: { + // regex: /^_/ + // } + }, + ecma: 5, + enclose: false, + keep_classnames: false, + keep_fnames: false, + ie8: false, + module: false, + nameCache: null, + safari10: false, + toplevel: false + }, + + rollupOptions: { + output: { + manualChunks(id: string) { + if (id.includes('node_modules')) { + // creating a chunk to react routes deps. Reducing the vendor chunk size + if (id.includes('react-router-dom') || id.includes('@remix-run') || id.includes('react-router')) { + return '@react-router'; + } + return 'vendor'; } } } } - }; - } + } + }; }); diff --git a/interface/yarn.lock b/interface/yarn.lock index 694cb7e40..390fa43ae 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -39,6 +39,16 @@ __metadata: languageName: node linkType: hard +"@babel/code-frame@npm:^7.24.1": + version: 7.24.1 + resolution: "@babel/code-frame@npm:7.24.1" + dependencies: + "@babel/highlight": "npm:^7.24.1" + picocolors: "npm:^1.0.0" + checksum: 10/71da2249ea5cea5f0cb4c6e0052e921574d16ae415c5b876123787d160abc98442a91701834c875363dadd75d200897aa278336c505335722298982f793bdf89 + languageName: node + linkType: hard + "@babel/compat-data@npm:^7.23.5": version: 7.23.5 resolution: "@babel/compat-data@npm:7.23.5" @@ -46,7 +56,7 @@ __metadata: languageName: node linkType: hard -"@babel/core@npm:^7.22.1, @babel/core@npm:^7.24.0": +"@babel/core@npm:^7.22.1": version: 7.24.0 resolution: "@babel/core@npm:7.24.0" dependencies: @@ -69,6 +79,29 @@ __metadata: languageName: node linkType: hard +"@babel/core@npm:^7.24.1": + version: 7.24.1 + resolution: "@babel/core@npm:7.24.1" + dependencies: + "@ampproject/remapping": "npm:^2.2.0" + "@babel/code-frame": "npm:^7.24.1" + "@babel/generator": "npm:^7.24.1" + "@babel/helper-compilation-targets": "npm:^7.23.6" + "@babel/helper-module-transforms": "npm:^7.23.3" + "@babel/helpers": "npm:^7.24.1" + "@babel/parser": "npm:^7.24.1" + "@babel/template": "npm:^7.24.0" + "@babel/traverse": "npm:^7.24.1" + "@babel/types": "npm:^7.24.0" + 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: 10/f8c153acd619a5d17caee7aff052a2aa306ceda280ffc07182d7b5dd40c41c7511ae89d64bc23ec5555e4639fc9c87ceb7b4afc12252acab548ebb7654397680 + languageName: node + linkType: hard + "@babel/generator@npm:^7.23.6": version: 7.23.6 resolution: "@babel/generator@npm:7.23.6" @@ -81,6 +114,18 @@ __metadata: languageName: node linkType: hard +"@babel/generator@npm:^7.24.1": + version: 7.24.1 + resolution: "@babel/generator@npm:7.24.1" + dependencies: + "@babel/types": "npm:^7.24.0" + "@jridgewell/gen-mapping": "npm:^0.3.5" + "@jridgewell/trace-mapping": "npm:^0.3.25" + jsesc: "npm:^2.5.1" + checksum: 10/c6160e9cd63d7ed7168dee27d827f9c46fab820c45861a5df56cd5c78047f7c3fc97c341e9ccfa1a6f97c87ec2563d9903380b5f92794e3540a6c5f99eb8f075 + 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" @@ -210,6 +255,17 @@ __metadata: languageName: node linkType: hard +"@babel/helpers@npm:^7.24.1": + version: 7.24.1 + resolution: "@babel/helpers@npm:7.24.1" + dependencies: + "@babel/template": "npm:^7.24.0" + "@babel/traverse": "npm:^7.24.1" + "@babel/types": "npm:^7.24.0" + checksum: 10/82d3cdd3beafc4583f237515ef220bc205ced8b0540c6c6e191fc367a9589bd7304b8f9800d3d7574d4db9f079bd555979816b1874c86e53b3e7dd2032ad6c7c + languageName: node + linkType: hard + "@babel/highlight@npm:^7.23.4": version: 7.23.4 resolution: "@babel/highlight@npm:7.23.4" @@ -221,6 +277,18 @@ __metadata: languageName: node linkType: hard +"@babel/highlight@npm:^7.24.1": + version: 7.24.1 + resolution: "@babel/highlight@npm:7.24.1" + dependencies: + "@babel/helper-validator-identifier": "npm:^7.22.20" + chalk: "npm:^2.4.2" + js-tokens: "npm:^4.0.0" + picocolors: "npm:^1.0.0" + checksum: 10/5d9ad31006f462d3863e9c73004bd46d94d2a4144b3fcc1c9945d8a82411d05477d47466a1121f1d1dea986780145bf934e8b2809c6f056b2203fe481b4d471d + languageName: node + linkType: hard + "@babel/parser@npm:^7.24.0": version: 7.24.0 resolution: "@babel/parser@npm:7.24.0" @@ -230,6 +298,15 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.24.1": + version: 7.24.1 + resolution: "@babel/parser@npm:7.24.1" + bin: + parser: ./bin/babel-parser.js + checksum: 10/561d9454091e07ecfec3828ce79204c0fc9d24e17763f36181c6984392be4ca6b79c8225f2224fdb7b1b3b70940e243368c8f83ac77ec2dc20f46d3d06bd6795 + languageName: node + linkType: hard + "@babel/plugin-syntax-jsx@npm:^7.23.3": version: 7.23.3 resolution: "@babel/plugin-syntax-jsx@npm:7.23.3" @@ -305,6 +382,24 @@ __metadata: languageName: node linkType: hard +"@babel/traverse@npm:^7.24.1": + version: 7.24.1 + resolution: "@babel/traverse@npm:7.24.1" + dependencies: + "@babel/code-frame": "npm:^7.24.1" + "@babel/generator": "npm:^7.24.1" + "@babel/helper-environment-visitor": "npm:^7.22.20" + "@babel/helper-function-name": "npm:^7.23.0" + "@babel/helper-hoist-variables": "npm:^7.22.5" + "@babel/helper-split-export-declaration": "npm:^7.22.6" + "@babel/parser": "npm:^7.24.1" + "@babel/types": "npm:^7.24.0" + debug: "npm:^4.3.1" + globals: "npm:^11.1.0" + checksum: 10/b9b0173c286ef549e179f3725df3c4958069ad79fe5b9840adeb99692eb4a5a08db4e735c0f086aab52e7e08ec711cee9e7c06cb908d8035641d1382172308d3 + languageName: node + linkType: hard + "@babel/types@npm:^7.22.15, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.23.4, @babel/types@npm:^7.23.6, @babel/types@npm:^7.24.0, @babel/types@npm:^7.8.3": version: 7.24.0 resolution: "@babel/types@npm:7.24.0" @@ -801,14 +896,14 @@ __metadata: languageName: node linkType: hard -"@mui/base@npm:5.0.0-beta.39": - version: 5.0.0-beta.39 - resolution: "@mui/base@npm:5.0.0-beta.39" +"@mui/base@npm:5.0.0-beta.40": + version: 5.0.0-beta.40 + resolution: "@mui/base@npm:5.0.0-beta.40" dependencies: "@babel/runtime": "npm:^7.23.9" "@floating-ui/react-dom": "npm:^2.0.8" - "@mui/types": "npm:^7.2.13" - "@mui/utils": "npm:^5.15.13" + "@mui/types": "npm:^7.2.14" + "@mui/utils": "npm:^5.15.14" "@popperjs/core": "npm:^2.11.8" clsx: "npm:^2.1.0" prop-types: "npm:^15.8.1" @@ -819,20 +914,20 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 10/320aeedb6c32df9807e2581065e98c3dd0510dcd8666c1c4804fc2281fa42e4e2111152961ded0ba1c3b9dc320936ee73d1a0861c0985a0da86a7bd7bf8cbada + checksum: 10/ebee3d9e1136710dcb2af5828acc6bd8d54f6b124785d011585c2665a48dc66e35ccb344d5ebc7fd8bfd776cccb8ea434911f151a62bee193677ee9dc67fc7fc languageName: node linkType: hard -"@mui/core-downloads-tracker@npm:^5.15.13": - version: 5.15.13 - resolution: "@mui/core-downloads-tracker@npm:5.15.13" - checksum: 10/988e5c7ff9c185c603b6c5d533e6dbb305b5d334c3f2b4ebcc9e2a5fb7dea141ccb05f70aa4cbf972e2556a67a0d928c7bd3bf7ab5d41b139fd0532af64e2c65 +"@mui/core-downloads-tracker@npm:^5.15.14": + version: 5.15.14 + resolution: "@mui/core-downloads-tracker@npm:5.15.14" + checksum: 10/0a1c63d906af594d0a7fb63d1d574482b3916351ea8908e8621c8bfa16ac38cf4edb5a334f0e28084f583ac928b587cab6e031f992195e0a590186faba13b9a5 languageName: node linkType: hard -"@mui/icons-material@npm:^5.15.13": - version: 5.15.13 - resolution: "@mui/icons-material@npm:5.15.13" +"@mui/icons-material@npm:^5.15.14": + version: 5.15.14 + resolution: "@mui/icons-material@npm:5.15.14" dependencies: "@babel/runtime": "npm:^7.23.9" peerDependencies: @@ -842,20 +937,20 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 10/89e79ebe4a0ab8594934f4056034dcffe57cc7c4468717545d67310cb74626c38ea79a7129d16fbf265745ceca7e8c35d21c3f59a4519e0776f774f6ea228fd3 + checksum: 10/a5033b67d4ff455f5fdd91fc51d26d967d634e861cde194b9dde02a8cc3f557d1b3f7e0b3175bc654b8e944f2118d46620485734ecd9d2ed4a6f748386447933 languageName: node linkType: hard -"@mui/material@npm:^5.15.13": - version: 5.15.13 - resolution: "@mui/material@npm:5.15.13" +"@mui/material@npm:^5.15.14": + version: 5.15.14 + resolution: "@mui/material@npm:5.15.14" dependencies: "@babel/runtime": "npm:^7.23.9" - "@mui/base": "npm:5.0.0-beta.39" - "@mui/core-downloads-tracker": "npm:^5.15.13" - "@mui/system": "npm:^5.15.13" - "@mui/types": "npm:^7.2.13" - "@mui/utils": "npm:^5.15.13" + "@mui/base": "npm:5.0.0-beta.40" + "@mui/core-downloads-tracker": "npm:^5.15.14" + "@mui/system": "npm:^5.15.14" + "@mui/types": "npm:^7.2.14" + "@mui/utils": "npm:^5.15.14" "@types/react-transition-group": "npm:^4.4.10" clsx: "npm:^2.1.0" csstype: "npm:^3.1.3" @@ -875,16 +970,16 @@ __metadata: optional: true "@types/react": optional: true - checksum: 10/565e219d58f93bd8cdcc5e9d432046d6bfc3b2d81e3f1b8d4b93347f895f26d3f348a312fe2b943c41275fb3ea492e76d9651ce16f64e5773fe2be07309c67a2 + checksum: 10/a2c3355b39b86472bf2debb84d6c032b1ea4ba691fbda0f25803f2702f9106130bb85a7d2757545ce97540fe185f07cf24574d5786a29df26baa298ff7db063b languageName: node linkType: hard -"@mui/private-theming@npm:^5.15.13": - version: 5.15.13 - resolution: "@mui/private-theming@npm:5.15.13" +"@mui/private-theming@npm:^5.15.14": + version: 5.15.14 + resolution: "@mui/private-theming@npm:5.15.14" dependencies: "@babel/runtime": "npm:^7.23.9" - "@mui/utils": "npm:^5.15.13" + "@mui/utils": "npm:^5.15.14" prop-types: "npm:^15.8.1" peerDependencies: "@types/react": ^17.0.0 || ^18.0.0 @@ -892,13 +987,13 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 10/677fa31f8caa1f3ae4b44806b2cf340b23eb9132baaca1421f615d1ef1aae5560a7c452b4f79e38bdb865a54306ba65c4ac95c1f4c0216f89217dd19fb320747 + checksum: 10/6a14311ed53ee4adccfe0ba93275b43773d22fdd10c0d4ba680b9368fc0616a5e0f38f29d2080bcd7e4ed79123047e5f245c403d3fd822e960a97762be65218d languageName: node linkType: hard -"@mui/styled-engine@npm:^5.15.11": - version: 5.15.11 - resolution: "@mui/styled-engine@npm:5.15.11" +"@mui/styled-engine@npm:^5.15.14": + version: 5.15.14 + resolution: "@mui/styled-engine@npm:5.15.14" dependencies: "@babel/runtime": "npm:^7.23.9" "@emotion/cache": "npm:^11.11.0" @@ -913,19 +1008,19 @@ __metadata: optional: true "@emotion/styled": optional: true - checksum: 10/fedbb9891abd633e5072d30aae7405cec9e5e22ac63c9e117c49ddb66e86ec7baaed58f934efc7847ea86cc856a8c9a9ec5a08cd0072a7850184321a968704ad + checksum: 10/2a5e03bb20502aef94cfb908898c50abb769192deb32d7f4237039683ce5266104cdc4055a7f0a8342aa62447d52b7439a4f2d0dda0fa6709c227c3621468cab languageName: node linkType: hard -"@mui/system@npm:^5.15.13": - version: 5.15.13 - resolution: "@mui/system@npm:5.15.13" +"@mui/system@npm:^5.15.14": + version: 5.15.14 + resolution: "@mui/system@npm:5.15.14" dependencies: "@babel/runtime": "npm:^7.23.9" - "@mui/private-theming": "npm:^5.15.13" - "@mui/styled-engine": "npm:^5.15.11" - "@mui/types": "npm:^7.2.13" - "@mui/utils": "npm:^5.15.13" + "@mui/private-theming": "npm:^5.15.14" + "@mui/styled-engine": "npm:^5.15.14" + "@mui/types": "npm:^7.2.14" + "@mui/utils": "npm:^5.15.14" clsx: "npm:^2.1.0" csstype: "npm:^3.1.3" prop-types: "npm:^15.8.1" @@ -941,25 +1036,25 @@ __metadata: optional: true "@types/react": optional: true - checksum: 10/678a741d872a4badba32f7b88d7db969af96cf3e029f984abd0f58e88e95203a1ee3f4110f970a015d15f7e9171d0dea57040cdb8419901236790df4900de017 + checksum: 10/64a9eac1bebefad3042cce28a75d0af2828aa71acd4c32fb0267f5e68bc75b16a093b6fb30709db83ec32130f14f1d67c1c27457ef62733e54a9d04f9b027cee languageName: node linkType: hard -"@mui/types@npm:^7.2.13": - version: 7.2.13 - resolution: "@mui/types@npm:7.2.13" +"@mui/types@npm:^7.2.14": + version: 7.2.14 + resolution: "@mui/types@npm:7.2.14" peerDependencies: "@types/react": ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@types/react": optional: true - checksum: 10/a35bff025f715073329bd7cbe11ef4ce331ea377adffc0c5cd264bea47283590ce928d1fdbbc27506d1d462151325c81e71f2378ac4335feef3042010bbf3fcd + checksum: 10/b10cca8f63ea522be4f7c185acd1f4d031947e53824cbf9dc5649c165bcfa8a2749e83fd0bd1809b8e2698f58638ab2b4ce03550095989189d14434ea5c6c0b6 languageName: node linkType: hard -"@mui/utils@npm:^5.15.13": - version: 5.15.13 - resolution: "@mui/utils@npm:5.15.13" +"@mui/utils@npm:^5.15.14": + version: 5.15.14 + resolution: "@mui/utils@npm:5.15.14" dependencies: "@babel/runtime": "npm:^7.23.9" "@types/prop-types": "npm:^15.7.11" @@ -971,7 +1066,7 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: 10/16f78b87bb88f6e1131ac1ff426d4fda128d56bbbca53b98ae45ce45bf0bb826dba66cbff98b25d842225fd1a983c17ae83b43ead17c9add88789eb9514d065b + checksum: 10/b3cbe2d0aa7ec65969752dababc39fc6e0b8bb1a9cf8b9bac42ca40e3dd3eaa59b79765bd259019318acc7421d64b9f421bc67e776a581d7c9da6a1c0c50bfbc languageName: node linkType: hard @@ -1396,7 +1491,7 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:^20.11.28": +"@types/node@npm:*": version: 20.11.28 resolution: "@types/node@npm:20.11.28" dependencies: @@ -1405,6 +1500,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20.11.30": + version: 20.11.30 + resolution: "@types/node@npm:20.11.30" + dependencies: + undici-types: "npm:~5.26.4" + checksum: 10/78515bc768d2b878e2e06a1c20eb4f5840072b79b8d28ff3dd0a7feaaf48fd3a2ac03cfa5bc7564da82db5906b43e9ba0e5df9f43d870b7aae2942306e208815 + languageName: node + linkType: hard + "@types/parse-json@npm:^4.0.0": version: 4.0.2 resolution: "@types/parse-json@npm:4.0.2" @@ -1512,15 +1616,15 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^7.3.0": - version: 7.3.0 - resolution: "@typescript-eslint/eslint-plugin@npm:7.3.0" +"@typescript-eslint/eslint-plugin@npm:^7.3.1": + version: 7.3.1 + resolution: "@typescript-eslint/eslint-plugin@npm:7.3.1" dependencies: "@eslint-community/regexpp": "npm:^4.5.1" - "@typescript-eslint/scope-manager": "npm:7.3.0" - "@typescript-eslint/type-utils": "npm:7.3.0" - "@typescript-eslint/utils": "npm:7.3.0" - "@typescript-eslint/visitor-keys": "npm:7.3.0" + "@typescript-eslint/scope-manager": "npm:7.3.1" + "@typescript-eslint/type-utils": "npm:7.3.1" + "@typescript-eslint/utils": "npm:7.3.1" + "@typescript-eslint/visitor-keys": "npm:7.3.1" debug: "npm:^4.3.4" graphemer: "npm:^1.4.0" ignore: "npm:^5.2.4" @@ -1533,44 +1637,44 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 10/6728d30193446f1477c3b566fb33b762c95e531b385f1aeb4d5a28b488278e7a66e1efaa7de8ffea75eb470a99c78c9ffe022067b043bd4e3c936dd26d59df0b + checksum: 10/8ed276113a714d93ab3ababb1179e4785bd9378e6d97726519ea1d2ac502a94475e0be988c2ec427dcfc1e6950329d58da6e64131ee87028fce63493461cc51a languageName: node linkType: hard -"@typescript-eslint/parser@npm:^7.3.0": - version: 7.3.0 - resolution: "@typescript-eslint/parser@npm:7.3.0" +"@typescript-eslint/parser@npm:^7.3.1": + version: 7.3.1 + resolution: "@typescript-eslint/parser@npm:7.3.1" dependencies: - "@typescript-eslint/scope-manager": "npm:7.3.0" - "@typescript-eslint/types": "npm:7.3.0" - "@typescript-eslint/typescript-estree": "npm:7.3.0" - "@typescript-eslint/visitor-keys": "npm:7.3.0" + "@typescript-eslint/scope-manager": "npm:7.3.1" + "@typescript-eslint/types": "npm:7.3.1" + "@typescript-eslint/typescript-estree": "npm:7.3.1" + "@typescript-eslint/visitor-keys": "npm:7.3.1" debug: "npm:^4.3.4" peerDependencies: eslint: ^8.56.0 peerDependenciesMeta: typescript: optional: true - checksum: 10/df06a4e8d734951bb6843797f04e315122be071bbc5cc7939c9a0e61480fa3045e363db8862cdc81ebf04abd594cc1cedf625ba33fc62918319c4bd2ba7fb5fc + checksum: 10/018326010fec1dcefd75809ccac5102a475bf1e052d824b898d707e7c0bf3e51e101164b410d1b2a513628985c96eb412538644d2005e26b99a22db6eb9402df languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:7.3.0": - version: 7.3.0 - resolution: "@typescript-eslint/scope-manager@npm:7.3.0" +"@typescript-eslint/scope-manager@npm:7.3.1": + version: 7.3.1 + resolution: "@typescript-eslint/scope-manager@npm:7.3.1" dependencies: - "@typescript-eslint/types": "npm:7.3.0" - "@typescript-eslint/visitor-keys": "npm:7.3.0" - checksum: 10/380ac558032f396dd7cf8a38d91a462358bef559cb2d6fcbe6a15faf846923ec31e46054d48e18def609e7c955d14ca67790d578e7a08511815b876b4497d8ac + "@typescript-eslint/types": "npm:7.3.1" + "@typescript-eslint/visitor-keys": "npm:7.3.1" + checksum: 10/7384d1f46d7f3678a1135a1ac0bd8b6dfa2f01e93b19e2510c7082766cf6983a1bf80b4ccf498651199a81d9f2bdb65101fd7a19226a723260514204d0c30b34 languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:7.3.0": - version: 7.3.0 - resolution: "@typescript-eslint/type-utils@npm:7.3.0" +"@typescript-eslint/type-utils@npm:7.3.1": + version: 7.3.1 + resolution: "@typescript-eslint/type-utils@npm:7.3.1" dependencies: - "@typescript-eslint/typescript-estree": "npm:7.3.0" - "@typescript-eslint/utils": "npm:7.3.0" + "@typescript-eslint/typescript-estree": "npm:7.3.1" + "@typescript-eslint/utils": "npm:7.3.1" debug: "npm:^4.3.4" ts-api-utils: "npm:^1.0.1" peerDependencies: @@ -1578,23 +1682,23 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 10/361ac197924ebc0d8530e786b1573c557589d264d3988dbe25d301d71470bcf0168e694ab31dc8b8c7385c54b178e0005e4e7b17fa2a7e617a58a363ec3d84af + checksum: 10/fae9003a76a8f2a2a4bb88dc0f82c0a1ca0688633183fac391920e7124a12807aac84bb287a21f61e99523c15223d1c08e7680685ebf21d07429604cba6c420b languageName: node linkType: hard -"@typescript-eslint/types@npm:7.3.0": - version: 7.3.0 - resolution: "@typescript-eslint/types@npm:7.3.0" - checksum: 10/7e190be9e051268f582b1ad6482adc60c1d55aef59c9ed7d962df7dfb114f41ff0b95b984cf91a295cdac6b8f530f70f5768e926eeb606801d6f2ec3f772427b +"@typescript-eslint/types@npm:7.3.1": + version: 7.3.1 + resolution: "@typescript-eslint/types@npm:7.3.1" + checksum: 10/c9c8eae1cf937cececd99a253bd65eb71b40206e79cf917ad9c3b3ab80cc7ce5fefb2804f9fd2a70e7438951f0d1e63df3031fc61e3a08dfef5fde208a12e0ed languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:7.3.0": - version: 7.3.0 - resolution: "@typescript-eslint/typescript-estree@npm:7.3.0" +"@typescript-eslint/typescript-estree@npm:7.3.1": + version: 7.3.1 + resolution: "@typescript-eslint/typescript-estree@npm:7.3.1" dependencies: - "@typescript-eslint/types": "npm:7.3.0" - "@typescript-eslint/visitor-keys": "npm:7.3.0" + "@typescript-eslint/types": "npm:7.3.1" + "@typescript-eslint/visitor-keys": "npm:7.3.1" debug: "npm:^4.3.4" globby: "npm:^11.1.0" is-glob: "npm:^4.0.3" @@ -1604,34 +1708,34 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 10/af3bf304401b184cd56d72aa95cc4f924ae33ae35206fa848c1ea3a2c647b03e05e8b19f42c14c5fdd67d4a47f4e9fcbc34c9b566d2fe3f93a7fd297c6241bbb + checksum: 10/363ad9864b56394b4000dff7c2b77d0ea52042c3c20e3b86c0f3c66044915632d9890255527c6f3a5ef056886dec72e38fbcfce49d4ad092c160440f54128230 languageName: node linkType: hard -"@typescript-eslint/utils@npm:7.3.0": - version: 7.3.0 - resolution: "@typescript-eslint/utils@npm:7.3.0" +"@typescript-eslint/utils@npm:7.3.1": + version: 7.3.1 + resolution: "@typescript-eslint/utils@npm:7.3.1" dependencies: "@eslint-community/eslint-utils": "npm:^4.4.0" "@types/json-schema": "npm:^7.0.12" "@types/semver": "npm:^7.5.0" - "@typescript-eslint/scope-manager": "npm:7.3.0" - "@typescript-eslint/types": "npm:7.3.0" - "@typescript-eslint/typescript-estree": "npm:7.3.0" + "@typescript-eslint/scope-manager": "npm:7.3.1" + "@typescript-eslint/types": "npm:7.3.1" + "@typescript-eslint/typescript-estree": "npm:7.3.1" semver: "npm:^7.5.4" peerDependencies: eslint: ^8.56.0 - checksum: 10/349b353fdf03ed8f627287136b0cbc1fe40c670e6bd59099a6cc8ea1e37f2cc12a4d0cdf84e3a635a4f44bab92bd9d84b2c4d16525130b34cc27484177ce19b8 + checksum: 10/234d9d65fe5d0f4a31345bd8f5a6f2879a578b3a531a14c2b3edaa7fb587c71d26249f86c41857382c0405384dc104955c02b588b3cee6fc2734f1ae40aef07b languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:7.3.0": - version: 7.3.0 - resolution: "@typescript-eslint/visitor-keys@npm:7.3.0" +"@typescript-eslint/visitor-keys@npm:7.3.1": + version: 7.3.1 + resolution: "@typescript-eslint/visitor-keys@npm:7.3.1" dependencies: - "@typescript-eslint/types": "npm:7.3.0" + "@typescript-eslint/types": "npm:7.3.1" eslint-visitor-keys: "npm:^3.4.1" - checksum: 10/814d52a33eefddd32d522c9f8f3f9e163efb642e1fef5c57981bbf51382c5081451d01050e1a00d20cfbf60bfd8274a1eee4f393dbd3ec69dc5a9d36fea89269 + checksum: 10/163a93597c1d696920a19b3c1627d02368bdd52059f811c0fadd680c38034bb6418ebefe99d8ce26e0dd44ae184f18fab186af775de1a8771256be1a7905c174 languageName: node linkType: hard @@ -1647,22 +1751,22 @@ __metadata: resolution: "EMS-ESP@workspace:." dependencies: "@alova/adapter-xhr": "npm:^1.0.3" - "@babel/core": "npm:^7.24.0" + "@babel/core": "npm:^7.24.1" "@emotion/react": "npm:^11.11.4" "@emotion/styled": "npm:^11.11.0" - "@mui/icons-material": "npm:^5.15.13" - "@mui/material": "npm:^5.15.13" + "@mui/icons-material": "npm:^5.15.14" + "@mui/material": "npm:^5.15.14" "@preact/compat": "npm:^17.1.2" "@preact/preset-vite": "npm:^2.8.2" "@table-library/react-table-library": "npm:4.1.7" "@types/imagemin": "npm:^8.0.5" "@types/lodash-es": "npm:^4.17.12" - "@types/node": "npm:^20.11.28" + "@types/node": "npm:^20.11.30" "@types/react": "npm:^18.2.67" "@types/react-dom": "npm:^18.2.22" "@types/react-router-dom": "npm:^5.3.3" - "@typescript-eslint/eslint-plugin": "npm:^7.3.0" - "@typescript-eslint/parser": "npm:^7.3.0" + "@typescript-eslint/eslint-plugin": "npm:^7.3.1" + "@typescript-eslint/parser": "npm:^7.3.1" alova: "npm:^2.17.1" async-validator: "npm:^4.2.5" concurrently: "npm:^8.2.2" diff --git a/mock-api/handler.ts b/mock-api/handler.ts index 9dfd6558c..38f310d5a 100644 --- a/mock-api/handler.ts +++ b/mock-api/handler.ts @@ -362,16 +362,23 @@ const mqtt_status = { connect_count: 2 }; -// SYSTEM -const VERIFY_AUTHORIZATION_ENDPOINT = REST_ENDPOINT_ROOT + 'verifyAuthorization'; +// STATUS const SYSTEM_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'systemStatus'; +const ACTIVITY_ENDPOINT = REST_ENDPOINT_ROOT + 'activity'; + +// SETTINGS +const ESPSYSTEM_STATUS_ENDPOINT = REST_ENDPOINT_ROOT + 'ESPSystemStatus'; const SECURITY_SETTINGS_ENDPOINT = REST_ENDPOINT_ROOT + 'securitySettings'; const RESTART_ENDPOINT = REST_ENDPOINT_ROOT + 'restart'; const FACTORY_RESET_ENDPOINT = REST_ENDPOINT_ROOT + 'factoryReset'; const UPLOAD_FILE_ENDPOINT = REST_ENDPOINT_ROOT + 'uploadFile'; + +// SYSTEM SIGNIN +const VERIFY_AUTHORIZATION_ENDPOINT = REST_ENDPOINT_ROOT + 'verifyAuthorization'; const SIGN_IN_ENDPOINT = REST_ENDPOINT_ROOT + 'signIn'; const GENERATE_TOKEN_ENDPOINT = REST_ENDPOINT_ROOT + 'generateToken'; -const system_status = { + +const ESPsystem_status = { emsesp_version: '3.6-demo', esp_platform: 'ESP32', cpu_type: 'ESP32-S3', @@ -390,10 +397,21 @@ const system_status = { partition: 'app0', app_used: 1863, app_free: 121, - uptime: '000+00:15:42.707', arduino_version: 'ESP32 Arduino v2.0.14' }; +const system_status = { + emsesp_version: '3.6-demo', + esp_platform: 'ESP32', + status: 0, + // status: 2, + tx_mode: 1, + uptime: 77186, + num_devices: 2, + num_sensors: 1, + num_analogs: 1 +}; + let security_settings = { jwt_secret: 'naughty!', users: [ @@ -777,14 +795,7 @@ const emsesp_sensordata = { analog_enabled: true }; -const status = { - status: 0, - // status: 2, - tx_mode: 1, - uptime: 77186, - num_devices: 2, - num_sensors: 1, - num_analogs: 1, +const activity = { stats: [ { id: 0, s: 56506, f: 11, q: 100 }, { id: 1, s: 9026, f: 0, q: 100 }, @@ -2374,9 +2385,11 @@ router return new Response('OK', { status: 200 }); }); -// SYSTEM +// SYSTEM and SETTINGS router .get(SYSTEM_STATUS_ENDPOINT, () => new Response(JSON.stringify(system_status), { headers })) + .get(ACTIVITY_ENDPOINT, () => new Response(JSON.stringify(activity), { headers })) + .get(ESPSYSTEM_STATUS_ENDPOINT, () => new Response(JSON.stringify(ESPsystem_status), { headers })) .get(SECURITY_SETTINGS_ENDPOINT, () => new Response(JSON.stringify(security_settings), { headers })) .post(SECURITY_SETTINGS_ENDPOINT, async (request: any) => { security_settings = await request.json(); diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index 9fab268c9..91b33c60e 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -21,7 +21,7 @@ namespace emsesp { WebStatusService::WebStatusService(AsyncWebServer * server, SecurityManager * securityManager) { - server->on(EMSESP_STATUS_SERVICE_PATH, + server->on(EMSESP_ACTIVITY_SERVICE_PATH, HTTP_GET, securityManager->wrapRequest([this](AsyncWebServerRequest * request) { webStatusService(request); }, AuthenticationPredicates::IS_AUTHENTICATED)); } diff --git a/src/web/WebStatusService.h b/src/web/WebStatusService.h index 97109b82b..e5b235f52 100644 --- a/src/web/WebStatusService.h +++ b/src/web/WebStatusService.h @@ -19,7 +19,7 @@ #ifndef WebStatusService_h #define WebStatusService_h -#define EMSESP_STATUS_SERVICE_PATH "/rest/status" +#define EMSESP_ACTIVITY_SERVICE_PATH "/rest/activity" namespace emsesp {