-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #755 from SignalK/status_page_item
Web UI class cleanups
- Loading branch information
Showing
10 changed files
with
138 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "status_page_item.h" | ||
|
||
namespace sensesp { | ||
|
||
std::map<String, StatusPageItemBase*> StatusPageItemBase::status_page_items_; | ||
|
||
} // namespace sensesp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef SENSESP_UI_UI_OUTPUT_H | ||
#define SENSESP_UI_UI_OUTPUT_H | ||
|
||
#include <ArduinoJson.h> | ||
#include <functional> | ||
#include <map> | ||
|
||
#include "Arduino.h" | ||
#include "sensesp/system/observablevalue.h" | ||
#include "sensesp/system/valueconsumer.h" | ||
#include "sensesp/system/valueproducer.h" | ||
|
||
namespace sensesp { | ||
|
||
constexpr char kUIOutputDefaultGroup[] = "Default"; | ||
constexpr int kUIOutputDefaultOrder = 1000; | ||
|
||
class StatusPageItemBase { | ||
public: | ||
StatusPageItemBase(String name, String group, int order) | ||
: name_(name), group_(group), order_(order) {} | ||
|
||
String& get_name() { return name_; } | ||
|
||
virtual JsonDocument as_json() = 0; | ||
|
||
static const std::map<String, StatusPageItemBase*>* get_status_page_items() { | ||
return &status_page_items_; | ||
} | ||
|
||
protected: | ||
String name_; | ||
String group_ = kUIOutputDefaultGroup; | ||
int order_ = kUIOutputDefaultOrder; | ||
static std::map<String, StatusPageItemBase*> status_page_items_; | ||
}; | ||
|
||
template <typename T> | ||
class StatusPageItem : public StatusPageItemBase, public ObservableValue<T> { | ||
public: | ||
StatusPageItem(String name, const T& value, String group, int order) | ||
: StatusPageItemBase(name, group, order), ObservableValue<T>(value) { | ||
status_page_items_[name] = this; | ||
} | ||
|
||
protected: | ||
virtual JsonDocument as_json() override{ | ||
JsonDocument obj; | ||
obj["name"] = name_; | ||
obj["value"] = this->get(); | ||
obj["group"] = group_; | ||
obj["order"] = order_; | ||
return obj; | ||
} | ||
}; | ||
|
||
} // namespace sensesp | ||
|
||
#endif |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.