bfg-common 1.5.869 → 1.5.871

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 (53) hide show
  1. package/assets/img/icons/icons-sprite-dark-5.svg +15 -2
  2. package/assets/img/icons/icons-sprite-light-5.svg +18 -5
  3. package/assets/localization/local_be.json +4 -1
  4. package/assets/localization/local_en.json +7 -4
  5. package/assets/localization/local_hy.json +4 -1
  6. package/assets/localization/local_kk.json +4 -1
  7. package/assets/localization/local_ru.json +10 -7
  8. package/assets/localization/local_zh.json +4 -1
  9. package/components/common/adapterManager/AdapterManagerNew.vue +39 -5
  10. package/components/common/adapterManager/addAdapterModal/AddAdapterModalNew.vue +3 -2
  11. package/components/common/adapterManager/addAdapterWarningModal/AddAdapterWarningModalNew.vue +3 -3
  12. package/components/common/adapterManager/ui/actions/moveDownAdapterButton/MoveDownAdapterButtonNew.vue +1 -0
  13. package/components/common/adapterManager/ui/actions/moveUpAdapterButton/MoveUpAdapterButtonNew.vue +1 -0
  14. package/components/common/adapterManager/ui/noSelectedAdapter/NoSelectedAdapterNew.vue +10 -4
  15. package/components/common/adapterManager/ui/secondTitle/SecondTitleNew.vue +15 -0
  16. package/components/common/adapterManager/ui/table/TableNew.vue +3 -2
  17. package/components/common/adapterManager/ui/table/adapters/AdaptersNew.vue +69 -36
  18. package/components/common/adapterManager/ui/table/header/HeaderNew.vue +5 -1
  19. package/components/common/diagramMain/modals/editSettings/tabs/NetworkProperties.vue +218 -218
  20. package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/common.ts +19 -19
  21. package/components/common/diagramMain/modals/viewSettings/info/InfoNew.vue +17 -0
  22. package/components/common/diagramMain/modals/viewSettings/viewSettings/ViewSettingsNew.vue +13 -8
  23. package/components/common/monitor/advanced/tools/chartOptionsModal/ChartOptionsModal.vue +1 -1
  24. package/components/common/monitor/advanced/tools/chartOptionsModal/metrics/lib/config/optionsMetrics.ts +6 -1
  25. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Cpu.vue +20 -4
  26. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/New.vue +2 -1
  27. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cpu/Old.vue +3 -2
  28. package/components/common/wizards/network/add/Add.vue +872 -872
  29. package/components/common/wizards/network/add/AddNew.vue +483 -476
  30. package/components/common/wizards/network/add/lib/config/initialData.ts +86 -86
  31. package/components/common/wizards/network/add/lib/config/selectSwitch.ts +237 -237
  32. package/components/common/wizards/network/add/lib/utils/utils.ts +9 -9
  33. package/components/common/wizards/network/add/mappers/mappers.ts +199 -199
  34. package/components/common/wizards/network/add/steps/connectionSettings/ConnectionSettings.vue +89 -84
  35. package/components/common/wizards/network/add/steps/connectionSettings/ConnectionSettingsNew.vue +3 -0
  36. package/components/common/wizards/network/add/steps/connectionSettings/ConnectionSettingsOld.vue +126 -126
  37. package/components/common/wizards/network/add/steps/createStandardSwitch/CreateStandardSwitch.vue +81 -81
  38. package/components/common/wizards/network/add/steps/ipFourSettings/IpFourSettings.vue +144 -144
  39. package/components/common/wizards/network/add/steps/ipFourSettings/IpFourSettingsNew.vue +48 -9
  40. package/components/common/wizards/network/add/steps/portProperties/PortProperties.vue +196 -193
  41. package/components/common/wizards/network/add/steps/portProperties/PortPropertiesNew.vue +312 -294
  42. package/components/common/wizards/network/add/steps/readyComplete/ReadyComplete.vue +24 -24
  43. package/components/common/wizards/network/add/steps/selectConnectionType/SelectConnectionType.vue +34 -34
  44. package/components/common/wizards/network/add/steps/selectTargetDevice/SelectTargetDevice.vue +187 -187
  45. package/components/common/wizards/network/add/steps/selectTargetDevice/SelectTargetDeviceNew.vue +455 -455
  46. package/components/common/wizards/network/add/steps/selectTargetDevice/modals/SelectNetwork.vue +63 -63
  47. package/components/common/wizards/network/add/steps/selectTargetDevice/modals/SelectStandardSwitch.vue +63 -63
  48. package/components/common/wizards/network/add/steps/selectTargetDevice/modals/SelectSwitch.vue +63 -63
  49. package/components/common/wizards/network/add/steps/selectTargetDevice/modals/new/SelectSwitch.vue +180 -180
  50. package/components/common/wizards/network/add/validations/common.ts +30 -30
  51. package/components/common/wizards/network/add/validations/networkValidation.ts +2 -2
  52. package/components/common/wizards/network/add/validations/portProperties.ts +115 -115
  53. package/package.json +2 -2
@@ -1,872 +1,872 @@
1
- <template>
2
- <div>
3
- <component
4
- :is="currentComponent"
5
- v-model:connection-type="connectionTypeLocal"
6
- :show="props.show"
7
- :wizard="wizard"
8
- :selected-scheme="selectedScheme"
9
- :wizard-title="title"
10
- :host-name="hostNameLocal"
11
- :project="props.project"
12
- :target-device="targetDevice"
13
- :standard-switches-initial="props.standardSwitchesInitial"
14
- :alert-messages="alertMessages"
15
- :selected-standard-switch-id="props.selectedStandardSwitchId"
16
- :selected-switch-id="props.selectedSwitchId"
17
- :free-adapters="props.freeAdapters"
18
- :added-adapters="addedAdapters"
19
- :core-adapters="coreAdapters"
20
- :adapter-status="adapterStatus"
21
- :adapters="props.adapters"
22
- :is-show-no-connected-active-adapters-modal="
23
- isShowNoConnectedActiveAdaptersModal
24
- "
25
- :is-show-no-active-adapters-modal="isShowNoActiveAdaptersModal"
26
- :is-dark-mode="props.isDarkMode"
27
- :port-properties="portProperties"
28
- :mtu-from-switch="mtuFromSwitch"
29
- :tcp-stacks="props.tcpStacks"
30
- :ip-four-settings="ipFourSettings"
31
- :gateway-flag="gatewayFlag"
32
- :connection-settings="connectionSettings"
33
- :ready-complete-fields="readyCompleteFields"
34
- :is-get-existing-switches-loading="props.isGetExistingSwitchesLoading"
35
- :is-get-tcp-stack-loading="props.isGetTcpStackLoading"
36
- @change-connection-settings="onChangeConnectionSettings"
37
- @change-gateway-flag="onChangeGatewayFlag"
38
- @change-ip-four-settings="onChangeIpFourSettings"
39
- @change-port-properties="onChangePortProperties"
40
- @get-free-adapters="onGetFreeAdapters"
41
- @change-added-adapters="onChangeAddedAdapters"
42
- @change-adapter-status="onChangeAdapterStatus"
43
- @confirm-no-active-adapters-modal="onConfirmNoActiveAdaptersModal"
44
- @hide-no-connected-active-adapters-modal="
45
- onHideNoConnectedActiveAdaptersModal
46
- "
47
- @hide-no-active-adapters-modal="onHideNoActiveAdaptersModal"
48
- @hide-alert="onHideAlert"
49
- @change-target-device="onChangeTargetDevice"
50
- @change-steps="onChangeSteps"
51
- @hide="onHideAddNetworkingModal"
52
- @submit="onSubmit"
53
- />
54
- </div>
55
- </template>
56
-
57
- <script setup lang="ts">
58
- import type {
59
- UI_I_ValidationReturn,
60
- UI_I_WizardStep,
61
- UI_I_WizardStepNavigation,
62
- } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
63
- import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
64
- import type {
65
- UI_I_ArbitraryObject,
66
- UI_I_Localization,
67
- UI_I_ItemsWithTotalCounts,
68
- } from '~/lib/models/interfaces'
69
- import type { UI_T_Project } from '~/lib/models/types'
70
- import type {
71
- UI_I_PortProperties,
72
- UI_I_IpFourSettings,
73
- UI_I_ConnectionSettings,
74
- UI_I_TargetDevice,
75
- UI_I_Switch,
76
- UI_I_ReadyCompleteFields,
77
- UI_I_AddNetworkingSecondOrThirdSchemeDataSend,
78
- UI_I_AddNetworkingZeroOrFirstSchemeDataSend,
79
- UI_I_AddNetworkingFourthOrFifthSchemeDataSend,
80
- // UI_I_AddNetworkingEmits,
81
- UI_I_TCPStack,
82
- } from '~/components/common/wizards/network/add/lib/models/interfaces'
83
- import type {
84
- UI_I_Adapter,
85
- UI_I_AdapterStatus,
86
- UI_I_SwitchAdapterItem,
87
- UI_I_DiagramData,
88
- API_UI_I_SwitchItem,
89
- UI_I_AvailableAdapters,
90
- } from '~/components/common/diagramMain/lib/models/interfaces'
91
- import { getAvailableAdapters } from '~/components/common/diagramMain/lib/utils/utils'
92
- import { UI_E_ValidationFields } from '~/components/common/wizards/network/add/lib/models/enums'
93
- import { getVlanId } from '~/components/common/wizards/network/add/lib/utils/utils'
94
- import {
95
- createZeroSchemeReadyCompleteFunc,
96
- createFirstSchemeReadyCompleteFunc,
97
- createSecondSchemeReadyCompleteFunc,
98
- createThirdSchemeReadyCompleteFunc,
99
- createFourthSchemeReadyCompleteFunc,
100
- createFifthSchemeReadyCompleteFunc,
101
- stepsSchemeInitial,
102
- stepsFunc,
103
- connectionSettingsInitial,
104
- portPropertiesInitial,
105
- ipFourSettingsInitial,
106
- targetDeviceInitialFunc,
107
- addNetworkingZeroOrFirstSchemeDataFunc,
108
- addNetworkingSecondOrThirdSchemeDataFunc,
109
- addNetworkingFourthOrFifthSchemeDataFunc,
110
- } from '~/components/common/wizards/network/add/lib/config/config'
111
- import {
112
- checkTargetDeviceSync,
113
- checkAdaptersSync,
114
- checkPortPropertiesSync,
115
- checkIpFourSettingsSync,
116
- checkConnectionSettingsSync,
117
- checkNetworkAsync,
118
- } from '~/components/common/wizards/network/add/validations/validations'
119
-
120
- const props = withDefaults(
121
- defineProps<{
122
- show: boolean
123
- adapters: UI_I_ItemsWithTotalCounts<UI_I_SwitchAdapterItem>
124
- standardSwitchesInitial?: UI_I_Switch[]
125
- freeAdapters?: UI_I_Adapter[]
126
- project?: UI_T_Project
127
- isDarkMode?: boolean
128
- selectedStandardSwitchId?: string
129
- selectedSwitchId?: string
130
- tcpStacks?: UI_I_TCPStack[]
131
- diagramsData?: UI_I_DiagramData[]
132
- isNetworkingLoading?: boolean
133
- isGetExistingSwitchesLoading?: boolean
134
- isGetTcpStackLoading?: boolean
135
- hostName?: string
136
- }>(),
137
- {
138
- standardSwitchesInitial: () => [],
139
- freeAdapters: () => [],
140
- project: 'procurator',
141
- isDarkMode: false,
142
- selectedStandardSwitchId: '',
143
- selectedSwitchId: '',
144
- tcpStacks: () => [],
145
- diagramsData: [],
146
- isNetworkingLoading: false,
147
- isGetExistingSwitchesLoading: false,
148
- isGetTcpStackLoading: false,
149
- }
150
- )
151
-
152
- const emits = defineEmits<{
153
- (event: 'hide'): void
154
- (
155
- event: 'add-networking-data-validate',
156
- data:
157
- | UI_I_AddNetworkingSecondOrThirdSchemeDataSend
158
- | UI_I_AddNetworkingZeroOrFirstSchemeDataSend
159
- | UI_I_AddNetworkingFourthOrFifthSchemeDataSend
160
- | API_UI_I_SwitchItem,
161
- type: string,
162
- setValidation: (err_arg: UI_I_ArbitraryObject<string>) => void
163
- ): void
164
- (
165
- event: 'send-add-networking-data',
166
- data:
167
- | UI_I_AddNetworkingSecondOrThirdSchemeDataSend
168
- | UI_I_AddNetworkingZeroOrFirstSchemeDataSend
169
- | UI_I_AddNetworkingFourthOrFifthSchemeDataSend
170
- | API_UI_I_SwitchItem,
171
- type: string,
172
- hideModal: () => void
173
- ): void
174
- (event: 'get-existing-standard-switches'): void
175
- (event: 'get-free-adapters', cb: () => void): void
176
- (
177
- event: 'check-network-label',
178
- label: string,
179
- sendMessage: (message: string) => void
180
- ): void
181
- (event: 'get-tcp-stacks'): void
182
- }>()
183
-
184
- const { $store }: any = useNuxtApp()
185
-
186
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
187
-
188
- const currentComponent = computed(() =>
189
- isNewView.value
190
- ? defineAsyncComponent(() => import('./AddNew.vue'))
191
- : defineAsyncComponent(() => import('./AddOld.vue'))
192
- )
193
-
194
- const localization = computed<UI_I_Localization>(() => useLocal())
195
-
196
- const localHostName = ref<string>('')
197
- const hostNameLocal = computed<string>(
198
- () => props.hostName || localHostName.value
199
- )
200
-
201
- const title = computed<string>(
202
- () => `${hostNameLocal.value} - ${localization.value.common.addNetworking}`
203
- )
204
-
205
- const wizard: Wizard = new Wizard(
206
- stepsFunc(localization.value),
207
- stepsSchemeInitial
208
- )
209
-
210
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
211
- const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
212
-
213
- const readyCompleteFields = ref<UI_I_ReadyCompleteFields[]>([])
214
-
215
- const globalPermissions = computed<any>(
216
- () => $store.getters['globalPermissions/getPermissions']
217
- )
218
-
219
- // Step's content data (connectionType)
220
- const connectionType = ref<string>(
221
- globalPermissions.value === undefined
222
- ? '0'
223
- : !globalPermissions.value?.['Networks.CreateSysx'] &&
224
- !globalPermissions.value?.['Networks.CreatePortGroup']
225
- ? '2'
226
- : !globalPermissions.value?.['Networks.CreateSysx']
227
- ? '1'
228
- : '0'
229
- )
230
-
231
- const connectionTypeLocal = computed<string>({
232
- get() {
233
- return connectionType.value
234
- },
235
- set(newValue: string) {
236
- wizard.resetAfterSelected()
237
- connectionType.value = newValue
238
- targetDevice.value.standardSwitch = props.selectedStandardSwitchId
239
- targetDevice.value.switch = props.selectedSwitchId
240
- },
241
- })
242
-
243
- // Step's content data (createStandardSwitch)
244
- const addedAdapters = ref<string[]>([])
245
- const coreAdapters = ref<string[]>([])
246
-
247
- const onChangeAddedAdapters = (addedAdaptersNew: string[]): void => {
248
- addedAdapters.value = addedAdaptersNew
249
- }
250
-
251
- const adapterStatus = ref<UI_I_AdapterStatus>({
252
- active: [],
253
- standby: [],
254
- unused: [],
255
- })
256
- const onChangeAdapterStatus = (adapterStatusNew: UI_I_AdapterStatus): void => {
257
- adapterStatus.value = adapterStatusNew
258
- }
259
-
260
- // Step's content data and changers (targetDevice)
261
- const targetDevice = ref<UI_I_TargetDevice>(
262
- useDeepCopy(
263
- targetDeviceInitialFunc(globalPermissions.value?.['Networks.UpdateSwitch'])
264
- )
265
- )
266
- const mtuFromSwitch = ref<number>(1500)
267
-
268
- const onChangeTargetDevice = (newTargetDevice: UI_I_TargetDevice): void => {
269
- const oldTargetDeviceSelected = useDeepCopy(targetDevice.value).selected
270
- const newTargetDeviceSelected = newTargetDevice.selected
271
-
272
- if (oldTargetDeviceSelected !== newTargetDeviceSelected) {
273
- wizard.resetAfterSelected()
274
- }
275
-
276
- const selectedSwitch = props.standardSwitchesInitial.find(
277
- (currentSwitch: UI_I_Switch) =>
278
- newTargetDevice.standardSwitch === currentSwitch.name
279
- )
280
-
281
- if (newTargetDeviceSelected === '1' && selectedSwitch) {
282
- mtuFromSwitch.value = selectedSwitch?.mtu || 1500
283
- }
284
- if (newTargetDeviceSelected === '3') {
285
- mtuFromSwitch.value = newTargetDevice.mtu || 1500
286
- }
287
-
288
- targetDevice.value = useDeepCopy(newTargetDevice)
289
- }
290
-
291
- // Step's content data and changers (portProperties)
292
- const portProperties = ref<UI_I_PortProperties>(
293
- useDeepCopy(portPropertiesInitial(localization.value))
294
- )
295
- const onChangePortProperties = (newFields: UI_I_PortProperties): void => {
296
- if (portProperties.value.tcp !== newFields.tcp) {
297
- ipFourSettings.value.static.defaultGateway.value =
298
- props.tcpStacks?.find((tcp: UI_I_TCPStack) => tcp.id === newFields.tcp)
299
- .gateway || ''
300
- }
301
- portProperties.value = newFields
302
- }
303
-
304
- // Step's content data and changers (ipFourSettings)
305
- const ipFourSettings = ref<UI_I_IpFourSettings>(ipFourSettingsInitial)
306
- const onChangeIpFourSettings = (newFields: UI_I_IpFourSettings): void => {
307
- ipFourSettings.value = newFields
308
- }
309
-
310
- const gatewayFlag = ref<boolean>(false)
311
- const onChangeGatewayFlag = (newValue: boolean) => {
312
- gatewayFlag.value = newValue
313
- }
314
-
315
- // Step's content data and changers (connectionSettings)
316
- const connectionSettings = ref<UI_I_ConnectionSettings>(
317
- connectionSettingsInitial(localization.value)
318
- )
319
- const onChangeConnectionSettings = (
320
- newFields: UI_I_ConnectionSettings
321
- ): void => {
322
- connectionSettings.value = newFields
323
- }
324
-
325
- const onHideAlert = (stepId: number, field?: string): void => {
326
- wizard.hideAlertMessagesByStepId(stepId, field)
327
- }
328
-
329
- let flagSwitch = ''
330
-
331
- // Choosing Scheme
332
- watch(
333
- [connectionTypeLocal, targetDevice],
334
- (
335
- newValues: [string, UI_I_TargetDevice],
336
- oldValues: [string, UI_I_TargetDevice]
337
- ) => {
338
- const newCT = newValues[0] // -> newConnectionType
339
- const oldCT = oldValues[0] // -> oldConnectionType
340
- const newTD = newValues[1] // -> newTargetDevice
341
- const oldTD = oldValues[1] // -> oldTargetDevice
342
-
343
- if (!oldTD || oldTD.selected !== newTD.selected) {
344
- flagSwitch = ''
345
- addedAdapters.value = []
346
- adapterStatus.value = {
347
- active: [],
348
- standby: [],
349
- unused: [],
350
- }
351
- }
352
- if (newCT !== oldCT) {
353
- newCT === '0' && props.selectedStandardSwitchId
354
- ? (targetDevice.value.selected = '1')
355
- : (targetDevice.value.selected = '0')
356
- newCT === '1' && (targetDevice.value.selected = '1')
357
- newCT === '2' &&
358
- (globalPermissions.value === undefined ||
359
- globalPermissions.value?.['Networks.UpdateSwitch']
360
- ? (targetDevice.value.selected = '2')
361
- : (targetDevice.value.selected = '3'))
362
- }
363
- if (newCT === '0') {
364
- ;(newTD.selected === '0' || newTD.selected === '1') &&
365
- wizard.changeScheme(0)
366
- newTD.selected === '3' && wizard.changeScheme(1)
367
- }
368
- if (newCT === '1') {
369
- newTD.selected === '1' && wizard.changeScheme(2)
370
- newTD.selected === '3' && wizard.changeScheme(3)
371
- }
372
- if (newCT === '2') {
373
- newTD.selected === '2' && wizard.changeScheme(4)
374
- newTD.selected === '3' && wizard.changeScheme(5)
375
- }
376
- },
377
- { deep: true, immediate: true }
378
- )
379
-
380
- const onGetExistingStandardSwitches = (): void => {
381
- emits('get-existing-standard-switches')
382
- }
383
-
384
- const onGetTcpStacks = (): void => {
385
- emits('get-tcp-stacks')
386
- }
387
-
388
- watch(
389
- () => wizard.selectedStepId,
390
- (newSelectedStep: number) => {
391
- if (newSelectedStep === 1) {
392
- onGetExistingStandardSwitches()
393
- }
394
- if (newSelectedStep === 3) {
395
- onGetTcpStacks()
396
- }
397
- if (newSelectedStep === 6 && flagSwitch !== targetDevice.value.switch) {
398
- const nics: UI_I_AdapterStatus = props.standardSwitchesInitial.find(
399
- (currentSwitch: UI_I_Switch) =>
400
- currentSwitch.id === targetDevice.value.switch
401
- ).nics
402
-
403
- const availableAdapters: UI_I_AvailableAdapters = getAvailableAdapters(
404
- props.adapters,
405
- nics
406
- )
407
-
408
- adapterStatus.value = {
409
- active: availableAdapters.activeAdapters || [],
410
- standby: availableAdapters.standbyAdapters || [],
411
- unused: availableAdapters.unusedAdapters || [],
412
- }
413
- coreAdapters.value = [
414
- ...adapterStatus.value.active,
415
- ...adapterStatus.value.standby,
416
- ...adapterStatus.value.unused,
417
- ]
418
- flagSwitch = targetDevice.value.switch
419
- }
420
-
421
- if (newSelectedStep !== 7) return // If last step
422
- if (wizard.isSelectedScheme(0)) {
423
- readyCompleteFields.value = createZeroSchemeReadyCompleteFunc(
424
- isNewView.value,
425
- targetDevice.value,
426
- portProperties.value,
427
- ipFourSettings.value,
428
- localization.value
429
- )
430
- return
431
- }
432
-
433
- if (wizard.isSelectedScheme(1)) {
434
- readyCompleteFields.value = createFirstSchemeReadyCompleteFunc(
435
- isNewView.value,
436
- targetDevice.value,
437
- portProperties.value,
438
- ipFourSettings.value,
439
- addedAdapters.value,
440
- localization.value
441
- )
442
- return
443
- }
444
- if (wizard.isSelectedScheme(2)) {
445
- readyCompleteFields.value = createSecondSchemeReadyCompleteFunc(
446
- isNewView.value,
447
- connectionSettings.value,
448
- targetDevice.value,
449
- localization.value
450
- )
451
- return
452
- }
453
- if (wizard.isSelectedScheme(3)) {
454
- readyCompleteFields.value = createThirdSchemeReadyCompleteFunc(
455
- isNewView.value,
456
- connectionSettings.value,
457
- targetDevice.value,
458
- addedAdapters.value,
459
- localization.value
460
- )
461
- return
462
- }
463
- if (wizard.isSelectedScheme(4)) {
464
- readyCompleteFields.value = createFourthSchemeReadyCompleteFunc(
465
- isNewView.value,
466
- targetDevice.value.switch,
467
- props.diagramsData,
468
- adapterStatus.value,
469
- localization.value
470
- )
471
- return
472
- }
473
- if (wizard.isSelectedScheme(5)) {
474
- readyCompleteFields.value = createFifthSchemeReadyCompleteFunc(
475
- isNewView.value,
476
- targetDevice.value,
477
- adapterStatus.value,
478
- localization.value
479
- )
480
- }
481
- }
482
- )
483
-
484
- // Reset data
485
- const reset = (): void => {
486
- wizard.reset()
487
- connectionTypeLocal.value = '0'
488
- targetDevice.value = useDeepCopy(
489
- targetDeviceInitialFunc(globalPermissions.value?.['Networks.UpdateSwitch'])
490
- )
491
- connectionSettings.value = useDeepCopy(
492
- connectionSettingsInitial(localization.value)
493
- )
494
- portProperties.value = useDeepCopy(portPropertiesInitial(localization.value))
495
- ipFourSettings.value = useDeepCopy(ipFourSettingsInitial)
496
- coreAdapters.value = []
497
- addedAdapters.value = []
498
- adapterStatus.value = {
499
- active: [],
500
- standby: [],
501
- unused: [],
502
- }
503
- }
504
-
505
- const isShowNoConnectedActiveAdaptersModal = ref(false)
506
- const isShowNoActiveAdaptersModal = ref(false)
507
-
508
- const showNoConnectedActiveAdaptersModal = (): void => {
509
- isShowNoConnectedActiveAdaptersModal.value = true
510
- }
511
- const onHideNoConnectedActiveAdaptersModal = (): void => {
512
- isShowNoConnectedActiveAdaptersModal.value = false
513
- }
514
- const showNoActiveAdaptersModal = (): void => {
515
- isShowNoActiveAdaptersModal.value = true
516
- }
517
- const onHideNoActiveAdaptersModal = (): void => {
518
- isShowNoActiveAdaptersModal.value = false
519
- }
520
-
521
- const onConfirmNoActiveAdaptersModal = (): void => {
522
- onHideNoConnectedActiveAdaptersModal()
523
- onHideNoActiveAdaptersModal()
524
- if (wizard.waitingStepId === 7) {
525
- wizard.changeSteps(
526
- wizard.selectedStepData(
527
- wizard.stepsInSelectedSchemeWithStatus.value.find(
528
- (step: UI_I_WizardStepNavigation) => step.id === 7
529
- )
530
- ),
531
- validationFunc,
532
- props.project === 'sphere' ? null : finalValidationFunc,
533
- true
534
- )
535
- wizard.waitingStepId = -1
536
- return
537
- }
538
- wizard.selectStepHard(wizard.waitingStepId)
539
- }
540
-
541
- const onGetFreeAdapters = (showModal: () => void): void => {
542
- emits('get-free-adapters', showModal)
543
- }
544
-
545
- const checkFinal = async (): Promise<UI_I_ArbitraryObject<string>> => {
546
- let data:
547
- | UI_I_AddNetworkingSecondOrThirdSchemeDataSend
548
- | UI_I_AddNetworkingZeroOrFirstSchemeDataSend
549
- | UI_I_AddNetworkingFourthOrFifthSchemeDataSend
550
- | API_UI_I_SwitchItem
551
- | null = null
552
-
553
- let type: 'network' | 'vmkernel' | 'adapter' | 'new-switch'
554
-
555
- if (wizard.isSelectedScheme(0) || wizard.isSelectedScheme(1)) {
556
- const vlan = getVlanId(portProperties.value.vlanId, localization.value)
557
-
558
- data = addNetworkingZeroOrFirstSchemeDataFunc(
559
- targetDevice.value,
560
- Number(vlan),
561
- portProperties.value,
562
- ipFourSettings.value,
563
- wizard.isSelectedScheme(1),
564
- adapterStatus.value
565
- )
566
-
567
- type = 'vmkernel'
568
- }
569
-
570
- if (wizard.isSelectedScheme(2) || wizard.isSelectedScheme(3)) {
571
- const vlan = getVlanId(connectionSettings.value.vlanId, localization.value)
572
-
573
- data = addNetworkingSecondOrThirdSchemeDataFunc(
574
- connectionSettings.value,
575
- targetDevice.value,
576
- Number(vlan),
577
- wizard.isSelectedScheme(2),
578
- adapterStatus.value
579
- )
580
-
581
- type = 'network'
582
- }
583
-
584
- if (wizard.isSelectedScheme(4) || wizard.isSelectedScheme(5)) {
585
- data = addNetworkingFourthOrFifthSchemeDataFunc(
586
- targetDevice.value.switch,
587
- wizard.isSelectedScheme(4),
588
- adapterStatus.value,
589
- props.diagramsData,
590
- targetDevice.value.mtu
591
- )
592
-
593
- type = wizard.isSelectedScheme(4) ? 'adapter' : 'new-switch'
594
- }
595
-
596
- return new Promise((resolve, _reject) =>
597
- emits(
598
- 'add-networking-data-validate',
599
- data,
600
- type,
601
- (err_arg: UI_I_ArbitraryObject<string>): void => {
602
- resolve(err_arg)
603
- }
604
- )
605
- )
606
- }
607
-
608
- const finalValidationFunc = async (
609
- value: UI_I_WizardStep[]
610
- ): Promise<UI_I_ValidationReturn> => {
611
- let stepHasError = false
612
-
613
- const validationFields: {
614
- [key: string]: string
615
- } = await checkFinal()
616
-
617
- for (const fieldName in validationFields) {
618
- const stepId = wizard.getStepIdByFieldName(fieldName)
619
-
620
- if (stepId !== -1) {
621
- stepHasError = wizard.setValidation(stepId, fieldName, {
622
- fieldMessage: validationFields[fieldName],
623
- alertMessage: validationFields[fieldName],
624
- })
625
- }
626
- }
627
-
628
- return {
629
- stepHasError,
630
- newValue: value,
631
- }
632
- }
633
-
634
- const validationFunc = async (
635
- value: UI_I_WizardStep[],
636
- currentStep: UI_I_WizardStep,
637
- nextStep: UI_I_WizardStep
638
- ): Promise<UI_I_ValidationReturn> => {
639
- let stepHasError = false
640
- let stepShouldStop = {
641
- ifOnCurrentStep: false,
642
- ifFromAnyStep: false,
643
- stoppageStepId: -1,
644
- }
645
-
646
- if (wizard.isValidateForStep(1, currentStep.id, nextStep.id)) {
647
- const targetDeviceValidation = checkTargetDeviceSync(
648
- localization.value,
649
- targetDevice.value,
650
- wizard,
651
- value,
652
- isNewView.value
653
- )
654
-
655
- value = targetDeviceValidation.newValue
656
-
657
- stepHasError = stepHasError || targetDeviceValidation.stepHasError
658
- }
659
-
660
- if (wizard.isValidateForStep(2, currentStep.id, nextStep.id)) {
661
- wizard.waitingStepId = nextStep.id
662
-
663
- const adapterValidation = checkAdaptersSync(
664
- localization.value,
665
- adapterStatus.value,
666
- value,
667
- currentStep.id,
668
- nextStep.id,
669
- props.freeAdapters,
670
- showNoActiveAdaptersModal,
671
- showNoConnectedActiveAdaptersModal,
672
- 2
673
- )
674
-
675
- value = adapterValidation.newValue
676
-
677
- stepShouldStop = adapterValidation.stepShouldStop || stepShouldStop
678
-
679
- stepHasError = stepHasError || adapterValidation.stepHasError
680
- }
681
-
682
- if (wizard.isValidateForStep(3, currentStep.id, nextStep.id)) {
683
- const labelValidation = await checkNetworkAsync(
684
- value,
685
- portProperties.value.networkLabel,
686
- 3,
687
- UI_E_ValidationFields.PORT_PROPERTIES_NETWORK,
688
- emits,
689
- localization.value,
690
- wizard
691
- )
692
-
693
- value = labelValidation.newValue
694
-
695
- const portPropertiesValidation = checkPortPropertiesSync(
696
- localization.value,
697
- portProperties.value,
698
- wizard,
699
- value
700
- )
701
-
702
- value = portPropertiesValidation.newValue
703
-
704
- stepHasError =
705
- stepHasError ||
706
- labelValidation.stepHasError ||
707
- portPropertiesValidation.stepHasError
708
- }
709
-
710
- if (wizard.isValidateForStep(4, currentStep.id, nextStep.id)) {
711
- const ipValidation = checkIpFourSettingsSync(
712
- localization.value,
713
- ipFourSettings.value,
714
- wizard,
715
- value
716
- )
717
-
718
- value = ipValidation.newValue
719
-
720
- stepHasError = stepHasError || ipValidation.stepHasError
721
- }
722
-
723
- if (wizard.isValidateForStep(5, currentStep.id, nextStep.id)) {
724
- const labelValidation = await checkNetworkAsync(
725
- value,
726
- connectionSettings.value.networkLabel,
727
- 5,
728
- UI_E_ValidationFields.CONNECTION_SETTINGS_NETWORK,
729
- emits,
730
- localization.value,
731
- wizard
732
- )
733
-
734
- value = labelValidation.newValue
735
-
736
- const connectionSettingsValidation = checkConnectionSettingsSync(
737
- localization.value,
738
- connectionSettings.value,
739
- wizard,
740
- value
741
- )
742
-
743
- value = connectionSettingsValidation.newValue
744
-
745
- stepHasError =
746
- stepHasError ||
747
- labelValidation.stepHasError ||
748
- connectionSettingsValidation.stepHasError
749
- }
750
-
751
- if (wizard.isValidateForStep(6, currentStep.id, nextStep.id)) {
752
- wizard.waitingStepId = nextStep.id
753
-
754
- const adapterValidation = checkAdaptersSync(
755
- localization.value,
756
- adapterStatus.value,
757
- value,
758
- currentStep.id,
759
- nextStep.id,
760
- props.adapters.items,
761
- showNoActiveAdaptersModal,
762
- showNoConnectedActiveAdaptersModal,
763
- 6
764
- )
765
-
766
- value = adapterValidation.newValue
767
-
768
- stepShouldStop = adapterValidation.stepShouldStop || stepShouldStop
769
-
770
- stepHasError = stepHasError || adapterValidation.stepHasError
771
- }
772
-
773
- return {
774
- newValue: value,
775
- stepHasError,
776
- stepShouldStop,
777
- }
778
- }
779
-
780
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> =>
781
- wizard.changeSteps(value, validationFunc, finalValidationFunc)
782
-
783
- const onHideAddNetworkingModal = (): void => {
784
- emits('hide')
785
- reset()
786
- }
787
-
788
- const onSubmit = async (): Promise<void> => {
789
- let data:
790
- | UI_I_AddNetworkingSecondOrThirdSchemeDataSend
791
- | UI_I_AddNetworkingZeroOrFirstSchemeDataSend
792
- | UI_I_AddNetworkingFourthOrFifthSchemeDataSend
793
- | API_UI_I_SwitchItem
794
- | null = null
795
-
796
- let type: 'network' | 'vmkernel' | 'adapter' | 'new-switch' = 'network'
797
-
798
- if (wizard.isSelectedScheme(0) || wizard.isSelectedScheme(1)) {
799
- const vlan = getVlanId(portProperties.value.vlanId, localization.value)
800
- type = 'vmkernel'
801
- data = addNetworkingZeroOrFirstSchemeDataFunc(
802
- targetDevice.value,
803
- Number(vlan),
804
- portProperties.value,
805
- ipFourSettings.value,
806
- wizard.isSelectedScheme(1),
807
- adapterStatus.value
808
- )
809
- }
810
-
811
- if (wizard.isSelectedScheme(2) || wizard.isSelectedScheme(3)) {
812
- const vlan = getVlanId(connectionSettings.value.vlanId, localization.value)
813
- type = 'network'
814
- data = addNetworkingSecondOrThirdSchemeDataFunc(
815
- connectionSettings.value,
816
- targetDevice.value,
817
- Number(vlan),
818
- wizard.isSelectedScheme(2),
819
- adapterStatus.value
820
- )
821
- }
822
-
823
- if (wizard.isSelectedScheme(4) || wizard.isSelectedScheme(5)) {
824
- type = wizard.isSelectedScheme(4) ? 'adapter' : 'new-switch'
825
- data = addNetworkingFourthOrFifthSchemeDataFunc(
826
- targetDevice.value.switch,
827
- wizard.isSelectedScheme(4),
828
- adapterStatus.value,
829
- props.diagramsData,
830
- targetDevice.value.mtu
831
- )
832
- }
833
-
834
- data &&
835
- emits('send-add-networking-data', data, type, onHideAddNetworkingModal)
836
- }
837
-
838
- onMounted(() => {
839
- localHostName.value = location.hostname
840
- })
841
-
842
- watch(
843
- [
844
- () => props.isNetworkingLoading,
845
- () => props.isGetExistingSwitchesLoading,
846
- () => props.isGetTcpStackLoading,
847
- ],
848
- (newValue: [boolean, boolean, boolean]) => {
849
- const wizardLoading = isNewView.value
850
- ? newValue[0]
851
- : newValue.some((loading: boolean) => loading)
852
-
853
- wizard.setLoader(wizardLoading)
854
- },
855
- {
856
- immediate: true,
857
- deep: true,
858
- }
859
- )
860
-
861
- watch(
862
- props.tcpStacks,
863
- (newValue: UI_I_TCPStack[]) => {
864
- portProperties.value.tcp = newValue?.[0]?.id || ''
865
- ipFourSettings.value.static.defaultGateway.value =
866
- newValue?.[0]?.gateway || ''
867
- },
868
- { deep: true }
869
- )
870
- </script>
871
-
872
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <div>
3
+ <component
4
+ :is="currentComponent"
5
+ v-model:connection-type="connectionTypeLocal"
6
+ :show="props.show"
7
+ :wizard="wizard"
8
+ :selected-scheme="selectedScheme"
9
+ :wizard-title="title"
10
+ :host-name="hostNameLocal"
11
+ :project="props.project"
12
+ :target-device="targetDevice"
13
+ :standard-switches-initial="props.standardSwitchesInitial"
14
+ :alert-messages="alertMessages"
15
+ :selected-standard-switch-id="props.selectedStandardSwitchId"
16
+ :selected-switch-id="props.selectedSwitchId"
17
+ :free-adapters="props.freeAdapters"
18
+ :added-adapters="addedAdapters"
19
+ :core-adapters="coreAdapters"
20
+ :adapter-status="adapterStatus"
21
+ :adapters="props.adapters"
22
+ :is-show-no-connected-active-adapters-modal="
23
+ isShowNoConnectedActiveAdaptersModal
24
+ "
25
+ :is-show-no-active-adapters-modal="isShowNoActiveAdaptersModal"
26
+ :is-dark-mode="props.isDarkMode"
27
+ :port-properties="portProperties"
28
+ :mtu-from-switch="mtuFromSwitch"
29
+ :tcp-stacks="props.tcpStacks"
30
+ :ip-four-settings="ipFourSettings"
31
+ :gateway-flag="gatewayFlag"
32
+ :connection-settings="connectionSettings"
33
+ :ready-complete-fields="readyCompleteFields"
34
+ :is-get-existing-switches-loading="props.isGetExistingSwitchesLoading"
35
+ :is-get-tcp-stack-loading="props.isGetTcpStackLoading"
36
+ @change-connection-settings="onChangeConnectionSettings"
37
+ @change-gateway-flag="onChangeGatewayFlag"
38
+ @change-ip-four-settings="onChangeIpFourSettings"
39
+ @change-port-properties="onChangePortProperties"
40
+ @get-free-adapters="onGetFreeAdapters"
41
+ @change-added-adapters="onChangeAddedAdapters"
42
+ @change-adapter-status="onChangeAdapterStatus"
43
+ @confirm-no-active-adapters-modal="onConfirmNoActiveAdaptersModal"
44
+ @hide-no-connected-active-adapters-modal="
45
+ onHideNoConnectedActiveAdaptersModal
46
+ "
47
+ @hide-no-active-adapters-modal="onHideNoActiveAdaptersModal"
48
+ @hide-alert="onHideAlert"
49
+ @change-target-device="onChangeTargetDevice"
50
+ @change-steps="onChangeSteps"
51
+ @hide="onHideAddNetworkingModal"
52
+ @submit="onSubmit"
53
+ />
54
+ </div>
55
+ </template>
56
+
57
+ <script setup lang="ts">
58
+ import type {
59
+ UI_I_ValidationReturn,
60
+ UI_I_WizardStep,
61
+ UI_I_WizardStepNavigation,
62
+ } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
63
+ import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
64
+ import type {
65
+ UI_I_ArbitraryObject,
66
+ UI_I_Localization,
67
+ UI_I_ItemsWithTotalCounts,
68
+ } from '~/lib/models/interfaces'
69
+ import type { UI_T_Project } from '~/lib/models/types'
70
+ import type {
71
+ UI_I_PortProperties,
72
+ UI_I_IpFourSettings,
73
+ UI_I_ConnectionSettings,
74
+ UI_I_TargetDevice,
75
+ UI_I_Switch,
76
+ UI_I_ReadyCompleteFields,
77
+ UI_I_AddNetworkingSecondOrThirdSchemeDataSend,
78
+ UI_I_AddNetworkingZeroOrFirstSchemeDataSend,
79
+ UI_I_AddNetworkingFourthOrFifthSchemeDataSend,
80
+ // UI_I_AddNetworkingEmits,
81
+ UI_I_TCPStack,
82
+ } from '~/components/common/wizards/network/add/lib/models/interfaces'
83
+ import type {
84
+ UI_I_Adapter,
85
+ UI_I_AdapterStatus,
86
+ UI_I_SwitchAdapterItem,
87
+ UI_I_DiagramData,
88
+ API_UI_I_SwitchItem,
89
+ UI_I_AvailableAdapters,
90
+ } from '~/components/common/diagramMain/lib/models/interfaces'
91
+ import { getAvailableAdapters } from '~/components/common/diagramMain/lib/utils/utils'
92
+ import { UI_E_ValidationFields } from '~/components/common/wizards/network/add/lib/models/enums'
93
+ import { getVlanId } from '~/components/common/wizards/network/add/lib/utils/utils'
94
+ import {
95
+ createZeroSchemeReadyCompleteFunc,
96
+ createFirstSchemeReadyCompleteFunc,
97
+ createSecondSchemeReadyCompleteFunc,
98
+ createThirdSchemeReadyCompleteFunc,
99
+ createFourthSchemeReadyCompleteFunc,
100
+ createFifthSchemeReadyCompleteFunc,
101
+ stepsSchemeInitial,
102
+ stepsFunc,
103
+ connectionSettingsInitial,
104
+ portPropertiesInitial,
105
+ ipFourSettingsInitial,
106
+ targetDeviceInitialFunc,
107
+ addNetworkingZeroOrFirstSchemeDataFunc,
108
+ addNetworkingSecondOrThirdSchemeDataFunc,
109
+ addNetworkingFourthOrFifthSchemeDataFunc,
110
+ } from '~/components/common/wizards/network/add/lib/config/config'
111
+ import {
112
+ checkTargetDeviceSync,
113
+ checkAdaptersSync,
114
+ checkPortPropertiesSync,
115
+ checkIpFourSettingsSync,
116
+ checkConnectionSettingsSync,
117
+ checkNetworkAsync,
118
+ } from '~/components/common/wizards/network/add/validations/validations'
119
+
120
+ const props = withDefaults(
121
+ defineProps<{
122
+ show: boolean
123
+ adapters: UI_I_ItemsWithTotalCounts<UI_I_SwitchAdapterItem>
124
+ standardSwitchesInitial?: UI_I_Switch[]
125
+ freeAdapters?: UI_I_Adapter[]
126
+ project?: UI_T_Project
127
+ isDarkMode?: boolean
128
+ selectedStandardSwitchId?: string
129
+ selectedSwitchId?: string
130
+ tcpStacks?: UI_I_TCPStack[]
131
+ diagramsData?: UI_I_DiagramData[]
132
+ isNetworkingLoading?: boolean
133
+ isGetExistingSwitchesLoading?: boolean
134
+ isGetTcpStackLoading?: boolean
135
+ hostName?: string
136
+ }>(),
137
+ {
138
+ standardSwitchesInitial: () => [],
139
+ freeAdapters: () => [],
140
+ project: 'procurator',
141
+ isDarkMode: false,
142
+ selectedStandardSwitchId: '',
143
+ selectedSwitchId: '',
144
+ tcpStacks: () => [],
145
+ diagramsData: [],
146
+ isNetworkingLoading: false,
147
+ isGetExistingSwitchesLoading: false,
148
+ isGetTcpStackLoading: false,
149
+ }
150
+ )
151
+
152
+ const emits = defineEmits<{
153
+ (event: 'hide'): void
154
+ (
155
+ event: 'add-networking-data-validate',
156
+ data:
157
+ | UI_I_AddNetworkingSecondOrThirdSchemeDataSend
158
+ | UI_I_AddNetworkingZeroOrFirstSchemeDataSend
159
+ | UI_I_AddNetworkingFourthOrFifthSchemeDataSend
160
+ | API_UI_I_SwitchItem,
161
+ type: string,
162
+ setValidation: (err_arg: UI_I_ArbitraryObject<string>) => void
163
+ ): void
164
+ (
165
+ event: 'send-add-networking-data',
166
+ data:
167
+ | UI_I_AddNetworkingSecondOrThirdSchemeDataSend
168
+ | UI_I_AddNetworkingZeroOrFirstSchemeDataSend
169
+ | UI_I_AddNetworkingFourthOrFifthSchemeDataSend
170
+ | API_UI_I_SwitchItem,
171
+ type: string,
172
+ hideModal: () => void
173
+ ): void
174
+ (event: 'get-existing-standard-switches'): void
175
+ (event: 'get-free-adapters', cb: () => void): void
176
+ (
177
+ event: 'check-network-label',
178
+ label: string,
179
+ sendMessage: (message: string) => void
180
+ ): void
181
+ (event: 'get-tcp-stacks'): void
182
+ }>()
183
+
184
+ const { $store }: any = useNuxtApp()
185
+
186
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
187
+
188
+ const currentComponent = computed(() =>
189
+ isNewView.value
190
+ ? defineAsyncComponent(() => import('./AddNew.vue'))
191
+ : defineAsyncComponent(() => import('./AddOld.vue'))
192
+ )
193
+
194
+ const localization = computed<UI_I_Localization>(() => useLocal())
195
+
196
+ const localHostName = ref<string>('')
197
+ const hostNameLocal = computed<string>(
198
+ () => props.hostName || localHostName.value
199
+ )
200
+
201
+ const title = computed<string>(
202
+ () => `${hostNameLocal.value} - ${localization.value.common.addNetworking}`
203
+ )
204
+
205
+ const wizard: Wizard = new Wizard(
206
+ stepsFunc(localization.value),
207
+ stepsSchemeInitial
208
+ )
209
+
210
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
211
+ const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
212
+
213
+ const readyCompleteFields = ref<UI_I_ReadyCompleteFields[]>([])
214
+
215
+ const globalPermissions = computed<any>(
216
+ () => $store.getters['globalPermissions/getPermissions']
217
+ )
218
+
219
+ // Step's content data (connectionType)
220
+ const connectionType = ref<string>(
221
+ globalPermissions.value === undefined
222
+ ? '0'
223
+ : !globalPermissions.value?.['Networks.CreateSysx'] &&
224
+ !globalPermissions.value?.['Networks.CreatePortGroup']
225
+ ? '2'
226
+ : !globalPermissions.value?.['Networks.CreateSysx']
227
+ ? '1'
228
+ : '0'
229
+ )
230
+
231
+ const connectionTypeLocal = computed<string>({
232
+ get() {
233
+ return connectionType.value
234
+ },
235
+ set(newValue: string) {
236
+ wizard.resetAfterSelected()
237
+ connectionType.value = newValue
238
+ targetDevice.value.standardSwitch = props.selectedStandardSwitchId
239
+ targetDevice.value.switch = props.selectedSwitchId
240
+ },
241
+ })
242
+
243
+ // Step's content data (createStandardSwitch)
244
+ const addedAdapters = ref<string[]>([])
245
+ const coreAdapters = ref<string[]>([])
246
+
247
+ const onChangeAddedAdapters = (addedAdaptersNew: string[]): void => {
248
+ addedAdapters.value = addedAdaptersNew
249
+ }
250
+
251
+ const adapterStatus = ref<UI_I_AdapterStatus>({
252
+ active: [],
253
+ standby: [],
254
+ unused: [],
255
+ })
256
+ const onChangeAdapterStatus = (adapterStatusNew: UI_I_AdapterStatus): void => {
257
+ adapterStatus.value = adapterStatusNew
258
+ }
259
+
260
+ // Step's content data and changers (targetDevice)
261
+ const targetDevice = ref<UI_I_TargetDevice>(
262
+ useDeepCopy(
263
+ targetDeviceInitialFunc(globalPermissions.value?.['Networks.UpdateSwitch'])
264
+ )
265
+ )
266
+ const mtuFromSwitch = ref<number>(1500)
267
+
268
+ const onChangeTargetDevice = (newTargetDevice: UI_I_TargetDevice): void => {
269
+ const oldTargetDeviceSelected = useDeepCopy(targetDevice.value).selected
270
+ const newTargetDeviceSelected = newTargetDevice.selected
271
+
272
+ if (oldTargetDeviceSelected !== newTargetDeviceSelected) {
273
+ wizard.resetAfterSelected()
274
+ }
275
+
276
+ const selectedSwitch = props.standardSwitchesInitial.find(
277
+ (currentSwitch: UI_I_Switch) =>
278
+ newTargetDevice.standardSwitch === currentSwitch.name
279
+ )
280
+
281
+ if (newTargetDeviceSelected === '1' && selectedSwitch) {
282
+ mtuFromSwitch.value = selectedSwitch?.mtu || 1500
283
+ }
284
+ if (newTargetDeviceSelected === '3') {
285
+ mtuFromSwitch.value = newTargetDevice.mtu || 1500
286
+ }
287
+
288
+ targetDevice.value = useDeepCopy(newTargetDevice)
289
+ }
290
+
291
+ // Step's content data and changers (portProperties)
292
+ const portProperties = ref<UI_I_PortProperties>(
293
+ useDeepCopy(portPropertiesInitial(localization.value))
294
+ )
295
+ const onChangePortProperties = (newFields: UI_I_PortProperties): void => {
296
+ if (portProperties.value.tcp !== newFields.tcp) {
297
+ ipFourSettings.value.static.defaultGateway.value =
298
+ props.tcpStacks?.find((tcp: UI_I_TCPStack) => tcp.id === newFields.tcp)
299
+ .gateway || ''
300
+ }
301
+ portProperties.value = newFields
302
+ }
303
+
304
+ // Step's content data and changers (ipFourSettings)
305
+ const ipFourSettings = ref<UI_I_IpFourSettings>(ipFourSettingsInitial)
306
+ const onChangeIpFourSettings = (newFields: UI_I_IpFourSettings): void => {
307
+ ipFourSettings.value = newFields
308
+ }
309
+
310
+ const gatewayFlag = ref<boolean>(false)
311
+ const onChangeGatewayFlag = (newValue: boolean) => {
312
+ gatewayFlag.value = newValue
313
+ }
314
+
315
+ // Step's content data and changers (connectionSettings)
316
+ const connectionSettings = ref<UI_I_ConnectionSettings>(
317
+ connectionSettingsInitial(localization.value)
318
+ )
319
+ const onChangeConnectionSettings = (
320
+ newFields: UI_I_ConnectionSettings
321
+ ): void => {
322
+ connectionSettings.value = newFields
323
+ }
324
+
325
+ const onHideAlert = (stepId: number, field?: string): void => {
326
+ wizard.hideAlertMessagesByStepId(stepId, field)
327
+ }
328
+
329
+ let flagSwitch = ''
330
+
331
+ // Choosing Scheme
332
+ watch(
333
+ [connectionTypeLocal, targetDevice],
334
+ (
335
+ newValues: [string, UI_I_TargetDevice],
336
+ oldValues: [string, UI_I_TargetDevice]
337
+ ) => {
338
+ const newCT = newValues[0] // -> newConnectionType
339
+ const oldCT = oldValues[0] // -> oldConnectionType
340
+ const newTD = newValues[1] // -> newTargetDevice
341
+ const oldTD = oldValues[1] // -> oldTargetDevice
342
+
343
+ if (!oldTD || oldTD.selected !== newTD.selected) {
344
+ flagSwitch = ''
345
+ addedAdapters.value = []
346
+ adapterStatus.value = {
347
+ active: [],
348
+ standby: [],
349
+ unused: [],
350
+ }
351
+ }
352
+ if (newCT !== oldCT) {
353
+ newCT === '0' && props.selectedStandardSwitchId
354
+ ? (targetDevice.value.selected = '1')
355
+ : (targetDevice.value.selected = '0')
356
+ newCT === '1' && (targetDevice.value.selected = '1')
357
+ newCT === '2' &&
358
+ (globalPermissions.value === undefined ||
359
+ globalPermissions.value?.['Networks.UpdateSwitch']
360
+ ? (targetDevice.value.selected = '2')
361
+ : (targetDevice.value.selected = '3'))
362
+ }
363
+ if (newCT === '0') {
364
+ ;(newTD.selected === '0' || newTD.selected === '1') &&
365
+ wizard.changeScheme(0)
366
+ newTD.selected === '3' && wizard.changeScheme(1)
367
+ }
368
+ if (newCT === '1') {
369
+ newTD.selected === '1' && wizard.changeScheme(2)
370
+ newTD.selected === '3' && wizard.changeScheme(3)
371
+ }
372
+ if (newCT === '2') {
373
+ newTD.selected === '2' && wizard.changeScheme(4)
374
+ newTD.selected === '3' && wizard.changeScheme(5)
375
+ }
376
+ },
377
+ { deep: true, immediate: true }
378
+ )
379
+
380
+ const onGetExistingStandardSwitches = (): void => {
381
+ emits('get-existing-standard-switches')
382
+ }
383
+
384
+ const onGetTcpStacks = (): void => {
385
+ emits('get-tcp-stacks')
386
+ }
387
+
388
+ watch(
389
+ () => wizard.selectedStepId,
390
+ (newSelectedStep: number) => {
391
+ if (newSelectedStep === 1) {
392
+ onGetExistingStandardSwitches()
393
+ }
394
+ if (newSelectedStep === 3) {
395
+ onGetTcpStacks()
396
+ }
397
+ if (newSelectedStep === 6 && flagSwitch !== targetDevice.value.switch) {
398
+ const nics: UI_I_AdapterStatus = props.standardSwitchesInitial.find(
399
+ (currentSwitch: UI_I_Switch) =>
400
+ currentSwitch.id === targetDevice.value.switch
401
+ ).nics
402
+
403
+ const availableAdapters: UI_I_AvailableAdapters = getAvailableAdapters(
404
+ props.adapters,
405
+ nics
406
+ )
407
+
408
+ adapterStatus.value = {
409
+ active: availableAdapters.activeAdapters || [],
410
+ standby: availableAdapters.standbyAdapters || [],
411
+ unused: availableAdapters.unusedAdapters || [],
412
+ }
413
+ coreAdapters.value = [
414
+ ...adapterStatus.value.active,
415
+ ...adapterStatus.value.standby,
416
+ ...adapterStatus.value.unused,
417
+ ]
418
+ flagSwitch = targetDevice.value.switch
419
+ }
420
+
421
+ if (newSelectedStep !== 7) return // If last step
422
+ if (wizard.isSelectedScheme(0)) {
423
+ readyCompleteFields.value = createZeroSchemeReadyCompleteFunc(
424
+ isNewView.value,
425
+ targetDevice.value,
426
+ portProperties.value,
427
+ ipFourSettings.value,
428
+ localization.value
429
+ )
430
+ return
431
+ }
432
+
433
+ if (wizard.isSelectedScheme(1)) {
434
+ readyCompleteFields.value = createFirstSchemeReadyCompleteFunc(
435
+ isNewView.value,
436
+ targetDevice.value,
437
+ portProperties.value,
438
+ ipFourSettings.value,
439
+ addedAdapters.value,
440
+ localization.value
441
+ )
442
+ return
443
+ }
444
+ if (wizard.isSelectedScheme(2)) {
445
+ readyCompleteFields.value = createSecondSchemeReadyCompleteFunc(
446
+ isNewView.value,
447
+ connectionSettings.value,
448
+ targetDevice.value,
449
+ localization.value
450
+ )
451
+ return
452
+ }
453
+ if (wizard.isSelectedScheme(3)) {
454
+ readyCompleteFields.value = createThirdSchemeReadyCompleteFunc(
455
+ isNewView.value,
456
+ connectionSettings.value,
457
+ targetDevice.value,
458
+ addedAdapters.value,
459
+ localization.value
460
+ )
461
+ return
462
+ }
463
+ if (wizard.isSelectedScheme(4)) {
464
+ readyCompleteFields.value = createFourthSchemeReadyCompleteFunc(
465
+ isNewView.value,
466
+ targetDevice.value.switch,
467
+ props.diagramsData,
468
+ adapterStatus.value,
469
+ localization.value
470
+ )
471
+ return
472
+ }
473
+ if (wizard.isSelectedScheme(5)) {
474
+ readyCompleteFields.value = createFifthSchemeReadyCompleteFunc(
475
+ isNewView.value,
476
+ targetDevice.value,
477
+ adapterStatus.value,
478
+ localization.value
479
+ )
480
+ }
481
+ }
482
+ )
483
+
484
+ // Reset data
485
+ const reset = (): void => {
486
+ wizard.reset()
487
+ connectionTypeLocal.value = '0'
488
+ targetDevice.value = useDeepCopy(
489
+ targetDeviceInitialFunc(globalPermissions.value?.['Networks.UpdateSwitch'])
490
+ )
491
+ connectionSettings.value = useDeepCopy(
492
+ connectionSettingsInitial(localization.value)
493
+ )
494
+ portProperties.value = useDeepCopy(portPropertiesInitial(localization.value))
495
+ ipFourSettings.value = useDeepCopy(ipFourSettingsInitial)
496
+ coreAdapters.value = []
497
+ addedAdapters.value = []
498
+ adapterStatus.value = {
499
+ active: [],
500
+ standby: [],
501
+ unused: [],
502
+ }
503
+ }
504
+
505
+ const isShowNoConnectedActiveAdaptersModal = ref(false)
506
+ const isShowNoActiveAdaptersModal = ref(false)
507
+
508
+ const showNoConnectedActiveAdaptersModal = (): void => {
509
+ isShowNoConnectedActiveAdaptersModal.value = true
510
+ }
511
+ const onHideNoConnectedActiveAdaptersModal = (): void => {
512
+ isShowNoConnectedActiveAdaptersModal.value = false
513
+ }
514
+ const showNoActiveAdaptersModal = (): void => {
515
+ isShowNoActiveAdaptersModal.value = true
516
+ }
517
+ const onHideNoActiveAdaptersModal = (): void => {
518
+ isShowNoActiveAdaptersModal.value = false
519
+ }
520
+
521
+ const onConfirmNoActiveAdaptersModal = (): void => {
522
+ onHideNoConnectedActiveAdaptersModal()
523
+ onHideNoActiveAdaptersModal()
524
+ if (wizard.waitingStepId === 7) {
525
+ wizard.changeSteps(
526
+ wizard.selectedStepData(
527
+ wizard.stepsInSelectedSchemeWithStatus.value.find(
528
+ (step: UI_I_WizardStepNavigation) => step.id === 7
529
+ )
530
+ ),
531
+ validationFunc,
532
+ props.project === 'sphere' ? null : finalValidationFunc,
533
+ true
534
+ )
535
+ wizard.waitingStepId = -1
536
+ return
537
+ }
538
+ wizard.selectStepHard(wizard.waitingStepId)
539
+ }
540
+
541
+ const onGetFreeAdapters = (showModal: () => void): void => {
542
+ emits('get-free-adapters', showModal)
543
+ }
544
+
545
+ const checkFinal = async (): Promise<UI_I_ArbitraryObject<string>> => {
546
+ let data:
547
+ | UI_I_AddNetworkingSecondOrThirdSchemeDataSend
548
+ | UI_I_AddNetworkingZeroOrFirstSchemeDataSend
549
+ | UI_I_AddNetworkingFourthOrFifthSchemeDataSend
550
+ | API_UI_I_SwitchItem
551
+ | null = null
552
+
553
+ let type: 'network' | 'vmkernel' | 'adapter' | 'new-switch'
554
+
555
+ if (wizard.isSelectedScheme(0) || wizard.isSelectedScheme(1)) {
556
+ const vlan = getVlanId(portProperties.value.vlanId, localization.value)
557
+
558
+ data = addNetworkingZeroOrFirstSchemeDataFunc(
559
+ targetDevice.value,
560
+ Number(vlan),
561
+ portProperties.value,
562
+ ipFourSettings.value,
563
+ wizard.isSelectedScheme(1),
564
+ adapterStatus.value
565
+ )
566
+
567
+ type = 'vmkernel'
568
+ }
569
+
570
+ if (wizard.isSelectedScheme(2) || wizard.isSelectedScheme(3)) {
571
+ const vlan = getVlanId(connectionSettings.value.vlanId, localization.value)
572
+
573
+ data = addNetworkingSecondOrThirdSchemeDataFunc(
574
+ connectionSettings.value,
575
+ targetDevice.value,
576
+ Number(vlan),
577
+ wizard.isSelectedScheme(2),
578
+ adapterStatus.value
579
+ )
580
+
581
+ type = 'network'
582
+ }
583
+
584
+ if (wizard.isSelectedScheme(4) || wizard.isSelectedScheme(5)) {
585
+ data = addNetworkingFourthOrFifthSchemeDataFunc(
586
+ targetDevice.value.switch,
587
+ wizard.isSelectedScheme(4),
588
+ adapterStatus.value,
589
+ props.diagramsData,
590
+ targetDevice.value.mtu
591
+ )
592
+
593
+ type = wizard.isSelectedScheme(4) ? 'adapter' : 'new-switch'
594
+ }
595
+
596
+ return new Promise((resolve, _reject) =>
597
+ emits(
598
+ 'add-networking-data-validate',
599
+ data,
600
+ type,
601
+ (err_arg: UI_I_ArbitraryObject<string>): void => {
602
+ resolve(err_arg)
603
+ }
604
+ )
605
+ )
606
+ }
607
+
608
+ const finalValidationFunc = async (
609
+ value: UI_I_WizardStep[]
610
+ ): Promise<UI_I_ValidationReturn> => {
611
+ let stepHasError = false
612
+
613
+ const validationFields: {
614
+ [key: string]: string
615
+ } = await checkFinal()
616
+
617
+ for (const fieldName in validationFields) {
618
+ const stepId = wizard.getStepIdByFieldName(fieldName)
619
+
620
+ if (stepId !== -1) {
621
+ stepHasError = wizard.setValidation(stepId, fieldName, {
622
+ fieldMessage: validationFields[fieldName],
623
+ alertMessage: validationFields[fieldName],
624
+ })
625
+ }
626
+ }
627
+
628
+ return {
629
+ stepHasError,
630
+ newValue: value,
631
+ }
632
+ }
633
+
634
+ const validationFunc = async (
635
+ value: UI_I_WizardStep[],
636
+ currentStep: UI_I_WizardStep,
637
+ nextStep: UI_I_WizardStep
638
+ ): Promise<UI_I_ValidationReturn> => {
639
+ let stepHasError = false
640
+ let stepShouldStop = {
641
+ ifOnCurrentStep: false,
642
+ ifFromAnyStep: false,
643
+ stoppageStepId: -1,
644
+ }
645
+
646
+ if (wizard.isValidateForStep(1, currentStep.id, nextStep.id)) {
647
+ const targetDeviceValidation = checkTargetDeviceSync(
648
+ localization.value,
649
+ targetDevice.value,
650
+ wizard,
651
+ value,
652
+ isNewView.value
653
+ )
654
+
655
+ value = targetDeviceValidation.newValue
656
+
657
+ stepHasError = stepHasError || targetDeviceValidation.stepHasError
658
+ }
659
+
660
+ if (wizard.isValidateForStep(2, currentStep.id, nextStep.id)) {
661
+ wizard.waitingStepId = nextStep.id
662
+
663
+ const adapterValidation = checkAdaptersSync(
664
+ localization.value,
665
+ adapterStatus.value,
666
+ value,
667
+ currentStep.id,
668
+ nextStep.id,
669
+ props.freeAdapters,
670
+ showNoActiveAdaptersModal,
671
+ showNoConnectedActiveAdaptersModal,
672
+ 2
673
+ )
674
+
675
+ value = adapterValidation.newValue
676
+
677
+ stepShouldStop = adapterValidation.stepShouldStop || stepShouldStop
678
+
679
+ stepHasError = stepHasError || adapterValidation.stepHasError
680
+ }
681
+
682
+ if (wizard.isValidateForStep(3, currentStep.id, nextStep.id)) {
683
+ const labelValidation = await checkNetworkAsync(
684
+ value,
685
+ portProperties.value.networkLabel,
686
+ 3,
687
+ UI_E_ValidationFields.PORT_PROPERTIES_NETWORK,
688
+ emits,
689
+ localization.value,
690
+ wizard
691
+ )
692
+
693
+ value = labelValidation.newValue
694
+
695
+ const portPropertiesValidation = checkPortPropertiesSync(
696
+ localization.value,
697
+ portProperties.value,
698
+ wizard,
699
+ value
700
+ )
701
+
702
+ value = portPropertiesValidation.newValue
703
+
704
+ stepHasError =
705
+ stepHasError ||
706
+ labelValidation.stepHasError ||
707
+ portPropertiesValidation.stepHasError
708
+ }
709
+
710
+ if (wizard.isValidateForStep(4, currentStep.id, nextStep.id)) {
711
+ const ipValidation = checkIpFourSettingsSync(
712
+ localization.value,
713
+ ipFourSettings.value,
714
+ wizard,
715
+ value
716
+ )
717
+
718
+ value = ipValidation.newValue
719
+
720
+ stepHasError = stepHasError || ipValidation.stepHasError
721
+ }
722
+
723
+ if (wizard.isValidateForStep(5, currentStep.id, nextStep.id)) {
724
+ const labelValidation = await checkNetworkAsync(
725
+ value,
726
+ connectionSettings.value.networkLabel,
727
+ 5,
728
+ UI_E_ValidationFields.CONNECTION_SETTINGS_NETWORK,
729
+ emits,
730
+ localization.value,
731
+ wizard
732
+ )
733
+
734
+ value = labelValidation.newValue
735
+
736
+ const connectionSettingsValidation = checkConnectionSettingsSync(
737
+ localization.value,
738
+ connectionSettings.value,
739
+ wizard,
740
+ value
741
+ )
742
+
743
+ value = connectionSettingsValidation.newValue
744
+
745
+ stepHasError =
746
+ stepHasError ||
747
+ labelValidation.stepHasError ||
748
+ connectionSettingsValidation.stepHasError
749
+ }
750
+
751
+ if (wizard.isValidateForStep(6, currentStep.id, nextStep.id)) {
752
+ wizard.waitingStepId = nextStep.id
753
+
754
+ const adapterValidation = checkAdaptersSync(
755
+ localization.value,
756
+ adapterStatus.value,
757
+ value,
758
+ currentStep.id,
759
+ nextStep.id,
760
+ props.adapters.items,
761
+ showNoActiveAdaptersModal,
762
+ showNoConnectedActiveAdaptersModal,
763
+ 6
764
+ )
765
+
766
+ value = adapterValidation.newValue
767
+
768
+ stepShouldStop = adapterValidation.stepShouldStop || stepShouldStop
769
+
770
+ stepHasError = stepHasError || adapterValidation.stepHasError
771
+ }
772
+
773
+ return {
774
+ newValue: value,
775
+ stepHasError,
776
+ stepShouldStop,
777
+ }
778
+ }
779
+
780
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> =>
781
+ wizard.changeSteps(value, validationFunc, finalValidationFunc)
782
+
783
+ const onHideAddNetworkingModal = (): void => {
784
+ emits('hide')
785
+ reset()
786
+ }
787
+
788
+ const onSubmit = async (): Promise<void> => {
789
+ let data:
790
+ | UI_I_AddNetworkingSecondOrThirdSchemeDataSend
791
+ | UI_I_AddNetworkingZeroOrFirstSchemeDataSend
792
+ | UI_I_AddNetworkingFourthOrFifthSchemeDataSend
793
+ | API_UI_I_SwitchItem
794
+ | null = null
795
+
796
+ let type: 'network' | 'vmkernel' | 'adapter' | 'new-switch' = 'network'
797
+
798
+ if (wizard.isSelectedScheme(0) || wizard.isSelectedScheme(1)) {
799
+ const vlan = getVlanId(portProperties.value.vlanId, localization.value)
800
+ type = 'vmkernel'
801
+ data = addNetworkingZeroOrFirstSchemeDataFunc(
802
+ targetDevice.value,
803
+ Number(vlan),
804
+ portProperties.value,
805
+ ipFourSettings.value,
806
+ wizard.isSelectedScheme(1),
807
+ adapterStatus.value
808
+ )
809
+ }
810
+
811
+ if (wizard.isSelectedScheme(2) || wizard.isSelectedScheme(3)) {
812
+ const vlan = getVlanId(connectionSettings.value.vlanId, localization.value)
813
+ type = 'network'
814
+ data = addNetworkingSecondOrThirdSchemeDataFunc(
815
+ connectionSettings.value,
816
+ targetDevice.value,
817
+ Number(vlan),
818
+ wizard.isSelectedScheme(2),
819
+ adapterStatus.value
820
+ )
821
+ }
822
+
823
+ if (wizard.isSelectedScheme(4) || wizard.isSelectedScheme(5)) {
824
+ type = wizard.isSelectedScheme(4) ? 'adapter' : 'new-switch'
825
+ data = addNetworkingFourthOrFifthSchemeDataFunc(
826
+ targetDevice.value.switch,
827
+ wizard.isSelectedScheme(4),
828
+ adapterStatus.value,
829
+ props.diagramsData,
830
+ targetDevice.value.mtu
831
+ )
832
+ }
833
+
834
+ data &&
835
+ emits('send-add-networking-data', data, type, onHideAddNetworkingModal)
836
+ }
837
+
838
+ onMounted(() => {
839
+ localHostName.value = location.hostname
840
+ })
841
+
842
+ watch(
843
+ [
844
+ () => props.isNetworkingLoading,
845
+ () => props.isGetExistingSwitchesLoading,
846
+ () => props.isGetTcpStackLoading,
847
+ ],
848
+ (newValue: [boolean, boolean, boolean]) => {
849
+ const wizardLoading = isNewView.value
850
+ ? newValue[0]
851
+ : newValue.some((loading: boolean) => loading)
852
+
853
+ wizard.setLoader(wizardLoading)
854
+ },
855
+ {
856
+ immediate: true,
857
+ deep: true,
858
+ }
859
+ )
860
+
861
+ watch(
862
+ props.tcpStacks,
863
+ (newValue: UI_I_TCPStack[]) => {
864
+ portProperties.value.tcp = newValue?.[0]?.id || ''
865
+ ipFourSettings.value.static.defaultGateway.value =
866
+ newValue?.[0]?.gateway || ''
867
+ },
868
+ { deep: true }
869
+ )
870
+ </script>
871
+
872
+ <style scoped lang="scss"></style>