bfg-common 1.3.349 → 1.3.351

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.
Files changed (48) hide show
  1. package/assets/localization/local_ru.json +4 -4
  2. package/components/atoms/switch/Switch.vue +111 -111
  3. package/components/atoms/table/compact/Compact.vue +526 -526
  4. package/components/common/adapterManager/ui/table/Header.vue +93 -93
  5. package/components/common/adapterManager/ui/table/Table.vue +162 -162
  6. package/components/common/context/Context.vue +99 -99
  7. package/components/common/lib/config/states.ts +126 -126
  8. package/components/common/resource/progressBlock/ProgressBlock.vue +142 -142
  9. package/components/common/vm/actions/add/Add.vue +602 -602
  10. package/components/common/vm/actions/clone/Clone.vue +518 -518
  11. package/components/common/vm/actions/common/customizeHardware/CustomizeHardware.vue +273 -273
  12. package/components/common/vm/actions/common/customizeHardware/virtualHardware/VirtualHardware.vue +697 -697
  13. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newNetwork/NewNetwork.vue +299 -299
  14. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/NewPciDevice.vue +165 -165
  15. package/components/common/vm/actions/common/select/computeResource/ComputeResource.vue +164 -164
  16. package/components/common/vm/actions/common/select/name/Name.vue +235 -235
  17. package/components/common/vm/actions/common/select/storage/Storage.vue +198 -198
  18. package/components/common/vm/actions/editSettings/EditSettings.vue +313 -313
  19. package/components/common/weekSelect/lib/config/options.ts +10 -10
  20. package/components/common/wizards/datastore/add/Add.vue +436 -434
  21. package/components/common/wizards/datastore/add/lib/config/stepItems.ts +191 -191
  22. package/components/common/wizards/datastore/add/lib/models/interfaces.ts +38 -38
  23. package/components/common/wizards/datastore/add/lib/utils.ts +70 -70
  24. package/components/common/wizards/datastore/add/local/createName/CreateName.vue +160 -160
  25. package/components/common/wizards/datastore/add/nfs/Nfs.vue +112 -112
  26. package/components/common/wizards/datastore/add/nfs/accessibility/Accessibility.vue +104 -104
  27. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/compatibleTable.ts +62 -62
  28. package/components/common/wizards/datastore/add/nfs/accessibility/tablesView/lib/config/hostsTableItems.ts +53 -53
  29. package/components/common/wizards/datastore/add/readyComplete/ReadyComplete.vue +86 -86
  30. package/components/common/wizards/datastore/add/readyComplete/lib/config/propertiesDetails.ts +184 -184
  31. package/components/common/wizards/datastore/add/sharedStorm/SharedStorm.vue +2 -0
  32. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/DeviceSelection.vue +459 -452
  33. package/components/common/wizards/datastore/add/types/Types.vue +80 -80
  34. package/components/common/wizards/datastore/add/types/lib/config/typeOptions.ts +49 -49
  35. package/composables/useAppVersion.ts +21 -21
  36. package/composables/useEnvLanguage.ts +20 -20
  37. package/lib/utils/sendTask.ts +72 -72
  38. package/minify.js +146 -146
  39. package/package.json +1 -1
  40. package/public/spice-console/application/codec.js +257 -257
  41. package/public/spice-console/lib/rasterEngine.js +907 -907
  42. package/public/spice-console/network/spicechannel.js +369 -369
  43. package/store/main/lib/interfaces.ts +9 -9
  44. package/store/tasks/actions.ts +133 -133
  45. package/store/tasks/getters.ts +25 -25
  46. package/store/tasks/lib/models/interfaces.ts +18 -18
  47. package/store/tasks/mutations.ts +58 -58
  48. package/store/tasks/state.ts +16 -16
@@ -1,165 +1,165 @@
1
- <template>
2
- <div class="hardware-pci-device">
3
- <atoms-stack-block
4
- :has-children="true"
5
- :removable="isRemovable"
6
- @remove="onRemovePciDevice"
7
- >
8
- <template #stackBlockKey>
9
- <div class="flex-align-center">
10
- <span>{{ label }}</span>
11
- </div>
12
- </template>
13
- <template #stackBlockContent>
14
- <span class="main-label">
15
- {{ selectedLabel }}
16
- </span>
17
- </template>
18
- <template #stackChildren>
19
- <template v-if="props.type === 'new'">
20
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-type-selection
21
- v-model="selectedType"
22
- :options="pciDeviceTypeOptions"
23
- :pci-device-index="props.index"
24
- />
25
-
26
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-direct-path-io
27
- v-show="selectedType.value === 'direct_path_io'"
28
- v-model="directPathIo"
29
- :pci-device-index="props.index"
30
- :passthrough-devices="props.passthroughDevices"
31
- />
32
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-dynamic-direct-path-io
33
- v-show="selectedType.value === 'dynamic_direct_path_io'"
34
- v-model="dynamicDirectPathIo"
35
- :pci-device-index="props.index"
36
- :passthrough-devices="props.passthroughDevices"
37
- />
38
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-nvidia-grid
39
- v-show="selectedType.value === 'nvidia_grid'"
40
- v-model="nvidiaGridProfile"
41
- :pci-device-index="props.index"
42
- />
43
- </template>
44
-
45
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-note />
46
- </template>
47
- </atoms-stack-block>
48
- </div>
49
- </template>
50
-
51
- <script setup lang="ts">
52
- import type { UI_I_Localization } from '~/lib/models/interfaces'
53
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
54
- import type { UI_I_SendDataNewPciDevice } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
55
- import type { UI_T_PciDeviceType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
56
- import type { UI_I_PciDevice } from '~/lib/models/store/vm/interfaces'
57
- import { pciDeviceTypeOptionsConfig } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/lib/config/options'
58
-
59
- const props = defineProps<{
60
- index: number
61
- pciDevice: UI_I_SendDataNewPciDevice
62
- passthroughDevices: UI_I_PciDevice[]
63
- type: UI_T_PciDeviceType
64
- isEdit: boolean
65
- state?: string | number
66
- // errorValidationFields: UI_I_ErrorValidationField<string>[]
67
- }>()
68
- const emits = defineEmits<{
69
- (event: 'send-data', value: UI_I_SendDataNewPciDevice): void
70
- (event: 'remove'): void
71
- }>()
72
-
73
- const localization = computed<UI_I_Localization>(() => useLocal())
74
-
75
- const isRunning = computed<boolean>(() => {
76
- return props.state === 2
77
- })
78
-
79
- const isRemovable = computed<boolean>(() => {
80
- return !props.isEdit || !isRunning.value
81
- })
82
-
83
- const label = computed<string>(() => {
84
- if (props.type === 'edit')
85
- return `${localization.value.newPciDevice} ${props.index + 1}`
86
-
87
- return `${localization.value.pciDevice} *`
88
- })
89
-
90
- const selectedLabel = computed<string>(() => {
91
- switch (selectedType.value.value) {
92
- case 'direct_path_io':
93
- return `${directPathIo.value.address}|${directPathIo.value.device_name}`
94
- case 'dynamic_direct_path_io':
95
- return dynamicDirectPathIo.value
96
- default:
97
- return nvidiaGridProfile.value
98
- }
99
- })
100
-
101
- const pciDeviceTypeOptions = ref<UI_I_OptionItem[]>(pciDeviceTypeOptionsConfig)
102
- const selectedType = ref<UI_I_OptionItem>(pciDeviceTypeOptionsConfig[0])
103
-
104
- const directPathIo = ref<UI_I_PciDevice>(
105
- props.passthroughDevices[0]
106
- )
107
- const dynamicDirectPathIo = ref<string>('')
108
- const nvidiaGridProfile = ref<string>('')
109
-
110
- watch(
111
- props.pciDevice,
112
- (newValue) => {
113
- // const passthroughDevice = props.passthroughDevices.find(
114
- // (item) => item.address === newValue.address
115
- // )
116
- // passthroughDevice && (directPathIo.value = passthroughDevice) // Todo change
117
- newValue && (directPathIo.value = newValue)
118
- },
119
- { immediate: true }
120
- )
121
-
122
- const sendData = computed<UI_I_SendDataNewPciDevice>(() => {
123
- switch (selectedType.value.value) {
124
- case 'direct_path_io':
125
- return {
126
- address: directPathIo.value.address,
127
- vendor_name: directPathIo.value.vendor_name,
128
- class_name: directPathIo.value.class_name,
129
- device_name: directPathIo.value.device_name,
130
- }
131
- case 'dynamic_direct_path_io':
132
- return {
133
- address: '',
134
- vendor_name: '',
135
- class_name: '',
136
- device_name: '',
137
- }
138
- default:
139
- return {
140
- address: '',
141
- vendor_name: '',
142
- class_name: '',
143
- device_name: '',
144
- }
145
- }
146
- })
147
-
148
- watch(
149
- sendData,
150
- (newValue) => {
151
- emits('send-data', newValue)
152
- },
153
- { immediate: true }
154
- )
155
-
156
- const onRemovePciDevice = (): void => {
157
- emits('remove')
158
- }
159
- </script>
160
-
161
- <style scoped lang="scss">
162
- #network-connect {
163
- margin-right: 4px;
164
- }
165
- </style>
1
+ <template>
2
+ <div class="hardware-pci-device">
3
+ <atoms-stack-block
4
+ :has-children="true"
5
+ :removable="isRemovable"
6
+ @remove="onRemovePciDevice"
7
+ >
8
+ <template #stackBlockKey>
9
+ <div class="flex-align-center">
10
+ <span>{{ label }}</span>
11
+ </div>
12
+ </template>
13
+ <template #stackBlockContent>
14
+ <span class="main-label">
15
+ {{ selectedLabel }}
16
+ </span>
17
+ </template>
18
+ <template #stackChildren>
19
+ <template v-if="props.type === 'new'">
20
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-type-selection
21
+ v-model="selectedType"
22
+ :options="pciDeviceTypeOptions"
23
+ :pci-device-index="props.index"
24
+ />
25
+
26
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-direct-path-io
27
+ v-show="selectedType.value === 'direct_path_io'"
28
+ v-model="directPathIo"
29
+ :pci-device-index="props.index"
30
+ :passthrough-devices="props.passthroughDevices"
31
+ />
32
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-dynamic-direct-path-io
33
+ v-show="selectedType.value === 'dynamic_direct_path_io'"
34
+ v-model="dynamicDirectPathIo"
35
+ :pci-device-index="props.index"
36
+ :passthrough-devices="props.passthroughDevices"
37
+ />
38
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-nvidia-grid
39
+ v-show="selectedType.value === 'nvidia_grid'"
40
+ v-model="nvidiaGridProfile"
41
+ :pci-device-index="props.index"
42
+ />
43
+ </template>
44
+
45
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-pci-device-note />
46
+ </template>
47
+ </atoms-stack-block>
48
+ </div>
49
+ </template>
50
+
51
+ <script setup lang="ts">
52
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
53
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
54
+ import type { UI_I_SendDataNewPciDevice } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
55
+ import type { UI_T_PciDeviceType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
56
+ import type { UI_I_PciDevice } from '~/lib/models/store/vm/interfaces'
57
+ import { pciDeviceTypeOptionsConfig } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/newPciDevice/lib/config/options'
58
+
59
+ const props = defineProps<{
60
+ index: number
61
+ pciDevice: UI_I_SendDataNewPciDevice
62
+ passthroughDevices: UI_I_PciDevice[]
63
+ type: UI_T_PciDeviceType
64
+ isEdit: boolean
65
+ state?: string | number
66
+ // errorValidationFields: UI_I_ErrorValidationField<string>[]
67
+ }>()
68
+ const emits = defineEmits<{
69
+ (event: 'send-data', value: UI_I_SendDataNewPciDevice): void
70
+ (event: 'remove'): void
71
+ }>()
72
+
73
+ const localization = computed<UI_I_Localization>(() => useLocal())
74
+
75
+ const isRunning = computed<boolean>(() => {
76
+ return props.state === 2
77
+ })
78
+
79
+ const isRemovable = computed<boolean>(() => {
80
+ return !props.isEdit || !isRunning.value
81
+ })
82
+
83
+ const label = computed<string>(() => {
84
+ if (props.type === 'edit')
85
+ return `${localization.value.newPciDevice} ${props.index + 1}`
86
+
87
+ return `${localization.value.pciDevice} *`
88
+ })
89
+
90
+ const selectedLabel = computed<string>(() => {
91
+ switch (selectedType.value.value) {
92
+ case 'direct_path_io':
93
+ return `${directPathIo.value.address}|${directPathIo.value.device_name}`
94
+ case 'dynamic_direct_path_io':
95
+ return dynamicDirectPathIo.value
96
+ default:
97
+ return nvidiaGridProfile.value
98
+ }
99
+ })
100
+
101
+ const pciDeviceTypeOptions = ref<UI_I_OptionItem[]>(pciDeviceTypeOptionsConfig)
102
+ const selectedType = ref<UI_I_OptionItem>(pciDeviceTypeOptionsConfig[0])
103
+
104
+ const directPathIo = ref<UI_I_PciDevice>(
105
+ props.passthroughDevices[0]
106
+ )
107
+ const dynamicDirectPathIo = ref<string>('')
108
+ const nvidiaGridProfile = ref<string>('')
109
+
110
+ watch(
111
+ props.pciDevice,
112
+ (newValue) => {
113
+ // const passthroughDevice = props.passthroughDevices.find(
114
+ // (item) => item.address === newValue.address
115
+ // )
116
+ // passthroughDevice && (directPathIo.value = passthroughDevice) // Todo change
117
+ newValue && (directPathIo.value = newValue)
118
+ },
119
+ { immediate: true }
120
+ )
121
+
122
+ const sendData = computed<UI_I_SendDataNewPciDevice>(() => {
123
+ switch (selectedType.value.value) {
124
+ case 'direct_path_io':
125
+ return {
126
+ address: directPathIo.value.address,
127
+ vendor_name: directPathIo.value.vendor_name,
128
+ class_name: directPathIo.value.class_name,
129
+ device_name: directPathIo.value.device_name,
130
+ }
131
+ case 'dynamic_direct_path_io':
132
+ return {
133
+ address: '',
134
+ vendor_name: '',
135
+ class_name: '',
136
+ device_name: '',
137
+ }
138
+ default:
139
+ return {
140
+ address: '',
141
+ vendor_name: '',
142
+ class_name: '',
143
+ device_name: '',
144
+ }
145
+ }
146
+ })
147
+
148
+ watch(
149
+ sendData,
150
+ (newValue) => {
151
+ emits('send-data', newValue)
152
+ },
153
+ { immediate: true }
154
+ )
155
+
156
+ const onRemovePciDevice = (): void => {
157
+ emits('remove')
158
+ }
159
+ </script>
160
+
161
+ <style scoped lang="scss">
162
+ #network-connect {
163
+ margin-right: 4px;
164
+ }
165
+ </style>
@@ -1,164 +1,164 @@
1
- <template>
2
- <div class="select-compute-resource">
3
- <atoms-alert
4
- v-show="errors.length"
5
- status="alert-danger"
6
- test-id="computed-resource-alert"
7
- :items="errors"
8
- @remove="removeValidationErrors"
9
- />
10
-
11
- <div class="tree-view-wrap mt-1">
12
- <common-vm-actions-common-select-compute-resource-tree-view
13
- v-model="selectedNode"
14
- :data-center="props.dataCenter"
15
- :compute-resource="props.computeResource"
16
- :compute-resource-tree="props.computeResourceTree"
17
- @get-compute-resource-tree="emits('get-compute-resource-tree', $event)"
18
- @show-compute-resource-tree="
19
- emits('show-compute-resource-tree', $event)
20
- "
21
- @select-compute-resource-tree="
22
- emits('select-compute-resource-tree', $event)
23
- "
24
- @clear-compute-resource-tree="
25
- emits('clear-compute-resource-tree', $event)
26
- "
27
- />
28
- </div>
29
-
30
- <div class="compatibility-wrap">
31
- <p class="compatibility">
32
- {{ localization.compatibility }}
33
- </p>
34
- <div class="compatibility-message flex-align-center">
35
- <template v-if="compatibilityText[1]">
36
- <atoms-the-icon
37
- v-show="!compatibilityText[0]"
38
- width="20"
39
- name="exclamation-circle"
40
- />
41
- <div v-show="compatibilityText[0]" class="icon-status-ok" />
42
- <span>{{ compatibilityText[1] }}</span>
43
- </template>
44
- </div>
45
- </div>
46
- </div>
47
- </template>
48
-
49
- <script setup lang="ts">
50
- import { UI_I_Localization } from '~/lib/models/interfaces'
51
- import { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
52
-
53
- const props = defineProps<{
54
- computeResourceSubmit: null | Function
55
- dataCenter: UI_I_TreeNode | null
56
- computeResource: UI_I_TreeNode
57
- computeResourceTree: UI_I_TreeNode[]
58
- modelValue: UI_I_TreeNode | null
59
- }>()
60
-
61
- const emits = defineEmits<{
62
- (event: 'submit', value: UI_I_TreeNode): void
63
- (event: 'update:model-value', value: UI_I_TreeNode | null): void
64
- (
65
- event: 'get-compute-resource-tree',
66
- value: { id: string | number; cb: () => void }
67
- ): void
68
- (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void
69
- (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void
70
- (event: 'clear-compute-resource-tree'): void
71
- }>()
72
-
73
- const localization = computed<UI_I_Localization>(() => useLocal())
74
-
75
- watch(
76
- () => props.computeResourceSubmit,
77
- (newValue: null | Function) => {
78
- newValue && submit(newValue)
79
- }
80
- )
81
- const submit = (cb: Function): void => {
82
- if (
83
- !selectedNode.value ||
84
- !compatibilityText.value[1] ||
85
- selectedNode.value.type === 'datacenter' ||
86
- selectedNode.value.type === 'folder' ||
87
- (selectedNode.value.type === 'cluster' && !selectedNode.value.nodes.length)
88
- ) {
89
- showValidationErrors(
90
- localization.value.specifyValidClusterOrHostDestination
91
- )
92
- cb(false)
93
- return
94
- }
95
-
96
- removeValidationErrors()
97
- emits('submit', selectedNode.value)
98
- cb(true)
99
- }
100
-
101
- const errors = ref<string[]>([])
102
- const showValidationErrors = (text: string): void => {
103
- errors.value = [text]
104
- }
105
- const removeValidationErrors = (): void => {
106
- errors.value = []
107
- }
108
-
109
- const selectedNode = defineModel<UI_I_TreeNode | null>('model')
110
-
111
- const compatibilityText = computed<[boolean, string]>(() => {
112
- let res: [boolean, string] = [
113
- true,
114
- localization.value.compatibilityChecksSucceeded,
115
- ]
116
-
117
- if (!selectedNode.value) res = [true, '']
118
-
119
- if (
120
- !['cluster', 'host', 'resource_pool'].includes(selectedNode.value?.type)
121
- ) {
122
- res = [false, localization.value.selectValidClusterOrHostDestination]
123
- }
124
- if (selectedNode.value?.type === 'cluster') {
125
- const hasHost = !!selectedNode.value.nodes.length
126
- if (!hasHost) {
127
- res = [false, localization.value.clusterNotContainAnyHosts]
128
- }
129
- }
130
-
131
- if (selectedNode.value?.type === 'host') {
132
- if (selectedNode.value.state === 'Error') {
133
- // TODO check Maintenance Mode
134
- res = [false, localization.value.selectedHostDisconnectedMaintenanceMode]
135
- }
136
- }
137
-
138
- return res
139
- })
140
- </script>
141
-
142
- <style scoped lang="scss">
143
- .select-compute-resource {
144
- .tree-view-wrap {
145
- max-height: 300px;
146
- min-height: 200px;
147
- position: relative;
148
- border: 1px solid #000;
149
- padding: 5px 0 0 5px;
150
- overflow: auto;
151
- }
152
-
153
- .compatibility-wrap {
154
- padding-top: 10px;
155
-
156
- .compatibility-message {
157
- border: 1px solid #000;
158
- padding-top: 5px;
159
- padding-left: 5px;
160
- overflow: auto;
161
- }
162
- }
163
- }
164
- </style>
1
+ <template>
2
+ <div class="select-compute-resource">
3
+ <atoms-alert
4
+ v-show="errors.length"
5
+ status="alert-danger"
6
+ test-id="computed-resource-alert"
7
+ :items="errors"
8
+ @remove="removeValidationErrors"
9
+ />
10
+
11
+ <div class="tree-view-wrap mt-1">
12
+ <common-vm-actions-common-select-compute-resource-tree-view
13
+ v-model="selectedNode"
14
+ :data-center="props.dataCenter"
15
+ :compute-resource="props.computeResource"
16
+ :compute-resource-tree="props.computeResourceTree"
17
+ @get-compute-resource-tree="emits('get-compute-resource-tree', $event)"
18
+ @show-compute-resource-tree="
19
+ emits('show-compute-resource-tree', $event)
20
+ "
21
+ @select-compute-resource-tree="
22
+ emits('select-compute-resource-tree', $event)
23
+ "
24
+ @clear-compute-resource-tree="
25
+ emits('clear-compute-resource-tree', $event)
26
+ "
27
+ />
28
+ </div>
29
+
30
+ <div class="compatibility-wrap">
31
+ <p class="compatibility">
32
+ {{ localization.compatibility }}
33
+ </p>
34
+ <div class="compatibility-message flex-align-center">
35
+ <template v-if="compatibilityText[1]">
36
+ <atoms-the-icon
37
+ v-show="!compatibilityText[0]"
38
+ width="20"
39
+ name="exclamation-circle"
40
+ />
41
+ <div v-show="compatibilityText[0]" class="icon-status-ok" />
42
+ <span>{{ compatibilityText[1] }}</span>
43
+ </template>
44
+ </div>
45
+ </div>
46
+ </div>
47
+ </template>
48
+
49
+ <script setup lang="ts">
50
+ import { UI_I_Localization } from '~/lib/models/interfaces'
51
+ import { UI_I_TreeNode } from '~/components/common/recursionTree/lib/models/interfaces'
52
+
53
+ const props = defineProps<{
54
+ computeResourceSubmit: null | Function
55
+ dataCenter: UI_I_TreeNode | null
56
+ computeResource: UI_I_TreeNode
57
+ computeResourceTree: UI_I_TreeNode[]
58
+ modelValue: UI_I_TreeNode | null
59
+ }>()
60
+
61
+ const emits = defineEmits<{
62
+ (event: 'submit', value: UI_I_TreeNode): void
63
+ (event: 'update:model-value', value: UI_I_TreeNode | null): void
64
+ (
65
+ event: 'get-compute-resource-tree',
66
+ value: { id: string | number; cb: () => void }
67
+ ): void
68
+ (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void
69
+ (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void
70
+ (event: 'clear-compute-resource-tree'): void
71
+ }>()
72
+
73
+ const localization = computed<UI_I_Localization>(() => useLocal())
74
+
75
+ watch(
76
+ () => props.computeResourceSubmit,
77
+ (newValue: null | Function) => {
78
+ newValue && submit(newValue)
79
+ }
80
+ )
81
+ const submit = (cb: Function): void => {
82
+ if (
83
+ !selectedNode.value ||
84
+ !compatibilityText.value[1] ||
85
+ selectedNode.value.type === 'datacenter' ||
86
+ selectedNode.value.type === 'folder' ||
87
+ (selectedNode.value.type === 'cluster' && !selectedNode.value.nodes.length)
88
+ ) {
89
+ showValidationErrors(
90
+ localization.value.specifyValidClusterOrHostDestination
91
+ )
92
+ cb(false)
93
+ return
94
+ }
95
+
96
+ removeValidationErrors()
97
+ emits('submit', selectedNode.value)
98
+ cb(true)
99
+ }
100
+
101
+ const errors = ref<string[]>([])
102
+ const showValidationErrors = (text: string): void => {
103
+ errors.value = [text]
104
+ }
105
+ const removeValidationErrors = (): void => {
106
+ errors.value = []
107
+ }
108
+
109
+ const selectedNode = defineModel<UI_I_TreeNode | null>('model')
110
+
111
+ const compatibilityText = computed<[boolean, string]>(() => {
112
+ let res: [boolean, string] = [
113
+ true,
114
+ localization.value.compatibilityChecksSucceeded,
115
+ ]
116
+
117
+ if (!selectedNode.value) res = [true, '']
118
+
119
+ if (
120
+ !['cluster', 'host', 'resource_pool'].includes(selectedNode.value?.type)
121
+ ) {
122
+ res = [false, localization.value.selectValidClusterOrHostDestination]
123
+ }
124
+ if (selectedNode.value?.type === 'cluster') {
125
+ const hasHost = !!selectedNode.value.nodes.length
126
+ if (!hasHost) {
127
+ res = [false, localization.value.clusterNotContainAnyHosts]
128
+ }
129
+ }
130
+
131
+ if (selectedNode.value?.type === 'host') {
132
+ if (selectedNode.value.state === 'Error') {
133
+ // TODO check Maintenance Mode
134
+ res = [false, localization.value.selectedHostDisconnectedMaintenanceMode]
135
+ }
136
+ }
137
+
138
+ return res
139
+ })
140
+ </script>
141
+
142
+ <style scoped lang="scss">
143
+ .select-compute-resource {
144
+ .tree-view-wrap {
145
+ max-height: 300px;
146
+ min-height: 200px;
147
+ position: relative;
148
+ border: 1px solid #000;
149
+ padding: 5px 0 0 5px;
150
+ overflow: auto;
151
+ }
152
+
153
+ .compatibility-wrap {
154
+ padding-top: 10px;
155
+
156
+ .compatibility-message {
157
+ border: 1px solid #000;
158
+ padding-top: 5px;
159
+ padding-left: 5px;
160
+ overflow: auto;
161
+ }
162
+ }
163
+ }
164
+ </style>