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