bfg-common 1.2.186 → 1.2.187
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/assets/localization/local_be.json +9 -2
- package/assets/localization/local_en.json +9 -2
- package/assets/localization/local_hy.json +9 -2
- package/assets/localization/local_kk.json +9 -2
- package/assets/localization/local_ru.json +9 -2
- package/assets/localization/local_zh.json +9 -2
- package/assets/scss/common/theme.scss +27 -25
- package/components/atoms/table/simpleTable/SimpleTable.vue +5 -2
- package/components/atoms/wizard/Wizard.vue +4 -4
- package/components/atoms/wizard/models/interfaces.ts +4 -3
- package/components/atoms/wizard/utils/utils.ts +106 -27
- package/components/common/diagramMain/DiagramMain.vue +10 -46
- package/components/common/diagramMain/modals/config/index.ts +0 -6
- package/components/common/diagramMain/modals/config/vmKernelAdapter.ts +2 -2
- package/components/common/diagramMain/modals/editSettings/tabs/NetworkProperties.vue +1 -1
- package/components/common/diagramMain/modals/editSettings/tabs/port/IpvFourSettings.vue +339 -339
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/MigrateVmkernelAdapter.vue +531 -0
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/config/steps.ts +114 -0
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/steps/ConnectionSettings.vue +161 -0
- package/components/common/diagramMain/modals/{steps → migrateVmkernelAdapter/steps}/SelectVmkernelAdapter.vue +24 -86
- package/components/common/diagramMain/modals/{steps → migrateVmkernelAdapter/steps}/VmkernelAdapterReadyComplete.vue +7 -11
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/common.ts +47 -0
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/connectionSettings.ts +146 -0
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/selectVmkernelAdapter.ts +54 -0
- package/components/common/diagramMain/modals/migrateVmkernelAdapter/validations/validations.ts +19 -0
- package/components/common/diagramMain/models/enums.ts +6 -7
- package/components/common/diagramMain/models/interfaces.ts +28 -29
- package/components/common/diagramMain/models/types.ts +0 -1
- package/components/common/monitor/advanced/Advanced.vue +5 -4
- package/components/common/wizards/network/add/Add.vue +874 -0
- package/components/common/{addNetworking → wizards/network/add}/config/index.ts +2 -16
- package/components/common/{addNetworking → wizards/network/add}/config/initialData.ts +4 -19
- package/components/common/{addNetworking → wizards/network/add}/config/portPropertiesStep.ts +1 -1
- package/components/common/{addNetworking → wizards/network/add}/config/selectSwitch.ts +1 -1
- package/components/common/{addNetworking → wizards/network/add}/config/sendData.ts +1 -1
- package/components/common/{addNetworking/config/addNetworkingSteps.ts → wizards/network/add/config/steps.ts} +107 -60
- package/components/common/{addNetworking → wizards/network/add}/modals/SelectNetwork.vue +2 -2
- package/components/common/{addNetworking → wizards/network/add}/modals/SelectStandardSwitch.vue +2 -2
- package/components/common/{addNetworking → wizards/network/add}/modals/SelectSwitch.vue +2 -2
- package/components/common/wizards/network/add/models/enums.ts +17 -0
- package/components/common/{addNetworking → wizards/network/add}/models/interfaces.ts +30 -37
- package/components/common/wizards/network/add/models/types.ts +2 -0
- package/components/common/wizards/network/add/steps/ConnectionSettings.vue +148 -0
- package/components/common/{addNetworking → wizards/network/add}/steps/CreateStandardSwitch.vue +0 -7
- package/components/common/wizards/network/add/steps/IpFourSettings.vue +245 -0
- package/components/common/{addNetworking → wizards/network/add}/steps/PhysicalAdapter.vue +1 -12
- package/components/common/{addNetworking → wizards/network/add}/steps/PortProperties.vue +57 -180
- package/components/common/{addNetworking → wizards/network/add}/steps/ReadyComplete.vue +1 -10
- package/components/common/{addNetworking → wizards/network/add}/steps/SelectConnectionType.vue +3 -15
- package/components/common/{addNetworking → wizards/network/add}/steps/SelectedTargetDevice.vue +103 -209
- package/components/common/wizards/network/add/utils/index.ts +4 -0
- package/components/common/wizards/network/add/validations/common.ts +58 -0
- package/components/common/wizards/network/add/validations/connectionSettings.ts +75 -0
- package/components/common/wizards/network/add/validations/createStandardSwitch.ts +58 -0
- package/components/common/wizards/network/add/validations/ipFourSettings.ts +188 -0
- package/components/common/wizards/network/add/validations/networkValidation.ts +73 -0
- package/components/common/wizards/network/add/validations/portProperties.ts +87 -0
- package/components/common/wizards/network/add/validations/targetDevice.ts +113 -0
- package/components/common/wizards/network/add/validations/validations.ts +43 -0
- package/components/common/wizards/vm/migrate/select/computeResource/ComputeResource.vue +2 -0
- package/package.json +1 -1
- package/components/common/addNetworking/AddNetworking.vue +0 -1123
- package/components/common/addNetworking/Wizard.vue +0 -286
- package/components/common/addNetworking/config/temporaryData.ts +0 -8
- package/components/common/addNetworking/config/validation.ts +0 -23
- package/components/common/addNetworking/models/enums.ts +0 -7
- package/components/common/addNetworking/models/types.ts +0 -13
- package/components/common/addNetworking/steps/ConnectionSettings.vue +0 -269
- package/components/common/addNetworking/steps/Header.vue +0 -53
- package/components/common/addNetworking/steps/IpFourSettings.vue +0 -361
- package/components/common/addNetworking/utils/index.ts +0 -212
- package/components/common/diagramMain/modals/MigrateVmkernelAdapter.vue +0 -603
- package/components/common/diagramMain/modals/config/migrateVmkernelAdapterSteps.ts +0 -81
- package/components/common/diagramMain/modals/config/validation.ts +0 -3
- package/components/common/diagramMain/modals/steps/ConnectionSettings.vue +0 -221
- package/components/common/diagramMain/modals/steps/Header.vue +0 -60
- /package/components/common/{addNetworking → wizards/network/add}/mappers/mappers.ts +0 -0
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="wizard-content-container add-networking-step">
|
|
3
|
-
<common-add-networking-steps-header
|
|
4
|
-
:title="props.title"
|
|
5
|
-
:text="props.text"
|
|
6
|
-
/>
|
|
7
|
-
<div class="wizard-content wizard-content-port">
|
|
8
|
-
<atoms-alert
|
|
9
|
-
v-if="hasValidationError"
|
|
10
|
-
status="alert-danger"
|
|
11
|
-
:items="props.errorMessages"
|
|
12
|
-
@remove="onHideErrorMessageAlert"
|
|
13
|
-
/>
|
|
14
|
-
<form>
|
|
15
|
-
<div class="radio">
|
|
16
|
-
<input
|
|
17
|
-
id="Obtain"
|
|
18
|
-
v-model="fields.ipSettings"
|
|
19
|
-
type="radio"
|
|
20
|
-
value="0"
|
|
21
|
-
name="IPv4-settings"
|
|
22
|
-
/>
|
|
23
|
-
<label for="Obtain">
|
|
24
|
-
{{ localization.obtainIPv4SettingsAutomatically }}
|
|
25
|
-
</label>
|
|
26
|
-
</div>
|
|
27
|
-
<div class="radio">
|
|
28
|
-
<input
|
|
29
|
-
id="static"
|
|
30
|
-
v-model="fields.ipSettings"
|
|
31
|
-
type="radio"
|
|
32
|
-
value="1"
|
|
33
|
-
name="IPv4-settings"
|
|
34
|
-
/>
|
|
35
|
-
<label for="static"> {{ localization.useStaticIPv4Settings }} </label>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<div
|
|
39
|
-
:class="[
|
|
40
|
-
'form-block form-block-ipv',
|
|
41
|
-
{ disabled: fields.ipSettings === '0' },
|
|
42
|
-
]"
|
|
43
|
-
>
|
|
44
|
-
<div class="horizontal-flex-container p-b-14">
|
|
45
|
-
<label class="property-label-group">
|
|
46
|
-
{{ localization.ipv4address }}
|
|
47
|
-
</label>
|
|
48
|
-
<div class="margin-left-property-value-group">
|
|
49
|
-
<div class="property-value-group">
|
|
50
|
-
<fieldset>
|
|
51
|
-
<atoms-tooltip-error
|
|
52
|
-
:has-error="!!fieldsErrorMessages.ipFourAddress"
|
|
53
|
-
>
|
|
54
|
-
<template #elem>
|
|
55
|
-
<input
|
|
56
|
-
v-model="fields.static.ipFourAddress"
|
|
57
|
-
type="text"
|
|
58
|
-
placeholder="e.g. 192.168.1.1"
|
|
59
|
-
:class="[
|
|
60
|
-
'tooltip-field port-properties-network-label',
|
|
61
|
-
{
|
|
62
|
-
'danger-not-valid':
|
|
63
|
-
fieldsErrorMessages.ipFourAddress,
|
|
64
|
-
},
|
|
65
|
-
]"
|
|
66
|
-
/>
|
|
67
|
-
</template>
|
|
68
|
-
<template #content>
|
|
69
|
-
{{ fieldsErrorMessages.ipFourAddress }}
|
|
70
|
-
</template>
|
|
71
|
-
</atoms-tooltip-error>
|
|
72
|
-
</fieldset>
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
<div class="horizontal-flex-container p-b-14">
|
|
77
|
-
<label class="property-label-group">
|
|
78
|
-
{{ localization.subnetMask }}
|
|
79
|
-
</label>
|
|
80
|
-
<div class="margin-left-property-value-group">
|
|
81
|
-
<div class="property-value-group">
|
|
82
|
-
<fieldset>
|
|
83
|
-
<atoms-tooltip-error
|
|
84
|
-
:has-error="!!fieldsErrorMessages.subnetMask"
|
|
85
|
-
>
|
|
86
|
-
<template #elem>
|
|
87
|
-
<input
|
|
88
|
-
v-model="fields.static.subnetMask"
|
|
89
|
-
type="text"
|
|
90
|
-
placeholder="e.g. 255.255.255.0"
|
|
91
|
-
:class="[
|
|
92
|
-
'tooltip-field',
|
|
93
|
-
{
|
|
94
|
-
'danger-not-valid': fieldsErrorMessages.subnetMask,
|
|
95
|
-
},
|
|
96
|
-
]"
|
|
97
|
-
/>
|
|
98
|
-
</template>
|
|
99
|
-
<template #content>
|
|
100
|
-
{{ fieldsErrorMessages.subnetMask }}
|
|
101
|
-
</template>
|
|
102
|
-
</atoms-tooltip-error>
|
|
103
|
-
</fieldset>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
<div class="horizontal-flex-container p-b-14">
|
|
108
|
-
<label class="property-label-group">
|
|
109
|
-
{{ localization.defaultGateway }}
|
|
110
|
-
</label>
|
|
111
|
-
<div class="margin-left-property-value-group">
|
|
112
|
-
<div class="property-value-group">
|
|
113
|
-
<div
|
|
114
|
-
class="flex-property-label-group small checkbox-inline with-margin p-b-14"
|
|
115
|
-
>
|
|
116
|
-
<input
|
|
117
|
-
id="default-gateway"
|
|
118
|
-
v-model="fields.static.defaultGateway.override"
|
|
119
|
-
type="checkbox"
|
|
120
|
-
/>
|
|
121
|
-
<label
|
|
122
|
-
for="default-gateway"
|
|
123
|
-
class="normal-weight normal-font-size"
|
|
124
|
-
>
|
|
125
|
-
{{ localization.overrideDefaultGatewayForThisAdapter }}
|
|
126
|
-
</label>
|
|
127
|
-
</div>
|
|
128
|
-
<div>
|
|
129
|
-
<fieldset>
|
|
130
|
-
<atoms-tooltip-error
|
|
131
|
-
:has-error="!!fieldsErrorMessages.defaultGateway"
|
|
132
|
-
>
|
|
133
|
-
<template #elem>
|
|
134
|
-
<input
|
|
135
|
-
v-model="fields.static.defaultGateway.value"
|
|
136
|
-
type="text"
|
|
137
|
-
:disabled="!fields.static.defaultGateway.override"
|
|
138
|
-
placeholder="10.10.101.1"
|
|
139
|
-
:class="[
|
|
140
|
-
'tooltip-field',
|
|
141
|
-
{
|
|
142
|
-
'danger-not-valid':
|
|
143
|
-
fieldsErrorMessages.defaultGateway,
|
|
144
|
-
},
|
|
145
|
-
]"
|
|
146
|
-
/>
|
|
147
|
-
</template>
|
|
148
|
-
<template #content>
|
|
149
|
-
{{ fieldsErrorMessages.defaultGateway }}
|
|
150
|
-
</template>
|
|
151
|
-
</atoms-tooltip-error>
|
|
152
|
-
</fieldset>
|
|
153
|
-
</div>
|
|
154
|
-
</div>
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
</form>
|
|
159
|
-
</div>
|
|
160
|
-
</div>
|
|
161
|
-
</template>
|
|
162
|
-
|
|
163
|
-
<script setup lang="ts">
|
|
164
|
-
import { UI_I_ArbitraryObject, UI_I_Localization } from '~/models/interfaces'
|
|
165
|
-
import {
|
|
166
|
-
UI_I_IpFourSettings,
|
|
167
|
-
UI_I_IpFourSettingsFieldsErrorMessages,
|
|
168
|
-
} from '~/components/common/addNetworking/models/interfaces'
|
|
169
|
-
import { UI_T_IpFourSettingsFieldName } from '~/components/common/addNetworking/models/types'
|
|
170
|
-
import { ipFourSettingsFieldsErrorMessages } from '~/components/common/addNetworking/config'
|
|
171
|
-
|
|
172
|
-
// Props from up
|
|
173
|
-
const props = defineProps<{
|
|
174
|
-
title: string
|
|
175
|
-
text: string
|
|
176
|
-
stepId: number
|
|
177
|
-
ipFourSettings: UI_I_IpFourSettings
|
|
178
|
-
isShowErrorMessageAlert: boolean
|
|
179
|
-
errorMessages: string[]
|
|
180
|
-
error: UI_I_ArbitraryObject<string>
|
|
181
|
-
}>()
|
|
182
|
-
|
|
183
|
-
// UI_I_Localization
|
|
184
|
-
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
185
|
-
|
|
186
|
-
// Define emits for changing data and validation messages
|
|
187
|
-
const emits = defineEmits<{
|
|
188
|
-
(event: 'change-ip-four-settings', ipFourSettings: UI_I_IpFourSettings): void
|
|
189
|
-
(
|
|
190
|
-
event: 'change-error-messages',
|
|
191
|
-
errorMessages: string[],
|
|
192
|
-
stepIndex: number
|
|
193
|
-
): void
|
|
194
|
-
(event: 'hide-error-message-alert'): void
|
|
195
|
-
// (event: 'set-error-empty', fieldName: string): void
|
|
196
|
-
}>()
|
|
197
|
-
|
|
198
|
-
// Validation error check for this step
|
|
199
|
-
const hasValidationError = computed<boolean>(
|
|
200
|
-
() => props.isShowErrorMessageAlert && !!props.errorMessages.length
|
|
201
|
-
)
|
|
202
|
-
const fields = ref<UI_I_IpFourSettings>({ ...props.ipFourSettings })
|
|
203
|
-
|
|
204
|
-
const fieldsErrorMessages = ref<UI_I_IpFourSettingsFieldsErrorMessages>(
|
|
205
|
-
ipFourSettingsFieldsErrorMessages
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
const checkIfValidIP = (str: string): boolean => {
|
|
209
|
-
const regexExp =
|
|
210
|
-
/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/gi
|
|
211
|
-
|
|
212
|
-
return regexExp.test(str)
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const messageTexts = (
|
|
216
|
-
local: UI_I_Localization
|
|
217
|
-
): UI_I_ArbitraryObject<string> => ({
|
|
218
|
-
ipFourAddressEmpty: local.ipFourAddressEmpty,
|
|
219
|
-
subnetMaskEmpty: local.subnetMaskEmpty,
|
|
220
|
-
defaultGatewayEmpty: local.defaultGatewayEmpty,
|
|
221
|
-
ipFourAddressInvalid: local.ipFourAddressInvalid,
|
|
222
|
-
subnetMaskInvalid: local.subnetMaskInvalid,
|
|
223
|
-
defaultGatewayInvalid: local.defaultGatewayInvalid,
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
const setMessageOnChangedField = (
|
|
227
|
-
values: string,
|
|
228
|
-
name: UI_T_IpFourSettingsFieldName,
|
|
229
|
-
ipSettings: string,
|
|
230
|
-
override?: boolean
|
|
231
|
-
): void => {
|
|
232
|
-
if (ipSettings === '0') {
|
|
233
|
-
fieldsErrorMessages.value[name] = ''
|
|
234
|
-
return
|
|
235
|
-
}
|
|
236
|
-
if (name === 'ipFourAddress') {
|
|
237
|
-
if (!values) {
|
|
238
|
-
fieldsErrorMessages.value[name] = messageTexts(localization.value)[
|
|
239
|
-
`${name}Empty`
|
|
240
|
-
]
|
|
241
|
-
return
|
|
242
|
-
}
|
|
243
|
-
if (!checkIfValidIP(values)) {
|
|
244
|
-
fieldsErrorMessages.value[name] = messageTexts(localization.value)[
|
|
245
|
-
`${name}Invalid`
|
|
246
|
-
]
|
|
247
|
-
return
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
if (name === 'subnetMask') {
|
|
251
|
-
if (!values) {
|
|
252
|
-
fieldsErrorMessages.value[name] = messageTexts(localization.value)[
|
|
253
|
-
`${name}Empty`
|
|
254
|
-
]
|
|
255
|
-
return
|
|
256
|
-
}
|
|
257
|
-
if (!checkIfValidIP(values)) {
|
|
258
|
-
fieldsErrorMessages.value[name] = messageTexts(localization.value)[
|
|
259
|
-
`${name}Invalid`
|
|
260
|
-
]
|
|
261
|
-
return
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
if (name === 'defaultGateway' && override) {
|
|
265
|
-
if (!values) {
|
|
266
|
-
fieldsErrorMessages.value[name] = messageTexts(localization.value)[
|
|
267
|
-
`${name}Empty`
|
|
268
|
-
]
|
|
269
|
-
return
|
|
270
|
-
}
|
|
271
|
-
if (!checkIfValidIP(values)) {
|
|
272
|
-
fieldsErrorMessages.value[name] = messageTexts(localization.value)[
|
|
273
|
-
`${name}Invalid`
|
|
274
|
-
]
|
|
275
|
-
return
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
fieldsErrorMessages.value[name] = ''
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// For late
|
|
282
|
-
// const setErrorEmpty = (
|
|
283
|
-
// newValue: UI_I_IpFourSettings,
|
|
284
|
-
// oldValue: UI_I_IpFourSettings,
|
|
285
|
-
// fieldName: keyof UI_I_IpFourSettings,
|
|
286
|
-
// errFieldName: string
|
|
287
|
-
// ) => {
|
|
288
|
-
// newValue[fieldName] !== oldValue[fieldName] &&
|
|
289
|
-
// emits('set-error-empty', errFieldName)
|
|
290
|
-
// }
|
|
291
|
-
|
|
292
|
-
// Changing data and validate they
|
|
293
|
-
watch(
|
|
294
|
-
fields,
|
|
295
|
-
(newFields: UI_I_IpFourSettings) => {
|
|
296
|
-
setMessageOnChangedField(
|
|
297
|
-
newFields.static.ipFourAddress,
|
|
298
|
-
'ipFourAddress',
|
|
299
|
-
newFields.ipSettings
|
|
300
|
-
)
|
|
301
|
-
setMessageOnChangedField(
|
|
302
|
-
newFields.static.subnetMask,
|
|
303
|
-
'subnetMask',
|
|
304
|
-
newFields.ipSettings
|
|
305
|
-
)
|
|
306
|
-
setMessageOnChangedField(
|
|
307
|
-
newFields.static.defaultGateway.value,
|
|
308
|
-
'defaultGateway',
|
|
309
|
-
newFields.ipSettings,
|
|
310
|
-
newFields.static.defaultGateway.override
|
|
311
|
-
)
|
|
312
|
-
const fieldsErrorMessagesFiltered = Object.values(
|
|
313
|
-
fieldsErrorMessages.value
|
|
314
|
-
).filter((errorMessage: string) => errorMessage !== '')
|
|
315
|
-
|
|
316
|
-
fieldsErrorMessagesFiltered.length === 0 &&
|
|
317
|
-
emits('hide-error-message-alert')
|
|
318
|
-
emits('change-error-messages', fieldsErrorMessagesFiltered, props.stepId)
|
|
319
|
-
|
|
320
|
-
emits('change-ip-four-settings', newFields)
|
|
321
|
-
},
|
|
322
|
-
{ deep: true }
|
|
323
|
-
)
|
|
324
|
-
|
|
325
|
-
watch(
|
|
326
|
-
() => props.error,
|
|
327
|
-
(newError) => {
|
|
328
|
-
fieldsErrorMessages.value = {
|
|
329
|
-
ipFourAddress: newError['tcp_config.ipv4'] || '',
|
|
330
|
-
subnetMask: newError['tcp_config.net_mask'] || '',
|
|
331
|
-
defaultGateway: newError['tcp_config.gateway'] || '',
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
const fieldsErrorMessagesFiltered = Object.values(
|
|
335
|
-
fieldsErrorMessages.value
|
|
336
|
-
).filter(
|
|
337
|
-
(errorMessage: string | undefined) =>
|
|
338
|
-
errorMessage !== '' && errorMessage !== undefined
|
|
339
|
-
)
|
|
340
|
-
|
|
341
|
-
emits('change-error-messages', fieldsErrorMessagesFiltered, props.stepId)
|
|
342
|
-
},
|
|
343
|
-
{ deep: true, immediate: true }
|
|
344
|
-
)
|
|
345
|
-
|
|
346
|
-
// Validation message show and hide
|
|
347
|
-
const onHideErrorMessageAlert = (): void => {
|
|
348
|
-
emits('hide-error-message-alert')
|
|
349
|
-
}
|
|
350
|
-
onUnmounted(() => {
|
|
351
|
-
emits('hide-error-message-alert')
|
|
352
|
-
})
|
|
353
|
-
</script>
|
|
354
|
-
<style lang="scss" scoped>
|
|
355
|
-
.p-b-14 {
|
|
356
|
-
padding-bottom: 14px;
|
|
357
|
-
}
|
|
358
|
-
fieldset :deep(.flex) {
|
|
359
|
-
width: 144px;
|
|
360
|
-
}
|
|
361
|
-
</style>
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
UI_I_NetworkLabelCheckExisting,
|
|
3
|
-
UI_I_Step,
|
|
4
|
-
} from '~/components/common/addNetworking/models/interfaces'
|
|
5
|
-
import { UI_E_StepStatus } from '~/components/common/addNetworking/models/enums'
|
|
6
|
-
|
|
7
|
-
export class Wizard {
|
|
8
|
-
stepsScheme: UI_I_Step[][]
|
|
9
|
-
selectedStepScheme: Ref<number>
|
|
10
|
-
private _selectedStep: Ref<number>
|
|
11
|
-
completedStepsId: Ref<number[]>
|
|
12
|
-
private _waitingStepId: Ref<number>
|
|
13
|
-
|
|
14
|
-
constructor(stepsScheme: UI_I_Step[][]) {
|
|
15
|
-
this.selectedStepScheme = ref<number>(0)
|
|
16
|
-
this._selectedStep = ref<number>(0)
|
|
17
|
-
this.stepsScheme = stepsScheme
|
|
18
|
-
this.completedStepsId = ref<number[]>([])
|
|
19
|
-
this._waitingStepId = ref<number>(0)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get selectedScheme(): number {
|
|
23
|
-
return this.selectedStepScheme.value
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
set selectedScheme(stepScheme: number) {
|
|
27
|
-
this.selectedStepScheme.value = stepScheme
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
isSelectedScheme(stepScheme: number): boolean {
|
|
31
|
-
return this.selectedStepScheme.value === stepScheme
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
resetStepsUntilX(x: number): void {
|
|
35
|
-
this.completedStepsId.value.length >= x &&
|
|
36
|
-
(this.completedStepsId.value.length = x - 1)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get selectedStep(): number {
|
|
40
|
-
return this._selectedStep.value
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
set selectedStep(step: number) {
|
|
44
|
-
this._selectedStep.value = step
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get waitingStepId(): number {
|
|
48
|
-
return this._waitingStepId.value
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
set waitingStepId(step: number) {
|
|
52
|
-
this._waitingStepId.value = step
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
isSelectedStep(step: number): boolean {
|
|
56
|
-
return this.selectedStep === step
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
isUpThenSelectedStep(step: number): boolean {
|
|
60
|
-
return this.selectedStep <= step
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
isDownThenSelectedStep(step: number): boolean {
|
|
64
|
-
return this.selectedStep >= step
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
reset(): void {
|
|
68
|
-
this.selectedScheme = 0
|
|
69
|
-
this.selectedStep = 0
|
|
70
|
-
this.resetStepsUntilX(1)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
goToNextStep(
|
|
74
|
-
cb?: (
|
|
75
|
-
selectedStepIndex: number,
|
|
76
|
-
nextStepId: number,
|
|
77
|
-
...args: any
|
|
78
|
-
) => boolean,
|
|
79
|
-
...args: any
|
|
80
|
-
): void {
|
|
81
|
-
const selectedStepIndex: number = this.stepsWithStatus().findIndex(
|
|
82
|
-
(step: UI_I_Step) => this.isSelectedStep(step.id)
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
const nextStepId: number = this.stepsWithStatus()[selectedStepIndex + 1].id
|
|
86
|
-
|
|
87
|
-
if (!cb || cb(selectedStepIndex, nextStepId, ...args)) {
|
|
88
|
-
this.selectedStep = this.stepsWithStatus()[selectedStepIndex + 1].id
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
goToSelectedStep(step: number, cb?: (step: number) => boolean): void {
|
|
93
|
-
if (!cb || cb(step)) {
|
|
94
|
-
this.selectedStep = step
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
goToBackStep(): void {
|
|
99
|
-
const selectedStepIndex: number = this.stepsWithStatus().findIndex(
|
|
100
|
-
(step: UI_I_Step) => this.isSelectedStep(step.id)
|
|
101
|
-
)
|
|
102
|
-
this.selectedStep = this.stepsWithStatus()[selectedStepIndex - 1].id
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
isBeforeLastStep(): boolean {
|
|
106
|
-
const selectedScheme: UI_I_Step[] = this.stepsScheme[this.selectedScheme]
|
|
107
|
-
|
|
108
|
-
return selectedScheme[selectedScheme.length - 2].id === this.selectedStep
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
isLastStep(step: number): boolean {
|
|
112
|
-
const selectedScheme: UI_I_Step[] = this.stepsScheme[this.selectedScheme]
|
|
113
|
-
|
|
114
|
-
return selectedScheme[selectedScheme.length - 1].id === step
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
stepsWithStatus(): UI_I_Step[] {
|
|
118
|
-
// let selectedFlag = false
|
|
119
|
-
let lastId = 0
|
|
120
|
-
|
|
121
|
-
return this.stepsScheme[this.selectedScheme].map(
|
|
122
|
-
(step: UI_I_Step): UI_I_Step => {
|
|
123
|
-
if (
|
|
124
|
-
// If a selected step is completed
|
|
125
|
-
step.id === this.selectedStep &&
|
|
126
|
-
this.completedStepsId.value.includes(step.id)
|
|
127
|
-
) {
|
|
128
|
-
lastId = step.id
|
|
129
|
-
return { ...step, status: UI_E_StepStatus.CompleteSelected }
|
|
130
|
-
} else if (
|
|
131
|
-
// If a step is completed
|
|
132
|
-
step.id < this.selectedStep ||
|
|
133
|
-
this.completedStepsId.value.includes(step.id)
|
|
134
|
-
) {
|
|
135
|
-
!this.completedStepsId.value.includes(step.id) &&
|
|
136
|
-
this.completedStepsId.value.push(step.id)
|
|
137
|
-
lastId = step.id
|
|
138
|
-
return { ...step, status: UI_E_StepStatus.Complete }
|
|
139
|
-
} else if (
|
|
140
|
-
// If a step is selected, but is not active
|
|
141
|
-
step.id === this.selectedStep
|
|
142
|
-
) {
|
|
143
|
-
// selectedFlag = true
|
|
144
|
-
lastId = step.id
|
|
145
|
-
return { ...step, status: UI_E_StepStatus.Selected }
|
|
146
|
-
} else if (
|
|
147
|
-
// If a step is active
|
|
148
|
-
|
|
149
|
-
lastId ===
|
|
150
|
-
this.completedStepsId.value[this.completedStepsId.value.length - 1]
|
|
151
|
-
) {
|
|
152
|
-
// console.log(selectedFlag)
|
|
153
|
-
// selectedFlag = false
|
|
154
|
-
lastId = step.id
|
|
155
|
-
return { ...step, status: UI_E_StepStatus.Active }
|
|
156
|
-
} // If a step is disabled
|
|
157
|
-
else {
|
|
158
|
-
lastId = step.id
|
|
159
|
-
return { ...step, status: UI_E_StepStatus.Disabled }
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// -----------------
|
|
166
|
-
// Not common-------
|
|
167
|
-
|
|
168
|
-
checkNetworkLabelBeforeGoToNextStep(
|
|
169
|
-
currentStep: number,
|
|
170
|
-
networkLabel: string,
|
|
171
|
-
isNetworkInvalid: UI_I_NetworkLabelCheckExisting | undefined,
|
|
172
|
-
checkNetwork: (networkLabel: string, nextStep?: number) => void
|
|
173
|
-
): boolean {
|
|
174
|
-
if (
|
|
175
|
-
this.isSelectedStep(currentStep) &&
|
|
176
|
-
(!isNetworkInvalid?.checked ||
|
|
177
|
-
(isNetworkInvalid.checked && !isNetworkInvalid.valid))
|
|
178
|
-
) {
|
|
179
|
-
checkNetwork(networkLabel)
|
|
180
|
-
return true
|
|
181
|
-
}
|
|
182
|
-
return false
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
checkNetworkLabelBeforeGoToNewStep(
|
|
186
|
-
nextStep: number,
|
|
187
|
-
currentStepScheme: number,
|
|
188
|
-
currentStep: number,
|
|
189
|
-
networkLabel: string,
|
|
190
|
-
isNetworkInvalid: UI_I_NetworkLabelCheckExisting | undefined,
|
|
191
|
-
checkNetwork: (networkLabel: string, nextStep?: number) => void
|
|
192
|
-
): boolean {
|
|
193
|
-
if (
|
|
194
|
-
this.isSelectedScheme(currentStepScheme) &&
|
|
195
|
-
nextStep > currentStep &&
|
|
196
|
-
(!isNetworkInvalid?.checked ||
|
|
197
|
-
(isNetworkInvalid.checked && !isNetworkInvalid.valid))
|
|
198
|
-
) {
|
|
199
|
-
checkNetwork(networkLabel, nextStep)
|
|
200
|
-
return true
|
|
201
|
-
}
|
|
202
|
-
return false
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Not common-------
|
|
206
|
-
// -----------------
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export const getVlanId = (vlanId: string): string =>
|
|
210
|
-
(vlanId === 'All (4095)' && '4095') ||
|
|
211
|
-
(vlanId === 'None (0)' && '0') ||
|
|
212
|
-
vlanId
|