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 kMinValue = "minValue";
31 static const std::string kMaxValue = "maxValue";
32 static const std::string kActiveSettingsSectionCaption = "Active settings section";
33 static const std::string kActiveSettingsGroupBoxCaption = "Active settings";
34 
35 static const std::string kActiveComboBoxId = "activeComboBox";
36 static const std::string kAdditionalComboBoxId = "additionalComboBox";
37 static const std::string kShowAdditionalComboBoxValue = "Show additional ComboBox";
38 static const std::string kAdditionalComboBoxValue = "Value 1";
39 
40 static const std::string kActiveCheckBoxId = "activeCheckBox";
41 static const std::string kAdditionalCheckBoxId = "additionalCheckBox";
42 static const std::string kShowAdditionalCheckBoxValue = "true";
43 static const std::string kAdditionalCheckBoxValue = "false";
44 
45 static const std::string kActiveRadioButtonGroupId = "activeRadioButtonGroup";
46 static const std::string kShowAdditionalRadioButtonValue = "Show something";
47 static const std::string kHideAdditionalRadioButtonValue = "Hide me";
48 static const std::string kDefaultActiveRadioButtonGroupValue = "Some value";
49 
50 static const std::string kActiveMinValueId = "activeMinValue";
51 static const std::string kActiveMaxValueId = "activeMaxValue";
52 
53 static const std::string kShowMessageButtonId = "showMessageButton";
54 static const std::string kShowUrlButtonId = "showUrlButton";
55 static const std::string kParametersModel = /*suppress newline*/ 1 + R"json(
56 {
57  "type": "Settings",
58  "items":
59  [
60  {
61  "type": "TextField",
62  "name": "parameter",
63  "caption": "Parameter"
64  }
65  ]
66 }
67 )json";
68 
69 // ------------------------------------------------------------------------------------------------
70 static const std::string kEnginePluginSideSetting = "testPluginSideSpinBox";
71 static const std::string kEnginePluginSideSettingValue = "42";
72 static const std::string kEngineSettingsModel = /*suppress newline*/ 1 + R"json("
73 {
74  "type": "Settings",
75  "items":
76  [
77  {
78  "type": "GroupBox",
79  "caption": "Example Stub Engine settings",
80  "items":
81  [
82  {
83  "type": "TextField",
84  "name": "text",
85  "caption": "Text Field",
86  "description": "A text field",
87  "defaultValue": "a text"
88  },
89  {
90  "type": "PasswordField",
91  "name": "passwordField1",
92  "caption": "Password Field",
93  "description": "A password field",
94  "defaultValue": "1234",
95  "validationErrorMessage": "Password must contain only digits",
96  "validationRegex": "^[0-9]+$",
97  "validationRegexFlags": "i"
98  },
99  {
100  "type": "SpinBox",
101  "name": "testSpinBox",
102  "caption": "Spin Box",
103  "defaultValue": 42,
104  "minValue": 0,
105  "maxValue": 100
106  },
107  {
108  "type": "SpinBox",
109  "name": ")json" + kEnginePluginSideSetting + R"json(",
110  "caption": "Spin Box (plugin side)",
111  "defaultValue": 42,
112  "minValue": 0,
113  "maxValue": 100
114  },
115  {
116  "type": "DoubleSpinBox",
117  "name": "testDoubleSpinBox",
118  "caption": "Double Spin Box",
119  "defaultValue": 3.1415,
120  "minValue": 0.0,
121  "maxValue": 100.0
122  },
123  {
124  "type": "ComboBox",
125  "name": "testComboBox",
126  "caption": "Combo Box",
127  "defaultValue": "value2",
128  "range": ["value1", "value2", "value3"]
129  },
130  {
131  "type": "CheckBox",
132  "name": "testCheckBox",
133  "caption": "Check Box",
134  "defaultValue": true
135  },
136  {
137  "type": "Link",
138  "caption": "Customer Support",
139  "url": "https://example.com/"
140  },
141  {
142  "type": "Banner",
143  "icon": "info",
144  "text": "Some text"
145  },
146  {
147  "type": "Placeholder",
148  "header": "Header",
149  "description": "Description",
150  "icon": "default"
151  }
152  ]
153  },
154  {
155  "type": "GroupBox",
156  "caption": ")json" + kActiveSettingsGroupBoxCaption + R"json(",
157  "items":
158  [
159  {
160  "type": "ComboBox",
161  "name": ")json" + kActiveComboBoxId + R"json(",
162  "caption": "Active ComboBox",
163  "defaultValue": "Some value",
164  "isActive": true,
165  "range":
166  [
167  "Some value",
168  ")json" + kShowAdditionalComboBoxValue + R"json("
169  ]
170  },
171  {
172  "type": "CheckBox",
173  "name": ")json" + kActiveCheckBoxId + R"json(",
174  "caption": "Active CheckBox",
175  "defaultValue": false,
176  "isActive": true
177  },
178  {
179  "type": "RadioButtonGroup",
180  "name": ")json" + kActiveRadioButtonGroupId + R"json(",
181  "caption": "Active RadioButton Group",
182  "defaultValue": "Some value",
183  "isActive": true,
184  "range":
185  [
186  "Some value",
187  ")json" + kShowAdditionalRadioButtonValue + R"json("
188  ]
189  },
190  {
191  "type": "SpinBox",
192  "name": ")json" + kActiveMinValueId + R"json(",
193  "caption": "Active Minimum",
194  "defaultValue": 42,
195  "minValue": 0,
196  "maxValue": 42,
197  "isActive": true
198  },
199  {
200  "type": "SpinBox",
201  "name": ")json" + kActiveMaxValueId + R"json(",
202  "caption": "Active Maximum",
203  "defaultValue": 42,
204  "minValue": 42,
205  "maxValue": 100,
206  "isActive": true
207  },
208  {
209  "type": "Button",
210  "name": ")json" + kShowMessageButtonId + R"json(",
211  "caption": "Show Message...",
212  "isActive": true,
213  "parametersModel": )json" + kParametersModel + R"json(
214  },
215  {
216  "type": "Button",
217  "name": ")json" + kShowUrlButtonId + R"json(",
218  "caption": "Show Webpage...",
219  "isActive": true
220  }
221  ]
222  }
223  ]
224 }
225 )json";
226 
227 static const std::string kAlternativeSettingsModel =
228  /*suppress newline*/ 1 + (const char*) R"json("
229 {
230  "type": "Settings",
231  "items":
232  [
233  {
234  "type": "ComboBox",
235  "name": ")json" + kSettingsModelSettings + R"json(",
236  "caption": "Settings model",
237  "defaultValue": ")json" + kRegularSettingsModelOption + R"json(",
238  "range":
239  [
240  ")json" + kRegularSettingsModelOption + R"json(",
241  ")json" + kAlternativeSettingsModelOption + R"json("
242  ]
243  },
244  {
245  "type": "GroupBox",
246  "caption": "Alternative GroupBox",
247  "items":
248  [
249  {
250  "type": "CheckBox",
251  "name": "alternativeCheckBox",
252  "caption": "Alternative CheckBox",
253  "defaultValue": true
254  },
255  {
256  "type": "TextField",
257  "name": "alternativeTextField",
258  "caption": "Alternative TextField",
259  "defaultValue": "alternative text"
260  }
261  ]
262  }
263  ]
264 }
265 )json";
266 
267 static const std::string kRegularSettingsModelPart1 = /*suppress newline*/ 1 + R"json(
268 {
269  "type": "Settings",
270  "items":
271  [
272  {
273  "type": "ComboBox",
274  "name": ")json" + kSettingsModelSettings + R"json(",
275  "caption": "Settings model",
276  "defaultValue": ")json" + kRegularSettingsModelOption + R"json(",
277  "range":
278  [
279  ")json" + kRegularSettingsModelOption + R"json(",
280  ")json" + kAlternativeSettingsModelOption + R"json("
281  ]
282  },
283  {
284  "type": "GroupBox",
285  "caption": "Example Stub DeviceAgent settings",
286  "items":
287  [
288  {
289  "type": "TextField",
290  "name": "testTextField",
291  "caption": "Device Agent Text Field",
292  "description": "A text field",
293  "defaultValue": "a text"
294  },
295  {
296  "type": "ComboBox",
297  "name": ")json" + kCitySelector + R"json(",
298  "caption": "Cities",
299  "defaultValue": "English",
300  "range": [
301  ")json" + kEnglishOption + R"json(",
302  ")json" + kGermanOption + R"json("
303  ]
304  },
305 )json";
306 
307 static const std::string kEnglishCitiesSettingsModelPart = /*suppress newline*/ 1 + R"json(
308  {
309  "type": "RadioButtonGroup",
310  "name": "testEnglishRadioButtonGroup",
311  "caption": "Choose one",
312  "description": "Choose one option",
313  "defaultValue": "London",
314  "range":
315  [
316  "London",
317  "Liverpool"
318  ]
319  },
320 )json";
321 
322 static const std::string kGermanCitiesSettingsModelPart = /*suppress newline*/ 1 + R"json(
323  {
324  "type": "RadioButtonGroup",
325  "name": "testGermanRadioButtonGroup",
326  "caption": "Choose one",
327  "description": "Choose one option",
328  "defaultValue": "Berlin",
329  "range":
330  [
331  "Berlin",
332  "Nuremberg",
333  "Leipzig"
334  ]
335  },
336 )json";
337 
338 static const std::string kRegularSettingsModelPart2 = /*suppress newline*/ 1 + R"json("
339  {
340  "type": "RadioButtonGroup",
341  "name": "testRadioButtonGroup",
342  "caption": "RadioButton Group",
343  "description": "Choose one option",
344  "defaultValue": "Cs_enodatum",
345  "range":
346  [
347  "K_gowerianus",
348  "K_galilaeii",
349  "S_calloviense",
350  "S_micans",
351  "Cs_enodatum",
352  "K_medea",
353  "K_jason",
354  "K_obductum",
355  "K_posterior"
356  ],
357  "itemCaptions":
358  {
359  "K_gowerianus": "Kepplerites gowerianus",
360  "K_galilaeii": "Kepplerites galilaeii",
361  "S_calloviense": "Sigaloceras calloviense",
362  "S_micans": "Sigaloceras micans",
363  "Cs_enodatum": "Catasigaloceras enodatum",
364  "K_medea": "Kosmoceras medea",
365  "K_jason": "Kosmoceras jason",
366  "K_obductum": "Kosmoceras obductum",
367  "K_posterior": "Kosmoceras posterior"
368  }
369  },
370  {
371  "type": "CheckBoxGroup",
372  "name": "testCheckBoxGroup",
373  "caption": "CheckBox Group",
374  "description": "Choose one or several options",
375  "defaultValue": ["Coleoidea", "Nautiloidea"],
376  "range":
377  [
378  "Coleoidea",
379  "Ammonoidea",
380  "Nautiloidea",
381  "Orthoceratoidea"
382  ],
383  "itemCaptions":
384  {
385  "Coleoidea": "Coleoidea (Bather, 1888)",
386  "Ammonoidea": "Ammonoidea (Zittel, 1884)",
387  "Nautiloidea": "Nautiloidea (Agassiz, 1847)",
388  "Orthoceratoidea": "Orthoceratoidea (M'Coy 1844)"
389  }
390  },
391  {
392  "type": "SpinBox",
393  "caption": "Device Agent SpinBox (plugin side)",
394  "name": "pluginSideTestSpinBox",
395  "defaultValue": 42,
396  "minValue": 0,
397  "maxValue": 100
398  },
399  {
400  "type": "DoubleSpinBox",
401  "caption": "Device Agent DoubleSpinBox",
402  "name": "testDoubleSpinBox",
403  "defaultValue": 3.1415,
404  "minValue": 0.0,
405  "maxValue": 100.0
406  },
407  {
408  "type": "ComboBox",
409  "name": "testComboBox",
410  "caption": "Device Agent ComboBox",
411  "defaultValue": "value2",
412  "range": ["value1", "value2", "value3"],
413  "itemCaptions":
414  {
415  "value1": "Device Agent Value #1",
416  "value2": "Device Agent Value #2",
417  "value3": "Device Agent Value #3"
418  }
419  },
420  {
421  "type": "Separator"
422  },
423  {
424  "type": "CheckBox",
425  "caption": "Device Agent CheckBox",
426  "name": "testCheckBox",
427  "defaultValue": true
428  },
429  {
430  "type": "CheckBox",
431  "caption": "Disabled Device Agent CheckBox",
432  "name": "disabledTestCheckBox",
433  "defaultValue": false,
434  "enabled": false
435  },
436  {
437  "type": "CheckBox",
438  "caption": "Hidden Device Agent CheckBox",
439  "name": "hiddenTestCheckBox",
440  "defaultValue": false,
441  "visible": false
442  },
443  {
444  "type": "Link",
445  "caption": "Customer Support",
446  "url": "https://example.com/"
447  },
448  {
449  "type": "Banner",
450  "icon": "info",
451  "text": "Some text"
452  },
453  {
454  "type": "Placeholder",
455  "header": "Header",
456  "description": "Description",
457  "icon": "default"
458  }
459  ]
460  }
461  ],
462  "sections":
463  [
464  {
465  "type": "Section",
466  "caption": "Example section",
467  "items":
468  [
469  {
470  "type": "GroupBox",
471  "caption": "Example Stub DeviceAgent settings section",
472  "items":
473  [
474  {
475  "type": "TextField",
476  "name": "testTextFieldWithValidation",
477  "caption": "Hexadecimal number text field",
478  "defaultValue": "12ab34cd",
479  "validationRegex": "^[a-f0-9]+$",
480  "validationRegexFlags": "i",
481  "validationErrorMessage":
482  "Text must contain only digits and characters a-f, e.g. 12ab34cd."
483  },
484  {
485  "type": "PasswordField",
486  "name": "passwordField1",
487  "caption": "Password Field",
488  "description": "A password field",
489  "defaultValue": "1234",
490  "validationErrorMessage": "Password must contain only digits",
491  "validationRegex": "^[0-9]+$",
492  "validationRegexFlags": "i"
493  },
494  {
495  "type": "SpinBox",
496  "caption": "Device Agent SpinBox (plugin side)",
497  "name": "pluginSideTestSpinBox2",
498  "defaultValue": 42,
499  "minValue": 0,
500  "maxValue": 100
501  },
502  {
503  "type": "DoubleSpinBox",
504  "caption": "Device Agent DoubleSpinBox",
505  "name": "testDoubleSpinBox2",
506  "defaultValue": 3.1415,
507  "minValue": 0.0,
508  "maxValue": 100.0
509  },
510  {
511  "type": "ComboBox",
512  "name": "testComboBox2",
513  "caption": "Device Agent ComboBox",
514  "defaultValue": "value2",
515  "range": ["value1", "value2", "value3"]
516  },
517  {
518  "type": "CheckBox",
519  "caption": "Device Agent CheckBox",
520  "name": "testCheckBox2",
521  "defaultValue": true
522  }
523  ]
524  }
525  ],
526  "sections":
527  [
528  {
529  "type": "Section",
530  "caption": "Nested section",
531  "items":
532  [
533  {
534  "type": "GroupBox",
535  "caption": "Example Stub DeviceAgent settings nested section",
536  "items":
537  [
538  {
539  "type": "SwitchButton",
540  "caption": "Switch Button",
541  "name": "testSwitch",
542  "description": "Tooltip for the switch button",
543  "defaultValue": false
544  },
545  {
546  "type": "SpinBox",
547  "caption": "SpinBox Parameter",
548  "name": "testSpinBox3",
549  "defaultValue": 42,
550  "minValue": 0,
551  "maxValue": 100
552  },
553  {
554  "type": "DoubleSpinBox",
555  "caption": "DoubleSpinBox Parameter",
556  "name": "testDoubleSpinBox3",
557  "defaultValue": 3.1415,
558  "minValue": 0.0,
559  "maxValue": 100.0
560  },
561  {
562  "type": "ComboBox",
563  "name": "testComboBox3",
564  "caption": "ComboBox Parameter",
565  "defaultValue": "value2",
566  "range": ["value1", "value2", "value3"]
567  },
568  {
569  "type": "CheckBox",
570  "caption": "CheckBox Parameter",
571  "name": "testCheckBox3",
572  "defaultValue": true
573  }
574  ]
575  }
576  ]
577  }
578  ]
579  },
580  {
581  "type": "Section",
582  "caption": ")json" + kActiveSettingsSectionCaption + R"json(",
583  "items":
584  [
585  {
586  "type": "ComboBox",
587  "name": ")json" + kActiveComboBoxId + R"json(",
588  "caption": "Active ComboBox",
589  "defaultValue": "Some value",
590  "isActive": true,
591  "range":
592  [
593  "Some value",
594  ")json" + kShowAdditionalComboBoxValue + R"json("
595  ]
596  },
597  {
598  "type": "CheckBox",
599  "name": ")json" + kActiveCheckBoxId + R"json(",
600  "caption": "Active CheckBox",
601  "defaultValue": false,
602  "isActive": true,
603  "parametersModel":
604  {
605  "type": "Settings",
606  "items":
607  [
608  {
609  "type": "TextField",
610  "name": "testTextField",
611  "caption": "Text Field Parameter",
612  "description": "A text field",
613  "defaultValue": "a text"
614  },
615  {
616  "type": "GroupBox",
617  "caption": "Parameter Group",
618  "items":
619  [
620  {
621  "type": "SpinBox",
622  "caption": "SpinBox Parameter",
623  "name": "testSpinBox",
624  "defaultValue": 42,
625  "minValue": 0,
626  "maxValue": 100
627  },
628  {
629  "type": "DoubleSpinBox",
630  "caption": "DoubleSpinBox Parameter",
631  "name": "testDoubleSpinBox",
632  "defaultValue": 3.1415,
633  "minValue": 0.0,
634  "maxValue": 100.0
635  },
636  {
637  "type": "ComboBox",
638  "caption": "ComboBox Parameter",
639  "name": "testComboBox",
640  "defaultValue": "value2",
641  "range": ["value1", "value2", "value3"]
642  },
643  {
644  "type": "CheckBox",
645  "caption": "CheckBox Parameter",
646  "name": "testCheckBox",
647  "defaultValue": true
648  },
649  {
650  "type": "TextArea",
651  "caption": "TextArea Parameter",
652  "name": "testTextArea"
653  }
654  ]
655  }
656  ]
657  }
658  },
659  {
660  "type": "RadioButtonGroup",
661  "name": ")json" + kActiveRadioButtonGroupId + R"json(",
662  "caption": "Active RadioButton Group",
663  "defaultValue": "Some value",
664  "isActive": true,
665  "range":
666  [
667  "Some value",
668  ")json" + kShowAdditionalRadioButtonValue + R"json("
669  ]
670  },
671  {
672  "type": "SpinBox",
673  "name": ")json" + kActiveMinValueId + R"json(",
674  "caption": "Active Minimum",
675  "defaultValue": 42,
676  "minValue": 0,
677  "maxValue": 42,
678  "isActive": true
679  },
680  {
681  "type": "SpinBox",
682  "name": ")json" + kActiveMaxValueId + R"json(",
683  "caption": "Active Maximum",
684  "defaultValue": 42,
685  "minValue": 42,
686  "maxValue": 100,
687  "isActive": true
688  },
689  {
690  "type": "Button",
691  "name": ")json" + kShowMessageButtonId + R"json(",
692  "caption": "Show Message...",
693  "isActive": true,
694  "parametersModel": )json" + kParametersModel + R"json(
695  },
696  {
697  "type": "Button",
698  "name": ")json" + kShowUrlButtonId + R"json(",
699  "caption": "Show Webpage...",
700  "isActive": true
701  }
702  ]
703  }
704  ]
705 }
706 )json";
707 
708 } // namespace settings
709 } // namespace stub
710 } // namespace analytics
711 } // namespace vms_server_plugins
712 } // namespace nx
Definition: apple_utils.h:6