bfg-common 1.5.387 → 1.5.388
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/img/icons/icons-sprite-dark-6.svg +114 -114
- package/assets/img/icons/icons-sprite-light-6.svg +114 -114
- package/assets/scss/common/icons/icons-6.scss +174 -174
- package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardwareNew.vue +501 -501
- package/components/common/vm/actions/common/customizeHardware/vmoptions/generalOptions/GeneralOptionsNew.vue +161 -161
- package/components/common/vm/actions/common/select/name/Name.vue +176 -174
- package/components/common/vm/actions/common/select/storage/new/lib/config/table.ts +337 -337
- package/components/common/vmt/actions/add/New.vue +345 -345
- package/package.json +1 -1
@@ -1,174 +1,176 @@
|
|
1
|
-
<template>
|
2
|
-
<common-vm-actions-common-select-name-new
|
3
|
-
v-if="isNewView"
|
4
|
-
v-model:vm-name="vmName"
|
5
|
-
v-model:is-show-help="isShowHelp"
|
6
|
-
:project="props.project"
|
7
|
-
:errors="errors"
|
8
|
-
:data-center="props.dataCenter"
|
9
|
-
@remove-validation-errors="onRemoveValidationErrors"
|
10
|
-
@select-node="onSelectNode"
|
11
|
-
/>
|
12
|
-
<common-vm-actions-common-select-name-old
|
13
|
-
v-else
|
14
|
-
v-model:vm-name="vmName"
|
15
|
-
v-model:is-show-help="isShowHelp"
|
16
|
-
:project="props.project"
|
17
|
-
:errors="errors"
|
18
|
-
:data-center="props.dataCenter"
|
19
|
-
@remove-validation-errors="onRemoveValidationErrors"
|
20
|
-
@select-node="onSelectNode"
|
21
|
-
/>
|
22
|
-
</template>
|
23
|
-
|
24
|
-
<script setup lang="ts">
|
25
|
-
// import { API_UI_I_Error } from '~/lib/models/store/interfaces'
|
26
|
-
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
27
|
-
import type { UI_T_Project } from '~/lib/models/types'
|
28
|
-
import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
|
29
|
-
|
30
|
-
const props = defineProps<{
|
31
|
-
nameFormSubmit: null | Function
|
32
|
-
show: boolean
|
33
|
-
project: UI_T_Project
|
34
|
-
dataCenter?: UI_I_TreeNode // для сферы
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
(event: '
|
39
|
-
(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
const
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
const
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
if (node
|
69
|
-
|
70
|
-
return
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
//
|
90
|
-
//
|
91
|
-
!
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
1
|
+
<template>
|
2
|
+
<common-vm-actions-common-select-name-new
|
3
|
+
v-if="isNewView"
|
4
|
+
v-model:vm-name="vmName"
|
5
|
+
v-model:is-show-help="isShowHelp"
|
6
|
+
:project="props.project"
|
7
|
+
:errors="errors"
|
8
|
+
:data-center="props.dataCenter"
|
9
|
+
@remove-validation-errors="onRemoveValidationErrors"
|
10
|
+
@select-node="onSelectNode"
|
11
|
+
/>
|
12
|
+
<common-vm-actions-common-select-name-old
|
13
|
+
v-else
|
14
|
+
v-model:vm-name="vmName"
|
15
|
+
v-model:is-show-help="isShowHelp"
|
16
|
+
:project="props.project"
|
17
|
+
:errors="errors"
|
18
|
+
:data-center="props.dataCenter"
|
19
|
+
@remove-validation-errors="onRemoveValidationErrors"
|
20
|
+
@select-node="onSelectNode"
|
21
|
+
/>
|
22
|
+
</template>
|
23
|
+
|
24
|
+
<script setup lang="ts">
|
25
|
+
// import { API_UI_I_Error } from '~/lib/models/store/interfaces'
|
26
|
+
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
27
|
+
import type { UI_T_Project } from '~/lib/models/types'
|
28
|
+
import type { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
|
29
|
+
|
30
|
+
const props = defineProps<{
|
31
|
+
nameFormSubmit: null | Function
|
32
|
+
show: boolean
|
33
|
+
project: UI_T_Project
|
34
|
+
dataCenter?: UI_I_TreeNode // для сферы
|
35
|
+
existName?: string
|
36
|
+
}>()
|
37
|
+
const emits = defineEmits<{
|
38
|
+
(event: 'submit', value: [string, UI_I_TreeNode | null]): void
|
39
|
+
(event: 'loading', value: boolean): void
|
40
|
+
(
|
41
|
+
event: 'check-name',
|
42
|
+
value: [[string, UI_I_TreeNode | null], (error: any) => void]
|
43
|
+
): void
|
44
|
+
(event: 'has-errors', value: boolean): void
|
45
|
+
}>()
|
46
|
+
|
47
|
+
const { $store }: any = useNuxtApp()
|
48
|
+
const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
|
49
|
+
|
50
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
51
|
+
|
52
|
+
// TODO 100
|
53
|
+
const vmName = ref<string>(props.existName || '')
|
54
|
+
|
55
|
+
const selectedNode = ref<UI_I_TreeNode | null>(null)
|
56
|
+
const onSelectNode = (node: UI_I_TreeNode): void => {
|
57
|
+
selectedNode.value = node
|
58
|
+
}
|
59
|
+
|
60
|
+
watch(
|
61
|
+
() => props.nameFormSubmit,
|
62
|
+
(newValue) => {
|
63
|
+
newValue && submit(newValue)
|
64
|
+
}
|
65
|
+
)
|
66
|
+
|
67
|
+
const isParentDatacenter = (node: UI_I_TreeNode | null): boolean => {
|
68
|
+
if (!node) return false
|
69
|
+
|
70
|
+
if (node.parent?.type === 'datacenter') return true
|
71
|
+
if (node.parent?.type === 'folder') return isParentDatacenter(node.parent)
|
72
|
+
return false
|
73
|
+
}
|
74
|
+
const submit = async (cb: Function): Promise<void> => {
|
75
|
+
const name = vmName.value
|
76
|
+
|
77
|
+
if (name !== '') {
|
78
|
+
const isNameValid = await checkNameIsValid(name)
|
79
|
+
if (!isNameValid) {
|
80
|
+
cb(false)
|
81
|
+
return
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
if (props.project === 'sphere') {
|
86
|
+
// const isDatacenterFolder = isParentDatacenter(selectedNode.value)
|
87
|
+
|
88
|
+
if (
|
89
|
+
// selectedNode.value?.type !== 'datacenter' &&
|
90
|
+
// selectedNode.value?.type === 'folder' &&
|
91
|
+
// !isDatacenterFolder
|
92
|
+
// TODO рефакторинг, здесь сейчас проверяем является ли выбранный элемент датацентром или папкой(вм)
|
93
|
+
![3, 7].includes(selectedNode.value?.kind)
|
94
|
+
) {
|
95
|
+
showValidationErrors([
|
96
|
+
localization.value.common.enterValidLocationVirtualMachine,
|
97
|
+
])
|
98
|
+
cb(false)
|
99
|
+
return
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
onRemoveValidationErrors()
|
104
|
+
emits('submit', [name, selectedNode.value])
|
105
|
+
cb(true)
|
106
|
+
}
|
107
|
+
const checkNameIsValid = async (name: string): Promise<boolean> => {
|
108
|
+
emits('loading', true)
|
109
|
+
|
110
|
+
return new Promise((resolve) => {
|
111
|
+
emits('check-name', [
|
112
|
+
[name, selectedNode.value],
|
113
|
+
(error) => {
|
114
|
+
emits('loading', false)
|
115
|
+
|
116
|
+
const status = error?.statusCode || 200
|
117
|
+
switch (status) {
|
118
|
+
case 405: // Invalid kind
|
119
|
+
showValidationErrors([
|
120
|
+
localization.value.common.kindValidationDescription,
|
121
|
+
])
|
122
|
+
resolve(false)
|
123
|
+
break
|
124
|
+
case 406: // Invalid name
|
125
|
+
showValidationErrors([
|
126
|
+
localization.value.common.vmNameValidationDescription,
|
127
|
+
])
|
128
|
+
resolve(false)
|
129
|
+
break
|
130
|
+
case 409: // Name exist
|
131
|
+
showValidationErrors([
|
132
|
+
localization.value.common.vmNameExistInSelectedLocation,
|
133
|
+
])
|
134
|
+
resolve(false)
|
135
|
+
break
|
136
|
+
}
|
137
|
+
|
138
|
+
resolve(true)
|
139
|
+
},
|
140
|
+
])
|
141
|
+
})
|
142
|
+
}
|
143
|
+
|
144
|
+
const errors = ref<string[]>([])
|
145
|
+
const showValidationErrors = (data: string[]): void => {
|
146
|
+
errors.value = data
|
147
|
+
}
|
148
|
+
const onRemoveValidationErrors = (): void => {
|
149
|
+
errors.value = []
|
150
|
+
}
|
151
|
+
watch(
|
152
|
+
errors,
|
153
|
+
(newValue) => {
|
154
|
+
emits('has-errors', !newValue.length)
|
155
|
+
},
|
156
|
+
{ immediate: true, deep: true }
|
157
|
+
)
|
158
|
+
|
159
|
+
watch(
|
160
|
+
() => props.show,
|
161
|
+
(newValue) => {
|
162
|
+
if (!newValue) return
|
163
|
+
|
164
|
+
const input = document.getElementById('virtual-machine-name')
|
165
|
+
if (!input) return
|
166
|
+
|
167
|
+
setTimeout(() => {
|
168
|
+
input.focus()
|
169
|
+
}, 0)
|
170
|
+
}
|
171
|
+
)
|
172
|
+
|
173
|
+
const isShowHelp = ref<boolean>(false)
|
174
|
+
</script>
|
175
|
+
|
176
|
+
<style scoped lang="scss"></style>
|