bfg-common 1.5.430 → 1.5.431

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.
@@ -75,7 +75,6 @@
75
75
  <script setup lang="ts">
76
76
  import type { UI_I_WizardStep } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
77
77
  import type Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
78
- import type { UI_I_WizardStep } from '~/components/atoms/wizard/lib/models/interfaces'
79
78
  import type { UI_I_Localization } from '~/lib/models/interfaces'
80
79
  import type { UI_T_Project } from '~/lib/models/types'
81
80
  import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
@@ -41,6 +41,7 @@
41
41
  </template>
42
42
 
43
43
  <script lang="ts" setup>
44
+ import type { UI_I_WizardStep } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
44
45
  import type { UI_T_Project } from '~/lib/models/types'
45
46
  import type { UI_I_SendTaskParams, UI_I_ModalPayload } from '~/lib/models/interfaces'
46
47
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
@@ -52,7 +53,6 @@ import type {
52
53
  } from '~/components/common/pages/backups/modals/lib/models/interfaces'
53
54
  import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
54
55
  import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
55
- import type { UI_I_WizardStep } from '~/components/atoms/wizard/lib/models/interfaces'
56
56
  import type { UI_I_BackupAction } from '~/components/common/pages/backups/lib/models/interfaces'
57
57
  import type { UI_I_NameCheck } from '~/components/common/pages/backups/modals/restore/name/lib/models/interfaces'
58
58
  import { sendTask } from '~/lib/utils/sendTask'
@@ -1,376 +1,379 @@
1
- <template>
2
- <div class="create-backup">
3
- <atoms-wizard
4
- show
5
- :wizard="wizard"
6
- :selected-scheme="selectedScheme"
7
- :title="title"
8
- :localization="localization"
9
- :test-id="testId"
10
- @change-steps="onChangeSteps"
11
- @hide="onHideModal"
12
- @submit="onFinish"
13
- >
14
- <template #modalBody="{ selectedStep }">
15
- <atoms-alert
16
- v-show="errors.length"
17
- status="alert-danger"
18
- :items="errors"
19
- test-id="create-backup-alert"
20
- @remove="onRemoveValidationErrors"
21
- />
22
-
23
- <common-pages-scheduled-tasks-modals-common-new-task-form
24
- v-show="selectedStep.id === dynamicSteps.schedulingOptions"
25
- v-model="modelSchedulerTask"
26
- :target="props.selectedVmName"
27
- class="new-task-form"
28
- />
29
-
30
- <common-pages-backups-modals-create-backup-general
31
- v-show="selectedStep.id === dynamicSteps.general"
32
- v-model="model"
33
- :show="selectedStep.id === dynamicSteps.general"
34
- :general-submit="generalSubmit"
35
- @check-name="onCheckName"
36
- />
37
-
38
- <common-pages-backups-modals-create-backup-disks
39
- v-show="selectedStep.id === dynamicSteps.disks"
40
- v-model="model"
41
- :disks="props.disks"
42
- :disks-loading="props.disksLoading"
43
- />
44
-
45
- <common-pages-backups-modals-create-backup-datastores
46
- v-show="selectedStep.id === dynamicSteps.datastores"
47
- v-model="model"
48
- :datastore-table="props.datastoreTable"
49
- :datastore-table-loading="props.datastoreTableLoading"
50
- @change="onChangeDatastore"
51
- />
52
-
53
- <common-pages-backups-modals-create-backup-configuration
54
- v-show="selectedStep.id === dynamicSteps.configuration"
55
- v-model="model"
56
- />
57
-
58
- <common-ready-to-complete
59
- v-show="selectedStep.id === dynamicSteps.readyComplete"
60
- :data="readyToCompleteInfo"
61
- />
62
- </template>
63
- </atoms-wizard>
64
- </div>
65
- </template>
66
-
67
- <script setup lang="ts">
68
- import type { UI_I_WizardStep, UI_I_ValidationReturn } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
69
- import type { UI_I_Localization } from '~/lib/models/interfaces'
70
- import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
71
- import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
72
- import type {
73
- UI_I_BackupDatastoreTable,
74
- UI_I_CreateBackupForm,
75
- UI_I_Pvm,
76
- } from '~/components/common/pages/backups/modals/lib/models/interfaces'
77
- import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
78
- import type { UI_I_NameCheck } from '~/components/common/pages/backups/modals/restore/name/lib/models/interfaces'
79
- import Wizard from '~/components/atoms/wizard/lib/utils/utils'
80
- import {
81
- stepsSchemeInitial,
82
- stepsFunc,
83
- dynamicSteps,
84
- } from '~/components/common/pages/backups/modals/createBackup/lib/config/steps'
85
- import { strategyOptionsFunc } from '~/components/common/pages/backups/modals/createBackup/lib/config/strategyOptions'
86
-
87
- const model = defineModel<UI_I_CreateBackupForm>({ required: true })
88
- const modelSchedulerTask = defineModel<UI_I_ScheduleNewTasksForm>(
89
- 'schedulerForm',
90
- { required: true }
91
- )
92
-
93
- const props = defineProps<{
94
- isEdit: boolean
95
- target: string
96
- isScheduledTasks: boolean
97
- isEditScheduledTasks: boolean
98
- selectedVmName: string
99
- disks: UI_I_Pvm['disk_devices']
100
- disksLoading: boolean
101
- datastoreTable: UI_I_BackupDatastoreTable
102
- datastoreTableLoading: boolean
103
- }>()
104
-
105
- const emits = defineEmits<{
106
- (event: 'change-step-create-backup', value: UI_I_WizardStep[]): void
107
- (event: 'check-name', value: UI_I_NameCheck): void
108
- (event: 'finish'): void
109
- (event: 'hide'): void
110
- }>()
111
-
112
- const localization = computed<UI_I_Localization>(() => useLocal())
113
- const { $binary }: any = useNuxtApp()
114
-
115
- const title = computed<string>(() => {
116
- const { createBackup, updateBackup, scheduleNewTasks, scheduleTaskEdit } =
117
- localization.value.common
118
- let result = props.isEdit ? updateBackup : createBackup
119
- if (props.isScheduledTasks) {
120
- const schedulerMode = props.isEditScheduledTasks
121
- ? scheduleTaskEdit
122
- : scheduleNewTasks
123
-
124
- result = `${schedulerMode} (${createBackup})`
125
- }
126
-
127
- return result
128
- })
129
-
130
- const testId = ref<string>(props.isEdit ? 'update-backup' : 'create-backup')
131
-
132
- const wizard: Wizard = new Wizard(
133
- stepsFunc(localization.value),
134
- stepsSchemeInitial(props.isScheduledTasks)
135
- )
136
-
137
- watch(
138
- modelSchedulerTask,
139
- (newValue: UI_I_ScheduleNewTasksForm) => {
140
- if (props.isScheduledTasks) wizard.setDisabledNextButton(newValue.isValid)
141
- },
142
- { immediate: true, deep: true }
143
- )
144
-
145
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
146
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
147
- emits('change-step-create-backup', value)
148
- wizard.changeSteps(value, validationFunc)
149
- }
150
-
151
- const generalSubmit = ref<null | Function>(null)
152
-
153
- const validationFunc = async (
154
- value: UI_I_WizardStep[],
155
- currentStep: UI_I_WizardStep,
156
- nextStep: UI_I_WizardStep
157
- ): Promise<UI_I_ValidationReturn> => {
158
- let stepHasError = false
159
- const stepShouldStop = {
160
- ifOnCurrentStep: false,
161
- ifFromAnyStep: false,
162
- stoppageStepId: -1,
163
- }
164
-
165
- if (
166
- wizard.isValidateForStep(dynamicSteps.general, currentStep.id, nextStep.id)
167
- ) {
168
- const nameValidation = await checkName(value)
169
-
170
- value = nameValidation.newValue
171
- stepHasError = stepHasError || nameValidation.stepHasError
172
- }
173
-
174
- if (
175
- wizard.isValidateForStep(dynamicSteps.disks, currentStep.id, nextStep.id)
176
- ) {
177
- const validation = checkDisks(value)
178
-
179
- value = validation.newValue
180
- stepHasError = stepHasError || validation.stepHasError
181
- }
182
-
183
- if (
184
- wizard.isValidateForStep(
185
- dynamicSteps.datastores,
186
- currentStep.id,
187
- nextStep.id
188
- )
189
- ) {
190
- const validation = checkDatastore(value)
191
-
192
- value = validation.newValue
193
- stepHasError = stepHasError || validation.stepHasError
194
- }
195
-
196
- return {
197
- newValue: value,
198
- stepHasError,
199
- stepShouldStop,
200
- }
201
- }
202
-
203
- const checkName = async (
204
- value: UI_I_WizardStep[]
205
- ): Promise<UI_I_ValidationReturn> => {
206
- let stepHasError = false
207
-
208
- const { name } = model.value
209
- if (!name) {
210
- stepHasError = wizard.setValidation(dynamicSteps.general, 'name', {
211
- fieldMessage: localization.value.common.nameIsRequired,
212
- alertMessage: localization.value.common.nameIsRequired,
213
- })
214
- return {
215
- stepHasError,
216
- newValue: value,
217
- }
218
- }
219
- return new Promise((resolve) => {
220
- generalSubmit.value = (isValid: boolean): void => {
221
- if (!isValid) {
222
- stepHasError = wizard.setValidation(dynamicSteps.general, 'name', {
223
- fieldMessage: 'aaa',
224
- alertMessage: 'aaa',
225
- })
226
- } else if (wizard.hasMessage(dynamicSteps.general, 'name')) {
227
- value = wizard.removeValidation(dynamicSteps.general, 'name', value)
228
- }
229
-
230
- resolve({
231
- stepHasError,
232
- newValue: value,
233
- })
234
- generalSubmit.value = null
235
- }
236
- })
237
- }
238
- const onCheckName = async (data: UI_I_NameCheck): Promise<void> => {
239
- emits('check-name', data)
240
- }
241
-
242
- const checkDisks = (value: UI_I_WizardStep[]): UI_I_ValidationReturn => {
243
- let stepHasError = false
244
-
245
- const isValidStores = !!model.value?.disk_devices.length
246
- if (!isValidStores) {
247
- stepHasError = wizard.setValidation(dynamicSteps.disks, 'disk_devices', {
248
- fieldMessage: localization.value.common.diskIsRequired,
249
- alertMessage: localization.value.common.diskIsRequired,
250
- })
251
- showValidationErrors([localization.value.common.diskIsRequired])
252
- } else if (wizard.hasMessage(dynamicSteps.disks, 'disk_devices')) {
253
- value = wizard.removeValidation(dynamicSteps.disks, 'disk_devices', value)
254
- onRemoveValidationErrors()
255
- }
256
-
257
- return {
258
- stepHasError,
259
- newValue: value,
260
- }
261
- }
262
-
263
- const checkDatastore = (value: UI_I_WizardStep[]): UI_I_ValidationReturn => {
264
- let stepHasError = false
265
-
266
- const isValidStorage = !!model.value?.backup_storage.length
267
- if (!isValidStorage) {
268
- stepHasError = wizard.setValidation(
269
- dynamicSteps.datastores,
270
- 'backup_storage',
271
- {
272
- fieldMessage: localization.value.common.datastoreIsRequired,
273
- alertMessage: localization.value.common.datastoreIsRequired,
274
- }
275
- )
276
- showValidationErrors([localization.value.common.datastoreIsRequired])
277
- } else if (wizard.hasMessage(dynamicSteps.datastores, 'backup_storage')) {
278
- value = wizard.removeValidation(
279
- dynamicSteps.datastores,
280
- 'backup_storage',
281
- value
282
- )
283
- onRemoveValidationErrors()
284
- }
285
-
286
- return {
287
- stepHasError,
288
- newValue: value,
289
- }
290
- }
291
-
292
- const selectedDatastoresNames = ref<string[]>([])
293
- const onChangeDatastore = (names: string[]): void => {
294
- selectedDatastoresNames.value = names
295
- }
296
-
297
- const strategyOptions = ref<UI_I_SelectInputItem[]>(
298
- strategyOptionsFunc(localization.value)
299
- )
300
-
301
- const readyToCompleteInfo = computed<UI_I_TableInfoItem[]>(() => {
302
- // General
303
- const result = [
304
- {
305
- label: localization.value.common.name,
306
- value: model.value.name,
307
- },
308
- {
309
- label: localization.value.common.description,
310
- value: model.value.description,
311
- },
312
- ]
313
-
314
- // Disks
315
- model.value.disk_devices.forEach((disk_device, i) => {
316
- result.push({
317
- label: `${localization.value.common.disk} ${i + 1}`,
318
- value: disk_device.location,
319
- })
320
- })
321
-
322
- // Datastores
323
- result.push({
324
- label: localization.value.common.datastore,
325
- value: selectedDatastoresNames.value.join(', '),
326
- })
327
-
328
- // Configuration
329
- result.push({
330
- label: localization.value.common.strategy,
331
- value:
332
- strategyOptions.value.find(
333
- (option) => option.value === model.value.strategy
334
- )?.label || '',
335
- })
336
- // result.push({
337
- // label: localization.value.common.backupWindow,
338
- // value: model.value.start_window_min + '',
339
- // })
340
-
341
- const gbSizeByB = 1_073_741_824
342
- const maxBandwidth =
343
- model.value.bandwidth_limit >= gbSizeByB
344
- ? $binary.bToGb(model.value.bandwidth_limit) + ' Gbps'
345
- : $binary.bToMb(model.value.bandwidth_limit) + ' Mbps'
346
-
347
- result.push({
348
- label: localization.value.common.maxBandwidth,
349
- value: maxBandwidth,
350
- })
351
-
352
- return result
353
- })
354
-
355
- const errors = ref<string[]>([])
356
- const showValidationErrors = (data: string[]): void => {
357
- errors.value = data
358
- }
359
- const onRemoveValidationErrors = (): void => {
360
- errors.value = []
361
- }
362
-
363
- const onFinish = (): void => {
364
- emits('finish')
365
- }
366
- const onHideModal = (): void => {
367
- emits('hide')
368
- }
369
- </script>
370
-
371
- <style scoped lang="scss">
372
- :deep(.modal-body) {
373
- display: flex;
374
- flex-direction: column;
375
- }
376
- </style>
1
+ <template>
2
+ <div class="create-backup">
3
+ <atoms-wizard
4
+ show
5
+ :wizard="wizard"
6
+ :selected-scheme="selectedScheme"
7
+ :title="title"
8
+ :localization="localization"
9
+ :test-id="testId"
10
+ @change-steps="onChangeSteps"
11
+ @hide="onHideModal"
12
+ @submit="onFinish"
13
+ >
14
+ <template #modalBody="{ selectedStep }">
15
+ <atoms-alert
16
+ v-show="errors.length"
17
+ status="alert-danger"
18
+ :items="errors"
19
+ test-id="create-backup-alert"
20
+ @remove="onRemoveValidationErrors"
21
+ />
22
+
23
+ <common-pages-scheduled-tasks-modals-common-new-task-form
24
+ v-show="selectedStep.id === dynamicSteps.schedulingOptions"
25
+ v-model="modelSchedulerTask"
26
+ :target="props.selectedVmName"
27
+ class="new-task-form"
28
+ />
29
+
30
+ <common-pages-backups-modals-create-backup-general
31
+ v-show="selectedStep.id === dynamicSteps.general"
32
+ v-model="model"
33
+ :show="selectedStep.id === dynamicSteps.general"
34
+ :general-submit="generalSubmit"
35
+ @check-name="onCheckName"
36
+ />
37
+
38
+ <common-pages-backups-modals-create-backup-disks
39
+ v-show="selectedStep.id === dynamicSteps.disks"
40
+ v-model="model"
41
+ :disks="props.disks"
42
+ :disks-loading="props.disksLoading"
43
+ />
44
+
45
+ <common-pages-backups-modals-create-backup-datastores
46
+ v-show="selectedStep.id === dynamicSteps.datastores"
47
+ v-model="model"
48
+ :datastore-table="props.datastoreTable"
49
+ :datastore-table-loading="props.datastoreTableLoading"
50
+ @change="onChangeDatastore"
51
+ />
52
+
53
+ <common-pages-backups-modals-create-backup-configuration
54
+ v-show="selectedStep.id === dynamicSteps.configuration"
55
+ v-model="model"
56
+ />
57
+
58
+ <common-ready-to-complete
59
+ v-show="selectedStep.id === dynamicSteps.readyComplete"
60
+ :data="readyToCompleteInfo"
61
+ />
62
+ </template>
63
+ </atoms-wizard>
64
+ </div>
65
+ </template>
66
+
67
+ <script setup lang="ts">
68
+ import type {
69
+ UI_I_WizardStep,
70
+ UI_I_ValidationReturn,
71
+ } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
72
+ import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
73
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
74
+ import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
75
+ import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
76
+ import type {
77
+ UI_I_BackupDatastoreTable,
78
+ UI_I_CreateBackupForm,
79
+ UI_I_Pvm,
80
+ } from '~/components/common/pages/backups/modals/lib/models/interfaces'
81
+ import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
82
+ import type { UI_I_NameCheck } from '~/components/common/pages/backups/modals/restore/name/lib/models/interfaces'
83
+ import {
84
+ stepsSchemeInitial,
85
+ stepsFunc,
86
+ dynamicSteps,
87
+ } from '~/components/common/pages/backups/modals/createBackup/lib/config/steps'
88
+ import { strategyOptionsFunc } from '~/components/common/pages/backups/modals/createBackup/lib/config/strategyOptions'
89
+
90
+ const model = defineModel<UI_I_CreateBackupForm>({ required: true })
91
+ const modelSchedulerTask = defineModel<UI_I_ScheduleNewTasksForm>(
92
+ 'schedulerForm',
93
+ { required: true }
94
+ )
95
+
96
+ const props = defineProps<{
97
+ isEdit: boolean
98
+ target: string
99
+ isScheduledTasks: boolean
100
+ isEditScheduledTasks: boolean
101
+ selectedVmName: string
102
+ disks: UI_I_Pvm['disk_devices']
103
+ disksLoading: boolean
104
+ datastoreTable: UI_I_BackupDatastoreTable
105
+ datastoreTableLoading: boolean
106
+ }>()
107
+
108
+ const emits = defineEmits<{
109
+ (event: 'change-step-create-backup', value: UI_I_WizardStep[]): void
110
+ (event: 'check-name', value: UI_I_NameCheck): void
111
+ (event: 'finish'): void
112
+ (event: 'hide'): void
113
+ }>()
114
+
115
+ const localization = computed<UI_I_Localization>(() => useLocal())
116
+ const { $binary }: any = useNuxtApp()
117
+
118
+ const title = computed<string>(() => {
119
+ const { createBackup, updateBackup, scheduleNewTasks, scheduleTaskEdit } =
120
+ localization.value.common
121
+ let result = props.isEdit ? updateBackup : createBackup
122
+ if (props.isScheduledTasks) {
123
+ const schedulerMode = props.isEditScheduledTasks
124
+ ? scheduleTaskEdit
125
+ : scheduleNewTasks
126
+
127
+ result = `${schedulerMode} (${createBackup})`
128
+ }
129
+
130
+ return result
131
+ })
132
+
133
+ const testId = ref<string>(props.isEdit ? 'update-backup' : 'create-backup')
134
+
135
+ const wizard: Wizard = new Wizard(
136
+ stepsFunc(localization.value),
137
+ stepsSchemeInitial(props.isScheduledTasks)
138
+ )
139
+
140
+ watch(
141
+ modelSchedulerTask,
142
+ (newValue: UI_I_ScheduleNewTasksForm) => {
143
+ if (props.isScheduledTasks) wizard.setDisabledNextButton(newValue.isValid)
144
+ },
145
+ { immediate: true, deep: true }
146
+ )
147
+
148
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
149
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> => {
150
+ emits('change-step-create-backup', value)
151
+ wizard.changeSteps(value, validationFunc)
152
+ }
153
+
154
+ const generalSubmit = ref<null | Function>(null)
155
+
156
+ const validationFunc = async (
157
+ value: UI_I_WizardStep[],
158
+ currentStep: UI_I_WizardStep,
159
+ nextStep: UI_I_WizardStep
160
+ ): Promise<UI_I_ValidationReturn> => {
161
+ let stepHasError = false
162
+ const stepShouldStop = {
163
+ ifOnCurrentStep: false,
164
+ ifFromAnyStep: false,
165
+ stoppageStepId: -1,
166
+ }
167
+
168
+ if (
169
+ wizard.isValidateForStep(dynamicSteps.general, currentStep.id, nextStep.id)
170
+ ) {
171
+ const nameValidation = await checkName(value)
172
+
173
+ value = nameValidation.newValue
174
+ stepHasError = stepHasError || nameValidation.stepHasError
175
+ }
176
+
177
+ if (
178
+ wizard.isValidateForStep(dynamicSteps.disks, currentStep.id, nextStep.id)
179
+ ) {
180
+ const validation = checkDisks(value)
181
+
182
+ value = validation.newValue
183
+ stepHasError = stepHasError || validation.stepHasError
184
+ }
185
+
186
+ if (
187
+ wizard.isValidateForStep(
188
+ dynamicSteps.datastores,
189
+ currentStep.id,
190
+ nextStep.id
191
+ )
192
+ ) {
193
+ const validation = checkDatastore(value)
194
+
195
+ value = validation.newValue
196
+ stepHasError = stepHasError || validation.stepHasError
197
+ }
198
+
199
+ return {
200
+ newValue: value,
201
+ stepHasError,
202
+ stepShouldStop,
203
+ }
204
+ }
205
+
206
+ const checkName = async (
207
+ value: UI_I_WizardStep[]
208
+ ): Promise<UI_I_ValidationReturn> => {
209
+ let stepHasError = false
210
+
211
+ const { name } = model.value
212
+ if (!name) {
213
+ stepHasError = wizard.setValidation(dynamicSteps.general, 'name', {
214
+ fieldMessage: localization.value.common.nameIsRequired,
215
+ alertMessage: localization.value.common.nameIsRequired,
216
+ })
217
+ return {
218
+ stepHasError,
219
+ newValue: value,
220
+ }
221
+ }
222
+ return new Promise((resolve) => {
223
+ generalSubmit.value = (isValid: boolean): void => {
224
+ if (!isValid) {
225
+ stepHasError = wizard.setValidation(dynamicSteps.general, 'name', {
226
+ fieldMessage: 'aaa',
227
+ alertMessage: 'aaa',
228
+ })
229
+ } else if (wizard.hasMessage(dynamicSteps.general, 'name')) {
230
+ value = wizard.removeValidation(dynamicSteps.general, 'name', value)
231
+ }
232
+
233
+ resolve({
234
+ stepHasError,
235
+ newValue: value,
236
+ })
237
+ generalSubmit.value = null
238
+ }
239
+ })
240
+ }
241
+ const onCheckName = async (data: UI_I_NameCheck): Promise<void> => {
242
+ emits('check-name', data)
243
+ }
244
+
245
+ const checkDisks = (value: UI_I_WizardStep[]): UI_I_ValidationReturn => {
246
+ let stepHasError = false
247
+
248
+ const isValidStores = !!model.value?.disk_devices.length
249
+ if (!isValidStores) {
250
+ stepHasError = wizard.setValidation(dynamicSteps.disks, 'disk_devices', {
251
+ fieldMessage: localization.value.common.diskIsRequired,
252
+ alertMessage: localization.value.common.diskIsRequired,
253
+ })
254
+ showValidationErrors([localization.value.common.diskIsRequired])
255
+ } else if (wizard.hasMessage(dynamicSteps.disks, 'disk_devices')) {
256
+ value = wizard.removeValidation(dynamicSteps.disks, 'disk_devices', value)
257
+ onRemoveValidationErrors()
258
+ }
259
+
260
+ return {
261
+ stepHasError,
262
+ newValue: value,
263
+ }
264
+ }
265
+
266
+ const checkDatastore = (value: UI_I_WizardStep[]): UI_I_ValidationReturn => {
267
+ let stepHasError = false
268
+
269
+ const isValidStorage = !!model.value?.backup_storage.length
270
+ if (!isValidStorage) {
271
+ stepHasError = wizard.setValidation(
272
+ dynamicSteps.datastores,
273
+ 'backup_storage',
274
+ {
275
+ fieldMessage: localization.value.common.datastoreIsRequired,
276
+ alertMessage: localization.value.common.datastoreIsRequired,
277
+ }
278
+ )
279
+ showValidationErrors([localization.value.common.datastoreIsRequired])
280
+ } else if (wizard.hasMessage(dynamicSteps.datastores, 'backup_storage')) {
281
+ value = wizard.removeValidation(
282
+ dynamicSteps.datastores,
283
+ 'backup_storage',
284
+ value
285
+ )
286
+ onRemoveValidationErrors()
287
+ }
288
+
289
+ return {
290
+ stepHasError,
291
+ newValue: value,
292
+ }
293
+ }
294
+
295
+ const selectedDatastoresNames = ref<string[]>([])
296
+ const onChangeDatastore = (names: string[]): void => {
297
+ selectedDatastoresNames.value = names
298
+ }
299
+
300
+ const strategyOptions = ref<UI_I_SelectInputItem[]>(
301
+ strategyOptionsFunc(localization.value)
302
+ )
303
+
304
+ const readyToCompleteInfo = computed<UI_I_TableInfoItem[]>(() => {
305
+ // General
306
+ const result = [
307
+ {
308
+ label: localization.value.common.name,
309
+ value: model.value.name,
310
+ },
311
+ {
312
+ label: localization.value.common.description,
313
+ value: model.value.description,
314
+ },
315
+ ]
316
+
317
+ // Disks
318
+ model.value.disk_devices.forEach((disk_device, i) => {
319
+ result.push({
320
+ label: `${localization.value.common.disk} ${i + 1}`,
321
+ value: disk_device.location,
322
+ })
323
+ })
324
+
325
+ // Datastores
326
+ result.push({
327
+ label: localization.value.common.datastore,
328
+ value: selectedDatastoresNames.value.join(', '),
329
+ })
330
+
331
+ // Configuration
332
+ result.push({
333
+ label: localization.value.common.strategy,
334
+ value:
335
+ strategyOptions.value.find(
336
+ (option) => option.value === model.value.strategy
337
+ )?.label || '',
338
+ })
339
+ // result.push({
340
+ // label: localization.value.common.backupWindow,
341
+ // value: model.value.start_window_min + '',
342
+ // })
343
+
344
+ const gbSizeByB = 1_073_741_824
345
+ const maxBandwidth =
346
+ model.value.bandwidth_limit >= gbSizeByB
347
+ ? $binary.bToGb(model.value.bandwidth_limit) + ' Gbps'
348
+ : $binary.bToMb(model.value.bandwidth_limit) + ' Mbps'
349
+
350
+ result.push({
351
+ label: localization.value.common.maxBandwidth,
352
+ value: maxBandwidth,
353
+ })
354
+
355
+ return result
356
+ })
357
+
358
+ const errors = ref<string[]>([])
359
+ const showValidationErrors = (data: string[]): void => {
360
+ errors.value = data
361
+ }
362
+ const onRemoveValidationErrors = (): void => {
363
+ errors.value = []
364
+ }
365
+
366
+ const onFinish = (): void => {
367
+ emits('finish')
368
+ }
369
+ const onHideModal = (): void => {
370
+ emits('hide')
371
+ }
372
+ </script>
373
+
374
+ <style scoped lang="scss">
375
+ :deep(.modal-body) {
376
+ display: flex;
377
+ flex-direction: column;
378
+ }
379
+ </style>
@@ -1,7 +1,7 @@
1
+ import type { UI_I_WizardStep } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
2
+ import { UI_E_WIZARD_STATUS } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/enums'
1
3
  import type { UI_I_Localization } from '~/lib/models/interfaces'
2
- import type { UI_I_WizardStep } from '~/components/atoms/wizard/lib/models/interfaces'
3
4
  import type { UI_I_DynamicSteps } from '~/components/common/pages/backups/modals/createBackup/lib/models/interfaces'
4
- import { UI_E_WIZARD_STATUS } from '~/components/atoms/wizard/lib/models/enums'
5
5
 
6
6
  export const dynamicSteps: UI_I_DynamicSteps = {
7
7
  schedulingOptions: 0,
@@ -85,12 +85,12 @@
85
85
  </template>
86
86
 
87
87
  <script setup lang="ts">
88
- import type { UI_I_Localization } from '~/lib/models/interfaces'
89
88
  import type {
90
89
  UI_I_WizardStep,
91
90
  UI_I_ValidationReturn,
92
- } from '~/components/atoms/wizard/lib/models/interfaces'
93
- import Wizard from '~/components/atoms/wizard/lib/utils/utils'
91
+ } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
92
+ import Wizard from '~/node_modules/bfg-uikit/components/ui/wizard/lib/utils/utils'
93
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
94
94
  import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
95
95
  import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/lib/models/interfaces'
96
96
  import type { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
@@ -1,6 +1,6 @@
1
+ import type { UI_I_WizardStep } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/interfaces'
2
+ import { UI_E_WIZARD_STATUS } from '~/node_modules/bfg-uikit/components/ui/wizard/lib/models/enums'
1
3
  import type { UI_I_Localization } from '~/lib/models/interfaces'
2
- import type { UI_I_WizardStep } from '~/components/atoms/wizard/lib/models/interfaces'
3
- import { UI_E_WIZARD_STATUS } from '~/components/atoms/wizard/lib/models/enums'
4
4
 
5
5
  export const dynamicSteps = {
6
6
  selectType: 0,
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "name": "bfg-common",
3
- "private": false,
4
- "version": "1.5.430",
5
- "scripts": {
6
- "build": "nuxt build",
7
- "dev": "nuxt dev --port=3002",
8
- "generate": "nuxt generate",
9
- "preview": "nuxt preview",
10
- "postinstall": "nuxt prepare",
11
- "minify": "node minify.js",
12
- "prepublishOnly": "node minify.js"
13
- },
14
- "devDependencies": {
15
- "@novnc/novnc": "1.4.0",
16
- "@vueuse/core": "10.1.2",
17
- "@vueuse/nuxt": "10.1.2",
18
- "eslint-config-prettier": "^8.5.0",
19
- "nuxt": "3.11.2",
20
- "prettier": "2.7.1",
21
- "sass": "^1.54.9",
22
- "sass-loader": "^10.3.1",
23
- "terser": "^5.22.0",
24
- "vite-plugin-eslint": "^1.8.1",
25
- "xterm": "^5.1.0",
26
- "xterm-addon-attach": "^0.8.0",
27
- "xterm-addon-fit": "^0.7.0",
28
- "xterm-addon-serialize": "^0.9.0",
29
- "xterm-addon-unicode11": "^0.5.0",
30
- "xterm-addon-web-links": "^0.8.0",
31
- "eslint-plugin-myrules": "file:./eslint"
32
- },
33
- "dependencies": {
34
- "@nuxtjs/eslint-config-typescript": "^12.0.0",
35
- "@vueuse/components": "^10.1.2",
36
- "date-fns": "^2.29.3",
37
- "bfg-nuxt-3-graph": "1.0.26",
38
- "bfg-uikit": "1.0.502",
39
- "html2canvas": "^1.4.1",
40
- "prettier-eslint": "^15.0.1"
41
- }
42
- }
1
+ {
2
+ "name": "bfg-common",
3
+ "private": false,
4
+ "version": "1.5.431",
5
+ "scripts": {
6
+ "build": "nuxt build",
7
+ "dev": "nuxt dev --port=3002",
8
+ "generate": "nuxt generate",
9
+ "preview": "nuxt preview",
10
+ "postinstall": "nuxt prepare",
11
+ "minify": "node minify.js",
12
+ "prepublishOnly": "node minify.js"
13
+ },
14
+ "devDependencies": {
15
+ "@novnc/novnc": "1.4.0",
16
+ "@vueuse/core": "10.1.2",
17
+ "@vueuse/nuxt": "10.1.2",
18
+ "eslint-config-prettier": "^8.5.0",
19
+ "nuxt": "3.11.2",
20
+ "prettier": "2.7.1",
21
+ "sass": "^1.54.9",
22
+ "sass-loader": "^10.3.1",
23
+ "terser": "^5.22.0",
24
+ "vite-plugin-eslint": "^1.8.1",
25
+ "xterm": "^5.1.0",
26
+ "xterm-addon-attach": "^0.8.0",
27
+ "xterm-addon-fit": "^0.7.0",
28
+ "xterm-addon-serialize": "^0.9.0",
29
+ "xterm-addon-unicode11": "^0.5.0",
30
+ "xterm-addon-web-links": "^0.8.0",
31
+ "eslint-plugin-myrules": "file:./eslint"
32
+ },
33
+ "dependencies": {
34
+ "@nuxtjs/eslint-config-typescript": "^12.0.0",
35
+ "@vueuse/components": "^10.1.2",
36
+ "date-fns": "^2.29.3",
37
+ "bfg-nuxt-3-graph": "1.0.26",
38
+ "bfg-uikit": "1.0.502",
39
+ "html2canvas": "^1.4.1",
40
+ "prettier-eslint": "^15.0.1"
41
+ }
42
+ }