Skip to content

Commit

Permalink
Merge pull request #1568 from MichaelDvP/dev
Browse files Browse the repository at this point in the history
fix #1565 and workaround for #1564
  • Loading branch information
proddy committed Jan 20, 2024
2 parents 2b6fd41 + 4d1a428 commit 549a030
Show file tree
Hide file tree
Showing 19 changed files with 133 additions and 56 deletions.
8 changes: 4 additions & 4 deletions interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@babel/core": "^7.23.7",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.4",
"@mui/icons-material": "^5.15.5",
"@mui/material": "^5.15.5",
"@table-library/react-table-library": "4.1.7",
"@types/imagemin": "^8.0.5",
Expand All @@ -43,7 +43,7 @@
"react-dom": "latest",
"react-dropzone": "^14.2.3",
"react-icons": "^5.0.1",
"react-router-dom": "^6.21.2",
"react-router-dom": "^6.21.3",
"react-toastify": "^10.0.3",
"sockette": "^2.0.6",
"typesafe-i18n": "^5.26.2",
Expand All @@ -69,8 +69,8 @@
"preact": "^10.19.3",
"prettier": "^3.2.4",
"rollup-plugin-visualizer": "^5.12.0",
"terser": "^5.26.0",
"vite": "^5.0.11",
"terser": "^5.27.0",
"vite": "^5.0.12",
"vite-plugin-imagemin": "^0.6.1",
"vite-tsconfig-paths": "^4.3.1"
},
Expand Down
14 changes: 11 additions & 3 deletions interface/src/components/upload/SingleUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, isUploading, pr

const progressText = () => {
if (uploading) {
if (progress.total) {
return LL.UPLOADING() + ': ' + Math.round((progress.loaded * 100) / progress.total) + '%';
if (progress.total && progress.loaded) {
return progress.loaded <= progress.total
? LL.UPLOADING() + ': ' + Math.round((progress.loaded * 100) / progress.total) + '%'
: LL.UPLOADING() + ': ' + Math.round((progress.total * 100) / progress.loaded) + '%';
}
}
return LL.UPLOAD_DROP_TEXT();
Expand Down Expand Up @@ -83,7 +85,13 @@ const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, isUploading, pr
<Box width="100%" p={2}>
<LinearProgress
variant="determinate"
value={progress.total === 0 ? 0 : Math.round((progress.loaded * 100) / progress.total)}
value={
progress.total === 0 || progress.loaded === 0
? 0
: progress.loaded <= progress.total
? Math.round((progress.loaded * 100) / progress.total)
: Math.round((progress.total * 100) / progress.loaded)
}
/>
</Box>
<Button startIcon={<CancelIcon />} variant="outlined" color="secondary" onClick={onCancel}>
Expand Down
1 change: 0 additions & 1 deletion interface/src/types/ntp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export interface NTPStatus {
utc_time: string;
local_time: string;
server: string;
uptime: number;
}

export interface NTPSettings {
Expand Down
54 changes: 27 additions & 27 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.23.7, @babel/runtime@npm:^7.23.8":
"@babel/runtime@npm:^7.23.8":
version: 7.23.8
resolution: "@babel/runtime@npm:7.23.8"
dependencies:
Expand Down Expand Up @@ -999,19 +999,19 @@ __metadata:
languageName: node
linkType: hard

"@mui/icons-material@npm:^5.15.4":
version: 5.15.4
resolution: "@mui/icons-material@npm:5.15.4"
"@mui/icons-material@npm:^5.15.5":
version: 5.15.5
resolution: "@mui/icons-material@npm:5.15.5"
dependencies:
"@babel/runtime": "npm:^7.23.7"
"@babel/runtime": "npm:^7.23.8"
peerDependencies:
"@mui/material": ^5.0.0
"@types/react": ^17.0.0 || ^18.0.0
react: ^17.0.0 || ^18.0.0
peerDependenciesMeta:
"@types/react":
optional: true
checksum: 1c9be5d3e23a6b565a36d36065e8a2480feebfb497ea7367f7fd32f90164e46420e5be8117fcfd05f2a3c1940b8fa48f56caccc19da78849fc8bda037f186954
checksum: 25feb86a76ce83c81391c95d0c1c867e988cc7bc1b5a05c5698b71cb3cd1005fd148b07c2fa8908cda9fc4e44ea8b6e0fd2197bc0abafac0ee4880b477852eea
languageName: node
linkType: hard

Expand Down Expand Up @@ -1829,7 +1829,7 @@ __metadata:
"@babel/core": "npm:^7.23.7"
"@emotion/react": "npm:^11.11.3"
"@emotion/styled": "npm:^11.11.0"
"@mui/icons-material": "npm:^5.15.4"
"@mui/icons-material": "npm:^5.15.5"
"@mui/material": "npm:^5.15.5"
"@preact/compat": "npm:^17.1.2"
"@preact/preset-vite": "npm:^2.8.1"
Expand Down Expand Up @@ -1866,14 +1866,14 @@ __metadata:
react-dom: "npm:latest"
react-dropzone: "npm:^14.2.3"
react-icons: "npm:^5.0.1"
react-router-dom: "npm:^6.21.2"
react-router-dom: "npm:^6.21.3"
react-toastify: "npm:^10.0.3"
rollup-plugin-visualizer: "npm:^5.12.0"
sockette: "npm:^2.0.6"
terser: "npm:^5.26.0"
terser: "npm:^5.27.0"
typesafe-i18n: "npm:^5.26.2"
typescript: "npm:^5.3.3"
vite: "npm:^5.0.11"
vite: "npm:^5.0.12"
vite-plugin-imagemin: "npm:^0.6.1"
vite-tsconfig-paths: "npm:^4.3.1"
languageName: unknown
Expand Down Expand Up @@ -7218,27 +7218,27 @@ __metadata:
languageName: node
linkType: hard

"react-router-dom@npm:^6.21.2":
version: 6.21.2
resolution: "react-router-dom@npm:6.21.2"
"react-router-dom@npm:^6.21.3":
version: 6.21.3
resolution: "react-router-dom@npm:6.21.3"
dependencies:
"@remix-run/router": "npm:1.14.2"
react-router: "npm:6.21.2"
react-router: "npm:6.21.3"
peerDependencies:
react: ">=16.8"
react-dom: ">=16.8"
checksum: 24d1470e68f11369776c623b8873c8cf0af476d102317cb3aa6b13b48c86908f10a6e51209ce24dccf40e429538d4e23fda796c190f2ff98f894cb476d51f44d
checksum: 6e23e35d02e5c83847c8e47d7912d1f6c2c42a35f2317802031bdd993a8205468138a045ff34f67fe807fe9f7dc9d0995ee05bab25aedc0bf978e620ac132815
languageName: node
linkType: hard

"react-router@npm:6.21.2":
version: 6.21.2
resolution: "react-router@npm:6.21.2"
"react-router@npm:6.21.3":
version: 6.21.3
resolution: "react-router@npm:6.21.3"
dependencies:
"@remix-run/router": "npm:1.14.2"
peerDependencies:
react: ">=16.8"
checksum: 08701bfe9e7b860442dd0f3c6e36d3ea6106d86db5ec9da930fd56d5782a13b82612826de7dd31bb38832f3fa76437d7a0ca36e63a76256f62d5b738f529a48c
checksum: 3d5107cfdb440519d84e6ad6d95454e3bf41ec97677b95f7b2a7f281f8ddf191b765cf1b599ead951f3cd33ed4429f140590d74a01cfdf835dc2f812023a978a
languageName: node
linkType: hard

Expand Down Expand Up @@ -8338,17 +8338,17 @@ __metadata:
languageName: node
linkType: hard

"terser@npm:^5.26.0":
version: 5.26.0
resolution: "terser@npm:5.26.0"
"terser@npm:^5.27.0":
version: 5.27.0
resolution: "terser@npm:5.27.0"
dependencies:
"@jridgewell/source-map": "npm:^0.3.3"
acorn: "npm:^8.8.2"
commander: "npm:^2.20.0"
source-map-support: "npm:~0.5.20"
bin:
terser: bin/terser
checksum: 0282c5c065cbfa1e725d5609b99579252bc20b83cd1d75e8ab8b46d5da2c9d0fcfc453a12624f2d2d4c1240bfa0017a90fcf1e3b88258e5842fca1b0b82be8d8
checksum: 9b2c5cb00747dea5994034ca064fb3cc7efc1be6b79a35247662d51ab43bdbe9cbf002bbf29170b5f3bd068c811d0212e22d94acd2cf0d8562687b96f1bffc9f
languageName: node
linkType: hard

Expand Down Expand Up @@ -8764,9 +8764,9 @@ __metadata:
languageName: node
linkType: hard

"vite@npm:^5.0.11":
version: 5.0.11
resolution: "vite@npm:5.0.11"
"vite@npm:^5.0.12":
version: 5.0.12
resolution: "vite@npm:5.0.12"
dependencies:
esbuild: "npm:^0.19.3"
fsevents: "npm:~2.3.3"
Expand Down Expand Up @@ -8800,7 +8800,7 @@ __metadata:
optional: true
bin:
vite: bin/vite.js
checksum: f1a8fea35ed9f162d7a10fd13efb2c96637028b0a319d726aeec8b31e20e4d047272bda5df82167618e7774a520236c66f3093ed172802660aec5227814072f4
checksum: ed0bb26a0d0c8e1dae0b70af9e36adffd7e15d80297443fe4da762596dc81570bad7f0291f590a57c1553f5e435338d8c7ffc483bd9431a95c09d9ac90665fad
languageName: node
linkType: hard

Expand Down
5 changes: 5 additions & 0 deletions lib/ArduinoJson/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
ArduinoJson: change log
=======================

v7.0.2 (2024-01-19)
------

* Fix assertion `poolIndex < count_` after `JsonDocument::clear()` (issue #2034)

v7.0.1 (2024-01-10)
------

Expand Down
25 changes: 25 additions & 0 deletions lib/ArduinoJson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ArduinoJson - https://arduinojson.org
# Copyright © 2014-2024, Benoit BLANCHON
# MIT License

cmake_minimum_required(VERSION 3.15)

if(ESP_PLATFORM)
# Build ArduinoJson as an ESP-IDF component
idf_component_register(INCLUDE_DIRS src)
return()
endif()

project(ArduinoJson VERSION 7.0.2)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
endif()

add_subdirectory(src)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
include(extras/CompileOptions.cmake)
add_subdirectory(extras/tests)
add_subdirectory(extras/fuzzing)
endif()
13 changes: 13 additions & 0 deletions lib/ArduinoJson/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "7.0.2"
description: >-
A simple and efficient JSON library for embedded C++.
⭐ 6444 stars on GitHub!
Supports serialization, deserialization, MessagePack, streams, filtering, and more.
Fully tested and documented.
url: https://arduinojson.org/
files:
exclude:
- "**/.vs/**/*"
- ".devcontainer/**/*"
- "examples/**/*"
- "extras/**/*"
23 changes: 23 additions & 0 deletions lib/ArduinoJson/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "ArduinoJson",
"keywords": "json, rest, http, web",
"description": "A simple and efficient JSON library for embedded C++. ⭐ 6444 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.",
"homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json",
"repository": {
"type": "git",
"url": "https://github.com/bblanchon/ArduinoJson.git"
},
"version": "7.0.2",
"authors": {
"name": "Benoit Blanchon",
"url": "https://blog.benoitblanchon.fr"
},
"export": {
"include": ["src", "examples", "LICENSE.txt", "ArduinoJson.h"]
},
"frameworks": "*",
"platforms": "*",
"build": {
"libArchive": false
}
}
11 changes: 11 additions & 0 deletions lib/ArduinoJson/library.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name=ArduinoJson
version=7.0.2
author=Benoit Blanchon <blog.benoitblanchon.fr>
maintainer=Benoit Blanchon <blog.benoitblanchon.fr>
sentence=A simple and efficient JSON library for embedded C++.
paragraph=⭐ 6444 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.
category=Data Processing
url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties
architectures=*
repository=https://github.com/bblanchon/ArduinoJson.git
license=MIT
2 changes: 1 addition & 1 deletion lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
}

// Reduces the capacity of the memory pool to match the current usage.
// https://arduinojson.org/v7/api/JsonDocument/shrinktofit/
// https://arduinojson.org/v7/api/jsondocument/shrinktofit/
void shrinkToFit() {
resources_.shrinkToFit();
}
Expand Down
1 change: 1 addition & 0 deletions lib/ArduinoJson/src/ArduinoJson/Memory/VariantPoolList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class VariantPoolList {
for (PoolCount i = 0; i < count_; i++)
pools_[i].destroy(allocator);
count_ = 0;
freeList_ = NULL_SLOT;
if (pools_ != preallocatedPools_) {
allocator->deallocate(pools_);
pools_ = preallocatedPools_;
Expand Down
6 changes: 3 additions & 3 deletions lib/ArduinoJson/src/ArduinoJson/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#pragma once

#define ARDUINOJSON_VERSION "7.0.1"
#define ARDUINOJSON_VERSION "7.0.2"
#define ARDUINOJSON_VERSION_MAJOR 7
#define ARDUINOJSON_VERSION_MINOR 0
#define ARDUINOJSON_VERSION_REVISION 1
#define ARDUINOJSON_VERSION_MACRO V701
#define ARDUINOJSON_VERSION_REVISION 2
#define ARDUINOJSON_VERSION_MACRO V702
2 changes: 1 addition & 1 deletion src/analogsensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ bool AnalogSensor::get_value_info(JsonObject output, const char * cmd, const int
// if we're filtering on an attribute, go find it
if (attribute_s) {
if (output.containsKey(attribute_s)) {
JsonVariant data = output[attribute_s];
String data = output[attribute_s].as<String>();
output.clear();
output["api_data"] = data;
return true;
Expand Down
11 changes: 2 additions & 9 deletions src/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,8 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {

if (return_code == CommandRet::OK && json.size()) {
if (json.containsKey("api_data")) {
JsonVariant data = json["api_data"];
if (data.is<int>()) {
shell.printfln("%d", data.as<int>());
} else if (data.is<float>()) {
char s[10];
shell.println(Helpers::render_value(s, data.as<float>(), 1));
} else {
shell.println(data.as<const char *>());
}
String data = json["api_data"].as<String>();
shell.println(data.c_str());
return;
}
serializeJsonPretty(doc, shell);
Expand Down
2 changes: 1 addition & 1 deletion src/emsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ bool EMSdevice::get_value_info(JsonObject output, const char * cmd, const int8_t
EMSESP::logger().debug("Attribute '%s'", attribute_s);
#endif
if (json.containsKey(attribute_s)) {
JsonVariant data = json[attribute_s];
String data = json[attribute_s].as<String>();
output.clear();
output["api_data"] = data;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/temperaturesensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ bool TemperatureSensor::get_value_info(JsonObject output, const char * cmd, cons
// if we're filtering on an attribute, go find it
if (attribute_s) {
if (output.containsKey(attribute_s)) {
JsonVariant data = output[attribute_s];
String data = output[attribute_s].as<String>();
output.clear();
output["api_data"] = data;
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/web/WebAPIService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
// if we're returning single values, just sent as plain text
// https://github.com/emsesp/EMS-ESP32/issues/462#issuecomment-1093877210
if (output.containsKey("api_data")) {
JsonVariant data = output["api_data"];
request->send(200, "text/plain; charset=utf-8", data.as<String>());
String data = output["api_data"].as<String>();
request->send(200, "text/plain; charset=utf-8", data);
api_count_++;
delete response;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/web/WebCustomEntityService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ bool WebCustomEntityService::get_value_info(JsonObject output, const char * cmd)
render_value(output, entity, true);
if (attribute_s) {
if (output.containsKey(attribute_s)) {
JsonVariant data = output[attribute_s];
String data = output[attribute_s].as<String>();
output.clear();
output["api_data"] = data;
return true;
Expand Down

0 comments on commit 549a030

Please sign in to comment.