@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.
Files changed (205) hide show
  1. package/CHANGELOG.md +1508 -0
  2. package/LICENSE +201 -0
  3. package/README.md +85 -0
  4. package/package.json +75 -0
  5. package/src/components/Calculator/Calculator.tsx +79 -0
  6. package/src/components/Calculator/index.ts +1 -0
  7. package/src/components/CalculatorContent/CalculatorContent.tsx +38 -0
  8. package/src/components/CalculatorContent/index.ts +1 -0
  9. package/src/components/CalculatorContent/styles.module.scss +79 -0
  10. package/src/components/Catalog/Catalog.tsx +225 -0
  11. package/src/components/Catalog/components/PrivateCardHeader.tsx +63 -0
  12. package/src/components/Catalog/components/index.ts +1 -0
  13. package/src/components/Catalog/components/styles.module.scss +35 -0
  14. package/src/components/Catalog/index.ts +1 -0
  15. package/src/components/Catalog/styles.module.scss +104 -0
  16. package/src/components/Controls/AlertControl/AlertControl.tsx +44 -0
  17. package/src/components/Controls/AlertControl/index.ts +1 -0
  18. package/src/components/Controls/ArrayControl/ArrayControl.tsx +105 -0
  19. package/src/components/Controls/ArrayControl/index.ts +1 -0
  20. package/src/components/Controls/ArrayControl/styles.module.scss +33 -0
  21. package/src/components/Controls/CarouselControl/CarouselControl.tsx +173 -0
  22. package/src/components/Controls/CarouselControl/index.ts +1 -0
  23. package/src/components/Controls/CarouselControl/styles.module.scss +32 -0
  24. package/src/components/Controls/Control/Control.tsx +205 -0
  25. package/src/components/Controls/Control/index.ts +1 -0
  26. package/src/components/Controls/ObjectControl/ObjectControl.tsx +150 -0
  27. package/src/components/Controls/ObjectControl/index.ts +1 -0
  28. package/src/components/Controls/ObjectControl/styles.module.scss +18 -0
  29. package/src/components/Controls/ObjectDecorator/ObjectDecorator.tsx +23 -0
  30. package/src/components/Controls/ObjectDecorator/index.ts +1 -0
  31. package/src/components/Controls/ObjectDecorator/styles.module.scss +15 -0
  32. package/src/components/Controls/SegmentedControl/SegmentedControl.tsx +79 -0
  33. package/src/components/Controls/SegmentedControl/SegmentedControlCard.tsx +38 -0
  34. package/src/components/Controls/SegmentedControl/index.ts +1 -0
  35. package/src/components/Controls/SegmentedControl/styles.module.scss +8 -0
  36. package/src/components/Controls/SelectControl/SelectControl.tsx +172 -0
  37. package/src/components/Controls/SelectControl/index.ts +1 -0
  38. package/src/components/Controls/SelectControl/styles.module.scss +5 -0
  39. package/src/components/Controls/SliderControl/SliderControl.tsx +92 -0
  40. package/src/components/Controls/SliderControl/index.ts +1 -0
  41. package/src/components/Controls/StepperControl/StepperControl.tsx +160 -0
  42. package/src/components/Controls/StepperControl/index.ts +1 -0
  43. package/src/components/Controls/StepperControl/styles.module.scss +16 -0
  44. package/src/components/Controls/TableControl/TableControl.tsx +162 -0
  45. package/src/components/Controls/TableControl/helperComponents/StepperWithAllowedValues.tsx +50 -0
  46. package/src/components/Controls/TableControl/helperComponents/index.ts +1 -0
  47. package/src/components/Controls/TableControl/helperComponents/styles.module.scss +53 -0
  48. package/src/components/Controls/TableControl/index.ts +1 -0
  49. package/src/components/Controls/TableControl/styles.module.scss +104 -0
  50. package/src/components/Controls/ToggleCard/ToggleCard.tsx +46 -0
  51. package/src/components/Controls/ToggleCard/index.ts +1 -0
  52. package/src/components/Controls/ToggleCard/styles.module.scss +11 -0
  53. package/src/components/Controls/ToggleCardsControl/ToggleCardsControl.tsx +93 -0
  54. package/src/components/Controls/ToggleCardsControl/index.ts +1 -0
  55. package/src/components/Controls/ToggleCardsControl/styles.module.scss +40 -0
  56. package/src/components/Controls/ToggleControl/ToggleControl.tsx +59 -0
  57. package/src/components/Controls/ToggleControl/components/SwitchRow.tsx +98 -0
  58. package/src/components/Controls/ToggleControl/components/index.ts +1 -0
  59. package/src/components/Controls/ToggleControl/components/styles.module.scss +110 -0
  60. package/src/components/Controls/ToggleControl/index.ts +1 -0
  61. package/src/components/Controls/ToggleObjectControl/ToggleObjectControl.tsx +111 -0
  62. package/src/components/Controls/ToggleObjectControl/index.ts +1 -0
  63. package/src/components/Controls/ToggleObjectControl/styles.module.scss +13 -0
  64. package/src/components/Controls/constants.ts +16 -0
  65. package/src/components/Controls/index.tsx +26 -0
  66. package/src/components/Controls/types.ts +181 -0
  67. package/src/components/Controls/utils.ts +49 -0
  68. package/src/components/Disclaimer/Disclaimer.tsx +33 -0
  69. package/src/components/Disclaimer/index.ts +1 -0
  70. package/src/components/Disclaimer/styles.module.scss +14 -0
  71. package/src/components/HeaderContainer/index.tsx +32 -0
  72. package/src/components/HeaderContainer/styles.module.scss +24 -0
  73. package/src/components/PriceSummary/PriceSummary.tsx +158 -0
  74. package/src/components/PriceSummary/components/PricePeriodSelect/PricePeriodSelect.tsx +81 -0
  75. package/src/components/PriceSummary/components/PricePeriodSelect/index.ts +1 -0
  76. package/src/components/PriceSummary/components/ProductCard/ProductCard.tsx +85 -0
  77. package/src/components/PriceSummary/components/ProductCard/index.ts +1 -0
  78. package/src/components/PriceSummary/components/ProductCard/styles.module.scss +7 -0
  79. package/src/components/PriceSummary/components/ProductListActions/ProductListActions.tsx +118 -0
  80. package/src/components/PriceSummary/components/ProductListActions/index.ts +1 -0
  81. package/src/components/PriceSummary/components/ProductListActions/styles.module.scss +38 -0
  82. package/src/components/PriceSummary/components/index.ts +3 -0
  83. package/src/components/PriceSummary/hooks.ts +36 -0
  84. package/src/components/PriceSummary/index.ts +1 -0
  85. package/src/components/PriceSummary/styles.module.scss +110 -0
  86. package/src/components/PriceSummary/utils/getTotalPrice.ts +19 -0
  87. package/src/components/PriceSummary/utils/index.ts +2 -0
  88. package/src/components/PriceSummary/utils/transformToProductCardData.ts +36 -0
  89. package/src/components/ProductHeadline/ProductPageHeadline.tsx +134 -0
  90. package/src/components/ProductHeadline/components/PriceCount.tsx +93 -0
  91. package/src/components/ProductHeadline/components/index.ts +1 -0
  92. package/src/components/ProductHeadline/components/styles.module.scss +52 -0
  93. package/src/components/ProductHeadline/index.ts +1 -0
  94. package/src/components/ProductHeadline/styles.module.scss +32 -0
  95. package/src/components/ProductPage/ProductPage.tsx +105 -0
  96. package/src/components/ProductPage/index.ts +1 -0
  97. package/src/components/ProductPage/styles.module.scss +13 -0
  98. package/src/components/Welcome/Welcome.tsx +138 -0
  99. package/src/components/Welcome/index.ts +1 -0
  100. package/src/components/Welcome/styles.module.scss +155 -0
  101. package/src/components/index.ts +3 -0
  102. package/src/config/config.tsx +27 -0
  103. package/src/config/index.ts +2 -0
  104. package/src/config/platforms/advanced/catalog.ts +82 -0
  105. package/src/config/platforms/advanced/constants.ts +23 -0
  106. package/src/config/platforms/advanced/index.ts +5 -0
  107. package/src/config/platforms/advanced/platform.tsx +13 -0
  108. package/src/config/platforms/advanced/product-config/AdvancedCloudBackup.ts +76 -0
  109. package/src/config/platforms/advanced/product-config/AdvancedCloudContainerEngine.tsx +260 -0
  110. package/src/config/platforms/advanced/product-config/AdvancedCloudServer.tsx +526 -0
  111. package/src/config/platforms/advanced/product-config/AdvancedDataAsYouUse.ts +159 -0
  112. package/src/config/platforms/advanced/product-config/AdvancedDataLakeInsight.ts +134 -0
  113. package/src/config/platforms/advanced/product-config/AdvancedDataWarehouseService.ts +94 -0
  114. package/src/config/platforms/advanced/product-config/AdvancedDcsMemcached.ts +69 -0
  115. package/src/config/platforms/advanced/product-config/AdvancedDcsRedis.ts +220 -0
  116. package/src/config/platforms/advanced/product-config/AdvancedDmsKafka.tsx +186 -0
  117. package/src/config/platforms/advanced/product-config/AdvancedDmsRabbitMq.ts +202 -0
  118. package/src/config/platforms/advanced/product-config/AdvancedDocumentDatabase.tsx +323 -0
  119. package/src/config/platforms/advanced/product-config/AdvancedElasticLoadBalance.tsx +252 -0
  120. package/src/config/platforms/advanced/product-config/AdvancedElasticSearch.ts +365 -0
  121. package/src/config/platforms/advanced/product-config/AdvancedFunctionGraph.tsx +65 -0
  122. package/src/config/platforms/advanced/product-config/AdvancedMapReduce.tsx +394 -0
  123. package/src/config/platforms/advanced/product-config/AdvancedMySqlDataBase.ts +417 -0
  124. package/src/config/platforms/advanced/product-config/AdvancedNetwork.ts +146 -0
  125. package/src/config/platforms/advanced/product-config/AdvancedObjectStorage.ts +232 -0
  126. package/src/config/platforms/advanced/product-config/AdvancedPostgreSqlDatabase.ts +402 -0
  127. package/src/config/platforms/advanced/product-config/AdvancedScalableFile.tsx +161 -0
  128. package/src/config/platforms/advanced/product-config/AdvancedSqlDatabase.ts +380 -0
  129. package/src/config/platforms/advanced/product-config/index.ts +21 -0
  130. package/src/config/platforms/advanced/products.ts +267 -0
  131. package/src/config/platforms/evolution/catalog.tsx +107 -0
  132. package/src/config/platforms/evolution/constants.ts +80 -0
  133. package/src/config/platforms/evolution/index.ts +5 -0
  134. package/src/config/platforms/evolution/platform.tsx +13 -0
  135. package/src/config/platforms/evolution/product-config/EvolutionArenadataDb.ts +151 -0
  136. package/src/config/platforms/evolution/product-config/EvolutionArtifactRegistry.ts +57 -0
  137. package/src/config/platforms/evolution/product-config/EvolutionBareMetal.tsx +172 -0
  138. package/src/config/platforms/evolution/product-config/EvolutionCloudServer.tsx +407 -0
  139. package/src/config/platforms/evolution/product-config/EvolutionCloudServerFreeTier.tsx +185 -0
  140. package/src/config/platforms/evolution/product-config/EvolutionCloudServerGpu.tsx +301 -0
  141. package/src/config/platforms/evolution/product-config/EvolutionContainerApps.ts +84 -0
  142. package/src/config/platforms/evolution/product-config/EvolutionContainerAppsFreeTier.ts +29 -0
  143. package/src/config/platforms/evolution/product-config/EvolutionKubernetes.ts +388 -0
  144. package/src/config/platforms/evolution/product-config/EvolutionManagedMetastore.ts +38 -0
  145. package/src/config/platforms/evolution/product-config/EvolutionManagedRedis.ts +161 -0
  146. package/src/config/platforms/evolution/product-config/EvolutionManagedSpark.ts +360 -0
  147. package/src/config/platforms/evolution/product-config/EvolutionManagedTrino.ts +53 -0
  148. package/src/config/platforms/evolution/product-config/EvolutionMlInference.tsx +703 -0
  149. package/src/config/platforms/evolution/product-config/EvolutionPostgreSql.ts +217 -0
  150. package/src/config/platforms/evolution/product-config/EvolutionPublicIp.ts +39 -0
  151. package/src/config/platforms/evolution/product-config/EvolutionSnatGateway.ts +22 -0
  152. package/src/config/platforms/evolution/product-config/EvolutionStorageS3.ts +223 -0
  153. package/src/config/platforms/evolution/product-config/EvolutionStorageS3FreeTier.ts +97 -0
  154. package/src/config/platforms/evolution/product-config/index.ts +17 -0
  155. package/src/config/platforms/evolution/products.ts +260 -0
  156. package/src/config/platforms/index.ts +3 -0
  157. package/src/config/platforms/vmware/catalog.ts +19 -0
  158. package/src/config/platforms/vmware/constants.ts +6 -0
  159. package/src/config/platforms/vmware/index.ts +5 -0
  160. package/src/config/platforms/vmware/platform.tsx +13 -0
  161. package/src/config/platforms/vmware/product-config/VmWareCloudBackup.ts +56 -0
  162. package/src/config/platforms/vmware/product-config/VmWareVirtualDataCenter.ts +309 -0
  163. package/src/config/platforms/vmware/product-config/VmWareVirtualMachinesBackup.ts +58 -0
  164. package/src/config/platforms/vmware/product-config/VmWareVirtualWorkspaces.tsx +210 -0
  165. package/src/config/platforms/vmware/product-config/index.ts +4 -0
  166. package/src/config/platforms/vmware/products.ts +63 -0
  167. package/src/config/styles.module.scss +9 -0
  168. package/src/config/utils/disk.ts +94 -0
  169. package/src/config/utils/diskPostgreSqlMySQL.ts +94 -0
  170. package/src/config/utils/eip.ts +104 -0
  171. package/src/config/utils/index.ts +52 -0
  172. package/src/config/utils/obs.ts +100 -0
  173. package/src/constants.ts +56 -0
  174. package/src/contexts/CalculatorContext.tsx +193 -0
  175. package/src/contexts/ProductContext.ts +25 -0
  176. package/src/contexts/index.ts +2 -0
  177. package/src/hooks/index.ts +6 -0
  178. package/src/hooks/useAdaptive.ts +20 -0
  179. package/src/hooks/useCatalogCardClick.ts +37 -0
  180. package/src/hooks/useProductClick.ts +14 -0
  181. package/src/hooks/useProductDelete.ts +46 -0
  182. package/src/index.ts +6 -0
  183. package/src/services/constants.ts +5 -0
  184. package/src/services/getFetcherFn.ts +57 -0
  185. package/src/services/getInitPrice.ts +64 -0
  186. package/src/services/getOnDownloadFileClick.ts +37 -0
  187. package/src/services/getOnShareClick.ts +56 -0
  188. package/src/services/index.ts +4 -0
  189. package/src/types/CalculatorType.ts +16 -0
  190. package/src/types/CatalogConfig.ts +13 -0
  191. package/src/types/Category.ts +14 -0
  192. package/src/types/FetcherFn.ts +26 -0
  193. package/src/types/FormValues.ts +4 -0
  194. package/src/types/Platform.ts +24 -0
  195. package/src/types/Price.ts +18 -0
  196. package/src/types/Product.ts +39 -0
  197. package/src/types/ProductState.ts +11 -0
  198. package/src/types/State.ts +7 -0
  199. package/src/types/index.ts +10 -0
  200. package/src/utils/filterNonEmptyArrays.ts +13 -0
  201. package/src/utils/formatNumber.ts +5 -0
  202. package/src/utils/getPrice.ts +38 -0
  203. package/src/utils/index.ts +5 -0
  204. package/src/utils/parseKeyToDataTest.ts +14 -0
  205. package/src/utils/value.ts +11 -0
@@ -0,0 +1,185 @@
1
+ import { CONTROL, FormConfig } from '../../../../components';
2
+ import { generateBaseItems, generateCpuItems, generateRamItems, getDisk } from '../../../utils';
3
+
4
+ const osItems = ['Fedora 38', 'Ubuntu 18.04', 'Ubuntu 20.04', 'Ubuntu 22.04'];
5
+
6
+ export const EVOLUTION_CLOUD_SERVER_FREE_TIER_FORM_CONFIG: FormConfig = {
7
+ ui: [
8
+ 'alert',
9
+ 'guaranteedPart',
10
+ ['os'],
11
+ ['vCpuCoreCount', 'ramAmount'],
12
+ ['systemDisk'],
13
+ 'additionalOptions',
14
+ 'networkIsNeeded',
15
+ ],
16
+ controls: {
17
+ alert: {
18
+ type: CONTROL.Alert,
19
+ uiProps: {
20
+ description: 'Можно подключить только 1 бесплатную виртуальную машину',
21
+ },
22
+ accessorKey: 'free',
23
+ },
24
+ guaranteedPart: {
25
+ decoratorProps: {
26
+ label: 'Гарантированная доля vCPU',
27
+ labelTooltip:
28
+ 'Гарантированная доля vCPU определяет долю использования процессора, выделенную для виртуальной машины. Этот параметр известен также как переподписка vCPU (vCPU Overcommitment). При 100% гарантируется использование полной мощности виртуальных ядер процессора хоста виртуализации, выделенных виртуальной машине.',
29
+ },
30
+ type: CONTROL.Carousel,
31
+ accessorKey: 'guaranteedPart',
32
+ defaultValue: '10',
33
+ items: [
34
+ {
35
+ value: '10',
36
+ label: 'Доля до 10%',
37
+ description: 'Для тестирования и несложных приложений',
38
+ },
39
+ ],
40
+ },
41
+
42
+ os: {
43
+ type: CONTROL.SelectSingle,
44
+ decoratorProps: {
45
+ label: 'Операционная система',
46
+ },
47
+ accessorKey: 'os',
48
+ defaultValue: 'Ubuntu 22.04',
49
+ items: generateBaseItems(osItems),
50
+ },
51
+
52
+ vCpuCoreCount: {
53
+ type: CONTROL.Segmented,
54
+ accessorKey: 'vCpuCoreCount',
55
+ defaultValue: '2',
56
+ items: generateCpuItems([2]),
57
+ decoratorProps: {
58
+ label: 'Количество ядер vCPU',
59
+ labelTooltip: 'Количество ядер vCPU',
60
+ },
61
+ },
62
+
63
+ ramAmount: {
64
+ type: CONTROL.Segmented,
65
+ accessorKey: 'ramAmount',
66
+ defaultValue: '4',
67
+ items: generateRamItems([4]),
68
+ decoratorProps: {
69
+ label: 'Количество оперативной памяти (RAM)',
70
+ },
71
+ uiProps: {
72
+ disabled: true,
73
+ },
74
+ },
75
+
76
+ systemDisk: getDisk({
77
+ space: {
78
+ label: 'Загрузочный диск',
79
+ accessorKey: 'evs.systemDisk.diskSpace',
80
+ defaultValue: 30,
81
+ uiProps: {
82
+ min: 30,
83
+ max: 30,
84
+ showHint: false,
85
+ disabled: true,
86
+ },
87
+ },
88
+ specification: {
89
+ accessorKey: 'evs.systemDisk.specification',
90
+ defaultValue: 'SSD',
91
+ uiProps: {
92
+ disabled: true,
93
+ },
94
+ },
95
+ }),
96
+
97
+ additionalOptions: {
98
+ type: CONTROL.Object,
99
+ decoratorProps: {
100
+ label: 'Дополнительные платные опции',
101
+ },
102
+ ui: ['additionalDisks'],
103
+ controls: {
104
+ additionalDisks: {
105
+ type: CONTROL.ToggleObject,
106
+ switchKey: 'evs.additionalDisksIsNeeded',
107
+ decoratorProps: {
108
+ label: 'Дополнительные диски',
109
+ },
110
+ control: {
111
+ type: 'object',
112
+ ui: ['alertAdditional', ['additionalDisks']],
113
+ controls: {
114
+ alertAdditional: {
115
+ type: 'alert',
116
+ uiProps: {
117
+ appearance: 'info',
118
+ outline: true,
119
+ description: 'Можно добавить до 7 дополнительных дисков',
120
+ },
121
+ accessorKey: 'disks',
122
+ },
123
+ additionalDisks: {
124
+ type: CONTROL.Array,
125
+ min: 1,
126
+ max: 7,
127
+ accessorKey: 'evs.additionalDisks',
128
+ addText: 'Добавить диск',
129
+ ui: ['disk'],
130
+ defaultValue: [
131
+ {
132
+ diskSpace: 5,
133
+ specification: 'SSD',
134
+ },
135
+ ],
136
+ controls: {
137
+ disk: getDisk({
138
+ space: {
139
+ label: 'Дополнительный диск',
140
+ accessorKey: 'diskSpace',
141
+ defaultValue: 10,
142
+ uiProps: {
143
+ min: 10,
144
+ max: 4_096,
145
+ },
146
+ },
147
+ specification: {
148
+ accessorKey: 'specification',
149
+ defaultValue: 'SSD',
150
+ uiProps: {
151
+ disabled: true,
152
+ },
153
+ },
154
+ }),
155
+ },
156
+ },
157
+ },
158
+ },
159
+ },
160
+ },
161
+ },
162
+ networkIsNeeded: {
163
+ type: CONTROL.Toggle,
164
+ defaultValue: false,
165
+ accessorKey: 'networkIsNeeded',
166
+ decoratorProps: {
167
+ label: 'Аренда публичного IP',
168
+ },
169
+ },
170
+
171
+ // Hidden
172
+ network: {
173
+ type: CONTROL.Object,
174
+ defaultValue: {
175
+ ipQuantity: 1,
176
+ bindingIpAddressesQuantity: 0,
177
+ publicGatewayQuantity: 0,
178
+ privateGatewayQuantity: 0,
179
+ },
180
+ ui: [],
181
+ controls: {},
182
+ visible: false,
183
+ },
184
+ },
185
+ };
@@ -0,0 +1,301 @@
1
+ import { CONTROL, FormConfig } from '../../../../components';
2
+ import { AnyType } from '../../../../types';
3
+ import { generateBaseItems, getDisk } from '../../../utils';
4
+
5
+ enum GpuType {
6
+ Tesla = 'GPU NVIDIA® Tesla® V100',
7
+ H100 = 'GPU NVIDIA® H100',
8
+ }
9
+
10
+ const gpuTypeItems = [GpuType.Tesla, GpuType.H100];
11
+
12
+ const MinAdditionalDiskSize = 15 as const;
13
+
14
+ enum OsType {
15
+ Ubuntu18_04 = 'Ubuntu_18.04',
16
+ Fedora38 = 'Fedora_38',
17
+ Debian10 = 'Debian_10',
18
+ Ubuntu22_04_4 = 'Ubuntu_22.04.4',
19
+ Ubuntu22_04 = 'Ubuntu_22.04',
20
+ Ubuntu20_04 = 'Ubuntu_20.04',
21
+ OpenSUSE15_2 = 'openSUSE_15.2',
22
+ Debian12 = 'Debian_12',
23
+ CentOS9 = 'CentOS_9',
24
+ CentOS8 = 'CentOS_8',
25
+ CentOS7Kernel5_4 = 'CentOS_7_kernel_5.4',
26
+ CentOS7 = 'CentOS_7',
27
+ Ubuntu24_04 = 'Ubuntu_24.04',
28
+ }
29
+
30
+ const osItems = [
31
+ OsType.CentOS7,
32
+ OsType.CentOS7Kernel5_4,
33
+ OsType.CentOS8,
34
+ OsType.CentOS9,
35
+ OsType.Debian10,
36
+ OsType.Debian12,
37
+ OsType.Fedora38,
38
+ OsType.Ubuntu22_04,
39
+ OsType.Ubuntu22_04_4,
40
+ OsType.Ubuntu20_04,
41
+ OsType.Ubuntu18_04,
42
+ OsType.Ubuntu24_04,
43
+ OsType.OpenSUSE15_2,
44
+ ];
45
+
46
+ const CardValuesTesla = {
47
+ GPU1_vCPU4_RAM64: `1 4 64`,
48
+ GPU2_vCPU8_RAM128: `2 8 128`,
49
+ GPU4_vCPU16_RAM256: `4 16 256`,
50
+ GPU8_vCPU32_RAM512: `8 32 512`,
51
+ GPU16_vCPU64_RAM1024: `16 64 1024`,
52
+ } as const;
53
+
54
+ const CardValuesH100 = {
55
+ GPU1_vCPU20_RAM185: `1 20 186`,
56
+ GPU2_vCPU40_RAM372: `2 40 372`,
57
+ GPU3_vCPU60_RAM558: `3 60 558`,
58
+ GPU4_vCPU80_RAM744: `4 80 744`,
59
+ GPU5_vCPU100_RAM930: `5 100 930`,
60
+ GPU6_vCPU120_RAM1116: `6 120 1116`,
61
+ GPU7_vCPU140_RAM1302: `7 140 1302`,
62
+ GPU8_vCPU160_RAM1488: `8 160 1488`,
63
+ } as const;
64
+
65
+ type FlavorGpuTeslaValue = (typeof CardValuesTesla)[keyof typeof CardValuesTesla];
66
+ type FlavorGpuH100Value = (typeof CardValuesH100)[keyof typeof CardValuesH100];
67
+
68
+ type FlavorsGpuValue = FlavorGpuTeslaValue | FlavorGpuH100Value;
69
+
70
+ const getParamsByConfigTypeCard = (value: FlavorsGpuValue) => {
71
+ const { 0: gpuCount, 1: vCpuCoreCount, 2: ramAmount } = value.split(' ');
72
+
73
+ return { gpuCount, vCpuCoreCount, ramAmount };
74
+ };
75
+
76
+ const generateCards = (cardsData: Record<string, string>, gpuType: GpuType) =>
77
+ Object.keys(cardsData).map(cardDataKey => {
78
+ const { gpuCount, vCpuCoreCount, ramAmount } = getParamsByConfigTypeCard(cardsData[cardDataKey] as FlavorsGpuValue);
79
+
80
+ return {
81
+ value: cardsData[cardDataKey],
82
+ label: gpuType,
83
+ description: (
84
+ <>
85
+ {gpuCount} GPU <br />
86
+ {vCpuCoreCount} vCPU <br />
87
+ {ramAmount} ГБ RAM
88
+ </>
89
+ ),
90
+ };
91
+ });
92
+
93
+ const getMinOsDiskSpace = (os: OsType) => {
94
+ const minSize5GbOs: OsType[] = [OsType.Fedora38, OsType.Ubuntu18_04, OsType.Debian10];
95
+ const minSize15GbOs: OsType[] = [OsType.Ubuntu24_04];
96
+
97
+ const minSizeByOsMap = {
98
+ 5: minSize5GbOs,
99
+ 15: minSize15GbOs,
100
+ };
101
+
102
+ const osMinDiskSizeEntry = Object.entries(minSizeByOsMap).find(osMinDiskSizeEntries => {
103
+ const { 1: osMap } = osMinDiskSizeEntries;
104
+
105
+ if (osMap.includes(os)) {
106
+ return true;
107
+ }
108
+ });
109
+
110
+ if (!osMinDiskSizeEntry) return 10;
111
+
112
+ return Number(osMinDiskSizeEntry[0]);
113
+ };
114
+
115
+ export const EVOLUTION_CLOUD_SERVER_GPU_FORM_CONFIG: FormConfig = {
116
+ ui: [['osType'], ['gpuType'], 'configTypeCard', ['systemDisk'], 'additionalOptions', 'networkIsNeeded'],
117
+ controls: {
118
+ osType: {
119
+ type: CONTROL.SelectSingle,
120
+ accessorKey: 'os',
121
+ defaultValue: OsType.Ubuntu22_04,
122
+ items: generateBaseItems(osItems, value => value.replace(/_/g, ' ')),
123
+ decoratorProps: {
124
+ label: 'Операционная система',
125
+ },
126
+ onChangeFn: (value: OsType, setValue) => {
127
+ const arr: [string, AnyType][] = [
128
+ ['os', value],
129
+ ['evs.systemDisk.diskSpace', getMinOsDiskSpace(value)],
130
+ ];
131
+
132
+ setValue(arr);
133
+ },
134
+ },
135
+ gpuType: {
136
+ type: CONTROL.SelectSingle,
137
+ accessorKey: 'gpuType',
138
+ defaultValue: GpuType.Tesla,
139
+ items: generateBaseItems(gpuTypeItems),
140
+ decoratorProps: {
141
+ label: 'Тип графического процессора',
142
+ },
143
+ uiProps: {
144
+ visible: false,
145
+ },
146
+ },
147
+ // значение не учитывается при подсчете data
148
+ configTypeCard: {
149
+ type: CONTROL.ToggleCards,
150
+ accessorKey: 'configTypeCard',
151
+ defaultValue: CardValuesTesla.GPU1_vCPU4_RAM64,
152
+ items: generateCards(CardValuesTesla, GpuType.Tesla),
153
+ decoratorProps: {
154
+ label: 'Конфигурация',
155
+ },
156
+ watchedControls: { gpuType: 'gpuType' },
157
+ onChangeFn: (value: FlavorGpuTeslaValue, setValue) => {
158
+ const { gpuCount, vCpuCoreCount, ramAmount } = getParamsByConfigTypeCard(value);
159
+
160
+ const valuesToSet = [
161
+ ['configTypeCard', value],
162
+ ['gpuCount', gpuCount],
163
+ ['vCpuCoreCount', vCpuCoreCount],
164
+ ['ramAmount', ramAmount],
165
+ ] as [string, AnyType][];
166
+
167
+ setValue(valuesToSet);
168
+ },
169
+ relateFn: ({ gpuType }: { gpuType: GpuType }) => ({
170
+ items:
171
+ gpuType === GpuType.H100
172
+ ? generateCards(CardValuesH100, GpuType.H100)
173
+ : generateCards(CardValuesTesla, GpuType.Tesla),
174
+ }),
175
+ },
176
+ gpuCount: {
177
+ type: CONTROL.Segmented,
178
+ accessorKey: 'gpuCount',
179
+ defaultValue: '1',
180
+ items: [],
181
+ decoratorProps: {
182
+ label: '',
183
+ },
184
+ uiProps: {
185
+ visible: false,
186
+ },
187
+ },
188
+ vCpuCoreCount: {
189
+ type: CONTROL.Segmented,
190
+ accessorKey: 'vCpuCoreCount',
191
+ defaultValue: '4',
192
+ items: [],
193
+ decoratorProps: {
194
+ label: '',
195
+ },
196
+ uiProps: {
197
+ visible: false,
198
+ },
199
+ },
200
+ ramAmount: {
201
+ type: CONTROL.Segmented,
202
+ accessorKey: 'ramAmount',
203
+ defaultValue: '64',
204
+ items: [],
205
+ decoratorProps: {
206
+ label: '',
207
+ },
208
+ uiProps: {
209
+ visible: false,
210
+ },
211
+ },
212
+ systemDisk: getDisk({
213
+ space: {
214
+ label: 'Диск',
215
+ accessorKey: 'evs.systemDisk.diskSpace',
216
+ defaultValue: 10,
217
+ uiProps: {
218
+ min: 10,
219
+ max: 4_096,
220
+ },
221
+ watchedControls: { os: 'os' },
222
+ relateFn: ({ os }: { os: OsType }) => ({
223
+ uiProps: {
224
+ min: getMinOsDiskSpace(os),
225
+ },
226
+ }),
227
+ },
228
+ specification: {
229
+ accessorKey: 'evs.systemDisk.specification',
230
+ defaultValue: 'SSD',
231
+ uiProps: {
232
+ disabled: true,
233
+ },
234
+ },
235
+ }),
236
+ additionalOptions: {
237
+ type: CONTROL.Object,
238
+ ui: ['alertAdditional', ['additionalDisks']],
239
+ controls: {
240
+ alertAdditional: {
241
+ type: 'alert',
242
+ uiProps: {
243
+ appearance: 'info',
244
+ outline: true,
245
+ description: 'Можно добавить до 7 дополнительных дисков',
246
+ },
247
+ accessorKey: 'addDisk',
248
+ },
249
+ additionalDisks: {
250
+ type: CONTROL.Array,
251
+ max: 7,
252
+ accessorKey: 'evs.additionalDisks',
253
+ addText: 'Добавить диск',
254
+ ui: ['disk'],
255
+ defaultValue: [],
256
+ controls: {
257
+ disk: getDisk({
258
+ space: {
259
+ label: 'Дополнительный диск',
260
+ accessorKey: 'diskSpace',
261
+ defaultValue: MinAdditionalDiskSize,
262
+ // TODO в текущем исполнении watchedControls и relateFn работают не корректно, поэтому в дальнейшем будут внесены правки, чтобы правильно отображать минимальные значения дисков
263
+ uiProps: {
264
+ min: MinAdditionalDiskSize,
265
+ max: 4_096,
266
+ },
267
+ },
268
+ specification: {
269
+ accessorKey: 'specification',
270
+ defaultValue: 'SSD',
271
+ uiProps: {
272
+ disabled: true,
273
+ },
274
+ },
275
+ }),
276
+ },
277
+ },
278
+ },
279
+ },
280
+ networkIsNeeded: {
281
+ type: CONTROL.Toggle,
282
+ defaultValue: false,
283
+ accessorKey: 'networkIsNeeded',
284
+ decoratorProps: {
285
+ label: 'Аренда публичного IP',
286
+ },
287
+ },
288
+ network: {
289
+ type: CONTROL.Object,
290
+ defaultValue: {
291
+ ipQuantity: 1,
292
+ bindingIpAddressesQuantity: 0,
293
+ publicGatewayQuantity: 0,
294
+ privateGatewayQuantity: 0,
295
+ },
296
+ ui: [],
297
+ controls: {},
298
+ visible: false,
299
+ },
300
+ },
301
+ };
@@ -0,0 +1,84 @@
1
+ import { CONTROL, FormConfig } from '../../../../components';
2
+ import { WORKING_HOURS_ITEMS, WorkingHoursSpecification } from '../../../../constants';
3
+ import { generateInstanceConfigItems, getMaxWorkingHoursAmount, getNumeralWord } from '../../../utils';
4
+
5
+ const configItems = generateInstanceConfigItems(
6
+ [
7
+ [0.1, 256],
8
+ [0.2, 512],
9
+ [0.3, 768],
10
+ [0.5, 1024],
11
+ ],
12
+ ['vCPU', 'МБ RAM'],
13
+ );
14
+
15
+ export const EVOLUTION_CONTAINER_APPS_CONFIG: FormConfig = {
16
+ ui: ['serviceAlert', ['config'], ['workingHours', 'workingHoursSpecification']],
17
+ controls: {
18
+ serviceAlert: {
19
+ type: CONTROL.Alert,
20
+ uiProps: {
21
+ description: 'Первые 120 vCPU и 480 ГБ RAM не тарифицируется каждый месяц в рамках free tier',
22
+ },
23
+ accessorKey: 'tarification',
24
+ },
25
+ config: {
26
+ type: CONTROL.SelectSingle,
27
+ accessorKey: 'config',
28
+ items: configItems,
29
+ defaultValue: '0.1 256',
30
+ decoratorProps: {
31
+ label: 'Конфигурация',
32
+ },
33
+ },
34
+ workingHours: {
35
+ type: CONTROL.Stepper,
36
+ accessorKey: 'workingHours',
37
+ defaultValue: 1,
38
+ uiProps: {
39
+ min: 1,
40
+ max: 1,
41
+ postfix: 'час',
42
+ },
43
+ decoratorProps: {
44
+ label: 'Время работы',
45
+ },
46
+ watchedControls: { period: 'workingHoursSpecification', workingHours: 'workingHours' },
47
+ relateFn: ({ period, workingHours }) => {
48
+ const maxWorkingHours = getMaxWorkingHoursAmount(period, {
49
+ hour: 1,
50
+ day: 24,
51
+ month: 744,
52
+ });
53
+ const isStepperDisabled = maxWorkingHours === 1;
54
+
55
+ return {
56
+ uiProps: {
57
+ min: 1,
58
+ max: maxWorkingHours,
59
+ showHint: !isStepperDisabled,
60
+ disabled: isStepperDisabled,
61
+ postfix: getNumeralWord(workingHours, ['час', 'часа', 'часов']),
62
+ },
63
+ };
64
+ },
65
+ },
66
+ workingHoursSpecification: {
67
+ type: CONTROL.SelectSingle,
68
+ accessorKey: 'workingHoursSpecification',
69
+ defaultValue: WorkingHoursSpecification.Hour,
70
+ items: WORKING_HOURS_ITEMS,
71
+ uiProps: {
72
+ showClearButton: false,
73
+ searchable: false,
74
+ },
75
+ decoratorProps: {
76
+ label: 'Период',
77
+ },
78
+ onChangePeriod: (period, setValue) => {
79
+ setValue([['workingHoursSpecification', period]]);
80
+ },
81
+ canChangeWholePricePeriod: true,
82
+ },
83
+ },
84
+ };
@@ -0,0 +1,29 @@
1
+ import { CONTROL, FormConfig } from '../../../../components';
2
+ import { generateInstanceConfigItems } from '../../../utils';
3
+
4
+ const configItems = generateInstanceConfigItems([[120, 480]]);
5
+
6
+ export const EVOLUTION_CONTAINER_APPS_FREE_TIER_CONFIG: FormConfig = {
7
+ ui: ['serviceAlert', ['config']],
8
+ controls: {
9
+ serviceAlert: {
10
+ type: CONTROL.Alert,
11
+ uiProps: {
12
+ description: 'Не тарифицируется каждый месяц',
13
+ },
14
+ accessorKey: 'tarification',
15
+ },
16
+ config: {
17
+ type: CONTROL.SelectSingle,
18
+ accessorKey: 'config',
19
+ items: configItems,
20
+ defaultValue: '120 480',
21
+ uiProps: {
22
+ disabled: true,
23
+ },
24
+ decoratorProps: {
25
+ label: 'Конфигурация',
26
+ },
27
+ },
28
+ },
29
+ };