From a1bb49359fc92c0d19a6509a76d6017293457fae Mon Sep 17 00:00:00 2001 From: Proddy Date: Tue, 17 Oct 2023 22:55:47 +0200 Subject: [PATCH 1/5] show entity count in device list, remove type --- interface/src/project/DashboardDevices.tsx | 18 ++++++++-------- interface/src/project/types.ts | 1 + mock-api/server.js | 24 ++++++++++++++-------- src/emsdevicevalue.cpp | 2 +- src/version.h | 2 +- src/web/WebDataService.cpp | 2 ++ 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/interface/src/project/DashboardDevices.tsx b/interface/src/project/DashboardDevices.tsx index 09dd0dfcb..2ee1932db 100644 --- a/interface/src/project/DashboardDevices.tsx +++ b/interface/src/project/DashboardDevices.tsx @@ -1,8 +1,8 @@ -import CancelIcon from '@mui/icons-material/Cancel'; import CommentsDisabledOutlinedIcon from '@mui/icons-material/CommentsDisabledOutlined'; import EditIcon from '@mui/icons-material/Edit'; import EditOffOutlinedIcon from '@mui/icons-material/EditOffOutlined'; import DownloadIcon from '@mui/icons-material/GetApp'; +import HighlightOffIcon from '@mui/icons-material/HighlightOff'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined'; import KeyboardArrowUpOutlinedIcon from '@mui/icons-material/KeyboardArrowUpOutlined'; @@ -26,6 +26,7 @@ import { Grid, Typography } from '@mui/material'; + import { useRowSelect } from '@table-library/react-table-library/select'; import { useSort, SortToggleType } from '@table-library/react-table-library/sort'; import { Table, Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table'; @@ -135,7 +136,7 @@ const DashboardDevices: FC = () => { common_theme, { Table: ` - --data-table-library_grid-template-columns: 40px repeat(1, minmax(0, 1fr)) 130px; + --data-table-library_grid-template-columns: 40px repeat(1, minmax(0, 1fr)); `, BaseRow: ` .td { @@ -417,7 +418,6 @@ const DashboardDevices: FC = () => { {LL.DESCRIPTION()} - {LL.TYPE(0)} @@ -426,8 +426,10 @@ const DashboardDevices: FC = () => { - {device.n} - {device.tn} + + {device.n} +   ({device.e}) + ))} @@ -485,8 +487,8 @@ const DashboardDevices: FC = () => { }} > - - {coreData.devices[deviceIndex].n} + + {coreData.devices[deviceIndex].tn} | {coreData.devices[deviceIndex].n} @@ -511,7 +513,7 @@ const DashboardDevices: FC = () => { - + diff --git a/interface/src/project/types.ts b/interface/src/project/types.ts index 74f0dded6..0e1ff3706 100644 --- a/interface/src/project/types.ts +++ b/interface/src/project/types.ts @@ -69,6 +69,7 @@ export interface Device { d: number; // deviceid p: number; // productid v: string; // version + e: number; // entities } export interface TemperatureSensor { diff --git a/mock-api/server.js b/mock-api/server.js index b12b379db..d2c4e3089 100644 --- a/mock-api/server.js +++ b/mock-api/server.js @@ -427,7 +427,8 @@ const emsesp_coredata = { // n: 'Enviline/Compress 6000AW/Hybrid 3000-7000iAW/SupraEco/Geo 5xx/WLW196i/WSW196i', d: 8, p: 123, - v: '06.01' + v: '06.01', + e: 69 }, { id: 3, @@ -437,7 +438,8 @@ const emsesp_coredata = { n: 'GB125/GB135/MC10', d: 8, p: 123, - v: '06.01' + v: '06.01', + e: 73 }, { id: 1, @@ -447,7 +449,8 @@ const emsesp_coredata = { n: 'RC35', d: 24, p: 86, - v: '04.01' + v: '04.01', + e: 57 }, { id: 2, @@ -457,7 +460,8 @@ const emsesp_coredata = { n: 'RC20/Moduline 300', d: 23, p: 77, - v: '03.03' + v: '03.03', + e: 6 }, { id: 4, @@ -467,7 +471,8 @@ const emsesp_coredata = { n: 'RC100/Moduline 1000/1010', d: 16, p: 165, - v: '04.01' + v: '04.01', + e: 3 }, { id: 5, @@ -477,7 +482,8 @@ const emsesp_coredata = { n: 'MM10', d: 32, p: 69, - v: '01.01' + v: '01.01', + e: 6 }, { id: 6, @@ -487,7 +493,8 @@ const emsesp_coredata = { n: 'SM10', d: 48, p: 73, - v: '01.02' + v: '01.02', + e: 22 }, { id: 99, @@ -497,7 +504,8 @@ const emsesp_coredata = { n: 'User defined entities', d: 1, p: 1, - v: '' + v: '', + e: 1 } ] }; diff --git a/src/emsdevicevalue.cpp b/src/emsdevicevalue.cpp index 7454a0c8b..99fe80062 100644 --- a/src/emsdevicevalue.cpp +++ b/src/emsdevicevalue.cpp @@ -243,7 +243,7 @@ bool DeviceValue::hasValue() const { has_value = Helpers::hasValue(*(uint32_t *)(value_p)); break; case DeviceValueType::CMD: - has_value = false; // commands don't have values! + has_value = true; // we count command as an actual entity break; default: break; diff --git a/src/version.h b/src/version.h index 72d6c2ace..2f10b99be 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.6.3-dev.3" +#define EMSESP_APP_VERSION "3.6.3-dev.4" diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index 92ab854d1..77185d233 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -88,6 +88,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) { obj["d"] = emsdevice->device_id(); // deviceid obj["p"] = emsdevice->product_id(); // productid obj["v"] = emsdevice->version(); // version + obj["e"] = emsdevice->count_entities(); // number of entities } } @@ -102,6 +103,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) { obj["d"] = 0; // deviceid obj["p"] = 0; // productid obj["v"] = 0; // version + obj["e"] = EMSESP::webCustomEntityService.count_entities(); // number of custom entities } root["connected"] = EMSESP::bus_status() != 2; From fddfa47b51d9d34dfcf43fb340fb4511c3a9a33e Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 18 Oct 2023 15:40:55 +0200 Subject: [PATCH 2/5] layout changes --- interface/package.json | 8 ++-- interface/src/project/DashboardDevices.tsx | 8 ++-- interface/yarn.lock | 48 +++++++++++++++------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/interface/package.json b/interface/package.json index d1cf7aa20..327f4fc81 100644 --- a/interface/package.json +++ b/interface/package.json @@ -26,9 +26,9 @@ "@mui/icons-material": "^5.14.14", "@mui/material": "^5.14.14", "@table-library/react-table-library": "4.1.7", - "@types/lodash-es": "^4.17.9", - "@types/node": "^20.8.6", - "@types/react": "^18.2.28", + "@types/lodash-es": "^4.17.10", + "@types/node": "^20.8.7", + "@types/react": "^18.2.29", "@types/react-dom": "^18.2.13", "@types/react-router-dom": "^5.3.3", "alova": "^2.13.1", @@ -68,7 +68,7 @@ "prettier": "^3.0.3", "rollup-plugin-visualizer": "^5.9.2", "terser": "^5.22.0", - "vite": "^4.4.11", + "vite": "^4.5.0", "vite-plugin-imagemin": "^0.6.1", "vite-tsconfig-paths": "^4.2.1" }, diff --git a/interface/src/project/DashboardDevices.tsx b/interface/src/project/DashboardDevices.tsx index 2ee1932db..34d2089ac 100644 --- a/interface/src/project/DashboardDevices.tsx +++ b/interface/src/project/DashboardDevices.tsx @@ -136,7 +136,7 @@ const DashboardDevices: FC = () => { common_theme, { Table: ` - --data-table-library_grid-template-columns: 40px repeat(1, minmax(0, 1fr)); + --data-table-library_grid-template-columns: 40px repeat(1, minmax(0, 1fr)) 130px; `, BaseRow: ` .td { @@ -418,6 +418,7 @@ const DashboardDevices: FC = () => { {LL.DESCRIPTION()} + {LL.TYPE(0)} @@ -430,6 +431,7 @@ const DashboardDevices: FC = () => { {device.n}   ({device.e}) + {device.tn} ))} @@ -482,8 +484,8 @@ const DashboardDevices: FC = () => { right: 16, bottom: 0, top: 128, - maxHeight: () => size[1] - 210, - zIndex: 'modal' + zIndex: 'modal', + border: '1px solid #177ac9' }} > diff --git a/interface/yarn.lock b/interface/yarn.lock index 01024701b..c6f5752e1 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -1265,12 +1265,12 @@ __metadata: languageName: node linkType: hard -"@types/lodash-es@npm:^4.17.9": - version: 4.17.9 - resolution: "@types/lodash-es@npm:4.17.9" +"@types/lodash-es@npm:^4.17.10": + version: 4.17.10 + resolution: "@types/lodash-es@npm:4.17.10" dependencies: "@types/lodash": "npm:*" - checksum: 5e3a8a74134e67c37f1b8eb4a2897c88038f1b1bd7f508feec9e5561b52787d7efcc30c18981e9c6edec2b894f127b60312a431d98b84e12e785bea9cb5d1d40 + checksum: a6c68872425418491d693186238e22c9da0e88bdf7ffe2b26e5436a19027ffedabeaec162e336b3722d5c43411866e859beae76a1a8f737bb5b115d5a574f758 languageName: node linkType: hard @@ -1288,7 +1288,7 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:^20.8.6": +"@types/node@npm:*": version: 20.8.6 resolution: "@types/node@npm:20.8.6" dependencies: @@ -1297,6 +1297,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20.8.7": + version: 20.8.7 + resolution: "@types/node@npm:20.8.7" + dependencies: + undici-types: "npm:~5.25.1" + checksum: a347ac7e6a9748ffff018ca01142ba625e774cb0b53785abb58b16a5a8468cc9b7656686dbe4c39c2f3fc477439994ee8aeae9b80ced86f320598bafaf83f802 + languageName: node + linkType: hard + "@types/parse-json@npm:^4.0.0": version: 4.0.0 resolution: "@types/parse-json@npm:4.0.0" @@ -1350,7 +1359,7 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:*, @types/react@npm:^18.2.28": +"@types/react@npm:*": version: 18.2.28 resolution: "@types/react@npm:18.2.28" dependencies: @@ -1361,6 +1370,17 @@ __metadata: languageName: node linkType: hard +"@types/react@npm:^18.2.29": + version: 18.2.29 + resolution: "@types/react@npm:18.2.29" + dependencies: + "@types/prop-types": "npm:*" + "@types/scheduler": "npm:*" + csstype: "npm:^3.0.2" + checksum: c261e4e2ec18a7244c959cb40ac2f43b0fa7f0b40fcce615243402fc61699cbebf6f2eae2632b8a0f0a2775a1ca735279b15543349cafa276c064b591712b85b + languageName: node + linkType: hard + "@types/responselike@npm:^1.0.0": version: 1.0.1 resolution: "@types/responselike@npm:1.0.1" @@ -1528,9 +1548,9 @@ __metadata: "@preact/compat": "npm:^17.1.2" "@preact/preset-vite": "npm:^2.6.0" "@table-library/react-table-library": "npm:4.1.7" - "@types/lodash-es": "npm:^4.17.9" - "@types/node": "npm:^20.8.6" - "@types/react": "npm:^18.2.28" + "@types/lodash-es": "npm:^4.17.10" + "@types/node": "npm:^20.8.7" + "@types/react": "npm:^18.2.29" "@types/react-dom": "npm:^18.2.13" "@types/react-router-dom": "npm:^5.3.3" "@typescript-eslint/eslint-plugin": "npm:^6.8.0" @@ -1566,7 +1586,7 @@ __metadata: terser: "npm:^5.22.0" typesafe-i18n: "npm:^5.26.2" typescript: "npm:^5.2.2" - vite: "npm:^4.4.11" + vite: "npm:^4.5.0" vite-plugin-imagemin: "npm:^0.6.1" vite-tsconfig-paths: "npm:^4.2.1" languageName: unknown @@ -8298,9 +8318,9 @@ __metadata: languageName: node linkType: hard -"vite@npm:^4.4.11": - version: 4.4.11 - resolution: "vite@npm:4.4.11" +"vite@npm:^4.5.0": + version: 4.5.0 + resolution: "vite@npm:4.5.0" dependencies: esbuild: "npm:^0.18.10" fsevents: "npm:~2.3.2" @@ -8334,7 +8354,7 @@ __metadata: optional: true bin: vite: bin/vite.js - checksum: 325e2955fe939bc5706aab2aa46498d98adace1df4d11f42cf4539754b886798b6bf7c247c94d23fb6cf3a569e56bad4a11561bf25e8e6dcc8c0e2f73ecc5e5b + checksum: b262ea4880ba7de8a77b0a665c771561ae3cb7f0d6c5b90e65298039755192550bf90cb96a2910d564506e2d499aa20e9becd330b835c34d414249083ac6e40c languageName: node linkType: hard From 18be921c1b2df02b1d90a5f2bd9b28e00f5a52f1 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 18 Oct 2023 23:15:13 +0200 Subject: [PATCH 3/5] package update --- interface/package.json | 2 +- interface/yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/package.json b/interface/package.json index 327f4fc81..d094bbb65 100644 --- a/interface/package.json +++ b/interface/package.json @@ -29,7 +29,7 @@ "@types/lodash-es": "^4.17.10", "@types/node": "^20.8.7", "@types/react": "^18.2.29", - "@types/react-dom": "^18.2.13", + "@types/react-dom": "^18.2.14", "@types/react-router-dom": "^5.3.3", "alova": "^2.13.1", "async-validator": "^4.2.5", diff --git a/interface/yarn.lock b/interface/yarn.lock index c6f5752e1..8ccbb91fb 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -1320,12 +1320,12 @@ __metadata: languageName: node linkType: hard -"@types/react-dom@npm:^18.2.13": - version: 18.2.13 - resolution: "@types/react-dom@npm:18.2.13" +"@types/react-dom@npm:^18.2.14": + version: 18.2.14 + resolution: "@types/react-dom@npm:18.2.14" dependencies: "@types/react": "npm:*" - checksum: 0355d036d062bfa69345851282a555817c57be44d909250926296383bcc82fb4b79df08ecc882c519883e5ab8d179961d4cd245157a5c5977a7247714757b0ac + checksum: c7feb6542dbeb3de18c9c03260229377e0a0d47a3d2c0bb91861996e2353375a45c57de7216edb8b88448584e363677244bd4355ddec45c243e70e777c2a150b languageName: node linkType: hard @@ -1551,7 +1551,7 @@ __metadata: "@types/lodash-es": "npm:^4.17.10" "@types/node": "npm:^20.8.7" "@types/react": "npm:^18.2.29" - "@types/react-dom": "npm:^18.2.13" + "@types/react-dom": "npm:^18.2.14" "@types/react-router-dom": "npm:^5.3.3" "@typescript-eslint/eslint-plugin": "npm:^6.8.0" "@typescript-eslint/parser": "npm:^6.8.0" From eb274a94c3929dd882c83167dac02f5d8c6092e4 Mon Sep 17 00:00:00 2001 From: Proddy Date: Wed, 18 Oct 2023 23:15:42 +0200 Subject: [PATCH 4/5] move system info to download page, add a restart warning on upload --- .../src/framework/system/UploadFileForm.tsx | 72 +++++++++++++++++-- interface/src/i18n/de/index.ts | 1 - interface/src/i18n/en/index.ts | 1 - interface/src/i18n/fr/index.ts | 1 - interface/src/i18n/it/index.ts | 1 - interface/src/i18n/nl/index.ts | 1 - interface/src/i18n/no/index.ts | 1 - interface/src/i18n/pl/index.ts | 1 - interface/src/i18n/sv/index.ts | 1 - interface/src/i18n/tr/index.ts | 1 - interface/src/project/DashboardDevices.tsx | 3 +- interface/src/project/HelpInformation.tsx | 47 ++---------- mock-api/server.js | 2 +- 13 files changed, 77 insertions(+), 56 deletions(-) diff --git a/interface/src/framework/system/UploadFileForm.tsx b/interface/src/framework/system/UploadFileForm.tsx index 6403c37fd..c904995c4 100644 --- a/interface/src/framework/system/UploadFileForm.tsx +++ b/interface/src/framework/system/UploadFileForm.tsx @@ -1,10 +1,13 @@ +import CancelIcon from '@mui/icons-material/Cancel'; import DownloadIcon from '@mui/icons-material/GetApp'; -import { Typography, Button, Box } from '@mui/material'; +import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew'; +import { Typography, Button, Box, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material'; import { useRequest } from 'alova'; import { useState, type FC } from 'react'; import { toast } from 'react-toastify'; import RestartMonitor from './RestartMonitor'; +import { dialogStyle } from 'CustomTheme'; import * as SystemApi from 'api/system'; import { SectionContent, SingleUpload } from 'components'; @@ -13,7 +16,8 @@ import * as EMSESP from 'project/api'; const UploadFileForm: FC = () => { const { LL } = useI18nContext(); - const [restarting, setRestarting] = useState(false); + const [restarting, setRestarting] = useState(); + const [confirmRestart, setConfirmRestart] = useState(false); const [md5, setMd5] = useState(); const { send: getSettings, onSuccess: onSuccessGetSettings } = useRequest(EMSESP.getSettings(), { @@ -28,6 +32,13 @@ const UploadFileForm: FC = () => { const { send: getSchedule, onSuccess: onSuccessGetSchedule } = useRequest(EMSESP.getSchedule(), { immediate: false }); + const { send: getInfo, onSuccess: onSuccessGetInfo } = useRequest((data) => EMSESP.API(data), { + immediate: false + }); + + const { send: restartCommand } = useRequest(SystemApi.restart(), { + immediate: false + }); const { loading: isUploading, @@ -45,7 +56,7 @@ const UploadFileForm: FC = () => { setMd5(data.md5); toast.success(LL.UPLOAD() + ' MD5 ' + LL.SUCCESSFUL()); } else { - setRestarting(true); + setConfirmRestart(true); } }); @@ -61,6 +72,19 @@ const UploadFileForm: FC = () => { }); }; + const restart = async () => { + await restartCommand() + .then(() => { + setRestarting(true); + }) + .catch((err) => { + toast.error(err.message); + }) + .finally(() => { + setConfirmRestart(false); + }); + }; + const saveFile = (json: any, endpoint: string) => { const anchor = document.createElement('a'); anchor.href = URL.createObjectURL( @@ -86,6 +110,9 @@ const UploadFileForm: FC = () => { onSuccessGetSchedule((event) => { saveFile(event.data, 'schedule'); }); + onSuccessGetInfo((event) => { + saveFile(event.data, 'info'); + }); const downloadSettings = async () => { await getSettings().catch((error) => { @@ -111,6 +138,32 @@ const UploadFileForm: FC = () => { }); }; + const downloadInfo = async () => { + await getInfo({ device: 'system', entity: 'info', id: 0 }).catch((error) => { + toast.error(error.message); + }); + }; + + const renderRestartDialog = () => ( + setConfirmRestart(false)}> + {LL.UPLOAD() + ' ' + LL.SUCCESSFUL()} + {LL.RESTART_TEXT()} + + + + + + ); + const content = () => ( <> @@ -140,7 +193,7 @@ const UploadFileForm: FC = () => { - {LL.DOWNLOAD_CUSTOMIZATION_TEXT()}{' '} + {LL.DOWNLOAD_CUSTOMIZATION_TEXT()} - {LL.DOWNLOAD_SCHEDULE_TEXT()}{' '} + {LL.DOWNLOAD_SCHEDULE_TEXT()} + + + {LL.DOWNLOAD(0)} {LL.SUPPORT_INFORMATION()} + + + )} + {renderRestartDialog()} ); return ( diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index 24261aaf1..cf5ba5d40 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -171,7 +171,6 @@ const de: Translation = { HELP_INFORMATION_3: 'Um neue Funktionen anzufragen oder Fehler zu melden, eröffnen Sie ein Issue auf Github', HELP_INFORMATION_4: 'Bitte laden Sie die System-Details und hängen Sie sie an das Support-Issue an. ', HELP_INFORMATION_5: 'EMS-ESP ist ein freies Open-Source Projekt. Bitte unterstützen Sie die zukünftige Entwicklung mit einem "Star" auf Github!', - SUPPORT_INFO: 'Support Info', UPLOAD: 'Hochladen', DOWNLOAD: '{{H|h|h}}erunterladen', ABORTED: 'abgebrochen', diff --git a/interface/src/i18n/en/index.ts b/interface/src/i18n/en/index.ts index d8edb747e..70b60526e 100644 --- a/interface/src/i18n/en/index.ts +++ b/interface/src/i18n/en/index.ts @@ -171,7 +171,6 @@ const en: Translation = { HELP_INFORMATION_3: 'To request a feature or report a bug', HELP_INFORMATION_4: 'remember to download and attach your system 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!', - SUPPORT_INFO: 'Support Info', UPLOAD: 'Upload', DOWNLOAD: '{{D|d|d}}ownload', ABORTED: 'aborted', diff --git a/interface/src/i18n/fr/index.ts b/interface/src/i18n/fr/index.ts index f2b065463..501ff73d7 100644 --- a/interface/src/i18n/fr/index.ts +++ b/interface/src/i18n/fr/index.ts @@ -171,7 +171,6 @@ const fr: Translation = { HELP_INFORMATION_3: 'Pour demander une fonctionnalité ou signaler un problème', HELP_INFORMATION_4: 'n\'oubliez pas de télécharger et de joindre les informations relatives à votre système pour obtenir une réponse plus rapide lorsque vous signalez un problème', HELP_INFORMATION_5: 'EMS-ESP est un projet libre et open-source. Merci de soutenir son développement futur en lui donnant une étoile sur Github !', - SUPPORT_INFO: 'Information de support', UPLOAD: 'Upload', DOWNLOAD: '{{D|d|d}}ownload', ABORTED: 'annulé', diff --git a/interface/src/i18n/it/index.ts b/interface/src/i18n/it/index.ts index 026d00305..8ed389116 100644 --- a/interface/src/i18n/it/index.ts +++ b/interface/src/i18n/it/index.ts @@ -173,7 +173,6 @@ const it: Translation = { HELP_INFORMATION_3: 'Per richiedere una funzionalità o segnalare un errore', HELP_INFORMATION_4: 'ricordati di scaricare e allegare le informazioni del tuo sistema per una risposta più rapida quando segnali un problema', HELP_INFORMATION_5: 'EMS-ESP è un progetto gratuito e open-source. Supporta il suo sviluppo futuro assegnandogli una stella su Github!', - SUPPORT_INFO: 'Info Supporto', UPLOAD: 'Carica', DOWNLOAD: 'Scarica', ABORTED: 'Annullato', diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index eb17d20af..1c80ce7f7 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -171,7 +171,6 @@ const nl: Translation = { HELP_INFORMATION_3: 'Om een nieuwe feature te vragen of een bug te rapporteren', HELP_INFORMATION_4: 'zorg dat je ook je systeem details zijn toevoeged voor een sneller antwoord', HELP_INFORMATION_5: 'EMS-ESP is een gratis en open source project. Steun ons met een Star op Github!', - SUPPORT_INFO: 'Support Info', UPLOAD: 'Upload', DOWNLOAD: '{{D|d|d}}ownload', ABORTED: 'afgebroken', diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index e52b65f61..d7995719b 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -171,7 +171,6 @@ const no: Translation = { HELP_INFORMATION_3: 'For å be om en ny funksjon eller melde feil', HELP_INFORMATION_4: 'husk å laste ned og legg ved din systeminformasjon for en raskere respons når du rapporterer et problem', HELP_INFORMATION_5: 'EMS-ESP er gratis og åpen kildekode. Bidra til utviklingen ved å gi oss en stjerne på GitHub!', - SUPPORT_INFO: 'Supportinfo', UPLOAD: 'Opplasning', DOWNLOAD: '{{N|n|n}}edlasting', ABORTED: 'avbrutt', diff --git a/interface/src/i18n/pl/index.ts b/interface/src/i18n/pl/index.ts index 4d073f702..6184c1aa8 100644 --- a/interface/src/i18n/pl/index.ts +++ b/interface/src/i18n/pl/index.ts @@ -171,7 +171,6 @@ const pl: BaseTranslation = { HELP_INFORMATION_3: 'Aby zaproponować nową funkcjonalność lub zgłosić problem', HELP_INFORMATION_4: 'Zgłaszając problem, nie zapomnij dołączyć informacji o swoim systemie!', HELP_INFORMATION_5: 'EMS-ESP jest darmowym projektem typu open-source. Aby go wesprzeć, rozważ przyznanie nam gwiazdki na Github!', - SUPPORT_INFO: 'Pobierz informacje', UPLOAD: 'Wysyłanie', DOWNLOAD: '{{P|p||P}}obier{{anie|z||z}}', ABORTED: 'zostało przerwane!', diff --git a/interface/src/i18n/sv/index.ts b/interface/src/i18n/sv/index.ts index 75eff2096..ea6a4e1c4 100644 --- a/interface/src/i18n/sv/index.ts +++ b/interface/src/i18n/sv/index.ts @@ -171,7 +171,6 @@ const sv: Translation = { HELP_INFORMATION_3: 'Önska en ny funktion eller rapportera en bugg', HELP_INFORMATION_4: 'Bifoga din systeminformation för snabbare hantering när du rapporterar ett problem', HELP_INFORMATION_5: 'EMS-ESP är gratis och är öppen källkod. Bidra till utvecklingen genom att ge oss en stjärna på GitHub!', - SUPPORT_INFO: 'Supportinfo', UPLOAD: 'Uppladdning', DOWNLOAD: '{{N|n|n}}edladdning', ABORTED: 'Avbruten', diff --git a/interface/src/i18n/tr/index.ts b/interface/src/i18n/tr/index.ts index c068bddd0..3311a9da0 100644 --- a/interface/src/i18n/tr/index.ts +++ b/interface/src/i18n/tr/index.ts @@ -171,7 +171,6 @@ const tr: Translation = { HELP_INFORMATION_3: 'Yeni bir özellik talep etmek yada hata bildirmek için', HELP_INFORMATION_4: 'Bir sorun bildirirken daha hızlı bir dönüş için sistem bilginizi indirip eklemeyi unutmayın', HELP_INFORMATION_5: 'EMS-ESP ücretsiz ve açık kaynaklı bir projedir. Lütfen geliştirmeyi desteklemek için Githubda projeye yıldız verin!', - SUPPORT_INFO: 'Destek Bilgisi', UPLOAD: 'Yükleme', DOWNLOAD: '{{İ|i|i}}İndirme', ABORTED: 'iptal edildi', diff --git a/interface/src/project/DashboardDevices.tsx b/interface/src/project/DashboardDevices.tsx index 34d2089ac..acf4f1fbc 100644 --- a/interface/src/project/DashboardDevices.tsx +++ b/interface/src/project/DashboardDevices.tsx @@ -53,9 +53,9 @@ import { AuthenticatedContext } from 'contexts/authentication'; import { useI18nContext } from 'i18n/i18n-react'; const DashboardDevices: FC = () => { - const [size, setSize] = useState([0, 0]); const { me } = useContext(AuthenticatedContext); const { LL } = useI18nContext(); + const [size, setSize] = useState([0, 0]); const [selectedDeviceValue, setSelectedDeviceValue] = useState(); const [onlyFav, setOnlyFav] = useState(false); const [deviceValueDialogOpen, setDeviceValueDialogOpen] = useState(false); @@ -485,6 +485,7 @@ const DashboardDevices: FC = () => { bottom: 0, top: 128, zIndex: 'modal', + maxHeight: () => size[1] - 189, border: '1px solid #177ac9' }} > diff --git a/interface/src/project/HelpInformation.tsx b/interface/src/project/HelpInformation.tsx index b85720508..9aae937f9 100644 --- a/interface/src/project/HelpInformation.tsx +++ b/interface/src/project/HelpInformation.tsx @@ -1,12 +1,8 @@ import CommentIcon from '@mui/icons-material/CommentTwoTone'; import EastIcon from '@mui/icons-material/East'; -import DownloadIcon from '@mui/icons-material/GetApp'; import GitHubIcon from '@mui/icons-material/GitHub'; import MenuBookIcon from '@mui/icons-material/MenuBookTwoTone'; -import { Typography, Button, Box, List, ListItem, ListItemText, Link, ListItemAvatar } from '@mui/material'; -import { useRequest } from 'alova'; -import { toast } from 'react-toastify'; -import * as EMSESP from './api'; +import { Typography, Box, List, ListItem, ListItemText, Link, ListItemAvatar } from '@mui/material'; import type { FC } from 'react'; import { SectionContent } from 'components'; @@ -16,30 +12,7 @@ import { useI18nContext } from 'i18n/i18n-react'; const HelpInformation: FC = () => { const { LL } = useI18nContext(); - const { send: API, onSuccess: onSuccessAPI } = useRequest((data) => EMSESP.API(data), { - immediate: false - }); - - onSuccessAPI((event) => { - const a = document.createElement('a'); - const filename = 'emsesp_info.txt'; - a.href = URL.createObjectURL( - new Blob([JSON.stringify(event.data, null, 2)], { - type: 'text/plain' - }) - ); - a.setAttribute('download', filename); - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - toast.info(LL.DOWNLOAD_SUCCESSFUL()); - }); - - const callAPI = async () => { - await API({ device: 'system', entity: 'info', id: 0 }).catch((error) => { - toast.error(error.message); - }); - }; + const uploadURL = window.location.origin + '/system/upload'; return ( @@ -83,17 +56,11 @@ const HelpInformation: FC = () => { {LL.CLICK_HERE()}
- ({LL.HELP_INFORMATION_4()}   - -  ) + ({LL.HELP_INFORMATION_4()}  + + {LL.UPLOAD()} + + ) diff --git a/mock-api/server.js b/mock-api/server.js index d2c4e3089..82fc53438 100644 --- a/mock-api/server.js +++ b/mock-api/server.js @@ -2162,7 +2162,7 @@ rest_server.post(UPLOAD_FILE_ENDPOINT, progress_middleware, upload.single('file' console.log(req.file); console.log('ext: ' + ext); - if (ext === 'bin') { + if (ext === 'bin' || ext === 'json') { return res.sendStatus(200); } else if (ext === 'md5') { return res.json({ md5: 'ef4304fc4d9025a58dcf25d71c882d2c' }); From 9698e787b28bae02ff2f80779dcc16b10a09641d Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 19 Oct 2023 21:37:46 +0200 Subject: [PATCH 5/5] remove dialog from upload as C++ code does restart immediately --- interface/package.json | 4 +- .../src/framework/system/UploadFileForm.tsx | 52 +++---------------- interface/yarn.lock | 20 +++---- 3 files changed, 19 insertions(+), 57 deletions(-) diff --git a/interface/package.json b/interface/package.json index d094bbb65..a8e216820 100644 --- a/interface/package.json +++ b/interface/package.json @@ -28,7 +28,7 @@ "@table-library/react-table-library": "4.1.7", "@types/lodash-es": "^4.17.10", "@types/node": "^20.8.7", - "@types/react": "^18.2.29", + "@types/react": "^18.2.30", "@types/react-dom": "^18.2.14", "@types/react-router-dom": "^5.3.3", "alova": "^2.13.1", @@ -52,7 +52,7 @@ "@preact/preset-vite": "^2.6.0", "@typescript-eslint/eslint-plugin": "^6.8.0", "@typescript-eslint/parser": "^6.8.0", - "concurrently": "^8.2.1", + "concurrently": "^8.2.2", "eslint": "^8.51.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^17.1.0", diff --git a/interface/src/framework/system/UploadFileForm.tsx b/interface/src/framework/system/UploadFileForm.tsx index c904995c4..3a22eb540 100644 --- a/interface/src/framework/system/UploadFileForm.tsx +++ b/interface/src/framework/system/UploadFileForm.tsx @@ -1,13 +1,10 @@ -import CancelIcon from '@mui/icons-material/Cancel'; import DownloadIcon from '@mui/icons-material/GetApp'; -import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew'; -import { Typography, Button, Box, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material'; +import { Typography, Button, Box } from '@mui/material'; import { useRequest } from 'alova'; import { useState, type FC } from 'react'; import { toast } from 'react-toastify'; import RestartMonitor from './RestartMonitor'; -import { dialogStyle } from 'CustomTheme'; import * as SystemApi from 'api/system'; import { SectionContent, SingleUpload } from 'components'; @@ -17,7 +14,6 @@ import * as EMSESP from 'project/api'; const UploadFileForm: FC = () => { const { LL } = useI18nContext(); const [restarting, setRestarting] = useState(); - const [confirmRestart, setConfirmRestart] = useState(false); const [md5, setMd5] = useState(); const { send: getSettings, onSuccess: onSuccessGetSettings } = useRequest(EMSESP.getSettings(), { @@ -36,10 +32,6 @@ const UploadFileForm: FC = () => { immediate: false }); - const { send: restartCommand } = useRequest(SystemApi.restart(), { - immediate: false - }); - const { loading: isUploading, uploading: progress, @@ -56,7 +48,7 @@ const UploadFileForm: FC = () => { setMd5(data.md5); toast.success(LL.UPLOAD() + ' MD5 ' + LL.SUCCESSFUL()); } else { - setConfirmRestart(true); + setRestarting(true); } }); @@ -72,19 +64,6 @@ const UploadFileForm: FC = () => { }); }; - const restart = async () => { - await restartCommand() - .then(() => { - setRestarting(true); - }) - .catch((err) => { - toast.error(err.message); - }) - .finally(() => { - setConfirmRestart(false); - }); - }; - const saveFile = (json: any, endpoint: string) => { const anchor = document.createElement('a'); anchor.href = URL.createObjectURL( @@ -144,33 +123,17 @@ const UploadFileForm: FC = () => { }); }; - const renderRestartDialog = () => ( - setConfirmRestart(false)}> - {LL.UPLOAD() + ' ' + LL.SUCCESSFUL()} - {LL.RESTART_TEXT()} - - - - - - ); - const content = () => ( <> {LL.UPLOAD()} - {LL.UPLOAD_TEXT()} + + {LL.UPLOAD_TEXT()} +
+ {LL.RESTART_TEXT()}. +
{md5 && ( @@ -226,7 +189,6 @@ const UploadFileForm: FC = () => { )} - {renderRestartDialog()} ); return ( diff --git a/interface/yarn.lock b/interface/yarn.lock index 8ccbb91fb..cffae6de8 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -1370,14 +1370,14 @@ __metadata: languageName: node linkType: hard -"@types/react@npm:^18.2.29": - version: 18.2.29 - resolution: "@types/react@npm:18.2.29" +"@types/react@npm:^18.2.30": + version: 18.2.30 + resolution: "@types/react@npm:18.2.30" dependencies: "@types/prop-types": "npm:*" "@types/scheduler": "npm:*" csstype: "npm:^3.0.2" - checksum: c261e4e2ec18a7244c959cb40ac2f43b0fa7f0b40fcce615243402fc61699cbebf6f2eae2632b8a0f0a2775a1ca735279b15543349cafa276c064b591712b85b + checksum: dcad8aed0d0bf5731f4c6a7e8d28d8f571bd031c6c94edbcc1b7ab2c86e7cf61ae49d66c3229e1849fb4b82c5aa7be7c40e71ac5c2d7fef4eafb7a3b4abd25d6 languageName: node linkType: hard @@ -1550,14 +1550,14 @@ __metadata: "@table-library/react-table-library": "npm:4.1.7" "@types/lodash-es": "npm:^4.17.10" "@types/node": "npm:^20.8.7" - "@types/react": "npm:^18.2.29" + "@types/react": "npm:^18.2.30" "@types/react-dom": "npm:^18.2.14" "@types/react-router-dom": "npm:^5.3.3" "@typescript-eslint/eslint-plugin": "npm:^6.8.0" "@typescript-eslint/parser": "npm:^6.8.0" alova: "npm:^2.13.1" async-validator: "npm:^4.2.5" - concurrently: "npm:^8.2.1" + concurrently: "npm:^8.2.2" eslint: "npm:^8.51.0" eslint-config-airbnb: "npm:^19.0.4" eslint-config-airbnb-typescript: "npm:^17.1.0" @@ -2384,9 +2384,9 @@ __metadata: languageName: node linkType: hard -"concurrently@npm:^8.2.1": - version: 8.2.1 - resolution: "concurrently@npm:8.2.1" +"concurrently@npm:^8.2.2": + version: 8.2.2 + resolution: "concurrently@npm:8.2.2" dependencies: chalk: "npm:^4.1.2" date-fns: "npm:^2.30.0" @@ -2400,7 +2400,7 @@ __metadata: bin: conc: dist/bin/concurrently.js concurrently: dist/bin/concurrently.js - checksum: 8a7cb8caeb9430f939ae6ba3ccdce6080e7f3084dcbffb6383059002937bbe771d71f8f4f854258e6138f52918637a3d66a6b21fd19d0ea69c426011f878e701 + checksum: dcb1aa69d9c611a7bda9d4fc0fe1e388f971d1744acec7e0d52dffa2ef55743f1266ec9292f414c5789b9f61734b3fce772bd005d4de9564a949fb121b97bae1 languageName: node linkType: hard