diff --git a/interface/src/system/SystemStatusForm.tsx b/interface/src/system/SystemStatusForm.tsx index 7c3f431..88fc7aa 100644 --- a/interface/src/system/SystemStatusForm.tsx +++ b/interface/src/system/SystemStatusForm.tsx @@ -7,6 +7,7 @@ import DevicesIcon from '@material-ui/icons/Devices'; import MemoryIcon from '@material-ui/icons/Memory'; import ShowChartIcon from '@material-ui/icons/ShowChart'; import SdStorageIcon from '@material-ui/icons/SdStorage'; +import StorageIcon from '@material-ui/icons/Storage'; import DataUsageIcon from '@material-ui/icons/DataUsage'; import PowerSettingsNewIcon from '@material-ui/icons/PowerSettingsNew'; import RefreshIcon from '@material-ui/icons/Refresh'; @@ -26,6 +27,11 @@ interface SystemStatusFormState { type SystemStatusFormProps = AuthenticatedContextProps & RestFormProps; +function formatNumber(num: number){ + return new Intl.NumberFormat().format(num); +} + + class SystemStatusForm extends Component { state: SystemStatusFormState = { @@ -67,7 +73,7 @@ class SystemStatusForm extends Component - + @@ -76,7 +82,7 @@ class SystemStatusForm extends Component - + @@ -85,12 +91,20 @@ class SystemStatusForm extends Component - + + + + + + + + + ); - } + } renderRestartDialog() { return ( diff --git a/interface/src/system/types.ts b/interface/src/system/types.ts index 323f947..c1c3bc0 100644 --- a/interface/src/system/types.ts +++ b/interface/src/system/types.ts @@ -8,6 +8,8 @@ export interface SystemStatus { sdk_version: string; flash_chip_size: number; flash_chip_speed: number; + spiffs_size:number; + spiffs_used:number; } export interface OTASettings { diff --git a/lib/framework/SystemStatus.cpp b/lib/framework/SystemStatus.cpp index cda53c9..0750184 100644 --- a/lib/framework/SystemStatus.cpp +++ b/lib/framework/SystemStatus.cpp @@ -1,29 +1,36 @@ -#include - -SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityManager) { - server->on(SYSTEM_STATUS_SERVICE_PATH, - HTTP_GET, - securityManager->wrapRequest(std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1), - AuthenticationPredicates::IS_AUTHENTICATED)); -} - -void SystemStatus::systemStatus(AsyncWebServerRequest* request) { - AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE); - JsonObject root = response->getRoot(); -#ifdef ESP32 - root["esp_platform"] = "esp32"; - root["max_alloc_heap"] = ESP.getMaxAllocHeap(); -#elif defined(ESP8266) - root["esp_platform"] = "esp8266"; - root["max_alloc_heap"] = ESP.getMaxFreeBlockSize(); -#endif - root["cpu_freq_mhz"] = ESP.getCpuFreqMHz(); - root["free_heap"] = ESP.getFreeHeap(); - root["sketch_size"] = ESP.getSketchSize(); - root["free_sketch_space"] = ESP.getFreeSketchSpace(); - root["sdk_version"] = ESP.getSdkVersion(); - root["flash_chip_size"] = ESP.getFlashChipSize(); - root["flash_chip_speed"] = ESP.getFlashChipSpeed(); - response->setLength(); - request->send(response); -} +#include +#ifdef ESP32 +#include +#elif defined(ESP8266) +#include +#endif + +SystemStatus::SystemStatus(AsyncWebServer* server, SecurityManager* securityManager) { + server->on(SYSTEM_STATUS_SERVICE_PATH, + HTTP_GET, + securityManager->wrapRequest(std::bind(&SystemStatus::systemStatus, this, std::placeholders::_1), + AuthenticationPredicates::IS_AUTHENTICATED)); +} + +void SystemStatus::systemStatus(AsyncWebServerRequest* request) { + AsyncJsonResponse* response = new AsyncJsonResponse(false, MAX_ESP_STATUS_SIZE); + JsonObject root = response->getRoot(); +#ifdef ESP32 + root["esp_platform"] = "esp32"; + root["max_alloc_heap"] = ESP.getMaxAllocHeap(); +#elif defined(ESP8266) + root["esp_platform"] = "esp8266"; + root["max_alloc_heap"] = ESP.getMaxFreeBlockSize(); +#endif + root["cpu_freq_mhz"] = ESP.getCpuFreqMHz(); + root["free_heap"] = ESP.getFreeHeap(); + root["sketch_size"] = ESP.getSketchSize(); + root["free_sketch_space"] = ESP.getFreeSketchSpace(); + root["sdk_version"] = ESP.getSdkVersion(); + root["flash_chip_size"] = ESP.getFlashChipSize(); + root["flash_chip_speed"] = ESP.getFlashChipSpeed(); + root["spiffs_used"] = SPIFFS.usedBytes(); + root["spiffs_size"] = SPIFFS.totalBytes(); + response->setLength(); + request->send(response); +}