feat: persistent custom labels
This commit is contained in:
@@ -20,6 +20,7 @@ public:
|
||||
NodeInfo self;
|
||||
std::map<String, NodeInfo>* memberList;
|
||||
::Config config;
|
||||
std::map<String, String> constructorLabels; // Labels passed to constructor (not persisted)
|
||||
|
||||
using EventCallback = std::function<void(void*)>;
|
||||
std::map<std::string, std::vector<EventCallback>> eventRegistry;
|
||||
@@ -29,4 +30,5 @@ public:
|
||||
void on(const std::string& event, EventCallback cb);
|
||||
void fire(const std::string& event, void* data);
|
||||
void onAny(AnyEventCallback cb);
|
||||
void rebuildLabels(); // Rebuild self.labels from constructorLabels + config.labels
|
||||
};
|
||||
|
||||
@@ -20,4 +20,5 @@ private:
|
||||
void handleUpdateUpload(AsyncWebServerRequest* request, const String& filename, size_t index, uint8_t* data, size_t len, bool final);
|
||||
void handleRestartRequest(AsyncWebServerRequest* request);
|
||||
void handleEndpointsRequest(AsyncWebServerRequest* request);
|
||||
void handleConfigRequest(AsyncWebServerRequest* request);
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <map>
|
||||
|
||||
class Config {
|
||||
public:
|
||||
@@ -62,6 +63,9 @@ public:
|
||||
uint32_t critical_memory_threshold_bytes;
|
||||
size_t max_concurrent_http_requests;
|
||||
|
||||
// Custom Labels
|
||||
std::map<String, String> labels;
|
||||
|
||||
// Constructor
|
||||
Config();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user