@cloud-ru/uikit-product-calculator 0.33.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1508 -0
- package/LICENSE +201 -0
- package/README.md +85 -0
- package/package.json +75 -0
- package/src/components/Calculator/Calculator.tsx +79 -0
- package/src/components/Calculator/index.ts +1 -0
- package/src/components/CalculatorContent/CalculatorContent.tsx +38 -0
- package/src/components/CalculatorContent/index.ts +1 -0
- package/src/components/CalculatorContent/styles.module.scss +79 -0
- package/src/components/Catalog/Catalog.tsx +225 -0
- package/src/components/Catalog/components/PrivateCardHeader.tsx +63 -0
- package/src/components/Catalog/components/index.ts +1 -0
- package/src/components/Catalog/components/styles.module.scss +35 -0
- package/src/components/Catalog/index.ts +1 -0
- package/src/components/Catalog/styles.module.scss +104 -0
- package/src/components/Controls/AlertControl/AlertControl.tsx +44 -0
- package/src/components/Controls/AlertControl/index.ts +1 -0
- package/src/components/Controls/ArrayControl/ArrayControl.tsx +105 -0
- package/src/components/Controls/ArrayControl/index.ts +1 -0
- package/src/components/Controls/ArrayControl/styles.module.scss +33 -0
- package/src/components/Controls/CarouselControl/CarouselControl.tsx +173 -0
- package/src/components/Controls/CarouselControl/index.ts +1 -0
- package/src/components/Controls/CarouselControl/styles.module.scss +32 -0
- package/src/components/Controls/Control/Control.tsx +205 -0
- package/src/components/Controls/Control/index.ts +1 -0
- package/src/components/Controls/ObjectControl/ObjectControl.tsx +150 -0
- package/src/components/Controls/ObjectControl/index.ts +1 -0
- package/src/components/Controls/ObjectControl/styles.module.scss +18 -0
- package/src/components/Controls/ObjectDecorator/ObjectDecorator.tsx +23 -0
- package/src/components/Controls/ObjectDecorator/index.ts +1 -0
- package/src/components/Controls/ObjectDecorator/styles.module.scss +15 -0
- package/src/components/Controls/SegmentedControl/SegmentedControl.tsx +79 -0
- package/src/components/Controls/SegmentedControl/SegmentedControlCard.tsx +38 -0
- package/src/components/Controls/SegmentedControl/index.ts +1 -0
- package/src/components/Controls/SegmentedControl/styles.module.scss +8 -0
- package/src/components/Controls/SelectControl/SelectControl.tsx +172 -0
- package/src/components/Controls/SelectControl/index.ts +1 -0
- package/src/components/Controls/SelectControl/styles.module.scss +5 -0
- package/src/components/Controls/SliderControl/SliderControl.tsx +92 -0
- package/src/components/Controls/SliderControl/index.ts +1 -0
- package/src/components/Controls/StepperControl/StepperControl.tsx +160 -0
- package/src/components/Controls/StepperControl/index.ts +1 -0
- package/src/components/Controls/StepperControl/styles.module.scss +16 -0
- package/src/components/Controls/TableControl/TableControl.tsx +162 -0
- package/src/components/Controls/TableControl/helperComponents/StepperWithAllowedValues.tsx +50 -0
- package/src/components/Controls/TableControl/helperComponents/index.ts +1 -0
- package/src/components/Controls/TableControl/helperComponents/styles.module.scss +53 -0
- package/src/components/Controls/TableControl/index.ts +1 -0
- package/src/components/Controls/TableControl/styles.module.scss +104 -0
- package/src/components/Controls/ToggleCard/ToggleCard.tsx +46 -0
- package/src/components/Controls/ToggleCard/index.ts +1 -0
- package/src/components/Controls/ToggleCard/styles.module.scss +11 -0
- package/src/components/Controls/ToggleCardsControl/ToggleCardsControl.tsx +93 -0
- package/src/components/Controls/ToggleCardsControl/index.ts +1 -0
- package/src/components/Controls/ToggleCardsControl/styles.module.scss +40 -0
- package/src/components/Controls/ToggleControl/ToggleControl.tsx +59 -0
- package/src/components/Controls/ToggleControl/components/SwitchRow.tsx +98 -0
- package/src/components/Controls/ToggleControl/components/index.ts +1 -0
- package/src/components/Controls/ToggleControl/components/styles.module.scss +110 -0
- package/src/components/Controls/ToggleControl/index.ts +1 -0
- package/src/components/Controls/ToggleObjectControl/ToggleObjectControl.tsx +111 -0
- package/src/components/Controls/ToggleObjectControl/index.ts +1 -0
- package/src/components/Controls/ToggleObjectControl/styles.module.scss +13 -0
- package/src/components/Controls/constants.ts +16 -0
- package/src/components/Controls/index.tsx +26 -0
- package/src/components/Controls/types.ts +181 -0
- package/src/components/Controls/utils.ts +49 -0
- package/src/components/Disclaimer/Disclaimer.tsx +33 -0
- package/src/components/Disclaimer/index.ts +1 -0
- package/src/components/Disclaimer/styles.module.scss +14 -0
- package/src/components/HeaderContainer/index.tsx +32 -0
- package/src/components/HeaderContainer/styles.module.scss +24 -0
- package/src/components/PriceSummary/PriceSummary.tsx +158 -0
- package/src/components/PriceSummary/components/PricePeriodSelect/PricePeriodSelect.tsx +81 -0
- package/src/components/PriceSummary/components/PricePeriodSelect/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductCard/ProductCard.tsx +85 -0
- package/src/components/PriceSummary/components/ProductCard/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductCard/styles.module.scss +7 -0
- package/src/components/PriceSummary/components/ProductListActions/ProductListActions.tsx +118 -0
- package/src/components/PriceSummary/components/ProductListActions/index.ts +1 -0
- package/src/components/PriceSummary/components/ProductListActions/styles.module.scss +38 -0
- package/src/components/PriceSummary/components/index.ts +3 -0
- package/src/components/PriceSummary/hooks.ts +36 -0
- package/src/components/PriceSummary/index.ts +1 -0
- package/src/components/PriceSummary/styles.module.scss +110 -0
- package/src/components/PriceSummary/utils/getTotalPrice.ts +19 -0
- package/src/components/PriceSummary/utils/index.ts +2 -0
- package/src/components/PriceSummary/utils/transformToProductCardData.ts +36 -0
- package/src/components/ProductHeadline/ProductPageHeadline.tsx +134 -0
- package/src/components/ProductHeadline/components/PriceCount.tsx +93 -0
- package/src/components/ProductHeadline/components/index.ts +1 -0
- package/src/components/ProductHeadline/components/styles.module.scss +52 -0
- package/src/components/ProductHeadline/index.ts +1 -0
- package/src/components/ProductHeadline/styles.module.scss +32 -0
- package/src/components/ProductPage/ProductPage.tsx +105 -0
- package/src/components/ProductPage/index.ts +1 -0
- package/src/components/ProductPage/styles.module.scss +13 -0
- package/src/components/Welcome/Welcome.tsx +138 -0
- package/src/components/Welcome/index.ts +1 -0
- package/src/components/Welcome/styles.module.scss +155 -0
- package/src/components/index.ts +3 -0
- package/src/config/config.tsx +27 -0
- package/src/config/index.ts +2 -0
- package/src/config/platforms/advanced/catalog.ts +82 -0
- package/src/config/platforms/advanced/constants.ts +23 -0
- package/src/config/platforms/advanced/index.ts +5 -0
- package/src/config/platforms/advanced/platform.tsx +13 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudBackup.ts +76 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudContainerEngine.tsx +260 -0
- package/src/config/platforms/advanced/product-config/AdvancedCloudServer.tsx +526 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataAsYouUse.ts +159 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataLakeInsight.ts +134 -0
- package/src/config/platforms/advanced/product-config/AdvancedDataWarehouseService.ts +94 -0
- package/src/config/platforms/advanced/product-config/AdvancedDcsMemcached.ts +69 -0
- package/src/config/platforms/advanced/product-config/AdvancedDcsRedis.ts +220 -0
- package/src/config/platforms/advanced/product-config/AdvancedDmsKafka.tsx +186 -0
- package/src/config/platforms/advanced/product-config/AdvancedDmsRabbitMq.ts +202 -0
- package/src/config/platforms/advanced/product-config/AdvancedDocumentDatabase.tsx +323 -0
- package/src/config/platforms/advanced/product-config/AdvancedElasticLoadBalance.tsx +252 -0
- package/src/config/platforms/advanced/product-config/AdvancedElasticSearch.ts +365 -0
- package/src/config/platforms/advanced/product-config/AdvancedFunctionGraph.tsx +65 -0
- package/src/config/platforms/advanced/product-config/AdvancedMapReduce.tsx +394 -0
- package/src/config/platforms/advanced/product-config/AdvancedMySqlDataBase.ts +417 -0
- package/src/config/platforms/advanced/product-config/AdvancedNetwork.ts +146 -0
- package/src/config/platforms/advanced/product-config/AdvancedObjectStorage.ts +232 -0
- package/src/config/platforms/advanced/product-config/AdvancedPostgreSqlDatabase.ts +402 -0
- package/src/config/platforms/advanced/product-config/AdvancedScalableFile.tsx +161 -0
- package/src/config/platforms/advanced/product-config/AdvancedSqlDatabase.ts +380 -0
- package/src/config/platforms/advanced/product-config/index.ts +21 -0
- package/src/config/platforms/advanced/products.ts +267 -0
- package/src/config/platforms/evolution/catalog.tsx +107 -0
- package/src/config/platforms/evolution/constants.ts +80 -0
- package/src/config/platforms/evolution/index.ts +5 -0
- package/src/config/platforms/evolution/platform.tsx +13 -0
- package/src/config/platforms/evolution/product-config/EvolutionArenadataDb.ts +151 -0
- package/src/config/platforms/evolution/product-config/EvolutionArtifactRegistry.ts +57 -0
- package/src/config/platforms/evolution/product-config/EvolutionBareMetal.tsx +172 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServer.tsx +407 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServerFreeTier.tsx +185 -0
- package/src/config/platforms/evolution/product-config/EvolutionCloudServerGpu.tsx +301 -0
- package/src/config/platforms/evolution/product-config/EvolutionContainerApps.ts +84 -0
- package/src/config/platforms/evolution/product-config/EvolutionContainerAppsFreeTier.ts +29 -0
- package/src/config/platforms/evolution/product-config/EvolutionKubernetes.ts +388 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedMetastore.ts +38 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedRedis.ts +161 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedSpark.ts +360 -0
- package/src/config/platforms/evolution/product-config/EvolutionManagedTrino.ts +53 -0
- package/src/config/platforms/evolution/product-config/EvolutionMlInference.tsx +703 -0
- package/src/config/platforms/evolution/product-config/EvolutionPostgreSql.ts +217 -0
- package/src/config/platforms/evolution/product-config/EvolutionPublicIp.ts +39 -0
- package/src/config/platforms/evolution/product-config/EvolutionSnatGateway.ts +22 -0
- package/src/config/platforms/evolution/product-config/EvolutionStorageS3.ts +223 -0
- package/src/config/platforms/evolution/product-config/EvolutionStorageS3FreeTier.ts +97 -0
- package/src/config/platforms/evolution/product-config/index.ts +17 -0
- package/src/config/platforms/evolution/products.ts +260 -0
- package/src/config/platforms/index.ts +3 -0
- package/src/config/platforms/vmware/catalog.ts +19 -0
- package/src/config/platforms/vmware/constants.ts +6 -0
- package/src/config/platforms/vmware/index.ts +5 -0
- package/src/config/platforms/vmware/platform.tsx +13 -0
- package/src/config/platforms/vmware/product-config/VmWareCloudBackup.ts +56 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualDataCenter.ts +309 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualMachinesBackup.ts +58 -0
- package/src/config/platforms/vmware/product-config/VmWareVirtualWorkspaces.tsx +210 -0
- package/src/config/platforms/vmware/product-config/index.ts +4 -0
- package/src/config/platforms/vmware/products.ts +63 -0
- package/src/config/styles.module.scss +9 -0
- package/src/config/utils/disk.ts +94 -0
- package/src/config/utils/diskPostgreSqlMySQL.ts +94 -0
- package/src/config/utils/eip.ts +104 -0
- package/src/config/utils/index.ts +52 -0
- package/src/config/utils/obs.ts +100 -0
- package/src/constants.ts +56 -0
- package/src/contexts/CalculatorContext.tsx +193 -0
- package/src/contexts/ProductContext.ts +25 -0
- package/src/contexts/index.ts +2 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useAdaptive.ts +20 -0
- package/src/hooks/useCatalogCardClick.ts +37 -0
- package/src/hooks/useProductClick.ts +14 -0
- package/src/hooks/useProductDelete.ts +46 -0
- package/src/index.ts +6 -0
- package/src/services/constants.ts +5 -0
- package/src/services/getFetcherFn.ts +57 -0
- package/src/services/getInitPrice.ts +64 -0
- package/src/services/getOnDownloadFileClick.ts +37 -0
- package/src/services/getOnShareClick.ts +56 -0
- package/src/services/index.ts +4 -0
- package/src/types/CalculatorType.ts +16 -0
- package/src/types/CatalogConfig.ts +13 -0
- package/src/types/Category.ts +14 -0
- package/src/types/FetcherFn.ts +26 -0
- package/src/types/FormValues.ts +4 -0
- package/src/types/Platform.ts +24 -0
- package/src/types/Price.ts +18 -0
- package/src/types/Product.ts +39 -0
- package/src/types/ProductState.ts +11 -0
- package/src/types/State.ts +7 -0
- package/src/types/index.ts +10 -0
- package/src/utils/filterNonEmptyArrays.ts +13 -0
- package/src/utils/formatNumber.ts +5 -0
- package/src/utils/getPrice.ts +38 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/parseKeyToDataTest.ts +14 -0
- package/src/utils/value.ts +11 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { CONTROL, FormConfig } from '../../../../components';
|
|
2
|
+
import { AnyType } from '../../../../types';
|
|
3
|
+
import { generateCpuItems, generateInstanceConfigItems, getDisk } from '../../../utils';
|
|
4
|
+
|
|
5
|
+
const instanceConfigitems = generateInstanceConfigItems([
|
|
6
|
+
[2, 4],
|
|
7
|
+
[4, 8],
|
|
8
|
+
[8, 16],
|
|
9
|
+
[16, 32],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const InstanceTypeItem = {
|
|
13
|
+
Single: 'Single-node',
|
|
14
|
+
Cluster: 'Cluster',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const instanceTypeItems = [
|
|
18
|
+
{
|
|
19
|
+
value: InstanceTypeItem.Single,
|
|
20
|
+
label: 'Single-Node',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: InstanceTypeItem.Cluster,
|
|
24
|
+
label: 'Cluster',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const instanceBrokersCountItems = generateCpuItems([1, 3, 5, 7]);
|
|
29
|
+
|
|
30
|
+
const accessorKey = {
|
|
31
|
+
instanceType: 'instance.type',
|
|
32
|
+
instanceConfig: 'instance.config',
|
|
33
|
+
instanceBrokersCount: 'instance.brokersCount',
|
|
34
|
+
evsDiskSpace: 'evs.systemDisk.diskSpace',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const DSC_RABBIT_MQ_FORM_CONFIG: FormConfig = {
|
|
38
|
+
ui: [['instanceType', 'instanceConfig'], 'instanceAlert', 'instanceBrokersCount', ['evs']],
|
|
39
|
+
controls: {
|
|
40
|
+
instanceType: {
|
|
41
|
+
type: CONTROL.Segmented,
|
|
42
|
+
accessorKey: accessorKey.instanceType,
|
|
43
|
+
defaultValue: InstanceTypeItem.Single,
|
|
44
|
+
items: instanceTypeItems,
|
|
45
|
+
decoratorProps: {
|
|
46
|
+
label: 'Тип инстанса',
|
|
47
|
+
},
|
|
48
|
+
onChangeFn: (value, setValue) => {
|
|
49
|
+
const arr: [string, AnyType][] = [[accessorKey.instanceType, value]];
|
|
50
|
+
|
|
51
|
+
switch (value) {
|
|
52
|
+
case InstanceTypeItem.Cluster: {
|
|
53
|
+
arr.push([accessorKey.evsDiskSpace, 600]);
|
|
54
|
+
arr.push(['instance.brokersCount', '3']);
|
|
55
|
+
arr.push([accessorKey.instanceConfig, '4 8']);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case InstanceTypeItem.Single:
|
|
60
|
+
default: {
|
|
61
|
+
arr.push([accessorKey.evsDiskSpace, 200]);
|
|
62
|
+
arr.push(['instance.brokersCount', '1']);
|
|
63
|
+
arr.push([accessorKey.instanceConfig, '2 4']);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
setValue(arr);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
instanceAlert: {
|
|
71
|
+
type: CONTROL.Alert,
|
|
72
|
+
uiProps: {
|
|
73
|
+
description: 'В состав инстанса Single-Node входит только один брокер',
|
|
74
|
+
},
|
|
75
|
+
watchedControls: { instanceType: accessorKey.instanceType },
|
|
76
|
+
relateFn: ({ instanceType }) => {
|
|
77
|
+
if (instanceType !== InstanceTypeItem.Single) {
|
|
78
|
+
return {
|
|
79
|
+
uiProps: {
|
|
80
|
+
visible: false,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
accessorKey: 'instance',
|
|
86
|
+
},
|
|
87
|
+
instanceConfig: {
|
|
88
|
+
type: CONTROL.SelectSingle,
|
|
89
|
+
accessorKey: accessorKey.instanceConfig,
|
|
90
|
+
defaultValue: instanceConfigitems[0].value,
|
|
91
|
+
items: instanceConfigitems,
|
|
92
|
+
decoratorProps: {
|
|
93
|
+
label: 'Конфигурация инстанса',
|
|
94
|
+
},
|
|
95
|
+
uiProps: {
|
|
96
|
+
showClearButton: false,
|
|
97
|
+
searchable: false,
|
|
98
|
+
},
|
|
99
|
+
watchedControls: { instanceType: accessorKey.instanceType },
|
|
100
|
+
relateFn: ({ instanceType }) => {
|
|
101
|
+
if (instanceType === instanceTypeItems[1].value) {
|
|
102
|
+
return {
|
|
103
|
+
items: instanceConfigitems.slice(1),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
instanceBrokersCount: {
|
|
109
|
+
type: CONTROL.Segmented,
|
|
110
|
+
accessorKey: accessorKey.instanceBrokersCount,
|
|
111
|
+
defaultValue: instanceBrokersCountItems[0].value,
|
|
112
|
+
items: instanceBrokersCountItems.slice(0, 1),
|
|
113
|
+
decoratorProps: {
|
|
114
|
+
label: 'Количество брокеров',
|
|
115
|
+
labelTooltip:
|
|
116
|
+
'Брокер — это приложение, которое преобразует сообщения и выступает посредником между другими приложениями',
|
|
117
|
+
},
|
|
118
|
+
uiProps: {
|
|
119
|
+
visible: false,
|
|
120
|
+
},
|
|
121
|
+
watchedControls: { instanceType: accessorKey.instanceType },
|
|
122
|
+
relateFn: ({ instanceType }) => {
|
|
123
|
+
if (instanceType === instanceTypeItems[1].value) {
|
|
124
|
+
return {
|
|
125
|
+
items: instanceBrokersCountItems.slice(1),
|
|
126
|
+
uiProps: {
|
|
127
|
+
visible: true,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
onChangeFn: (value, setValue) => {
|
|
133
|
+
const arr: [string, AnyType][] = [[accessorKey.instanceBrokersCount, value]];
|
|
134
|
+
|
|
135
|
+
switch (value) {
|
|
136
|
+
case '3': {
|
|
137
|
+
arr.push([accessorKey.evsDiskSpace, 600]);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
case '5': {
|
|
142
|
+
arr.push([accessorKey.evsDiskSpace, 1000]);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
case '7': {
|
|
147
|
+
arr.push([accessorKey.evsDiskSpace, 1400]);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
default: {
|
|
152
|
+
arr.push([accessorKey.evsDiskSpace, 200]);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setValue(arr);
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
evs: getDisk({
|
|
160
|
+
space: {
|
|
161
|
+
accessorKey: accessorKey.evsDiskSpace,
|
|
162
|
+
defaultValue: 200,
|
|
163
|
+
uiProps: {
|
|
164
|
+
min: 200,
|
|
165
|
+
max: 90000,
|
|
166
|
+
},
|
|
167
|
+
watchedControls: { instanceBrokersCount: accessorKey.instanceBrokersCount },
|
|
168
|
+
relateFn: ({ instanceBrokersCount }) => {
|
|
169
|
+
switch (instanceBrokersCount) {
|
|
170
|
+
case '3': {
|
|
171
|
+
return {
|
|
172
|
+
uiProps: {
|
|
173
|
+
min: 600,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
case '5': {
|
|
178
|
+
return {
|
|
179
|
+
uiProps: {
|
|
180
|
+
min: 1000,
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
case '7': {
|
|
185
|
+
return {
|
|
186
|
+
uiProps: {
|
|
187
|
+
min: 1400,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
default: {
|
|
192
|
+
/* empty */
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
specification: {
|
|
198
|
+
accessorKey: 'evs.systemDisk.specification',
|
|
199
|
+
},
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
};
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONTROL,
|
|
3
|
+
FormConfig,
|
|
4
|
+
ObjectControl,
|
|
5
|
+
SegmentedControl,
|
|
6
|
+
StepperControl,
|
|
7
|
+
ToggleObjectControl,
|
|
8
|
+
} from '../../../../components';
|
|
9
|
+
import styles from '../../../styles.module.scss';
|
|
10
|
+
import { generateCpuItems, generateRamItems, getDisk, getEip, getObs } from '../../../utils';
|
|
11
|
+
|
|
12
|
+
const DbClassTypeItem = {
|
|
13
|
+
Cluster: 'cluster',
|
|
14
|
+
Replica: 'replica',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const dbClassTypeItems = [
|
|
18
|
+
{
|
|
19
|
+
value: DbClassTypeItem.Cluster,
|
|
20
|
+
label: 'Кластер',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: DbClassTypeItem.Replica,
|
|
24
|
+
label: 'Реплика',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const CpuRamMap: Record<string, number[]> = {
|
|
29
|
+
'2': [4, 8],
|
|
30
|
+
'4': [8, 16],
|
|
31
|
+
'8': [16, 32],
|
|
32
|
+
'16': [32, 64],
|
|
33
|
+
'32': [64, 128],
|
|
34
|
+
'64': [128, 256],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type GetRdsControlsProps = {
|
|
38
|
+
prefix: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getNodeControls = ({
|
|
42
|
+
prefix,
|
|
43
|
+
}: GetRdsControlsProps): {
|
|
44
|
+
cpu: SegmentedControl;
|
|
45
|
+
ram: SegmentedControl;
|
|
46
|
+
counter: StepperControl;
|
|
47
|
+
eip: ToggleObjectControl;
|
|
48
|
+
} => ({
|
|
49
|
+
cpu: {
|
|
50
|
+
type: CONTROL.Segmented,
|
|
51
|
+
accessorKey: `${prefix}.cpu`,
|
|
52
|
+
defaultValue: '2',
|
|
53
|
+
items: generateCpuItems([2, 4, 8, 16, 32, 64]),
|
|
54
|
+
decoratorProps: {
|
|
55
|
+
label: 'Количество vCPU',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
ram: {
|
|
59
|
+
type: CONTROL.Segmented,
|
|
60
|
+
accessorKey: `${prefix}.ram`,
|
|
61
|
+
defaultValue: '4',
|
|
62
|
+
items: generateRamItems([4, 8]),
|
|
63
|
+
decoratorProps: {
|
|
64
|
+
label: 'Объём RAM',
|
|
65
|
+
},
|
|
66
|
+
watchedControls: {
|
|
67
|
+
cpu: `${prefix}.cpu`,
|
|
68
|
+
},
|
|
69
|
+
relateFn: ({ cpu }: { cpu: string }) => {
|
|
70
|
+
const items: number[] = CpuRamMap[cpu] || [];
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
items: generateRamItems(items),
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
counter: {
|
|
78
|
+
type: CONTROL.Stepper,
|
|
79
|
+
accessorKey: `${prefix}.counter`,
|
|
80
|
+
defaultValue: 2,
|
|
81
|
+
decoratorProps: {
|
|
82
|
+
label: 'Количество Node',
|
|
83
|
+
},
|
|
84
|
+
uiProps: {
|
|
85
|
+
min: 2,
|
|
86
|
+
max: 16,
|
|
87
|
+
postfix: 'Шт',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
eip: getEip({
|
|
91
|
+
trafficKey: `${prefix}.eip.traffic`,
|
|
92
|
+
velocityKey: `${prefix}.eip.velocity`,
|
|
93
|
+
specificationKey: `${prefix}.eip.specification`,
|
|
94
|
+
switchKey: `${prefix}.eipIsNeeded`,
|
|
95
|
+
}),
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const mongosNodeControls = getNodeControls({ prefix: 'mongosNode' });
|
|
99
|
+
const shardNodeControls = getNodeControls({ prefix: 'shardNode' });
|
|
100
|
+
const configNodeControls = getNodeControls({ prefix: 'configNode' });
|
|
101
|
+
|
|
102
|
+
const replicaNodeControls = getNodeControls({ prefix: 'replica' });
|
|
103
|
+
|
|
104
|
+
const getReplica = (): ObjectControl => ({
|
|
105
|
+
type: CONTROL.Object,
|
|
106
|
+
ui: [
|
|
107
|
+
['cpu', 'ram'],
|
|
108
|
+
['disk', 'storage'],
|
|
109
|
+
],
|
|
110
|
+
controls: {
|
|
111
|
+
cpu: replicaNodeControls.cpu,
|
|
112
|
+
ram: replicaNodeControls.ram,
|
|
113
|
+
disk: getDisk({
|
|
114
|
+
space: {
|
|
115
|
+
accessorKey: 'replica.diskSpace',
|
|
116
|
+
defaultValue: 10,
|
|
117
|
+
uiProps: {
|
|
118
|
+
min: 10,
|
|
119
|
+
max: 2000,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
specification: {
|
|
123
|
+
defaultValue: 'SSD',
|
|
124
|
+
accessorKey: 'replica.specification',
|
|
125
|
+
uiProps: {
|
|
126
|
+
disabled: true,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
}),
|
|
130
|
+
storage: getObs({
|
|
131
|
+
space: {
|
|
132
|
+
accessorKey: 'replica.storage.space',
|
|
133
|
+
defaultValue: 1,
|
|
134
|
+
uiProps: {
|
|
135
|
+
min: 1,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
units: {
|
|
139
|
+
accessorKey: 'replica.storage.unitsOfCalculation',
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export const DOCUMENT_DATABASE_FORM_CONFIG: FormConfig = {
|
|
146
|
+
ui: [['dbClassType'], 'clusterDbClassTypeObj', 'replicaDbClassTypeObj'],
|
|
147
|
+
controls: {
|
|
148
|
+
dbClassType: {
|
|
149
|
+
type: CONTROL.Segmented,
|
|
150
|
+
accessorKey: 'dbClassType',
|
|
151
|
+
items: dbClassTypeItems,
|
|
152
|
+
defaultValue: DbClassTypeItem.Cluster,
|
|
153
|
+
decoratorProps: {
|
|
154
|
+
label: 'Тип базы данных',
|
|
155
|
+
labelTooltip: (
|
|
156
|
+
<ul className={styles.tip}>
|
|
157
|
+
<li>
|
|
158
|
+
Каждый кластер DDS представляет собой независимую базу данных документов. Сегментированный кластер состоит
|
|
159
|
+
из ноды конфигурации и нескольких нод mongos и shard
|
|
160
|
+
</li>
|
|
161
|
+
<li>
|
|
162
|
+
Набор реплик состоит из совокупности процессов mongod. Это набор нод, которые помогают обеспечить
|
|
163
|
+
резервирование и надежность данных
|
|
164
|
+
</li>
|
|
165
|
+
</ul>
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
clusterDbClassTypeObj: {
|
|
170
|
+
type: CONTROL.Object,
|
|
171
|
+
ui: ['mongosNode', 'shardNode', 'configNode', 'replica'],
|
|
172
|
+
controls: {
|
|
173
|
+
mongosNode: {
|
|
174
|
+
type: CONTROL.Object,
|
|
175
|
+
ui: [['cpu', 'ram'], ['counter'], 'eip'],
|
|
176
|
+
decoratorProps: {
|
|
177
|
+
label: 'Mongos Node',
|
|
178
|
+
labelTooltip:
|
|
179
|
+
'Каждый mongos представляет собой отдельную ноду, которая пересылает запросы на чтение и запись данных',
|
|
180
|
+
},
|
|
181
|
+
controls: {
|
|
182
|
+
cpu: mongosNodeControls.cpu,
|
|
183
|
+
ram: mongosNodeControls.ram,
|
|
184
|
+
counter: {
|
|
185
|
+
...mongosNodeControls.counter,
|
|
186
|
+
decoratorProps: {
|
|
187
|
+
label: 'Количество Mongos Node',
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
eip: mongosNodeControls.eip,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
shardNode: {
|
|
194
|
+
type: CONTROL.Object,
|
|
195
|
+
ui: [['cpu', 'ram'], ['disk', 'counter'], 'eip'],
|
|
196
|
+
decoratorProps: {
|
|
197
|
+
label: 'Shard Node',
|
|
198
|
+
labelTooltip: 'Каждый шард (shard) представляет собой набор реплик из трех нод',
|
|
199
|
+
},
|
|
200
|
+
controls: {
|
|
201
|
+
cpu: shardNodeControls.cpu,
|
|
202
|
+
ram: shardNodeControls.ram,
|
|
203
|
+
counter: {
|
|
204
|
+
...shardNodeControls.counter,
|
|
205
|
+
decoratorProps: {
|
|
206
|
+
label: 'Количество Shard Node',
|
|
207
|
+
labelTooltip: 'Каждому Shard Node присваивается отдельный системный диск',
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
eip: shardNodeControls.eip,
|
|
211
|
+
disk: getDisk({
|
|
212
|
+
space: {
|
|
213
|
+
accessorKey: 'shardNode.diskSpace',
|
|
214
|
+
defaultValue: 10,
|
|
215
|
+
uiProps: {
|
|
216
|
+
min: 10,
|
|
217
|
+
max: 1000,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
specification: {
|
|
221
|
+
defaultValue: 'SSD',
|
|
222
|
+
accessorKey: 'shardNode.specification',
|
|
223
|
+
uiProps: {
|
|
224
|
+
disabled: true,
|
|
225
|
+
},
|
|
226
|
+
onChangeFn: () => {},
|
|
227
|
+
},
|
|
228
|
+
}),
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
configNode: {
|
|
232
|
+
type: CONTROL.Object,
|
|
233
|
+
ui: [['cpu', 'ram'], ['disk', 'storage'], 'eip'],
|
|
234
|
+
decoratorProps: {
|
|
235
|
+
label: 'Config Node',
|
|
236
|
+
labelTooltip:
|
|
237
|
+
'Нода конфигурации (config) является необходимой частью экземпляра кластера, а также развертывается как набор реплик. Она хранит данные конфигурации экземпляра',
|
|
238
|
+
},
|
|
239
|
+
controls: {
|
|
240
|
+
cpu: {
|
|
241
|
+
...configNodeControls.cpu,
|
|
242
|
+
defaultValue: '2',
|
|
243
|
+
items: generateCpuItems([2]),
|
|
244
|
+
relateFn: undefined,
|
|
245
|
+
watchedControls: undefined,
|
|
246
|
+
},
|
|
247
|
+
ram: {
|
|
248
|
+
...configNodeControls.ram,
|
|
249
|
+
defaultValue: '4',
|
|
250
|
+
items: generateRamItems([4]),
|
|
251
|
+
relateFn: undefined,
|
|
252
|
+
watchedControls: undefined,
|
|
253
|
+
},
|
|
254
|
+
disk: getDisk({
|
|
255
|
+
space: {
|
|
256
|
+
accessorKey: 'configNode.diskSpace',
|
|
257
|
+
defaultValue: 20,
|
|
258
|
+
uiProps: {
|
|
259
|
+
min: 20,
|
|
260
|
+
max: 20,
|
|
261
|
+
disabled: true,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
specification: {
|
|
265
|
+
defaultValue: 'SSD',
|
|
266
|
+
accessorKey: 'configNode.specification',
|
|
267
|
+
uiProps: {
|
|
268
|
+
disabled: true,
|
|
269
|
+
},
|
|
270
|
+
onChangeFn: () => {},
|
|
271
|
+
},
|
|
272
|
+
}),
|
|
273
|
+
storage: getObs({
|
|
274
|
+
space: {
|
|
275
|
+
accessorKey: 'configNode.storage.space',
|
|
276
|
+
defaultValue: 1,
|
|
277
|
+
uiProps: {
|
|
278
|
+
min: 1,
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
units: {
|
|
282
|
+
accessorKey: 'configNode.storage.unitsOfCalculation',
|
|
283
|
+
},
|
|
284
|
+
}),
|
|
285
|
+
|
|
286
|
+
eip: mongosNodeControls.eip,
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
replica: {
|
|
290
|
+
type: CONTROL.ToggleObject,
|
|
291
|
+
switchKey: 'replicaIsNeeded',
|
|
292
|
+
control: getReplica(),
|
|
293
|
+
decoratorProps: {
|
|
294
|
+
label: 'Реплика',
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
watchedControls: { dbClassType: 'dbClassType' },
|
|
299
|
+
relateFn: ({ dbClassType }) => {
|
|
300
|
+
if (dbClassType === DbClassTypeItem.Replica) {
|
|
301
|
+
return {
|
|
302
|
+
visible: false,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
replicaDbClassTypeObj: {
|
|
308
|
+
type: CONTROL.Object,
|
|
309
|
+
ui: ['replica'],
|
|
310
|
+
controls: {
|
|
311
|
+
replica: getReplica(),
|
|
312
|
+
},
|
|
313
|
+
watchedControls: { dbClassType: 'dbClassType' },
|
|
314
|
+
relateFn: ({ dbClassType }) => {
|
|
315
|
+
if (dbClassType !== DbClassTypeItem.Replica) {
|
|
316
|
+
return {
|
|
317
|
+
visible: false,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
};
|