bfg-common 1.3.199 → 1.3.200

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,288 +1,294 @@
1
- <template>
2
- <div class="hardware-network">
3
- <atoms-stack-block
4
- :has-children="true"
5
- :removable="isRemovable"
6
- @remove="removeNetwork"
7
- >
8
- <template #stackBlockKey>
9
- <div class="vm-wizard-toggle-block-network flex-align-center">
10
- <span>{{ label }}</span>
11
- <atoms-the-icon
12
- v-show="newNetworkInvalid"
13
- width="24px"
14
- height="24px"
15
- class="is-error tooltip-trigger"
16
- name="info"
17
- />
18
- </div>
19
- </template>
20
- <template #stackBlockContent>
21
- <div class="flex-align-center flex-space-between">
22
- <atoms-tooltip-error
23
- :has-error="!!apiError"
24
- :selector="`.vm-wizard-network-field-${props.index}`"
25
- @remove="onRemoveValidationError"
26
- >
27
- <template #elem>
28
- <div class="select">
29
- <select
30
- :id="`vm-wizard-network-field-${props.index}`"
31
- v-model="selectedLocation"
32
- :class="`vm-wizard-network-field-${props.index} input-text-color`"
33
- :disabled="props.type === 'edit' && state !== 1"
34
- @click.stop
35
- @change="changeLocation"
36
- >
37
- <option
38
- v-for="(item, key) in locationOptions"
39
- :key="key"
40
- :value="item.value"
41
- >
42
- {{ item.text }}
43
- </option>
44
- </select>
45
- </div>
46
- </template>
47
- <template #content>{{ apiError }}</template>
48
- </atoms-tooltip-error>
49
- </div>
50
- </template>
51
- <template #stackChildren>
52
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-network-adapter-type
53
- v-model:adapter-type="adapterType"
54
- :index="props.index"
55
- :disabled="props.type === 'edit' || isRunning"
56
- :error-validation-fields="props.errorValidationFields"
57
- @remove-error-by-title="emits('remove-error-by-title', $event)"
58
- />
59
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-network-mac-address
60
- v-model:mac-address="macAddress"
61
- v-model:mac-address-type="macAddressType"
62
- :index="props.index"
63
- :disabled="props.type === 'edit'"
64
- :error-validation-fields="props.errorValidationFields"
65
- @invalid="newNetworkInvalid = $event"
66
- @remove-error-by-title="emits('remove-error-by-title', $event)"
67
- />
68
- </template>
69
- </atoms-stack-block>
70
-
71
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-network-location
72
- :location-modal-is-show="locationModalIsShow"
73
- :networks-table="networksTable"
74
- @hide="onHideLocationModal"
75
- @select="onSelectLocation"
76
- />
77
- </div>
78
- </template>
79
-
80
- <script setup lang="ts">
81
- import { UI_I_TablePayload } from '~/lib/models/table/interfaces'
82
- import { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
83
- import { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
84
- import { UI_I_SendDataNewNetwork } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
85
- import { UI_T_NetworkType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
86
- import { UI_I_Localization, UI_I_HTMLSelectElement } from '~/lib/models/interfaces'
87
- import { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
88
-
89
- const props = defineProps<{
90
- index: number
91
- type: UI_T_NetworkType
92
- network: UI_I_SendDataNewNetwork
93
- networksTable: UI_I_NetworkTableItem[]
94
- errorValidationFields: UI_I_ErrorValidationField[]
95
- isEdit: boolean
96
- state?: string | number
97
- }>()
98
-
99
- const emits = defineEmits<{
100
- (event: 'send-data', value: UI_I_SendDataNewNetwork): void
101
- (event: 'invalid', value: boolean): void
102
- (event: 'remove'): void
103
- (event: 'remove-error-by-title', value: string): void
104
- (event: 'get-networks-table', value: UI_I_TablePayload): void
105
- }>()
106
-
107
- const localization = computed<UI_I_Localization>(() => useLocal())
108
-
109
- const isRunning = computed<boolean>(() => {
110
- return props.state === 2
111
- })
112
-
113
- const isRemovable = computed<boolean>(() => {
114
- return (
115
- !props.isEdit ||
116
- !isRunning.value ||
117
- (isRunning.value && adapterType.value === 'virtio')
118
- )
119
- })
120
-
121
- const label = computed<string>(() => {
122
- if (props.type === 'edit')
123
- return `${localization.value.networkAdapter} ${props.index + 1}`
124
-
125
- return `${localization.value.newNetwork} *`
126
- })
127
-
128
- const removeNetwork = (): void => {
129
- emits('remove')
130
- }
131
-
132
- const selectedLocationOld = ref<string>('')
133
- const selectedLocation = ref<string>('')
134
- const locationOptions = ref<UI_I_OptionItem[]>([])
135
-
136
- const getNetworks = (): void => {
137
- // if (props.networksTable.length) return // Из-за этого кода был баг. Открыть визард вм -> создать сеть -> открыть визард вм и в списке сетей нету новой сети
138
-
139
- const payload: UI_I_TablePayload = {
140
- pagination: {
141
- page: 1,
142
- pageSize: 100,
143
- },
144
- schema: 'full',
145
- type: 'network',
146
- sortBy: null,
147
- }
148
- emits('get-networks-table', payload)
149
- }
150
- getNetworks()
151
- watch(
152
- () => props.networksTable,
153
- (newValue) => {
154
- if (!newValue.length || props.type === 'edit') return
155
-
156
- selectedLocationOld.value = newValue[0].net_bridge
157
- selectedLocation.value = newValue[0].net_bridge
158
-
159
- locationOptions.value = [
160
- { text: newValue[0].name, value: newValue[0].net_bridge },
161
- { text: `${localization.value.browse}...`, value: '' },
162
- ]
163
- },
164
- { immediate: true }
165
- )
166
-
167
- const locationModalIsShow = ref<boolean>(false)
168
- const onHideLocationModal = (): void => {
169
- locationModalIsShow.value = false
170
- selectedLocation.value = selectedLocationOld.value
171
- }
172
- const changeLocation = (event: UI_I_HTMLSelectElement): void => {
173
- const value = event.target.value
174
- if (value === '') {
175
- locationModalIsShow.value = true
176
- return
177
- }
178
-
179
- selectedLocationOld.value = value
180
- selectedLocation.value = value
181
- // netBridge.value = value
182
- }
183
- const onSelectLocation = (network: UI_I_NetworkTableItem): void => {
184
- locationModalIsShow.value = false
185
-
186
- selectedLocationOld.value = network.net_bridge
187
- selectedLocation.value = network.net_bridge
188
-
189
- const hasNetwork = locationOptions.value.some(
190
- (option) => option.value === network.net_bridge
191
- )
192
- if (hasNetwork) {
193
- return
194
- }
195
-
196
- locationOptions.value = [
197
- ...locationOptions.value.slice(0, -1),
198
- { text: network.name, value: network.net_bridge },
199
- locationOptions.value[locationOptions.value.length - 1],
200
- ]
201
- }
202
-
203
- const adapterType = ref<string>('rtl8139')
204
-
205
- const target = ref<string>('')
206
-
207
- const macAddress = ref<string>('')
208
- const macAddressType = ref<string>('automatic')
209
- const newNetworkInvalid = ref<boolean>(false)
210
- watch(
211
- newNetworkInvalid,
212
- (newValue) => {
213
- emits('invalid', newValue)
214
- },
215
- { immediate: true }
216
- )
217
-
218
- watch(
219
- [selectedLocation, adapterType, macAddress, macAddressType, locationOptions],
220
- () => {
221
- const option = locationOptions.value.find(
222
- (option) => option.value === selectedLocation.value
223
- )
224
- if (!option) return
225
-
226
- emits('send-data', {
227
- network: option.text,
228
- net_bridge: option.value,
229
- target: target.value,
230
- model: adapterType.value,
231
- mac: macAddress.value,
232
- boot_order: props.network.boot_order,
233
- })
234
- },
235
- { immediate: true }
236
- )
237
-
238
- // Добавляем данные для редактирования
239
- watch(
240
- () => props.network,
241
- (newValue) => {
242
- if (props.type !== 'edit') return
243
-
244
- locationOptions.value = [
245
- { text: newValue.network, value: newValue.net_bridge },
246
- { text: `${localization.value.browse}...`, value: '' },
247
- ]
248
- selectedLocation.value = newValue.net_bridge
249
-
250
- adapterType.value = newValue.model
251
- macAddress.value = newValue.mac
252
- target.value = newValue.target
253
- },
254
- { immediate: true }
255
- )
256
-
257
- watch(
258
- isRunning,
259
- (newValue) => {
260
- if (newValue && props.type === 'new') {
261
- adapterType.value = 'virtio'
262
- }
263
- },
264
- { immediate: true }
265
- )
266
-
267
- const typeError = computed<string>(
268
- () => `network_devices[${props.index}].network`
269
- )
270
-
271
- const apiError = computed<string>(() => {
272
- return (
273
- props.errorValidationFields?.find(
274
- (message) => message.field === typeError.value
275
- )?.error_message || ''
276
- )
277
- })
278
-
279
- const onRemoveValidationError = (): void => {
280
- emits('remove-error-by-title', typeError.value)
281
- }
282
- </script>
283
-
284
- <style scoped lang="scss">
285
- #network-connect {
286
- margin-right: 4px;
287
- }
288
- </style>
1
+ <template>
2
+ <div class="hardware-network">
3
+ <atoms-stack-block
4
+ :has-children="true"
5
+ :removable="isRemovable"
6
+ @remove="removeNetwork"
7
+ >
8
+ <template #stackBlockKey>
9
+ <div class="vm-wizard-toggle-block-network flex-align-center">
10
+ <span>{{ label }}</span>
11
+ <atoms-the-icon
12
+ v-show="newNetworkInvalid"
13
+ width="24px"
14
+ height="24px"
15
+ class="is-error tooltip-trigger"
16
+ name="info"
17
+ />
18
+ </div>
19
+ </template>
20
+ <template #stackBlockContent>
21
+ <div class="flex-align-center flex-space-between">
22
+ <atoms-tooltip-error
23
+ :has-error="!!apiError"
24
+ :selector="`.vm-wizard-network-field-${props.index}`"
25
+ @remove="onRemoveValidationError"
26
+ >
27
+ <template #elem>
28
+ <div class="select">
29
+ <select
30
+ :id="`vm-wizard-network-field-${props.index}`"
31
+ v-model="selectedLocation"
32
+ :class="`vm-wizard-network-field-${props.index} input-text-color`"
33
+ :disabled="props.type === 'edit' && state !== 1"
34
+ @click.stop
35
+ @change="changeLocation"
36
+ >
37
+ <option
38
+ v-for="(item, key) in locationOptions"
39
+ :key="key"
40
+ :value="item.value"
41
+ >
42
+ {{ item.text }}
43
+ </option>
44
+ </select>
45
+ </div>
46
+ </template>
47
+ <template #content>{{ apiError }}</template>
48
+ </atoms-tooltip-error>
49
+ </div>
50
+ </template>
51
+ <template #stackChildren>
52
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-network-adapter-type
53
+ v-model:adapter-type="adapterType"
54
+ :index="props.index"
55
+ :disabled="props.type === 'edit' || isRunning"
56
+ :error-validation-fields="props.errorValidationFields"
57
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
58
+ />
59
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-network-mac-address
60
+ v-model:mac-address="macAddress"
61
+ v-model:mac-address-type="macAddressType"
62
+ :index="props.index"
63
+ :disabled="props.type === 'edit'"
64
+ :error-validation-fields="props.errorValidationFields"
65
+ @invalid="newNetworkInvalid = $event"
66
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
67
+ />
68
+ </template>
69
+ </atoms-stack-block>
70
+
71
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-network-location
72
+ :location-modal-is-show="locationModalIsShow"
73
+ :networks-table="networksTable"
74
+ @hide="onHideLocationModal"
75
+ @select="onSelectLocation"
76
+ />
77
+ </div>
78
+ </template>
79
+
80
+ <script setup lang="ts">
81
+ import { UI_I_TablePayload } from '~/lib/models/table/interfaces'
82
+ import { UI_I_NetworkTableItem } from '~/lib/models/store/network/interfaces'
83
+ import { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
84
+ import { UI_I_SendDataNewNetwork } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
85
+ import { UI_T_NetworkType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
86
+ import {
87
+ UI_I_Localization,
88
+ UI_I_HTMLSelectElement,
89
+ } from '~/lib/models/interfaces'
90
+ import { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
91
+
92
+ const props = defineProps<{
93
+ index: number
94
+ type: UI_T_NetworkType
95
+ network: UI_I_SendDataNewNetwork
96
+ networksTable: UI_I_NetworkTableItem[]
97
+ errorValidationFields: UI_I_ErrorValidationField[]
98
+ isEdit: boolean
99
+ state?: string | number
100
+ }>()
101
+
102
+ const emits = defineEmits<{
103
+ (event: 'send-data', value: UI_I_SendDataNewNetwork): void
104
+ (event: 'invalid', value: boolean): void
105
+ (event: 'remove'): void
106
+ (event: 'remove-error-by-title', value: string): void
107
+ (event: 'get-networks-table', value: UI_I_TablePayload): void
108
+ }>()
109
+
110
+ const localization = computed<UI_I_Localization>(() => useLocal())
111
+
112
+ const isRunning = computed<boolean>(() => {
113
+ return props.state === 2
114
+ })
115
+
116
+ const isRemovable = computed<boolean>(() => {
117
+ return (
118
+ !props.isEdit ||
119
+ !isRunning.value ||
120
+ (isRunning.value && adapterType.value === 'virtio')
121
+ )
122
+ })
123
+
124
+ const label = computed<string>(() => {
125
+ if (props.type === 'edit')
126
+ return `${localization.value.networkAdapter} ${props.index + 1}`
127
+
128
+ return `${localization.value.newNetwork} *`
129
+ })
130
+
131
+ const removeNetwork = (): void => {
132
+ emits('remove')
133
+ }
134
+
135
+ const selectedLocationOld = ref<string>('')
136
+ const selectedLocation = ref<string>('')
137
+ const locationOptions = ref<UI_I_OptionItem[]>([])
138
+
139
+ const getNetworks = (): void => {
140
+ // if (props.networksTable.length) return // Из-за этого кода был баг. Открыть визард вм -> создать сеть -> открыть визард вм и в списке сетей нету новой сети
141
+
142
+ const payload: UI_I_TablePayload = {
143
+ pagination: {
144
+ page: 1,
145
+ pageSize: 100,
146
+ },
147
+ schema: 'full',
148
+ type: 'network',
149
+ sortBy: null,
150
+ }
151
+ emits('get-networks-table', payload)
152
+ }
153
+ getNetworks()
154
+ watch(
155
+ () => props.networksTable,
156
+ (newValue) => {
157
+ const isExistValue = newValue.some(
158
+ (network) => network.net_bridge === selectedLocation.value
159
+ )
160
+ if (!newValue.length || props.type === 'edit' || isExistValue) return
161
+
162
+ selectedLocationOld.value = newValue[0].net_bridge
163
+ selectedLocation.value = newValue[0].net_bridge
164
+
165
+ locationOptions.value = [
166
+ { text: newValue[0].name, value: newValue[0].net_bridge },
167
+ { text: `${localization.value.browse}...`, value: '' },
168
+ ]
169
+ },
170
+ { immediate: true }
171
+ )
172
+
173
+ const locationModalIsShow = ref<boolean>(false)
174
+ const onHideLocationModal = (): void => {
175
+ locationModalIsShow.value = false
176
+ selectedLocation.value = selectedLocationOld.value
177
+ }
178
+ const changeLocation = (event: UI_I_HTMLSelectElement): void => {
179
+ const value = event.target.value
180
+ if (value === '') {
181
+ locationModalIsShow.value = true
182
+ return
183
+ }
184
+
185
+ selectedLocationOld.value = value
186
+ selectedLocation.value = value
187
+ // netBridge.value = value
188
+ }
189
+ const onSelectLocation = (network: UI_I_NetworkTableItem): void => {
190
+ locationModalIsShow.value = false
191
+
192
+ selectedLocationOld.value = network.net_bridge
193
+ selectedLocation.value = network.net_bridge
194
+
195
+ const hasNetwork = locationOptions.value.some(
196
+ (option) => option.value === network.net_bridge
197
+ )
198
+ if (hasNetwork) {
199
+ return
200
+ }
201
+
202
+ locationOptions.value = [
203
+ ...locationOptions.value.slice(0, -1),
204
+ { text: network.name, value: network.net_bridge },
205
+ locationOptions.value[locationOptions.value.length - 1],
206
+ ]
207
+ }
208
+
209
+ const adapterType = ref<string>('rtl8139')
210
+
211
+ const target = ref<string>('')
212
+
213
+ const macAddress = ref<string>('')
214
+ const macAddressType = ref<string>('automatic')
215
+ const newNetworkInvalid = ref<boolean>(false)
216
+ watch(
217
+ newNetworkInvalid,
218
+ (newValue) => {
219
+ emits('invalid', newValue)
220
+ },
221
+ { immediate: true }
222
+ )
223
+
224
+ watch(
225
+ [selectedLocation, adapterType, macAddress, macAddressType, locationOptions],
226
+ () => {
227
+ const option = locationOptions.value.find(
228
+ (option) => option.value === selectedLocation.value
229
+ )
230
+ if (!option) return
231
+
232
+ emits('send-data', {
233
+ network: option.text,
234
+ net_bridge: option.value,
235
+ target: target.value,
236
+ model: adapterType.value,
237
+ mac: macAddress.value,
238
+ boot_order: props.network.boot_order,
239
+ })
240
+ },
241
+ { immediate: true }
242
+ )
243
+
244
+ // Добавляем данные для редактирования
245
+ watch(
246
+ () => props.network,
247
+ (newValue) => {
248
+ if (props.type !== 'edit') return
249
+
250
+ locationOptions.value = [
251
+ { text: newValue.network, value: newValue.net_bridge },
252
+ { text: `${localization.value.browse}...`, value: '' },
253
+ ]
254
+ selectedLocation.value = newValue.net_bridge
255
+
256
+ adapterType.value = newValue.model
257
+ macAddress.value = newValue.mac
258
+ target.value = newValue.target
259
+ },
260
+ { immediate: true }
261
+ )
262
+
263
+ watch(
264
+ isRunning,
265
+ (newValue) => {
266
+ if (newValue && props.type === 'new') {
267
+ adapterType.value = 'virtio'
268
+ }
269
+ },
270
+ { immediate: true }
271
+ )
272
+
273
+ const typeError = computed<string>(
274
+ () => `network_devices[${props.index}].network`
275
+ )
276
+
277
+ const apiError = computed<string>(() => {
278
+ return (
279
+ props.errorValidationFields?.find(
280
+ (message) => message.field === typeError.value
281
+ )?.error_message || ''
282
+ )
283
+ })
284
+
285
+ const onRemoveValidationError = (): void => {
286
+ emits('remove-error-by-title', typeError.value)
287
+ }
288
+ </script>
289
+
290
+ <style scoped lang="scss">
291
+ #network-connect {
292
+ margin-right: 4px;
293
+ }
294
+ </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.199",
4
+ "version": "1.3.200",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",