21 #ifndef INCLUDE_OLA_WEB_JSONSECTIONS_H_
22 #define INCLUDE_OLA_WEB_JSONSECTIONS_H_
44 GenericItem(
const std::string &description,
const std::string &
id):
45 m_description(description),
52 void SetButtonText(
const std::string &text) {
59 virtual std::string Type()
const = 0;
60 virtual void SetValue(
JsonObject *item)
const = 0;
61 virtual void SetExtraProperties(
JsonObject *item)
const {
66 std::string m_description;
68 std::string m_button_text;
78 const std::string &value,
79 const std::string &
id =
""):
85 std::string Type()
const {
return "string"; }
87 item->
Add(
"value", m_value);
100 UIntItem(
const std::string &description,
102 const std::string &
id =
""):
109 void SetMin(
unsigned int min) {
113 void SetMax(
unsigned int max) {
119 void SetExtraProperties(
JsonObject *item)
const;
120 std::string Type()
const {
return "uint"; }
122 item->
Add(
"value", m_value);
126 unsigned int m_value;
127 bool m_min_set, m_max_set;
135 BoolItem(
const std::string &description,
137 const std::string &
id):
143 std::string Type()
const {
return "bool"; }
145 item->
Add(
"value", m_value);
155 HiddenItem(
const std::string &value,
const std::string &
id):
161 std::string Type()
const {
return "hidden"; }
163 item->
Add(
"value", m_value);
177 const std::string &
id =
""):
179 m_selected_offset(0) {
182 void SetSelectedOffset(
unsigned int offset) { m_selected_offset = offset; }
183 void AddItem(
const std::string &label,
const std::string &value);
185 void AddItem(
const std::string &label,
unsigned int value);
188 void SetExtraProperties(
JsonObject *item)
const {
189 item->
Add(
"selected_offset", m_selected_offset);
191 std::string Type()
const {
return "select"; }
195 std::vector<std::pair<std::string, std::string> > m_values;
196 unsigned int m_selected_offset;
205 void SetSaveButton(
const std::string &text) { m_save_button_text = text; }
206 void SetError(
const std::string &error) { m_error = error; }
209 std::string AsString()
const;
212 bool m_allow_refresh;
214 std::string m_save_button_text;
215 std::vector<const GenericItem*> m_items;
219 #endif // INCLUDE_OLA_WEB_JSONSECTIONS_H_