diff --git a/interface/package.json b/interface/package.json index 76b8c0c09..5da5cc5b6 100644 --- a/interface/package.json +++ b/interface/package.json @@ -23,7 +23,7 @@ "@emotion/react": "^11.11.0", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.11.16", - "@mui/material": "^5.13.3", + "@mui/material": "^5.13.4", "@table-library/react-table-library": "4.1.4", "@types/lodash-es": "^4.17.7", "@types/node": "^20.2.5", @@ -47,8 +47,8 @@ "typescript": "^5.1.3" }, "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.59.8", - "@typescript-eslint/parser": "^5.59.8", + "@typescript-eslint/eslint-plugin": "^5.59.9", + "@typescript-eslint/parser": "^5.59.9", "@vitejs/plugin-react-swc": "^3.3.2", "eslint": "^8.42.0", "eslint-config-airbnb": "^19.0.4", diff --git a/interface/src/api/endpoints.ts b/interface/src/api/endpoints.ts index 3c8d5e480..684d9934d 100644 --- a/interface/src/api/endpoints.ts +++ b/interface/src/api/endpoints.ts @@ -1,9 +1,9 @@ import { xhrRequestAdapter } from '@alova/adapter-xhr'; import { createAlova } from 'alova'; -import GlobalFetch from 'alova/GlobalFetch'; +// import GlobalFetch from 'alova/GlobalFetch'; import ReactHook from 'alova/react'; import axios from 'axios'; -import { unpack } from './unpack'; +import { unpack } from '../api/unpack'; import type { AxiosPromise, CancelToken, AxiosProgressEvent } from 'axios'; @@ -31,32 +31,26 @@ export const alovaInstance = createAlova({ method.config.headers.token = 'Bearer ' + localStorage.getItem(ACCESS_TOKEN); } }, - responsed: (response) => response.data - // TODO add error handling for Push? + responded: { + onSuccess: async (response, method) => { + if (response.status === 400) { + throw new Error('Invalid command'); + } + if (response.status >= 400) { + throw new Error(response.statusText); + } + const data = await response.data; + if (response.data instanceof ArrayBuffer) { + return unpack(data); + } + return data; + }, - // return JSON.stringify(response.data); - - // responded: { - // // When using the GlobalFetch request adapter, the first parameter receives the Response object - // // The second parameter is the method instance of the current request, you can use it to synchronize the configuration information before and after the request - // onSuccess: async (response, method) => { - // if (response.status >= 400) { - // throw new Error(response.statusText); - // } - // console.log('response', response); - // const json = await response.json(); - // // The parsed response data will be passed to the transformData hook function of the method instance, and these functions will be explained later - // return json; - // }, - - // // Interceptor for request failure - // // This interceptor will be entered when the request is wrong. - // // The second parameter is the method instance of the current request, you can use it to synchronize the configuration information before and after the request - // onError: (error, method) => { - // alert(error.message); - // } - // } + onError: (error) => { + alert(error.message); + } + } }); export const AXIOS = axios.create({ diff --git a/interface/src/i18n/de/index.ts b/interface/src/i18n/de/index.ts index 219f158bd..89a113724 100644 --- a/interface/src/i18n/de/index.ts +++ b/interface/src/i18n/de/index.ts @@ -51,7 +51,7 @@ const de: Translation = { REMOVE: 'Entfernen', PROBLEM_UPDATING: 'Problem beim Aktualisieren', PROBLEM_LOADING: 'Problem beim Laden', - ACCESS_DENIED: 'Zugriff abgelehnt', + HTTP_ERROR: 'Error {0}', // TODO translate ANALOG_SENSOR: 'Analogsensor', ANALOG_SENSORS: 'Analogsensoren', SETTINGS: 'Einstellungen', @@ -71,7 +71,6 @@ const de: Translation = { TEMP_SENSOR: 'Temperatursensor', TEMP_SENSORS: 'Temperatursensoren', WRITE_CMD_SENT: 'Befehl schreiben wurde gesendet', - WRITE_CMD_FAILED: 'Befehl schreiben failed', // TODO translate EMS_BUS_WARNING: 'EMS-Bus getrennt. Wenn diese Warnung nach einigen Sekunden immer noch besteht, überprüfen Sie bitte die Einstellungen und das Board-Profil', EMS_BUS_SCANNING: 'Suche nach EMS Geräten...', CONNECTED: 'Verbunden', diff --git a/interface/src/i18n/en/index.ts b/interface/src/i18n/en/index.ts index 2f758ca24..f355dfa83 100644 --- a/interface/src/i18n/en/index.ts +++ b/interface/src/i18n/en/index.ts @@ -51,7 +51,7 @@ const en: Translation = { REMOVE: 'Remove', PROBLEM_UPDATING: 'Problem updating', PROBLEM_LOADING: 'Problem loading', - ACCESS_DENIED: 'Access Denied', + HTTP_ERROR: 'Error {0}', ANALOG_SENSOR: 'Analog Sensor', ANALOG_SENSORS: 'Analog Sensors', SETTINGS: 'Settings', @@ -71,7 +71,6 @@ const en: Translation = { TEMP_SENSOR: 'Temperature Sensor', TEMP_SENSORS: 'Temperature Sensors', WRITE_CMD_SENT: 'Write command sent', - WRITE_CMD_FAILED: 'Write command failed', EMS_BUS_WARNING: 'EMS bus disconnected. If this warning still persists after a few seconds please check settings and board profile', EMS_BUS_SCANNING: 'Scanning for EMS devices...', CONNECTED: 'Connected', diff --git a/interface/src/i18n/fr/index.ts b/interface/src/i18n/fr/index.ts index a8249202e..08dbf762e 100644 --- a/interface/src/i18n/fr/index.ts +++ b/interface/src/i18n/fr/index.ts @@ -51,7 +51,7 @@ const fr: Translation = { REMOVE: 'Enlever', PROBLEM_UPDATING: 'Problème lors de la mise à jour', PROBLEM_LOADING: 'Problème lors du chargement', - ACCESS_DENIED: 'Accès refusé', + HTTP_ERROR: 'Error {0}', // TODO translate ANALOG_SENSOR: 'Capteur analogique', ANALOG_SENSORS: 'Capteurs analogiques', SETTINGS: 'Paramètres', @@ -71,7 +71,6 @@ const fr: Translation = { TEMP_SENSOR: 'Capteur de température', TEMP_SENSORS: 'Capteurs de température', WRITE_CMD_SENT: 'Envoyer la commande sent', // TODO translate - WRITE_CMD_FAILED: 'Envoyer la commande failed', // TODO translate EMS_BUS_WARNING: 'Bus EMS déconnecté. Si ce message persiste après quelques secondes, vérifiez les paramètres et la configuration de la carte.', EMS_BUS_SCANNING: 'Scan des appareils EMS...', CONNECTED: 'Connecté', diff --git a/interface/src/i18n/nl/index.ts b/interface/src/i18n/nl/index.ts index 8906221be..d94ef323d 100644 --- a/interface/src/i18n/nl/index.ts +++ b/interface/src/i18n/nl/index.ts @@ -51,7 +51,7 @@ const nl: Translation = { REMOVE: 'Verwijderen', PROBLEM_UPDATING: 'Probleem met updaten', PROBLEM_LOADING: 'Probleem met laden', - ACCESS_DENIED: 'Toegang geweigerd', + HTTP_ERROR: 'Error {0}', // TODO translate ANALOG_SENSOR: 'Analoge sensor', ANALOG_SENSORS: 'Analoge Sensoren', SETTINGS: 'Instellingen', @@ -71,7 +71,6 @@ const nl: Translation = { TEMP_SENSOR: 'Temperatuur sensor', TEMP_SENSORS: 'Temperatuur Sensoren', WRITE_CMD_SENT: 'Schrijf commando sent', // TODO translate - WRITE_CMD_FAILED: 'Schrijf commando failed', // TODO translate EMS_BUS_WARNING: 'EMS bus niet gevonden. Als deze waarschuwing blijft staan na een paar seconden dan loop de instellingen na en in het bijzonder het apparaat type profiel na.', EMS_BUS_SCANNING: 'Scannen naar EMS apparaten...', CONNECTED: 'Verbonden', diff --git a/interface/src/i18n/no/index.ts b/interface/src/i18n/no/index.ts index ccfbbfb5a..ae4a1eae8 100644 --- a/interface/src/i18n/no/index.ts +++ b/interface/src/i18n/no/index.ts @@ -51,7 +51,7 @@ const no: Translation = { REMOVE: 'Fjern', PROBLEM_UPDATING: 'Problem med oppdatering', PROBLEM_LOADING: 'Problem med opplasting', - ACCESS_DENIED: 'Tilgang nektet', + HTTP_ERROR: 'Error {0}', // TODO translate ANALOG_SENSOR: 'Analog Sensor', ANALOG_SENSORS: 'Analoge Sensorer', SETTINGS: 'Innstillinger', @@ -71,7 +71,6 @@ const no: Translation = { TEMP_SENSOR: 'Temperatursensor', TEMP_SENSORS: 'Temperaturesensorer', WRITE_CMD_SENT: 'Skriv kommando sent', - WRITE_CMD_FAILED: 'Skriv kommando som har feilet', EMS_BUS_WARNING: 'EMS bussen koblet ned. Hvis denne advarselen fortsetter etter noen f¨sekunder sjekk instillinger og prosessorkort', EMS_BUS_SCANNING: 'Søker etter EMS enheter...', CONNECTED: 'Tilkoblet', diff --git a/interface/src/i18n/pl/index.ts b/interface/src/i18n/pl/index.ts index d071daaa3..9ec0afc12 100644 --- a/interface/src/i18n/pl/index.ts +++ b/interface/src/i18n/pl/index.ts @@ -51,7 +51,7 @@ const pl: BaseTranslation = { REMOVE: 'Usuń', PROBLEM_UPDATING: 'Problem z uaktualnieniem!', PROBLEM_LOADING: 'Problem z załadowaniem!', - ACCESS_DENIED: 'Brak dostępu!', + HTTP_ERROR: 'Error {0}', // TODO translate ANALOG_SENSOR: '{{u|u||ustawienia u|ustawień u}}rządzeni{{a podłączonego do EMS-ESP|e||a podłączonego do EMS-ESP|a podłączonego do EMS-ESP}}', ANALOG_SENSORS: 'Urządzenia podłączone do EMS-ESP', SETTINGS: 'ustawienia', @@ -71,7 +71,6 @@ const pl: BaseTranslation = { TEMP_SENSOR: 'czujnika temperatury', TEMP_SENSORS: 'Czujniki temperatury 1-Wire®', WRITE_CMD_SENT: 'Komenda zapisu została wysłana.', - WRITE_CMD_FAILED: 'Komenda zapisu nie powiodła się!', EMS_BUS_WARNING: 'Brak połączenia z magistralą EMS. Jeśli ten błąd występuje dłużej niż kilka sekund, sprawdź ustawienia oraz profil płytki interfejsu.', EMS_BUS_SCANNING: 'Trwa skanowanie urządzeń na magistrali EMS...', CONNECTED: '{{połączono|połączenie|}}', diff --git a/interface/src/i18n/sv/index.ts b/interface/src/i18n/sv/index.ts index 1048e405a..1c8de2a89 100644 --- a/interface/src/i18n/sv/index.ts +++ b/interface/src/i18n/sv/index.ts @@ -51,7 +51,7 @@ const sv: Translation = { REMOVE: 'Ta bort', PROBLEM_UPDATING: 'Problem vid uppdatering', PROBLEM_LOADING: 'Problem vid hämtning', - ACCESS_DENIED: 'Åtkomst Nekad', + HTTP_ERROR: 'Error {0}', // TODO translate ANALOG_SENSOR: 'Analog Sensor', ANALOG_SENSORS: 'Analoga Sensorer', SETTINGS: 'Inställningar', @@ -71,7 +71,6 @@ const sv: Translation = { TEMP_SENSOR: 'Temperatursensor', TEMP_SENSORS: 'Temperatursensorer', WRITE_CMD_SENT: 'Skrivkommandon skickade', - WRITE_CMD_FAILED: 'Skrivkommandon misslyckade', EMS_BUS_WARNING: 'EMS-buss nedkopplad. Om denna varning kvarstår efter några sekunder, kontrollera inställningar och enhets-profil.', EMS_BUS_SCANNING: 'Söker efter EMS-enheter...', CONNECTED: 'Ansluten', diff --git a/interface/src/i18n/tr/index.ts b/interface/src/i18n/tr/index.ts index fc80585bd..c9ef87e1c 100644 --- a/interface/src/i18n/tr/index.ts +++ b/interface/src/i18n/tr/index.ts @@ -51,7 +51,7 @@ const tr: Translation = { REMOVE: 'Kaldır', PROBLEM_UPDATING: 'Güncelleme Sorunu', PROBLEM_LOADING: 'Yükleme Sorunu', - ACCESS_DENIED: 'Erişim Reddedildi', + HTTP_ERROR: 'Error {0}', // TODO translate ANALOG_SENSOR: 'Analog Sensör', ANALOG_SENSORS: 'Analog Sensörler', SETTINGS: 'Ayarlar', @@ -71,7 +71,6 @@ const tr: Translation = { TEMP_SENSOR: 'Sıcaklık Sensörü', TEMP_SENSORS: 'Sıcaklık Sensörleri', WRITE_CMD_SENT: 'Yazma komutu gönderildi', - WRITE_CMD_FAILED: 'Yazma komutu başarısız oldu', EMS_BUS_WARNING: 'EMS hat bağlantısı kesildi. Eğer bu uyarı birkaç saniye sonra devam ediyorsa lütfen ayarları ve kart tipini kontrol edin', EMS_BUS_SCANNING: 'EMS cihazları aranıyor...', CONNECTED: 'Bağlandı', diff --git a/interface/src/project/DashboardDevices.tsx b/interface/src/project/DashboardDevices.tsx index 4e12f06a5..d1831f40f 100644 --- a/interface/src/project/DashboardDevices.tsx +++ b/interface/src/project/DashboardDevices.tsx @@ -49,6 +49,8 @@ import { ButtonRow, SectionContent, MessageBox } from 'components'; import { AuthenticatedContext } from 'contexts/authentication'; import { useI18nContext } from 'i18n/i18n-react'; + +// TODO what to do with extractErrorMessage? import { extractErrorMessage } from 'utils'; const DashboardDevices: FC = () => { @@ -61,13 +63,6 @@ const DashboardDevices: FC = () => { const [showDeviceInfo, setShowDeviceInfo] = useState(false); const [selectedDevice, setSelectedDevice] = useState(); - // TODO remove - // const [deviceData, setDeviceData] = useState({ data: [] }); - // const [coreData, setCoreData] = useState({ - // connected: true, - // devices: [] - // }); - const { data: coreData, send: readCoreData } = useRequest(() => EMSESP.readCoreData(), { initialData: { connected: true, @@ -88,6 +83,7 @@ const DashboardDevices: FC = () => { const { loading: submitting, send: writeDeviceValue } = useRequest( (id: number, deviceValue: DeviceValue) => EMSESP.writeDeviceValue(id, deviceValue), { + // } = useRequest((data) => alovaInstance.Post('/writeDeviceValue', data), { immediate: false } ); @@ -239,15 +235,6 @@ const DashboardDevices: FC = () => { } ); - // TODO remove - // const fetchDeviceData = async (id: number) => { - // try { - // setDeviceData((await EMSESP.readDeviceData({ id })).data); - // } catch (error) { - // toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING())); - // } - // }; - async function onSelectChange(action: any, state: any) { setSelectedDevice(state.id); if (action.type === 'ADD_BY_ID_EXCLUSIVELY') { @@ -284,21 +271,6 @@ const DashboardDevices: FC = () => { }; }, [escFunction]); - // TODO remove - // const fetchCoreData = useCallback(async () => { - // try { - // setSelectedDevice(undefined); - // setCoreData((await EMSESP.readCoreData()).data); - // } catch (error) { - // toast.error(extractErrorMessage(error, LL.PROBLEM_LOADING())); - // } - // }, [LL]); - - // TODO remove - // useEffect(() => { - // void fetchCoreData2(); - // }, [fetchCoreData2]); - const refreshData = () => { if (deviceValueDialogOpen) { return; @@ -375,34 +347,20 @@ const DashboardDevices: FC = () => { }; }); - const deviceValueDialogSave = async (dv: DeviceValue) => { - const selectedDeviceID = Number(device_select.state.id); - // TODO For all Push, do error handling? - const response = await writeDeviceValue(selectedDeviceID, dv); - console.log(response); - setDeviceValueDialogOpen(false); - await readDeviceData(selectedDeviceID); - setSelectedDeviceValue(undefined); - - // try { - // const response = await EMSESP.writeDeviceValue({ - // id: selectedDeviceID, - // devicevalue: dv - // }); - // if (response.status === 204) { - // toast.error(LL.WRITE_CMD_FAILED()); - // } else if (response.status === 403) { - // toast.error(LL.ACCESS_DENIED()); - // } else { - // toast.success(LL.WRITE_CMD_SENT()); - // } - // } catch (error) { - // toast.error(extractErrorMessage(error, LL.PROBLEM_UPDATING())); - // } finally { - // setDeviceValueDialogOpen(false); - // await readDeviceData(selectedDeviceID); - // setSelectedDeviceValue(undefined); - // } + const deviceValueDialogSave = async (devicevalue: DeviceValue) => { + const id = Number(device_select.state.id); + await writeDeviceValue({ id, devicevalue }) + .then(() => { + toast.success(LL.WRITE_CMD_SENT()); + }) + .catch((error) => { + toast.error(LL.HTTP_ERROR(error)); + }) + .finally(async () => { + setDeviceValueDialogOpen(false); + await readDeviceData(id); + setSelectedDeviceValue(undefined); + }); }; const renderDeviceDetails = () => { diff --git a/interface/src/project/DashboardSensors.tsx b/interface/src/project/DashboardSensors.tsx index 6ced5a217..964110507 100644 --- a/interface/src/project/DashboardSensors.tsx +++ b/interface/src/project/DashboardSensors.tsx @@ -238,7 +238,8 @@ const DashboardSensors: FC = () => { if (response.status === 204) { toast.error(LL.UPDATE_OF(LL.SENSOR(2)) + ' ' + LL.FAILED(1)); } else if (response.status === 403) { - toast.error(LL.ACCESS_DENIED()); + // TODO fix + toast.error(LL.HTTP_ERROR('poep')); } else { toast.success(LL.UPDATED_OF(LL.SENSOR(1))); } @@ -295,7 +296,8 @@ const DashboardSensors: FC = () => { if (response.status === 204) { toast.error(LL.UPDATE_OF(LL.ANALOG_SENSOR(5)) + ' ' + LL.FAILED(1)); } else if (response.status === 403) { - toast.error(LL.ACCESS_DENIED()); + // TODO fix + toast.error(LL.HTTP_ERROR('poep')); } else { toast.success(LL.UPDATED_OF(LL.ANALOG_SENSOR(2))); } diff --git a/interface/src/project/api.ts b/interface/src/project/api.ts index 5d9c39be4..445e0e61f 100644 --- a/interface/src/project/api.ts +++ b/interface/src/project/api.ts @@ -1,4 +1,3 @@ -import { unpack } from '../api/unpack'; import type { BoardProfile, BoardProfileName, @@ -23,14 +22,10 @@ import { AXIOS, AXIOS_API, AXIOS_BIN, alovaInstance } from 'api/endpoints'; export const readCoreData = () => alovaInstance.Get(`/coreData`); -// uses msgpack export const readDeviceData = (id: number) => alovaInstance.Get('/deviceData', { params: { id }, - responseType: 'arraybuffer', - transformData(data) { - return unpack(data); - } + responseType: 'arraybuffer' // uses msgpack }); export const writeDeviceValue = (id: number, devicevalue: DeviceValue) => diff --git a/interface/yarn.lock b/interface/yarn.lock index faf39b8ed..8e337fd77 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -721,15 +721,15 @@ __metadata: languageName: node linkType: hard -"@mui/base@npm:5.0.0-beta.3": - version: 5.0.0-beta.3 - resolution: "@mui/base@npm:5.0.0-beta.3" +"@mui/base@npm:5.0.0-beta.4": + version: 5.0.0-beta.4 + resolution: "@mui/base@npm:5.0.0-beta.4" dependencies: "@babel/runtime": ^7.21.0 "@emotion/is-prop-valid": ^1.2.1 "@mui/types": ^7.2.4 "@mui/utils": ^5.13.1 - "@popperjs/core": ^2.11.7 + "@popperjs/core": ^2.11.8 clsx: ^1.2.1 prop-types: ^15.8.1 react-is: ^18.2.0 @@ -740,14 +740,14 @@ __metadata: peerDependenciesMeta: "@types/react": optional: true - checksum: d1b0aa82efcca8b22f301082fa4157e6b5e6c233f3b65b6295ff0cf5bd8e60c1b289e6340cf68110b01c76c6da9467a6ad1dfc91f26401ff79ed9a81c9104ae9 + checksum: 3d809a8bd82bfd7e0838a455d13a23f83ba7464859ce2efa3909b285c494f312df4c56d4f997672d1ce36154bab8e9140db654909efd8ddb4f426d56bea1eac9 languageName: node linkType: hard -"@mui/core-downloads-tracker@npm:^5.13.3": - version: 5.13.3 - resolution: "@mui/core-downloads-tracker@npm:5.13.3" - checksum: edf92ed962e3e7ab74279db52b8f75393dced39db393a0f7162fc493f3fd9b428353472621839d94ab7c5813b1d4bc71889eb20473ca196106c3654cbd78ad28 +"@mui/core-downloads-tracker@npm:^5.13.4": + version: 5.13.4 + resolution: "@mui/core-downloads-tracker@npm:5.13.4" + checksum: f00f3d086df55531da600b2b58197c4c3d9b586129b00a72a14320492934c098fb1cb1c50a23ea394367c92cac869eab9588bb83885c163c3b0ba0e28c3815ec languageName: node linkType: hard @@ -767,13 +767,13 @@ __metadata: languageName: node linkType: hard -"@mui/material@npm:^5.13.3": - version: 5.13.3 - resolution: "@mui/material@npm:5.13.3" +"@mui/material@npm:^5.13.4": + version: 5.13.4 + resolution: "@mui/material@npm:5.13.4" dependencies: "@babel/runtime": ^7.21.0 - "@mui/base": 5.0.0-beta.3 - "@mui/core-downloads-tracker": ^5.13.3 + "@mui/base": 5.0.0-beta.4 + "@mui/core-downloads-tracker": ^5.13.4 "@mui/system": ^5.13.2 "@mui/types": ^7.2.4 "@mui/utils": ^5.13.1 @@ -796,7 +796,7 @@ __metadata: optional: true "@types/react": optional: true - checksum: 28d782d9366b5e8209fc1ef7a8eacc46c30366a437994927a029debaf44a99582136d56a734633b833512de888d658deebffae584a52427ecdacdba65c28147f + checksum: 1f0b26c74e06fb6849af7398b8bc1d211d0af146822c998a9c55c31552ffcf426834eac56dc909c15bae8a3b957df91f32d9c1b6cb1300e063d184bfb530512f languageName: node linkType: hard @@ -954,10 +954,10 @@ __metadata: languageName: node linkType: hard -"@popperjs/core@npm:^2.11.7": - version: 2.11.7 - resolution: "@popperjs/core@npm:2.11.7" - checksum: e3238267a1c010f7e46adf0d1bf2a6530ccba603cce320ed8f8208217b919f0d9b12c45d4aa535d4945ee791a42b6ef3d016ba108e2d962d29cfb3f7bf18bd28 +"@popperjs/core@npm:^2.11.8": + version: 2.11.8 + resolution: "@popperjs/core@npm:2.11.8" + checksum: 4681e682abc006d25eb380d0cf3efc7557043f53b6aea7a5057d0d1e7df849a00e281cd8ea79c902a35a414d7919621fc2ba293ecec05f413598e0b23d5a1e63 languageName: node linkType: hard @@ -1393,14 +1393,14 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^5.59.8": - version: 5.59.8 - resolution: "@typescript-eslint/eslint-plugin@npm:5.59.8" +"@typescript-eslint/eslint-plugin@npm:^5.59.9": + version: 5.59.9 + resolution: "@typescript-eslint/eslint-plugin@npm:5.59.9" dependencies: "@eslint-community/regexpp": ^4.4.0 - "@typescript-eslint/scope-manager": 5.59.8 - "@typescript-eslint/type-utils": 5.59.8 - "@typescript-eslint/utils": 5.59.8 + "@typescript-eslint/scope-manager": 5.59.9 + "@typescript-eslint/type-utils": 5.59.9 + "@typescript-eslint/utils": 5.59.9 debug: ^4.3.4 grapheme-splitter: ^1.0.4 ignore: ^5.2.0 @@ -1413,43 +1413,43 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 491f88984dd032f309d84b41af6a227a9da944ad6c806b868e71122bd55ad355d8738e7925019f54929784ba631ae9b186a028b194bdb9bad72d122229c029e4 + checksum: 4bb9981bcc009c044ffd6b64288309480df2b6c9cdf6b345987e4b565d0973d1d98b7209f6b46b92880735d788f564e17553641087aa59f67990c84526622a27 languageName: node linkType: hard -"@typescript-eslint/parser@npm:^5.59.8": - version: 5.59.8 - resolution: "@typescript-eslint/parser@npm:5.59.8" +"@typescript-eslint/parser@npm:^5.59.9": + version: 5.59.9 + resolution: "@typescript-eslint/parser@npm:5.59.9" dependencies: - "@typescript-eslint/scope-manager": 5.59.8 - "@typescript-eslint/types": 5.59.8 - "@typescript-eslint/typescript-estree": 5.59.8 + "@typescript-eslint/scope-manager": 5.59.9 + "@typescript-eslint/types": 5.59.9 + "@typescript-eslint/typescript-estree": 5.59.9 debug: ^4.3.4 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: 710daf64331d5bc198c22c66c1fdd06db2300487f655d161f0e59971fcd0c70661a7059ff7e3cf2ed66fc72d6674a3f4a317d5d5778ce6605d18e831b0a7039e + checksum: af0e041e8a541734ff237ec0eac47e355c2f78dd2b0db4eb4ab0c10ba1b6d5d70f84ddc16f856bc72c4cacd53ef04b5f4948baffb5c8cb2d9a0ffd83a8fbc547 languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:5.59.8": - version: 5.59.8 - resolution: "@typescript-eslint/scope-manager@npm:5.59.8" +"@typescript-eslint/scope-manager@npm:5.59.9": + version: 5.59.9 + resolution: "@typescript-eslint/scope-manager@npm:5.59.9" dependencies: - "@typescript-eslint/types": 5.59.8 - "@typescript-eslint/visitor-keys": 5.59.8 - checksum: 164ea98d0d7dd4dd0c462eb7238266b2260af63fd29b96746dd978322114c7ebf31ba697c424397e3fb36027704e1c5d788cb6049a6ccb52fec8c6c134d7503b + "@typescript-eslint/types": 5.59.9 + "@typescript-eslint/visitor-keys": 5.59.9 + checksum: 41622fd270e5b8574347ed5dd020bbb9752d85e6f40df180e944c1110d9bd2227a949067feb23dd4117dd2be0623c05a47bc363abe605c96deb295753f6dd080 languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:5.59.8": - version: 5.59.8 - resolution: "@typescript-eslint/type-utils@npm:5.59.8" +"@typescript-eslint/type-utils@npm:5.59.9": + version: 5.59.9 + resolution: "@typescript-eslint/type-utils@npm:5.59.9" dependencies: - "@typescript-eslint/typescript-estree": 5.59.8 - "@typescript-eslint/utils": 5.59.8 + "@typescript-eslint/typescript-estree": 5.59.9 + "@typescript-eslint/utils": 5.59.9 debug: ^4.3.4 tsutils: ^3.21.0 peerDependencies: @@ -1457,23 +1457,23 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 70c64edb564d4c5270cb8cea226544eebcf0f0a394c185a3c5b5bfd9df2e97e0396fa6324ba58da3136d99d12adcfe5f21243aa6c997734e6daa154a6708ae60 + checksum: c3a9773d2b81350923025933623e1572538f79bf119b40bed17389eda11632f6d364a49b385aa6d915d85f7c3d45376085cc55263d865dbc2b753598bba6473b languageName: node linkType: hard -"@typescript-eslint/types@npm:5.59.8": - version: 5.59.8 - resolution: "@typescript-eslint/types@npm:5.59.8" - checksum: 3f5000f556b4fe45c16e00b24d18c0f8930a214e61a0302daf3ef952a7a45342d9e63119626bd0556b252a6345e1fa423e34908eaf08560756f6c747dcffb56a +"@typescript-eslint/types@npm:5.59.9": + version: 5.59.9 + resolution: "@typescript-eslint/types@npm:5.59.9" + checksum: 951046891bcc9fa27d72a5489b496291e44cedcff204d3ce6c10c8916fc5e255332738efd4d7555200a55b49ff4ba1204e186960d216d51fea89fe92a982180e languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:5.59.8": - version: 5.59.8 - resolution: "@typescript-eslint/typescript-estree@npm:5.59.8" +"@typescript-eslint/typescript-estree@npm:5.59.9": + version: 5.59.9 + resolution: "@typescript-eslint/typescript-estree@npm:5.59.9" dependencies: - "@typescript-eslint/types": 5.59.8 - "@typescript-eslint/visitor-keys": 5.59.8 + "@typescript-eslint/types": 5.59.9 + "@typescript-eslint/visitor-keys": 5.59.9 debug: ^4.3.4 globby: ^11.1.0 is-glob: ^4.0.3 @@ -1482,35 +1482,35 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: a6ec2654c5c8c0bead99e1a43936a56e9bd0e1422b993fcd9d603ff31fe4701e9562fbc6d0f2b4d50a7d113d27d5fb68c428f78b938bd110b0112ed4df81ed72 + checksum: 2f3d8df6d454fbc52d305abfe8447bff8e8d63294ce47e4679c920f647643f5d15a1f693caf74f4fabece12d5ba27ebdb156d507b16fbd2751fc01ba6c4df3c8 languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.59.8": - version: 5.59.8 - resolution: "@typescript-eslint/utils@npm:5.59.8" +"@typescript-eslint/utils@npm:5.59.9": + version: 5.59.9 + resolution: "@typescript-eslint/utils@npm:5.59.9" dependencies: "@eslint-community/eslint-utils": ^4.2.0 "@types/json-schema": ^7.0.9 "@types/semver": ^7.3.12 - "@typescript-eslint/scope-manager": 5.59.8 - "@typescript-eslint/types": 5.59.8 - "@typescript-eslint/typescript-estree": 5.59.8 + "@typescript-eslint/scope-manager": 5.59.9 + "@typescript-eslint/types": 5.59.9 + "@typescript-eslint/typescript-estree": 5.59.9 eslint-scope: ^5.1.1 semver: ^7.3.7 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: 20b859508942b79111ddbea8e777864fa76a5597b217bff921ba0e9ad245f71cff7ed598d18f384f441d4b433cfae0645654455fa38f313e24869fa062582964 + checksum: b8a04a83c121faa3e36abb2b6113f2e0ec5cf86884d0cb8619bfc50f7442341ee17e4495d69f8abeb6edad9e0347de8382ea1708a5fd6da1e4c80b7b8215c6ab languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:5.59.8": - version: 5.59.8 - resolution: "@typescript-eslint/visitor-keys@npm:5.59.8" +"@typescript-eslint/visitor-keys@npm:5.59.9": + version: 5.59.9 + resolution: "@typescript-eslint/visitor-keys@npm:5.59.9" dependencies: - "@typescript-eslint/types": 5.59.8 + "@typescript-eslint/types": 5.59.9 eslint-visitor-keys: ^3.3.0 - checksum: 0e7cdb5c0e9106bbb77bb599d9a6464306d7cfa1b35435810c5d59b951f3b65ac3a1a829894e328e43d411da189247568eb24d28dd9ceca95dfc3f19011b889f + checksum: 882fd03830cbe0eca8f9a547aecc6519ddbec10e55f5f3de66e605a3f3d42a6237abd3c09b34d9cc3343c8e11386e999876aec384efe523e1478cb22752d326d languageName: node linkType: hard @@ -1533,15 +1533,15 @@ __metadata: "@emotion/react": ^11.11.0 "@emotion/styled": ^11.11.0 "@mui/icons-material": ^5.11.16 - "@mui/material": ^5.13.3 + "@mui/material": ^5.13.4 "@table-library/react-table-library": 4.1.4 "@types/lodash-es": ^4.17.7 "@types/node": ^20.2.5 "@types/react": ^18.2.8 "@types/react-dom": ^18.2.4 "@types/react-router-dom": ^5.3.3 - "@typescript-eslint/eslint-plugin": ^5.59.8 - "@typescript-eslint/parser": ^5.59.8 + "@typescript-eslint/eslint-plugin": ^5.59.9 + "@typescript-eslint/parser": ^5.59.9 "@vitejs/plugin-react-swc": ^3.3.2 alova: ^2.5.5 async-validator: ^4.2.5 diff --git a/mock-api/server.js b/mock-api/server.js index e687ebc51..97f209dd5 100644 --- a/mock-api/server.js +++ b/mock-api/server.js @@ -2375,7 +2375,7 @@ rest_server.post(EMSESP_WRITE_VALUE_ENDPOINT, async (req, res) => { } // await delay(2000); // wait 2 seconds to show spinner - + // res.sendStatus(400); // bad request res.sendStatus(200); }); diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index 01430cdfd..0b6233f08 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -171,7 +171,7 @@ void WebCustomizationService::reset_customization(AsyncWebServerRequest * reques return; } // failed - AsyncWebServerResponse * response = request->beginResponse(204); // no content error + AsyncWebServerResponse * response = request->beginResponse(400); // bad request request->send(response); #endif } diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index 054082011..6fd4637d5 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -265,7 +265,7 @@ void WebDataService::write_device_value(AsyncWebServerRequest * request, JsonVar #endif } - response->setCode((return_code == CommandRet::OK) ? 200 : 204); + response->setCode((return_code == CommandRet::OK) ? 200 : 400); // bad request response->setLength(); request->send(response); return; @@ -297,14 +297,14 @@ void WebDataService::write_device_value(AsyncWebServerRequest * request, JsonVar EMSESP::logger().debug("Write command successful"); #endif } - response->setCode((return_code == CommandRet::OK) ? 200 : 204); + response->setCode((return_code == CommandRet::OK) ? 200 : 400); // bad request response->setLength(); request->send(response); return; } } - AsyncWebServerResponse * response = request->beginResponse(204); // Write command failed + AsyncWebServerResponse * response = request->beginResponse(400); // bad request request->send(response); } @@ -327,7 +327,7 @@ void WebDataService::write_temperature_sensor(AsyncWebServerRequest * request, J ok = EMSESP::temperaturesensor_.update(id, name, offset10); } - AsyncWebServerResponse * response = request->beginResponse(ok ? 200 : 204); + AsyncWebServerResponse * response = request->beginResponse(ok ? 200 : 400); // bad request request->send(response); } @@ -347,7 +347,7 @@ void WebDataService::write_analog_sensor(AsyncWebServerRequest * request, JsonVa ok = EMSESP::analogsensor_.update(gpio, name, offset, factor, uom, type, deleted); } - AsyncWebServerResponse * response = request->beginResponse(ok ? 200 : 204); + AsyncWebServerResponse * response = request->beginResponse(ok ? 200 : 400); // bad request request->send(response); }