bfg-common 1.4.730 → 1.4.731

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,174 +1,184 @@
1
- <template>
2
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-new
3
- v-if="isNewView"
4
- v-model:selected-type="selectedType"
5
- v-model:direct-path-io="directPathIo"
6
- v-model:dynamic-direct-path-io="dynamicDirectPathIo"
7
- v-model:nvidia-grid-profile="nvidiaGridProfile"
8
- :index="props.index"
9
- :passthrough-devices="props.passthroughDevices"
10
- :mediated-devices="props.mediatedDevices"
11
- :type="props.type"
12
- :is-removable="isRemovable"
13
- :label="label"
14
- :selected-label="selectedLabel"
15
- :pci-device-type-options="pciDeviceTypeOptions"
16
- @remove="emits('remove')"
17
- />
18
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-old
19
- v-else
20
- v-model:selected-type="selectedType"
21
- v-model:direct-path-io="directPathIo"
22
- v-model:dynamic-direct-path-io="dynamicDirectPathIo"
23
- v-model:nvidia-grid-profile="nvidiaGridProfile"
24
- :index="props.index"
25
- :passthrough-devices="props.passthroughDevices"
26
- :mediated-devices="props.mediatedDevices"
27
- :type="props.type"
28
- :is-removable="isRemovable"
29
- :label="label"
30
- :selected-label="selectedLabel"
31
- :pci-device-type-options="pciDeviceTypeOptions"
32
- @remove="emits('remove')"
33
- />
34
- </template>
35
-
36
- <script setup lang="ts">
37
- import type { UI_I_Localization } from '~/lib/models/interfaces'
38
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
39
- import type { UI_I_SendDataNewPciDevice } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
40
- import type { UI_T_PciDeviceType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
41
- import type { UI_I_PciDevice } from '~/lib/models/store/vm/interfaces'
42
- import { pciDeviceTypeOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/lib/config/options'
43
-
44
- const props = defineProps<{
45
- index: number
46
- pciDevice: UI_I_SendDataNewPciDevice
47
- passthroughDevices: UI_I_PciDevice[]
48
- mediatedDevices: any[]
49
- type: UI_T_PciDeviceType
50
- isEdit: boolean
51
- state?: string | number
52
- // errorValidationFields: UI_I_ErrorValidationField<string>[]
53
- }>()
54
- const emits = defineEmits<{
55
- (event: 'send-data', value: UI_I_SendDataNewPciDevice): void
56
- (event: 'remove'): void
57
- }>()
58
-
59
- const { $store }: any = useNuxtApp()
60
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
61
-
62
- const localization = computed<UI_I_Localization>(() => useLocal())
63
-
64
- const isRunning = computed<boolean>(() => {
65
- return props.state === 2
66
- })
67
-
68
- const isRemovable = computed<boolean>(() => {
69
- return !props.isEdit || !isRunning.value
70
- })
71
-
72
- const label = computed<string>(() => {
73
- if (props.type === 'edit')
74
- return `${localization.value.common.newPciDevice} ${props.index + 1}`
75
-
76
- return `${localization.value.common.pciDevice} *`
77
- })
78
-
79
- const selectedLabel = computed<string>(() => {
80
- switch (selectedType.value.value) {
81
- case 'direct_path_io':
82
- return `${directPathIo.value.address} | ${directPathIo.value.device_name}`
83
- case 'dynamic_direct_path_io':
84
- return dynamicDirectPathIo.value
85
- default:
86
- return nvidiaGridProfile.value
87
- }
88
- })
89
-
90
- const pciDeviceTypeOptions = ref<UI_I_OptionItem[]>(
91
- pciDeviceTypeOptionsFunc(
92
- !props.passthroughDevices.length,
93
- !props.mediatedDevices.length
94
- )
95
- )
96
- const selectedType = ref<UI_I_OptionItem>(pciDeviceTypeOptions.value[0])
97
- pciDeviceTypeOptions.value.forEach((option) => {
98
- if (!option.disabled) selectedType.value = option
99
- })
100
-
101
- const directPathIo = ref<UI_I_PciDevice>(props.passthroughDevices[0])
102
- const dynamicDirectPathIo = ref<string>('')
103
- const nvidiaGridProfile = ref<any>(props.mediatedDevices[0].value)
104
-
105
- watch(
106
- props.pciDevice,
107
- (newValue) => {
108
- // const passthroughDevice = props.passthroughDevices.find(
109
- // (item) => item.address === newValue.address
110
- // )
111
- // passthroughDevice && (directPathIo.value = passthroughDevice) // Todo change
112
- newValue && (directPathIo.value = newValue)
113
- },
114
- { immediate: true }
115
- )
116
-
117
- const sendData = computed<UI_I_SendDataNewPciDevice>(() => {
118
- const nvidea = props.mediatedDevices.find(
119
- (device) =>
120
- nvidiaGridProfile.value === device.profile_name + '_' + device.root_device
121
- )
122
- console.log(
123
- directPathIo.value,
124
- 111,
125
- nvidiaGridProfile.value,
126
- props.mediatedDevices
127
- )
128
- switch (selectedType.value.value) {
129
- case 'direct_path_io':
130
- return {
131
- address: directPathIo.value.address,
132
- vendor_name: directPathIo.value.vendor_name,
133
- class_name: directPathIo.value.class_name,
134
- device_name: directPathIo.value.device_name,
135
- mediated_devices: false,
136
- }
137
- case 'dynamic_direct_path_io':
138
- return {
139
- address: '',
140
- vendor_name: '',
141
- class_name: '',
142
- device_name: '',
143
- mediated_devices: false,
144
- }
145
- case 'nvidia_grid':
146
- return {
147
- address: nvidea.root_device || '',
148
- vendor_name: '',
149
- class_name: nvidea.profile_name || '',
150
- device_name: nvidea.name || '',
151
- mediated_devices: true,
152
- mediated_devices_uuid: '',
153
- }
154
- default:
155
- return {
156
- address: '',
157
- vendor_name: '',
158
- class_name: '',
159
- device_name: '',
160
- mediated_devices: false,
161
- }
162
- }
163
- })
164
-
165
- watch(
166
- sendData,
167
- (newValue) => {
168
- emits('send-data', newValue)
169
- },
170
- { immediate: true }
171
- )
172
- </script>
173
-
174
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-new
3
+ v-if="isNewView"
4
+ v-model:selected-type="selectedType"
5
+ v-model:direct-path-io="directPathIo"
6
+ v-model:dynamic-direct-path-io="dynamicDirectPathIo"
7
+ v-model:nvidia-grid-profile="nvidiaGridProfile"
8
+ :index="props.index"
9
+ :passthrough-devices="props.passthroughDevices"
10
+ :mediated-devices="props.mediatedDevices"
11
+ :type="props.type"
12
+ :is-removable="isRemovable"
13
+ :label="label"
14
+ :selected-label="selectedLabel"
15
+ :pci-device-type-options="pciDeviceTypeOptions"
16
+ @remove="emits('remove')"
17
+ />
18
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-old
19
+ v-else
20
+ v-model:selected-type="selectedType"
21
+ v-model:direct-path-io="directPathIo"
22
+ v-model:dynamic-direct-path-io="dynamicDirectPathIo"
23
+ v-model:nvidia-grid-profile="nvidiaGridProfile"
24
+ :index="props.index"
25
+ :passthrough-devices="props.passthroughDevices"
26
+ :mediated-devices="props.mediatedDevices"
27
+ :type="props.type"
28
+ :is-removable="isRemovable"
29
+ :label="label"
30
+ :selected-label="selectedLabel"
31
+ :pci-device-type-options="pciDeviceTypeOptions"
32
+ @remove="emits('remove')"
33
+ />
34
+ </template>
35
+
36
+ <script setup lang="ts">
37
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
38
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
39
+ import type { UI_I_SendDataNewPciDevice } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
40
+ import type { UI_T_PciDeviceType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
41
+ import type { UI_I_PciDevice } from '~/lib/models/store/vm/interfaces'
42
+ import { pciDeviceTypeOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/lib/config/options'
43
+
44
+ const props = defineProps<{
45
+ index: number
46
+ pciDevice: UI_I_SendDataNewPciDevice
47
+ passthroughDevices: UI_I_PciDevice[]
48
+ mediatedDevices: any[]
49
+ type: UI_T_PciDeviceType
50
+ isEdit: boolean
51
+ state?: string | number
52
+ // errorValidationFields: UI_I_ErrorValidationField<string>[]
53
+ }>()
54
+ const emits = defineEmits<{
55
+ (event: 'send-data', value: UI_I_SendDataNewPciDevice): void
56
+ (event: 'remove'): void
57
+ }>()
58
+
59
+ const { $store }: any = useNuxtApp()
60
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
61
+
62
+ const localization = computed<UI_I_Localization>(() => useLocal())
63
+
64
+ const isRunning = computed<boolean>(() => {
65
+ return props.state === 2
66
+ })
67
+
68
+ const isRemovable = computed<boolean>(() => {
69
+ return !props.isEdit || !isRunning.value
70
+ })
71
+
72
+ const label = computed<string>(() => {
73
+ if (props.type === 'edit')
74
+ return `${localization.value.common.newPciDevice} ${props.index + 1}`
75
+
76
+ return `${localization.value.common.pciDevice} *`
77
+ })
78
+
79
+ const selectedLabel = computed<string>(() => {
80
+ switch (selectedType.value.value) {
81
+ case 'direct_path_io':
82
+ return `${directPathIo.value.address} | ${directPathIo.value.device_name}`
83
+ case 'dynamic_direct_path_io':
84
+ return dynamicDirectPathIo.value
85
+ default:
86
+ return nvidiaGridProfile.value
87
+ }
88
+ })
89
+
90
+ const pciDeviceTypeOptions = ref<UI_I_OptionItem[]>(
91
+ pciDeviceTypeOptionsFunc(
92
+ !props.passthroughDevices.length,
93
+ !props.mediatedDevices.length
94
+ )
95
+ )
96
+ const selectedType = ref<UI_I_OptionItem>(pciDeviceTypeOptions.value[0])
97
+ pciDeviceTypeOptions.value.forEach((option) => {
98
+ if (!option.disabled) selectedType.value = option
99
+ })
100
+
101
+ const directPathIo = ref<UI_I_PciDevice>(props.passthroughDevices[0])
102
+ const dynamicDirectPathIo = ref<string>('')
103
+ const nvidiaGridProfile = ref<any>(props.mediatedDevices[0]?.value)
104
+
105
+ watch(
106
+ [() => props.pciDevice, () => props.mediatedDevices],
107
+ ([newValue1]) => {
108
+ // const passthroughDevice = props.passthroughDevices.find(
109
+ // (item) => item.address === newValue.address
110
+ // )
111
+ // passthroughDevice && (directPathIo.value = passthroughDevice) // Todo change
112
+ if (newValue1) {
113
+ directPathIo.value = newValue1
114
+ const mediatedDevice = props.mediatedDevices.find((device) => {
115
+ return (
116
+ device.profile_name + '_' + device.root_device ===
117
+ newValue1.class_name + '_' + newValue1.address
118
+ )
119
+ })
120
+ if (mediatedDevice) {
121
+ nvidiaGridProfile.value = mediatedDevice.profile_name + '_' + mediatedDevice.root_device
122
+
123
+ selectedType.value =
124
+ pciDeviceTypeOptions.value.find(
125
+ (option) => option.value === 'nvidia_grid'
126
+ ) || selectedType.value
127
+ }
128
+ }
129
+ },
130
+ { immediate: true, deep: true }
131
+ )
132
+
133
+ const sendData = computed<UI_I_SendDataNewPciDevice>(() => {
134
+ const nvidea = props.mediatedDevices.find(
135
+ (device) =>
136
+ nvidiaGridProfile.value === device.profile_name + '_' + device.root_device
137
+ )
138
+ switch (selectedType.value.value) {
139
+ case 'direct_path_io':
140
+ return {
141
+ address: directPathIo.value.address,
142
+ vendor_name: directPathIo.value.vendor_name,
143
+ class_name: directPathIo.value.class_name,
144
+ device_name: directPathIo.value.device_name,
145
+ mediated_devices: false,
146
+ }
147
+ case 'dynamic_direct_path_io':
148
+ return {
149
+ address: '',
150
+ vendor_name: '',
151
+ class_name: '',
152
+ device_name: '',
153
+ mediated_devices: false,
154
+ }
155
+ case 'nvidia_grid':
156
+ return {
157
+ address: nvidea?.root_device || '',
158
+ vendor_name: '',
159
+ class_name: nvidea?.profile_name || '',
160
+ device_name: nvidea?.name || '',
161
+ mediated_devices: true,
162
+ mediated_devices_uuid: '',
163
+ }
164
+ default:
165
+ return {
166
+ address: '',
167
+ vendor_name: '',
168
+ class_name: '',
169
+ device_name: '',
170
+ mediated_devices: false,
171
+ }
172
+ }
173
+ })
174
+
175
+ watch(
176
+ sendData,
177
+ (newValue) => {
178
+ emits('send-data', newValue)
179
+ },
180
+ { immediate: true }
181
+ )
182
+ </script>
183
+
184
+ <style scoped lang="scss"></style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.730",
4
+ "version": "1.4.731",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",