bfg-common 1.5.392 → 1.5.393

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.
@@ -1,250 +1,248 @@
1
- <template>
2
- <common-backup-storage-actions-add-new
3
- v-if="isNewView"
4
- v-model="form"
5
- :project="props.project"
6
- :wizard="wizard"
7
- :selected-scheme="selectedScheme"
8
- :alert-messages="alertMessages"
9
- :title="title"
10
- :hosts="props.hosts"
11
- :datastore="props.datastore"
12
- :is-datastore-loading="props.isDatastoreLoading"
13
- :get-datastore-table-func="props.getDatastoreTableFunc"
14
- @change-steps="onChangeSteps"
15
- @change-storage="onChangeStorage"
16
- @submit="onCreate"
17
- @hide="onHideModal"
18
- />
19
- <common-backup-storage-actions-add-old
20
- v-else
21
- v-model="form"
22
- :project="props.project"
23
- :wizard="wizard"
24
- :selected-scheme="selectedScheme"
25
- :alert-messages="alertMessages"
26
- :title="title"
27
- :hosts="props.hosts"
28
- :datastore="props.datastore"
29
- :is-datastore-loading="props.isDatastoreLoading"
30
- :get-datastore-table-func="props.getDatastoreTableFunc"
31
- @change-steps="onChangeSteps"
32
- @change-storage="onChangeStorage"
33
- @submit="onCreate"
34
- @hide="onHideModal"
35
- />
36
- </template>
37
-
38
- <script setup lang="ts">
39
- import type { UI_T_Project } from '~/lib/models/types'
40
- import type { UI_I_CreateDatastoreForm } from '~/components/common/backup/storage/actions/add/lib/models/interfaces'
41
- import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
42
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
43
- import type { UI_I_Localization } from '~/lib/models/interfaces'
44
- import type {
45
- UI_I_ValidationReturn,
46
- UI_I_WizardStep,
47
- } from '~/components/atoms/wizard/lib/models/interfaces'
48
- import type { UI_T_DatastoreTypeCode } from '~/components/common/backup/storage/actions/add/lib/models/types'
49
- // TODO use from uikit
50
- import Wizard from "~/components/atoms/wizard/lib/utils/utils";
51
- import {
52
- stepsFunc,
53
- stepsSchemeInitial,
54
- } from '~/components/common/backup/storage/actions/add/lib/config/steps'
55
- import { datastoreDefaultFormFunc } from '~/components/common/backup/storage/actions/add/lib/config/createDatastore'
56
- import {
57
- dynamicSteps,
58
- getStepScheme,
59
- } from '~/components/common/backup/storage/actions/add/lib/config/steps'
60
- import * as validation from '~/components/common/backup/storage/actions/add/lib/validations'
61
-
62
- const props = withDefaults(
63
- defineProps<{
64
- project: UI_T_Project
65
- datastore: UI_I_DatastoreTableItem[]
66
- isDatastoreLoading: boolean
67
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
68
- hosts?: any[]
69
- }>(),
70
- { hosts: [] }
71
- )
72
- const emits = defineEmits<{
73
- (event: 'create', value: UI_I_CreateDatastoreForm): void
74
- (event: 'hide'): void
75
- }>()
76
-
77
- const { $store }: any = useNuxtApp()
78
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
79
-
80
- const localization = computed<UI_I_Localization>(() => useLocal())
81
-
82
- const title = ref(localization.value.common.newBackupStorage)
83
-
84
- const wizard: Wizard = new Wizard(
85
- stepsFunc(localization.value),
86
- stepsSchemeInitial
87
- )
88
-
89
- const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
90
- const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
91
-
92
- const form = ref<UI_I_CreateDatastoreForm>(
93
- useDeepCopy(datastoreDefaultFormFunc())
94
- )
95
-
96
- const validationFunc = async (
97
- value: UI_I_WizardStep[],
98
- currentStep: UI_I_WizardStep,
99
- nextStep: UI_I_WizardStep
100
- ): Promise<UI_I_ValidationReturn> => {
101
- let stepHasError = false
102
-
103
- if (
104
- wizard.isValidateForStep(dynamicSteps.name, currentStep.id, nextStep.id)
105
- ) {
106
- const nameValidation = await validation.checkDatastoreNameAsync(
107
- localization.value,
108
- value,
109
- form.value,
110
- dynamicSteps.name,
111
- 'name',
112
- wizard,
113
- props.project
114
- )
115
-
116
- value = nameValidation.newValue
117
-
118
- stepHasError = nameValidation.stepHasError
119
- }
120
-
121
- if (
122
- wizard.isValidateForStep(
123
- dynamicSteps.nameAndConfigure,
124
- currentStep.id,
125
- nextStep.id
126
- )
127
- ) {
128
- const nameValidation = await validation.checkDatastoreNameAsync(
129
- localization.value,
130
- value,
131
- form.value,
132
- dynamicSteps.nameAndConfigure,
133
- 'name',
134
- wizard,
135
- props.project
136
- )
137
- value = nameValidation.newValue
138
-
139
- const folderValidation = validation.checkFolderSync(
140
- localization.value,
141
- form.value.folder,
142
- wizard,
143
- value
144
- )
145
- value = folderValidation.newValue
146
-
147
- const serverValidation = validation.checkServerSync(
148
- localization.value,
149
- form.value.server,
150
- wizard,
151
- value
152
- )
153
- value = serverValidation.newValue
154
-
155
- const usernameValidation = validation.checkUsernameSync(
156
- localization.value,
157
- form.value.user,
158
- wizard,
159
- value
160
- )
161
- value = usernameValidation.newValue
162
-
163
- const passwordValidation = validation.checkPasswordSync(
164
- localization.value,
165
- form.value.password,
166
- wizard,
167
- value
168
- )
169
- value = passwordValidation.newValue
170
-
171
- stepHasError =
172
- nameValidation.stepHasError ||
173
- folderValidation.stepHasError ||
174
- serverValidation.stepHasError ||
175
- usernameValidation.stepHasError ||
176
- passwordValidation.stepHasError
177
- }
178
-
179
- if (
180
- wizard.isValidateForStep(
181
- dynamicSteps.hostAccessibility,
182
- currentStep.id,
183
- nextStep.id
184
- )
185
- ) {
186
- const hostsValidation = await validation.checkHostsAccessibilitySync(
187
- localization.value,
188
- form.value.hosts,
189
- wizard,
190
- value
191
- )
192
-
193
- value = hostsValidation.newValue
194
-
195
- stepHasError = hostsValidation.stepHasError
196
- }
197
-
198
- if (
199
- wizard.isValidateForStep(dynamicSteps.storage, currentStep.id, nextStep.id)
200
- ) {
201
- const storageValidation = await validation.checkStorageSync(
202
- localization.value,
203
- form.value.storm_id,
204
- wizard,
205
- value
206
- )
207
-
208
- value = storageValidation.newValue
209
-
210
- stepHasError = storageValidation.stepHasError
211
- }
212
-
213
- return {
214
- newValue: value,
215
- stepHasError,
216
- }
217
- }
218
-
219
- const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> =>
220
- wizard.changeSteps(value, validationFunc)
221
-
222
- // Choosing Scheme
223
- watch(
224
- () => form.value.type_code,
225
- (newValue: UI_T_DatastoreTypeCode) => {
226
- const step = getStepScheme(props.project, newValue)
227
- if (step !== undefined) {
228
- wizard.changeScheme(step)
229
- }
230
- },
231
- { immediate: true }
232
- )
233
-
234
- const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
235
- if (!storage) return
236
-
237
- form.value.storm_id = storage.id
238
- }
239
-
240
- const onCreate = async (
241
- ): Promise<void> => {
242
- emits('create', form.value)
243
- }
244
-
245
- const onHideModal = (): void => {
246
- emits('hide')
247
- }
248
- </script>
249
-
250
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-backup-storage-actions-add-new
3
+ v-if="isNewView"
4
+ v-model="form"
5
+ :project="props.project"
6
+ :wizard="wizard"
7
+ :selected-scheme="selectedScheme"
8
+ :alert-messages="alertMessages"
9
+ :title="title"
10
+ :hosts="props.hosts"
11
+ :datastore="props.datastore"
12
+ :is-datastore-loading="props.isDatastoreLoading"
13
+ :get-datastore-table-func="props.getDatastoreTableFunc"
14
+ @change-steps="onChangeSteps"
15
+ @change-storage="onChangeStorage"
16
+ @submit="onCreate"
17
+ @hide="onHideModal"
18
+ />
19
+ <common-backup-storage-actions-add-old
20
+ v-else
21
+ v-model="form"
22
+ :project="props.project"
23
+ :wizard="wizard"
24
+ :selected-scheme="selectedScheme"
25
+ :alert-messages="alertMessages"
26
+ :title="title"
27
+ :hosts="props.hosts"
28
+ :datastore="props.datastore"
29
+ :is-datastore-loading="props.isDatastoreLoading"
30
+ :get-datastore-table-func="props.getDatastoreTableFunc"
31
+ @change-steps="onChangeSteps"
32
+ @change-storage="onChangeStorage"
33
+ @submit="onCreate"
34
+ @hide="onHideModal"
35
+ />
36
+ </template>
37
+
38
+ <script setup lang="ts">
39
+ import type { UI_T_Project } from '~/lib/models/types'
40
+ import type { UI_I_CreateDatastoreForm } from '~/components/common/backup/storage/actions/add/lib/models/interfaces'
41
+ import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
42
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
43
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
44
+ import type {
45
+ UI_I_ValidationReturn,
46
+ UI_I_WizardStep,
47
+ } from '~/components/atoms/wizard/lib/models/interfaces'
48
+ import type { UI_T_DatastoreTypeCode } from '~/components/common/backup/storage/actions/add/lib/models/types'
49
+ // TODO use from uikit
50
+ import Wizard from '~/components/atoms/wizard/lib/utils/utils'
51
+ import {
52
+ stepsFunc,
53
+ stepsSchemeInitial,
54
+ } from '~/components/common/backup/storage/actions/add/lib/config/steps'
55
+ import { datastoreDefaultFormFunc } from '~/components/common/backup/storage/actions/add/lib/config/createDatastore'
56
+ import {
57
+ dynamicSteps,
58
+ getStepScheme,
59
+ } from '~/components/common/backup/storage/actions/add/lib/config/steps'
60
+ import * as validation from '~/components/common/backup/storage/actions/add/lib/validations'
61
+
62
+ const props = withDefaults(
63
+ defineProps<{
64
+ project: UI_T_Project
65
+ datastore: UI_I_DatastoreTableItem[]
66
+ isDatastoreLoading: boolean
67
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
68
+ hosts?: any[]
69
+ }>(),
70
+ { hosts: [] }
71
+ )
72
+ const emits = defineEmits<{
73
+ (event: 'create', value: UI_I_CreateDatastoreForm): void
74
+ (event: 'hide'): void
75
+ }>()
76
+
77
+ const { $store }: any = useNuxtApp()
78
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
79
+
80
+ const localization = computed<UI_I_Localization>(() => useLocal())
81
+
82
+ const title = ref(localization.value.common.newBackupStorage)
83
+
84
+ const wizard: Wizard = new Wizard(
85
+ stepsFunc(localization.value),
86
+ stepsSchemeInitial
87
+ )
88
+
89
+ const selectedScheme = computed<number[]>(() => wizard.selectedScheme.value)
90
+ const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
91
+
92
+ const form = ref<UI_I_CreateDatastoreForm>(
93
+ useDeepCopy(datastoreDefaultFormFunc())
94
+ )
95
+
96
+ const validationFunc = async (
97
+ value: UI_I_WizardStep[],
98
+ currentStep: UI_I_WizardStep,
99
+ nextStep: UI_I_WizardStep
100
+ ): Promise<UI_I_ValidationReturn> => {
101
+ let stepHasError = false
102
+
103
+ if (
104
+ wizard.isValidateForStep(dynamicSteps.name, currentStep.id, nextStep.id)
105
+ ) {
106
+ const nameValidation = await validation.checkDatastoreNameAsync(
107
+ localization.value,
108
+ value,
109
+ form.value,
110
+ dynamicSteps.name,
111
+ 'name',
112
+ wizard,
113
+ props.project
114
+ )
115
+
116
+ value = nameValidation.newValue
117
+
118
+ stepHasError = nameValidation.stepHasError
119
+ }
120
+
121
+ if (
122
+ wizard.isValidateForStep(
123
+ dynamicSteps.nameAndConfigure,
124
+ currentStep.id,
125
+ nextStep.id
126
+ )
127
+ ) {
128
+ const nameValidation = await validation.checkDatastoreNameAsync(
129
+ localization.value,
130
+ value,
131
+ form.value,
132
+ dynamicSteps.nameAndConfigure,
133
+ 'name',
134
+ wizard,
135
+ props.project
136
+ )
137
+ value = nameValidation.newValue
138
+
139
+ const folderValidation = validation.checkFolderSync(
140
+ localization.value,
141
+ form.value.folder,
142
+ wizard,
143
+ value
144
+ )
145
+ value = folderValidation.newValue
146
+
147
+ const serverValidation = validation.checkServerSync(
148
+ localization.value,
149
+ form.value.server,
150
+ wizard,
151
+ value
152
+ )
153
+ value = serverValidation.newValue
154
+
155
+ // PC-2542
156
+ // const usernameValidation = validation.checkUsernameSync(
157
+ // localization.value,
158
+ // form.value.user,
159
+ // wizard,
160
+ // value
161
+ // )
162
+ // value = usernameValidation.newValue
163
+
164
+ // const passwordValidation = validation.checkPasswordSync(
165
+ // localization.value,
166
+ // form.value.password,
167
+ // wizard,
168
+ // value
169
+ // )
170
+ // value = passwordValidation.newValue
171
+
172
+ stepHasError =
173
+ nameValidation.stepHasError ||
174
+ folderValidation.stepHasError ||
175
+ serverValidation.stepHasError
176
+ }
177
+
178
+ if (
179
+ wizard.isValidateForStep(
180
+ dynamicSteps.hostAccessibility,
181
+ currentStep.id,
182
+ nextStep.id
183
+ )
184
+ ) {
185
+ const hostsValidation = await validation.checkHostsAccessibilitySync(
186
+ localization.value,
187
+ form.value.hosts,
188
+ wizard,
189
+ value
190
+ )
191
+
192
+ value = hostsValidation.newValue
193
+
194
+ stepHasError = hostsValidation.stepHasError
195
+ }
196
+
197
+ if (
198
+ wizard.isValidateForStep(dynamicSteps.storage, currentStep.id, nextStep.id)
199
+ ) {
200
+ const storageValidation = await validation.checkStorageSync(
201
+ localization.value,
202
+ form.value.storm_id,
203
+ wizard,
204
+ value
205
+ )
206
+
207
+ value = storageValidation.newValue
208
+
209
+ stepHasError = storageValidation.stepHasError
210
+ }
211
+
212
+ return {
213
+ newValue: value,
214
+ stepHasError,
215
+ }
216
+ }
217
+
218
+ const onChangeSteps = async (value: UI_I_WizardStep[]): Promise<void> =>
219
+ wizard.changeSteps(value, validationFunc)
220
+
221
+ // Choosing Scheme
222
+ watch(
223
+ () => form.value.type_code,
224
+ (newValue: UI_T_DatastoreTypeCode) => {
225
+ const step = getStepScheme(props.project, newValue)
226
+ if (step !== undefined) {
227
+ wizard.changeScheme(step)
228
+ }
229
+ },
230
+ { immediate: true }
231
+ )
232
+
233
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem | null): void => {
234
+ if (!storage) return
235
+
236
+ form.value.storm_id = storage.id
237
+ }
238
+
239
+ const onCreate = async (): Promise<void> => {
240
+ emits('create', form.value)
241
+ }
242
+
243
+ const onHideModal = (): void => {
244
+ emits('hide')
245
+ }
246
+ </script>
247
+
248
+ <style scoped lang="scss"></style>