bfg-common 1.1.62 → 1.1.64

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.
@@ -209,7 +209,7 @@ watch(
209
209
  io: 'native',
210
210
  limit_iops: 0,
211
211
  discard: 'unmap',
212
- boot_order: -1,
212
+ boot_order: props.cdDvdDrive.boot_order,
213
213
  detach: props.type === 'removed',
214
214
  remove: props.type === 'removed' && deleteFilesFromDatastore.value, // Проверяем если удалили диск и указали Delete files from datastore
215
215
  })
@@ -382,7 +382,7 @@ watch(
382
382
  limit_iops: limitIopsLocal,
383
383
  discard: discard.value,
384
384
  capacity: sizeInMb.value,
385
- boot_order: -1,
385
+ boot_order: props.hardDisk.boot_order,
386
386
  detach: props.type === 'removed',
387
387
  remove: props.type === 'removed' && deleteFilesFromDatastore.value, // Проверяем если удалили диск и указали Delete files from datastore
388
388
  })
@@ -208,7 +208,7 @@ watch(
208
208
  target: '',
209
209
  model: adapterType.value,
210
210
  mac: macAddress.value,
211
- boot_order: -1,
211
+ boot_order: props.network.boot_order,
212
212
  })
213
213
  },
214
214
  { immediate: true }
@@ -1,195 +1,203 @@
1
- <template>
2
- <div class="boot-orders">
3
- <atoms-stack-block :has-children="false">
4
- <template #stackBlockKey>
5
- {{ localization.bootOrder }}
6
- </template>
7
- <template #stackBlockContent>
8
- <atoms-list-drag-drop-list
9
- :items="bootList"
10
- grab-item-key="text"
11
- @drop="onChangeOrder"
12
- >
13
- <template
14
- v-for="(item, index) in bootList"
15
- :key="index"
16
- #[`leftSide${index}`]
17
- >
18
- <input
19
- v-model="item.isChecked"
20
- :id="`boot-order-${index}`"
21
- type="checkbox"
22
- />
23
- </template>
24
- <template
25
- v-for="(item, index) in bootList"
26
- :key="index + 5"
27
- #[`rightSide${index}`]
28
- >
29
- <div :class="['device-icon', item.iconClassName]" />
30
- <span>{{ item.text }}</span>
31
- </template>
32
- </atoms-list-drag-drop-list>
33
- </template>
34
- </atoms-stack-block>
35
- </div>
36
- </template>
37
-
38
- <script setup lang="ts">
39
- import type { UI_I_BootItem } from '~/components/common/vm/actions/add/customizeHardware/vmoptions/bootOptions/order/models/interfaces'
40
- import {
41
- UI_I_SendDataNewCdDvdDrive,
42
- UI_I_SendDataNewHardDisk,
43
- UI_I_SendDataNewNetwork,
44
- } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/models/interfaces'
45
- import { UI_I_Localization } from '~/models/interfaces'
46
- import { UI_I_DropEvent } from '~/components/atoms/list/dragDropList/config/events'
47
-
48
- const localization = computed<UI_I_Localization>(() => useLocal())
49
-
50
- const props = defineProps<{
51
- hardDisks: UI_I_SendDataNewHardDisk[] | null
52
- cdDvdDrives: UI_I_SendDataNewCdDvdDrive[] | null
53
- networks: UI_I_SendDataNewNetwork[] | null
54
- }>()
55
- const emits = defineEmits<{
56
- (
57
- event: 'change',
58
- value: [
59
- UI_I_SendDataNewHardDisk[],
60
- UI_I_SendDataNewCdDvdDrive[],
61
- UI_I_SendDataNewNetwork[]
62
- ]
63
- ): void
64
- }>()
65
-
66
- const bootList = ref<UI_I_BootItem[]>([])
67
-
68
- const hardDisksAndNetworks = computed<
69
- [
70
- UI_I_SendDataNewHardDisk[] | null,
71
- UI_I_SendDataNewCdDvdDrive[] | null,
72
- UI_I_SendDataNewNetwork[] | null
73
- ]
74
- >(() => [props.hardDisks, props.cdDvdDrives, props.networks])
75
- watch(
76
- hardDisksAndNetworks,
77
- (
78
- newValue: [
79
- UI_I_SendDataNewHardDisk[] | null,
80
- UI_I_SendDataNewCdDvdDrive[] | null,
81
- UI_I_SendDataNewNetwork[] | null
82
- ]
83
- ) => {
84
- const hardDisks: UI_I_BootItem[] =
85
- newValue[0]?.map((item, index) => {
86
- return {
87
- isChecked: true,
88
- order: item.boot_order || 0,
89
- text: `disk${index}`,
90
- iconClassName: 'icon-disk',
91
- type: 'disk',
92
- name: item.source + index,
93
- }
94
- }) || []
95
- const cdDvdDrives: UI_I_BootItem[] =
96
- newValue[1]?.map((item, index) => {
97
- return {
98
- isChecked: true,
99
- order: item.boot_order || 0,
100
- text: `cdrom${index}`,
101
- iconClassName: 'icon-disk',
102
- type: 'cdDvd',
103
- name: item.source + index,
104
- }
105
- }) || []
106
- const networks: UI_I_BootItem[] =
107
- newValue[2]?.map((item, index) => {
108
- return {
109
- isChecked: true,
110
- order: item.boot_order || 0,
111
- text: `nic${index}`,
112
- iconClassName: 'vsphere-icon-network',
113
- type: 'nic',
114
- name: item.network + index,
115
- }
116
- }) || []
117
-
118
- bootList.value = [...hardDisks, ...cdDvdDrives, ...networks].sort(
119
- (a, b) => a.order - b.order
120
- )
121
- },
122
- { deep: true, immediate: true }
123
- )
124
-
125
- const onChangeOrder = (event: UI_I_DropEvent): void => {
126
- let order = -1
127
- bootList.value = bootList.value
128
- .map((item) => {
129
- if (item === event.target) {
130
- item.order = event.toPosition
131
- return item
132
- }
133
-
134
- item.order = order + 1 === event.toPosition ? (order += 2) : order++
135
-
136
- return item
137
- })
138
- .sort((a, b) => a.order - b.order)
139
- }
140
-
141
- watch(
142
- bootList,
143
- (newValue) => {
144
- const boots = newValue.filter((item) => item.isChecked).map((item) => item)
145
-
146
- const networks: UI_I_SendDataNewNetwork[] = []
147
- const hardDisks: UI_I_SendDataNewHardDisk[] = []
148
- const cdDvdDrives: UI_I_SendDataNewCdDvdDrive[] = []
149
- boots.forEach((boot, index) => {
150
- if (boot.type === 'nic') {
151
- const network = props.networks?.find(
152
- (network, index2) => network.network + index2 === boot.name
153
- )
154
- if (network) {
155
- networks.push({
156
- ...network,
157
- boot_order: index + 1,
158
- })
159
- }
160
- } else if (boot.type === 'disk') {
161
- const hardDisk = props.hardDisks?.find(
162
- (hardDisk, index2) => hardDisk.source + index2 === boot.name
163
- )
164
- if (hardDisk) {
165
- hardDisks.push({
166
- ...hardDisk,
167
- boot_order: index + 1,
168
- })
169
- }
170
- } else {
171
- const cdDvdDrive = props.cdDvdDrives?.find(
172
- (cdDvdDrive, index2) => cdDvdDrive.source + index2 === boot.name
173
- )
174
- if (cdDvdDrive) {
175
- cdDvdDrives.push({
176
- ...cdDvdDrive,
177
- boot_order: index + 1,
178
- })
179
- }
180
- }
181
- })
182
-
183
- emits('change', [hardDisks, cdDvdDrives, networks])
184
- },
185
- { deep: true, immediate: true }
186
- )
187
- </script>
188
-
189
- <style scoped lang="scss">
190
- .boot-orders {
191
- .device-icon {
192
- margin-right: 6px;
193
- }
194
- }
195
- </style>
1
+ <template>
2
+ <div class="boot-orders">
3
+ <atoms-stack-block :has-children="false">
4
+ <template #stackBlockKey>
5
+ {{ localization.bootOrder }}
6
+ </template>
7
+ <template #stackBlockContent>
8
+ <atoms-list-drag-drop-list
9
+ :items="bootList"
10
+ grab-item-key="text"
11
+ @drop="onChangeOrder"
12
+ >
13
+ <template
14
+ v-for="(item, index) in bootList"
15
+ :key="index"
16
+ #[`leftSide${index}`]
17
+ >
18
+ <input
19
+ v-model="item.isChecked"
20
+ :id="`boot-order-${index}`"
21
+ type="checkbox"
22
+ />
23
+ </template>
24
+ <template
25
+ v-for="(item, index) in bootList"
26
+ :key="index + 5"
27
+ #[`rightSide${index}`]
28
+ >
29
+ <div :class="['device-icon', item.iconClassName]" />
30
+ <span>{{ item.text }}</span>
31
+ </template>
32
+ </atoms-list-drag-drop-list>
33
+ </template>
34
+ </atoms-stack-block>
35
+ </div>
36
+ </template>
37
+
38
+ <script setup lang="ts">
39
+ import type { UI_I_BootItem } from '~/components/common/vm/actions/add/customizeHardware/vmoptions/bootOptions/order/models/interfaces'
40
+ import {
41
+ UI_I_SendDataNewCdDvdDrive,
42
+ UI_I_SendDataNewHardDisk,
43
+ UI_I_SendDataNewNetwork,
44
+ } from '~/components/common/vm/actions/add/customizeHardware/virtualHardware/models/interfaces'
45
+ import { UI_I_Localization } from '~/models/interfaces'
46
+ import { UI_I_DropEvent } from '~/components/atoms/list/dragDropList/config/events'
47
+
48
+ const localization = computed<UI_I_Localization>(() => useLocal())
49
+
50
+ const props = defineProps<{
51
+ hardDisks: UI_I_SendDataNewHardDisk[] | null
52
+ cdDvdDrives: UI_I_SendDataNewCdDvdDrive[] | null
53
+ networks: UI_I_SendDataNewNetwork[] | null
54
+ }>()
55
+ const emits = defineEmits<{
56
+ (
57
+ event: 'change',
58
+ value: [
59
+ UI_I_SendDataNewHardDisk[],
60
+ UI_I_SendDataNewCdDvdDrive[],
61
+ UI_I_SendDataNewNetwork[]
62
+ ]
63
+ ): void
64
+ }>()
65
+
66
+ const bootList = ref<UI_I_BootItem[]>([])
67
+
68
+ const hardDisksAndNetworks = computed<
69
+ [
70
+ UI_I_SendDataNewHardDisk[] | null,
71
+ UI_I_SendDataNewCdDvdDrive[] | null,
72
+ UI_I_SendDataNewNetwork[] | null
73
+ ]
74
+ >(() => [props.hardDisks, props.cdDvdDrives, props.networks])
75
+ watch(
76
+ hardDisksAndNetworks,
77
+ (
78
+ newValue: [
79
+ UI_I_SendDataNewHardDisk[] | null,
80
+ UI_I_SendDataNewCdDvdDrive[] | null,
81
+ UI_I_SendDataNewNetwork[] | null
82
+ ]
83
+ ) => {
84
+ const hardDisks: UI_I_BootItem[] =
85
+ newValue[0]?.map((item, index) => {
86
+ const order = item.boot_order || 0
87
+ return {
88
+ order,
89
+ isChecked: !!order,
90
+ text: `disk${index}`,
91
+ iconClassName: 'icon-disk',
92
+ type: 'disk',
93
+ name: item.source + index,
94
+ }
95
+ }) || []
96
+ const cdDvdDrives: UI_I_BootItem[] =
97
+ newValue[1]?.map((item, index) => {
98
+ const order = item.boot_order || 0
99
+ return {
100
+ order,
101
+ isChecked: !!order,
102
+ text: `cdrom${index}`,
103
+ iconClassName: 'icon-disk',
104
+ type: 'cdDvd',
105
+ name: item.source + index,
106
+ }
107
+ }) || []
108
+ const networks: UI_I_BootItem[] =
109
+ newValue[2]?.map((item, index) => {
110
+ const order = item.boot_order || 0
111
+ return {
112
+ order,
113
+ isChecked: !!order,
114
+ text: `nic${index} ${item.mac || undefined} mac`,
115
+ iconClassName: 'vsphere-icon-network',
116
+ type: 'nic',
117
+ name: item.network + index,
118
+ }
119
+ }) || []
120
+
121
+ bootList.value = [...hardDisks, ...cdDvdDrives, ...networks].sort(
122
+ (a, b) => a.order - b.order
123
+ )
124
+ },
125
+ { deep: true, immediate: true }
126
+ )
127
+
128
+ const onChangeOrder = (event: UI_I_DropEvent): void => {
129
+ let order = -1
130
+ bootList.value = bootList.value
131
+ .map((item) => {
132
+ if (item === event.target) {
133
+ item.order = event.toPosition
134
+ return item
135
+ }
136
+
137
+ item.order = order + 1 === event.toPosition ? (order += 2) : order++
138
+
139
+ return item
140
+ })
141
+ .sort((a, b) => a.order - b.order)
142
+ }
143
+
144
+ watch(
145
+ bootList,
146
+ (newValue) => {
147
+ // const boots = newValue.filter((item) => item.isChecked).map((item) => item)
148
+ // const boots = newValue.map((item) => {
149
+ // if (!item.isChecked) item.boot_order = 0
150
+ // return item
151
+ // })
152
+
153
+ const networks: UI_I_SendDataNewNetwork[] = []
154
+ const hardDisks: UI_I_SendDataNewHardDisk[] = []
155
+ const cdDvdDrives: UI_I_SendDataNewCdDvdDrive[] = []
156
+ let index = 0
157
+ newValue.forEach((boot) => {
158
+ if (boot.type === 'nic') {
159
+ const network = props.networks?.find(
160
+ (network, index2) => network.network + index2 === boot.name
161
+ )
162
+ if (network) {
163
+ networks.push({
164
+ ...network,
165
+ boot_order: boot.isChecked ? ++index : 0,
166
+ })
167
+ }
168
+ } else if (boot.type === 'disk') {
169
+ const hardDisk = props.hardDisks?.find(
170
+ (hardDisk, index2) => hardDisk.source + index2 === boot.name
171
+ )
172
+ if (hardDisk) {
173
+ hardDisks.push({
174
+ ...hardDisk,
175
+ boot_order: boot.isChecked ? ++index : 0,
176
+ })
177
+ }
178
+ } else {
179
+ const cdDvdDrive = props.cdDvdDrives?.find(
180
+ (cdDvdDrive, index2) => cdDvdDrive.source + index2 === boot.name
181
+ )
182
+ if (cdDvdDrive) {
183
+ cdDvdDrives.push({
184
+ ...cdDvdDrive,
185
+ boot_order: boot.isChecked ? ++index : 0,
186
+ })
187
+ }
188
+ }
189
+ })
190
+
191
+ emits('change', [hardDisks, cdDvdDrives, networks])
192
+ },
193
+ { deep: true, immediate: true }
194
+ )
195
+ </script>
196
+
197
+ <style scoped lang="scss">
198
+ .boot-orders {
199
+ .device-icon {
200
+ margin-right: 6px;
201
+ }
202
+ }
203
+ </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.1.62",
4
+ "version": "1.1.64",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",