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