nx_metadata_sdk  1.0
Metadata SDK
settings_model.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2 
3 #pragma once
4 
5 #include <string>
6 
7 namespace nx {
8 namespace vms_server_plugins {
9 namespace analytics {
10 namespace stub {
11 namespace settings {
12 
13 static const std::string kRegularSettingsModelOption = "regular";
14 static const std::string kAlternativeSettingsModelOption = "alternative";
15 
16 static const std::string kSettingsModelSettings = "settingsModelComboBox";
17 
18 static const std::string kCitySelector = "languageSelectorSettings";
19 static const std::string kEnglishOption = "English";
20 static const std::string kGermanOption = "German";
21 
22 // ------------------------------------------------------------------------------------------------
23 
24 static const std::string kCaption = "caption";
25 static const std::string kSections = "sections";
26 static const std::string kName = "name";
27 static const std::string kRange = "range";
28 static const std::string kItems = "items";
29 static const std::string kIsActive = "isActive";
30 static const std::string kActiveSettingsSectionCaption = "Active settings section";
31 static const std::string kActiveSettingsGroupBoxCaption = "Active settings";
32 
33 static const std::string kActiveComboBoxId = "activeComboBox";
34 static const std::string kAdditionalComboBoxId = "additionalComboBox";
35 static const std::string kShowAdditionalComboBoxValue = "Show additional ComboBox";
36 static const std::string kAdditionalComboBoxValue = "Value 1";
37 
38 static const std::string kActiveCheckBoxId = "activeCheckBox";
39 static const std::string kAdditionalCheckBoxId = "additionalCheckBox";
40 static const std::string kShowAdditionalCheckBoxValue = "true";
41 static const std::string kAdditionalCheckBoxValue = "false";
42 
43 static const std::string kActiveRadioButtonGroupId = "activeRadioButtonGroup";
44 static const std::string kShowAdditionalRadioButtonValue = "Show something";
45 static const std::string kHideAdditionalRadioButtonValue = "Hide me";
46 static const std::string kDefaultActiveRadioButtonGroupValue = "Some value";
47 
48 static const std::string kShowMessageButtonId = "showMessageButton";
49 static const std::string kShowUrlButtonId = "showUrlButton";
50 static const std::string kParametersModel = /*suppress newline*/ 1 + (const char*) R"json(
51 {
52  "type": "Settings",
53  "items":
54  [
55  {
56  "type": "TextField",
57  "name": "url",
58  "caption": "Url",
59  "defaultValue": "https://example.com/"
60  }
61  ]
62 }
63 )json";
64 
65 // ------------------------------------------------------------------------------------------------
66 
67 static const std::string kAlternativeSettingsModel =
68  /*suppress newline*/ 1 + (const char*) R"json("
69 {
70  "type": "Settings",
71  "items":
72  [
73  {
74  "type": "ComboBox",
75  "name": ")json" + kSettingsModelSettings + R"json(",
76  "caption": "Settings model",
77  "defaultValue": ")json" + kRegularSettingsModelOption + R"json(",
78  "range":
79  [
80  ")json" + kRegularSettingsModelOption + R"json(",
81  ")json" + kAlternativeSettingsModelOption + R"json("
82  ]
83  },
84  {
85  "type": "GroupBox",
86  "caption": "Alternative GroupBox",
87  "items":
88  [
89  {
90  "type": "CheckBox",
91  "name": "alternativeCheckBox",
92  "caption": "Alternative CheckBox",
93  "defaultValue": true
94  },
95  {
96  "type": "TextField",
97  "name": "alternativeTextField",
98  "caption": "Alternative TextField",
99  "defaultValue": "alternative text"
100  }
101  ]
102  }
103  ]
104 }
105 )json";
106 
107 static const std::string kRegularSettingsModelPart1 = /*suppress newline*/ 1 + R"json(
108 {
109  "type": "Settings",
110  "items":
111  [
112  {
113  "type": "ComboBox",
114  "name": ")json" + kSettingsModelSettings + R"json(",
115  "caption": "Settings model",
116  "defaultValue": ")json" + kRegularSettingsModelOption + R"json(",
117  "range":
118  [
119  ")json" + kRegularSettingsModelOption + R"json(",
120  ")json" + kAlternativeSettingsModelOption + R"json("
121  ]
122  },
123  {
124  "type": "GroupBox",
125  "caption": "Example Stub DeviceAgent settings",
126  "items":
127  [
128  {
129  "type": "TextField",
130  "name": "testTextField",
131  "caption": "Device Agent Text Field",
132  "description": "A text field",
133  "defaultValue": "a text"
134  },
135  {
136  "type": "ComboBox",
137  "name": ")json" + kCitySelector + R"json(",
138  "caption": "Cities",
139  "defaultValue": "English",
140  "range": [
141  ")json" + kEnglishOption + R"json(",
142  ")json" + kGermanOption + R"json("
143  ]
144  },
145 )json";
146 
147 static const std::string kEnglishCitiesSettingsModelPart = /*suppress newline*/ 1 + R"json(
148  {
149  "type": "RadioButtonGroup",
150  "name": "testEnglishRadioButtonGroup",
151  "caption": "Choose one",
152  "description": "Choose one option",
153  "defaultValue": "London",
154  "range":
155  [
156  "London",
157  "Liverpool"
158  ]
159  },
160 )json";
161 
162 static const std::string kGermanCitiesSettingsModelPart = /*suppress newline*/ 1 + R"json(
163  {
164  "type": "RadioButtonGroup",
165  "name": "testGermanRadioButtonGroup",
166  "caption": "Choose one",
167  "description": "Choose one option",
168  "defaultValue": "Berlin",
169  "range":
170  [
171  "Berlin",
172  "Nuremberg",
173  "Leipzig"
174  ]
175  },
176 )json";
177 
178 static const std::string kRegularSettingsModelPart2 = /*suppress newline*/ 1 + R"json("
179  {
180  "type": "RadioButtonGroup",
181  "name": "testRadioButtonGroup",
182  "caption": "RadioButton Group",
183  "description": "Choose one option",
184  "defaultValue": "Cs_enodatum",
185  "range":
186  [
187  "K_gowerianus",
188  "K_galilaeii",
189  "S_calloviense",
190  "S_micans",
191  "Cs_enodatum",
192  "K_medea",
193  "K_jason",
194  "K_obductum",
195  "K_posterior"
196  ],
197  "itemCaptions":
198  {
199  "K_gowerianus": "Kepplerites gowerianus",
200  "K_galilaeii": "Kepplerites galilaeii",
201  "S_calloviense": "Sigaloceras calloviense",
202  "S_micans": "Sigaloceras micans",
203  "Cs_enodatum": "Catasigaloceras enodatum",
204  "K_medea": "Kosmoceras medea",
205  "K_jason": "Kosmoceras jason",
206  "K_obductum": "Kosmoceras obductum",
207  "K_posterior": "Kosmoceras posterior"
208  }
209  },
210  {
211  "type": "CheckBoxGroup",
212  "name": "testCheckBoxGroup",
213  "caption": "CheckBox Group",
214  "description": "Choose one or several options",
215  "defaultValue": ["Coleoidea", "Nautiloidea"],
216  "range":
217  [
218  "Coleoidea",
219  "Ammonoidea",
220  "Nautiloidea",
221  "Orthoceratoidea"
222  ],
223  "itemCaptions":
224  {
225  "Coleoidea": "Coleoidea (Bather, 1888)",
226  "Ammonoidea": "Ammonoidea (Zittel, 1884)",
227  "Nautiloidea": "Nautiloidea (Agassiz, 1847)",
228  "Orthoceratoidea": "Orthoceratoidea (M'Coy 1844)"
229  }
230  },
231  {
232  "type": "SpinBox",
233  "caption": "Device Agent SpinBox (plugin side)",
234  "name": "pluginSideTestSpinBox",
235  "defaultValue": 42,
236  "minValue": 0,
237  "maxValue": 100
238  },
239  {
240  "type": "DoubleSpinBox",
241  "caption": "Device Agent DoubleSpinBox",
242  "name": "testDoubleSpinBox",
243  "defaultValue": 3.1415,
244  "minValue": 0.0,
245  "maxValue": 100.0
246  },
247  {
248  "type": "ComboBox",
249  "name": "testComboBox",
250  "caption": "Device Agent ComboBox",
251  "defaultValue": "value2",
252  "range": ["value1", "value2", "value3"],
253  "itemCaptions":
254  {
255  "value1": "Device Agent Value #1",
256  "value2": "Device Agent Value #2",
257  "value3": "Device Agent Value #3"
258  }
259  },
260  {
261  "type": "Separator"
262  },
263  {
264  "type": "CheckBox",
265  "caption": "Device Agent CheckBox",
266  "name": "testCheckBox",
267  "defaultValue": true
268  },
269  {
270  "type": "CheckBox",
271  "caption": "Disabled Device Agent CheckBox",
272  "name": "disabledTestCheckBox",
273  "defaultValue": false,
274  "enabled": false
275  },
276  {
277  "type": "CheckBox",
278  "caption": "Hidden Device Agent CheckBox",
279  "name": "hiddenTestCheckBox",
280  "defaultValue": false,
281  "visible": false
282  },
283  {
284  "type": "Link",
285  "caption": "Customer Support",
286  "url": "https://example.com/"
287  },
288  {
289  "type": "Banner",
290  "icon": "info",
291  "text": "Some text"
292  },
293  {
294  "type": "Placeholder",
295  "header": "Header",
296  "description": "Description",
297  "icon": "default"
298  }
299  ]
300  }
301  ],
302  "sections":
303  [
304  {
305  "type": "Section",
306  "caption": "Example section",
307  "items":
308  [
309  {
310  "type": "GroupBox",
311  "caption": "Example Stub DeviceAgent settings section",
312  "items":
313  [
314  {
315  "type": "TextField",
316  "name": "testTextFieldWithValidation",
317  "caption": "Hexadecimal number text field",
318  "defaultValue": "12ab34cd",
319  "validationRegex": "^[a-f0-9]+$",
320  "validationRegexFlags": "i",
321  "validationErrorMessage":
322  "Text must contain only digits and characters a-f, e.g. 12ab34cd."
323  },
324  {
325  "type": "PasswordField",
326  "name": "passwordField1",
327  "caption": "Password Field",
328  "description": "A password field",
329  "defaultValue": "1234",
330  "validationErrorMessage": "Password must contain only digits",
331  "validationRegex": "^[0-9]+$",
332  "validationRegexFlags": "i"
333  },
334  {
335  "type": "SpinBox",
336  "caption": "Device Agent SpinBox (plugin side)",
337  "name": "pluginSideTestSpinBox2",
338  "defaultValue": 42,
339  "minValue": 0,
340  "maxValue": 100
341  },
342  {
343  "type": "DoubleSpinBox",
344  "caption": "Device Agent DoubleSpinBox",
345  "name": "testDoubleSpinBox2",
346  "defaultValue": 3.1415,
347  "minValue": 0.0,
348  "maxValue": 100.0
349  },
350  {
351  "type": "ComboBox",
352  "name": "testComboBox2",
353  "caption": "Device Agent ComboBox",
354  "defaultValue": "value2",
355  "range": ["value1", "value2", "value3"]
356  },
357  {
358  "type": "CheckBox",
359  "caption": "Device Agent CheckBox",
360  "name": "testCheckBox2",
361  "defaultValue": true
362  }
363  ]
364  }
365  ],
366  "sections":
367  [
368  {
369  "type": "Section",
370  "caption": "Nested section",
371  "items":
372  [
373  {
374  "type": "GroupBox",
375  "caption": "Example Stub DeviceAgent settings nested section",
376  "items":
377  [
378  {
379  "type": "SwitchButton",
380  "caption": "Switch Button",
381  "name": "testSwitch",
382  "description": "Tooltip for the switch button",
383  "defaultValue": false
384  },
385  {
386  "type": "SpinBox",
387  "caption": "SpinBox Parameter",
388  "name": "testSpinBox3",
389  "defaultValue": 42,
390  "minValue": 0,
391  "maxValue": 100
392  },
393  {
394  "type": "DoubleSpinBox",
395  "caption": "DoubleSpinBox Parameter",
396  "name": "testDoubleSpinBox3",
397  "defaultValue": 3.1415,
398  "minValue": 0.0,
399  "maxValue": 100.0
400  },
401  {
402  "type": "ComboBox",
403  "name": "testComboBox3",
404  "caption": "ComboBox Parameter",
405  "defaultValue": "value2",
406  "range": ["value1", "value2", "value3"]
407  },
408  {
409  "type": "CheckBox",
410  "caption": "CheckBox Parameter",
411  "name": "testCheckBox3",
412  "defaultValue": true
413  }
414  ]
415  }
416  ]
417  }
418  ]
419  },
420  {
421  "type": "Section",
422  "caption": ")json" + kActiveSettingsSectionCaption + R"json(",
423  "items":
424  [
425  {
426  "type": "ComboBox",
427  "name": ")json" + kActiveComboBoxId + R"json(",
428  "caption": "Active ComboBox",
429  "defaultValue": "Some value",
430  "isActive": true,
431  "range":
432  [
433  "Some value",
434  ")json" + kShowAdditionalComboBoxValue + R"json("
435  ]
436  },
437  {
438  "type": "CheckBox",
439  "name": ")json" + kActiveCheckBoxId + R"json(",
440  "caption": "Active CheckBox",
441  "defaultValue": false,
442  "isActive": true,
443  "parametersModel":
444  {
445  "type": "Settings",
446  "items":
447  [
448  {
449  "type": "TextField",
450  "name": "testTextField",
451  "caption": "Text Field Parameter",
452  "description": "A text field",
453  "defaultValue": "a text"
454  },
455  {
456  "type": "GroupBox",
457  "caption": "Parameter Group",
458  "items":
459  [
460  {
461  "type": "SpinBox",
462  "caption": "SpinBox Parameter",
463  "name": "testSpinBox",
464  "defaultValue": 42,
465  "minValue": 0,
466  "maxValue": 100
467  },
468  {
469  "type": "DoubleSpinBox",
470  "caption": "DoubleSpinBox Parameter",
471  "name": "testDoubleSpinBox",
472  "defaultValue": 3.1415,
473  "minValue": 0.0,
474  "maxValue": 100.0
475  },
476  {
477  "type": "ComboBox",
478  "caption": "ComboBox Parameter",
479  "name": "testComboBox",
480  "defaultValue": "value2",
481  "range": ["value1", "value2", "value3"]
482  },
483  {
484  "type": "CheckBox",
485  "caption": "CheckBox Parameter",
486  "name": "testCheckBox",
487  "defaultValue": true
488  },
489  {
490  "type": "TextArea",
491  "caption": "TextArea Parameter",
492  "name": "testTextArea"
493  }
494  ]
495  }
496  ]
497  }
498  },
499  {
500  "type": "RadioButtonGroup",
501  "name": ")json" + kActiveRadioButtonGroupId + R"json(",
502  "caption": "Active RadioButton Group",
503  "defaultValue": "Some value",
504  "isActive": true,
505  "range":
506  [
507  "Some value",
508  ")json" + kShowAdditionalRadioButtonValue + R"json("
509  ]
510  },
511  {
512  "type": "Button",
513  "name": ")json" + kShowMessageButtonId + R"json(",
514  "caption": "Show a message",
515  "isActive": true
516  },
517  {
518  "type": "Button",
519  "name": ")json" + kShowUrlButtonId + R"json(",
520  "caption": "Show a web-page",
521  "isActive": true,
522  "parametersModel": )json" + kParametersModel + R"json(
523  }
524  ]
525  }
526  ]
527 }
528 )json";
529 
530 } // namespace settings
531 } // namespace stub
532 } // namespace analytics
533 } // namespace vms_server_plugins
534 } // namespace nx
Definition: apple_utils.h:6