bfg-common 1.3.398 → 1.3.399

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 (24) hide show
  1. package/assets/img/icons/icons-sprite-dark-1-old.svg +1 -0
  2. package/assets/img/icons/icons-sprite-dark-1.svg +360 -1
  3. package/assets/img/icons/icons-sprite-dark-2-old.svg +1 -0
  4. package/assets/img/icons/icons-sprite-dark-2.svg +296 -1
  5. package/assets/img/icons/icons-sprite-dark-3-old.svg +1 -0
  6. package/assets/img/icons/icons-sprite-dark-3.svg +221 -1
  7. package/assets/img/icons/icons-sprite-dark-4-old.svg +1 -0
  8. package/assets/img/icons/icons-sprite-dark-4.svg +247 -1
  9. package/assets/img/icons/icons-sprite-dark-7.svg +8 -0
  10. package/assets/img/icons/icons-sprite-light-1-old.svg +1 -0
  11. package/assets/img/icons/icons-sprite-light-1.svg +360 -1
  12. package/assets/img/icons/icons-sprite-light-2-old.svg +1 -0
  13. package/assets/img/icons/icons-sprite-light-2.svg +296 -1
  14. package/assets/img/icons/icons-sprite-light-3-old.svg +1 -0
  15. package/assets/img/icons/icons-sprite-light-3.svg +221 -1
  16. package/assets/img/icons/icons-sprite-light-4-old.svg +1 -0
  17. package/assets/img/icons/icons-sprite-light-4.svg +247 -1
  18. package/assets/img/icons/icons-sprite-light-7.svg +8 -0
  19. package/assets/scss/common/icons/icons-7.scss +29 -0
  20. package/assets/scss/common/icons/icons.scss +1 -0
  21. package/components/common/vm/actions/common/customizeHardware/virtualHardware/bus/Bus.vue +9 -4
  22. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +267 -266
  23. package/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +459 -458
  24. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ <svg width="38" height="38" viewBox="0 0 38 38" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M18.7665 3.1665H11.611C9.8621 3.1665 8.44434 4.58427 8.44434 6.33317V31.6665C8.44434 33.4154 9.8621 34.8332 11.611 34.8332H26.3888C28.1377 34.8332 29.5554 33.4154 29.5554 31.6665V21.0636C29.2078 21.0949 28.8557 21.1109 28.4999 21.1109C28.1441 21.1109 27.792 21.0949 27.4443 21.0636V31.6665C27.4443 32.2495 26.9717 32.7221 26.3888 32.7221H11.611C11.028 32.7221 10.5554 32.2495 10.5554 31.6665V6.33317C10.5554 5.7502 11.028 5.27762 11.611 5.27762H17.6803C17.9709 4.53352 18.336 3.82676 18.7665 3.1665Z" fill="#4D5D69"/>
3
+ <path d="M16.919 8.65539L13.7221 8.65539C13.2557 8.65539 12.8777 9.03346 12.8777 9.49984C12.8777 9.96621 13.2557 10.3443 13.7221 10.3443L16.919 10.3443C16.899 10.0654 16.8888 9.78381 16.8888 9.49984C16.8888 9.21586 16.899 8.93426 16.919 8.65539Z" fill="#4D5D69"/>
4
+ <path d="M17.7652 13.9332H14.7777C14.3113 13.9332 13.9332 14.3112 13.9332 14.7776C13.9332 15.244 14.3113 15.6221 14.7777 15.6221H18.6321C18.2992 15.0866 18.0087 14.5221 17.7652 13.9332Z" fill="#4D5D69"/>
5
+ <path d="M20.7603 18.1554C21.5011 18.8183 22.3275 19.3874 23.2209 19.8443H14.7777C14.3113 19.8443 13.9332 19.4662 13.9332 18.9998C13.9332 18.5335 14.3113 18.1554 14.7777 18.1554L20.7603 18.1554Z" fill="#4D5D69"/>
6
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M18.9999 24.4887C17.3676 24.4887 16.0443 25.812 16.0443 27.4443C16.0443 29.0766 17.3676 30.3998 18.9999 30.3998C20.6322 30.3998 21.9554 29.0766 21.9554 27.4443C21.9554 25.812 20.6322 24.4887 18.9999 24.4887ZM17.7332 27.4443C17.7332 26.7447 18.3003 26.1776 18.9999 26.1776C19.6995 26.1776 20.2666 26.7447 20.2666 27.4443C20.2666 28.1438 19.6995 28.7109 18.9999 28.7109C18.3003 28.7109 17.7332 28.1438 17.7332 27.4443Z" fill="#4D5D69"/>
7
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M38 9.5C38 14.7467 33.7467 19 28.5 19C23.2533 19 19 14.7467 19 9.5C19 4.25329 23.2533 0 28.5 0C33.7467 0 38 4.25329 38 9.5ZM24.3352 13.6652C24.7804 14.1104 25.5023 14.1104 25.9474 13.6652L28.5001 11.1126L31.0528 13.6652C31.498 14.1104 32.2198 14.1104 32.665 13.6652C33.1102 13.22 33.1102 12.4982 32.665 12.053L30.1123 9.50038L32.665 6.94772C33.1102 6.50253 33.1102 5.78072 32.665 5.33552C32.2198 4.89032 31.498 4.89032 31.0528 5.33552L28.5001 7.88818L25.9474 5.33552C25.5023 4.89032 24.7804 4.89032 24.3352 5.33552C23.89 5.78072 23.89 6.50253 24.3352 6.94772L26.8879 9.50038L24.3352 12.053C23.89 12.4982 23.89 13.22 24.3352 13.6652Z" fill="#EA3223"/>
8
+ </svg>
@@ -0,0 +1,29 @@
1
+ /* _____BACKGROUND POSITION_____ */
2
+ .host-disconnect {
3
+ background-position: 0 100%;
4
+ }
5
+
6
+ /* _____BACKGROUND IMAGE_____ */
7
+ .host-disconnect {
8
+ background-image: url('../img/icons/icons-sprite-light-7.svg');
9
+
10
+ html.dark-theme & {
11
+ background-image: url('../img/icons/icons-sprite-dark-7.svg');
12
+ }
13
+ }
14
+ .active .host-disconnect {
15
+ background-image: url('../img/icons/icons-sprite-dark-7.svg');
16
+
17
+ html.dark-theme & {
18
+ background-image: url('../img/icons/icons-sprite-light-7.svg');
19
+ }
20
+ }
21
+
22
+ /* _____ICONS COMMON STYLES_____ */
23
+ .host-disconnect {
24
+ width: 18px;
25
+ min-width: 18px;
26
+ height: 18px;
27
+ min-height: 18px;
28
+ background-size: 100% auto;
29
+ }
@@ -4,6 +4,7 @@
4
4
  @import 'icons-4';
5
5
  @import 'icons-5';
6
6
  @import 'icons-6';
7
+ @import 'icons-7';
7
8
  @import 'lib-icons';
8
9
 
9
10
  /* _____ICONS COMMON STYLES_____ */
@@ -16,7 +16,7 @@
16
16
  <select
17
17
  :id="`vm-wizard-${props.componentType}-bus-field-${props.index}`"
18
18
  v-model="busLocal"
19
- :data-id="`vm-wizard-${props.componentType}-bus-field-${props.index}`"
19
+ :data-id="`${props.testId}-select`"
20
20
  :class="`vm-wizard-${props.componentType}-bus-field-${props.index}`"
21
21
  :disabled="props.disabled"
22
22
  >
@@ -32,9 +32,13 @@
32
32
  </template>
33
33
  <template #content>{{ apiError }}</template>
34
34
  </atoms-tooltip-error>
35
- <div v-if="props.helpText" :id="helpId" class="content-signpost relative">
35
+ <div
36
+ v-if="props.helpText"
37
+ :id="helpId"
38
+ class="content-signpost relative"
39
+ >
36
40
  <atoms-the-icon
37
- :data-id="`vm-wizard-${props.componentType}-bus-field-${props.index}-show-help-icon`"
41
+ :data-id="`${props.testId}-show-help-icon`"
38
42
  class="icon-show-help"
39
43
  fill="#0072a3"
40
44
  width="24px"
@@ -50,7 +54,7 @@
50
54
  @hide="isShowHelp = false"
51
55
  >
52
56
  <p>
53
- <!-- {{ localization.busVirtioHelpDesc }}-->
57
+ <!-- {{ localization.busVirtioHelpDesc }}-->
54
58
  {{ props.helpText }}
55
59
  </p>
56
60
  </atoms-tooltip-signpost>
@@ -74,6 +78,7 @@ const props = defineProps<{
74
78
  bus: string
75
79
  index: number
76
80
  componentType: string
81
+ testId: string
77
82
  errorValidationFields: UI_I_ErrorValidationField<string>[]
78
83
  disabled?: boolean
79
84
  shortOptions?: boolean
@@ -1,266 +1,267 @@
1
- <template>
2
- <div class="hardware-cd-dvd-drive">
3
- <atoms-stack-block
4
- :has-children="true"
5
- :is-roll-back="props.type === 'removed'"
6
- :removable="isRemovable"
7
- @remove="onRemoveCdDvdDrive"
8
- @roll-back="onRollBackCdDvdDrive"
9
- >
10
- <template #stackBlockKey>
11
- <div
12
- :id="`vm-wizard-toggle-block-cd-dvd-drive-${props.index}`"
13
- :data-id="`vm-wizard-toggle-block-cd-dvd-drive-${props.index}`"
14
- class="vm-wizard-toggle-block-cd-dvd-drive vm-wizard-toggle-block-hard-disk"
15
- >
16
- <span>{{ label }}</span>
17
- </div>
18
- </template>
19
- <template #stackBlockContent>
20
- <div class="flex-align-center flex-space-between">
21
- <template v-if="props.type === 'removed'">
22
- <span>{{ localization.deviceWillRemoved }}</span>
23
- <div class="flex-align-center" @click.stop>
24
- <input
25
- :id="`cd-dvd-delete-files-from-datastore-${props.index}`"
26
- v-model="deleteFilesFromDatastore"
27
- :data-id="`cd-dvd-delete-files-from-datastore-${props.index}`"
28
- :disabled="props.disabled"
29
- type="checkbox"
30
- class="pointer"
31
- @click.stop
32
- />
33
- <label
34
- :for="`cd-dvd-delete-files-from-datastore-${props.index}`"
35
- :class="[
36
- 'label-text-normal pointer',
37
- props.disabled && 'div-disabled',
38
- ]"
39
- >{{ localization.deleteFilesFromDatastore }}</label
40
- >
41
- </div>
42
- </template>
43
- <template v-else>
44
- <div class="select">
45
- <select
46
- id="vm-wizard-cd-dvd-drive-field"
47
- v-model="selectedCdDvdDrive"
48
- :data-id="`vm-wizard-cd-dvd-drive-field-${props.index}`"
49
- class="vm-wizard-cd-dvd-drive-field input-text-color"
50
- @click.stop
51
- @change="changeCdDvdDrive"
52
- >
53
- <option
54
- v-for="(item, key) in cdDvdDriveOptions"
55
- :key="key"
56
- :value="item.value"
57
- >
58
- {{ item.text }}
59
- </option>
60
- </select>
61
- </div>
62
- </template>
63
- </div>
64
- </template>
65
- <template #stackChildren>
66
- <common-vm-actions-common-customize-hardware-virtual-hardware-cd-dvd-drive-media
67
- v-if="selectedCdDvdDrive === 'datastoreIsoFile'"
68
- v-model:cd-dvd-media="cdDvdMedia"
69
- @browse="isShowFileModal = true"
70
- />
71
-
72
- <!-- :short-options="props.type === 'edit'" // поменял из-за задачки PNCWEB-384-->
73
- <common-vm-actions-common-customize-hardware-virtual-hardware-bus
74
- v-model:bus="bus"
75
- :index="indexByHardDisks"
76
- :validation-type="busValidationType"
77
- :error-validation-fields="props.errorValidationFields"
78
- :disabled="isRunning"
79
- short-options
80
- component-type="disk_devices"
81
- @remove-error-by-title="emits('remove-error-by-title', $event)"
82
- />
83
- </template>
84
- </atoms-stack-block>
85
-
86
- <Teleport to="body">
87
- <common-vm-actions-common-customize-hardware-virtual-hardware-browse-view
88
- v-if="isShowFileModal"
89
- :show="isShowFileModal"
90
- :file-types="fileTypes"
91
- :nodes="props.nodes"
92
- :files="props.files"
93
- @submit="onSelectFile"
94
- @get-storage="emits('get-storage', $event)"
95
- @get-folders-or-files="emits('get-folders-or-files', $event)"
96
- @get-active-device-child="emits('get-active-device-child', $event)"
97
- @show-datastore-child="emits('show-datastore-child', $event)"
98
- @hide="onHideFileModal"
99
- />
100
- </Teleport>
101
- </div>
102
- </template>
103
-
104
- <script lang="ts" setup>
105
- import { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
106
- import { UI_I_TablePayload } from '~/lib/models/table/interfaces'
107
- import { UI_T_CdDvdDrive } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/lib/models/types'
108
- import { UI_I_SendDataNewCdDvdDrive } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
109
- import {
110
- UI_I_Localization,
111
- UI_I_HTMLSelectElement,
112
- } from '~/lib/models/interfaces'
113
- import { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
114
- import { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
115
- import { UI_I_FolderOrFileTreePayload } from '~/lib/models/store/storage/interfaces'
116
- import { UI_T_CdDvdType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
117
- import { cdDvdDriveOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/lib/config/options'
118
- import { fileTypesFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/lib/config/fileTypes'
119
-
120
- const props = defineProps<{
121
- hardDisksCount: number
122
- index: number
123
- cdDvdDrive: UI_I_SendDataNewCdDvdDrive
124
- nodes: UI_I_FileTreeNode[]
125
- files: UI_I_FileTreeNode[]
126
- errorValidationFields: UI_I_ErrorValidationField<string>[]
127
- type: UI_T_CdDvdType
128
- isEdit: boolean
129
- state?: string | number
130
- }>()
131
-
132
- const emits = defineEmits<{
133
- (event: 'send-data', value: UI_I_SendDataNewCdDvdDrive): void
134
- (event: 'remove'): void
135
- (event: 'roll-back'): void
136
- (event: 'remove-error-by-title', value: string): void
137
- (event: 'get-storage', value: UI_I_TablePayload): void
138
- (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
139
- (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
140
- (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
141
- }>()
142
-
143
- const localization = computed<UI_I_Localization>(() => useLocal())
144
-
145
- const isRunning = computed<boolean>(() => {
146
- return props.state === 2
147
- })
148
-
149
- const isRemovable = computed<boolean>(() => {
150
- return (
151
- !props.isEdit ||
152
- !isRunning.value ||
153
- (isRunning.value && bus.value === 'virtio')
154
- )
155
- })
156
-
157
- const indexByHardDisks = computed<number>(
158
- () => props.index + props.hardDisksCount
159
- )
160
-
161
- const label = computed<string>(() => {
162
- if (props.type === 'edit' || props.type === 'removed')
163
- // 2 так как из-под капота создается еще один cd/dvd driver
164
- return `${localization.value.cdDvdDrive} ${props.index + 2}`
165
-
166
- return `${localization.value.newCdDvdDrive} *`
167
- })
168
-
169
- const busValidationType = computed<string>(
170
- () => `disk_devices[${indexByHardDisks}].bus`
171
- )
172
-
173
- const selectedCdDvdDrive = ref<UI_T_CdDvdDrive>('clientDevice')
174
- const cdDvdDriveOptions = ref<UI_I_OptionItem[]>(
175
- cdDvdDriveOptionsFunc(localization.value)
176
- )
177
- const changeCdDvdDrive = (event: UI_I_HTMLSelectElement): void => {
178
- const isDatastoreIsoFile = event.target.value === 'datastoreIsoFile'
179
- if (!isDatastoreIsoFile) {
180
- cdDvdMedia.value = ''
181
- return
182
- }
183
-
184
- isShowFileModal.value = true
185
- }
186
- const isShowFileModal = ref<boolean>(false)
187
- const onHideFileModal = (): void => {
188
- if (!cdDvdMedia.value) {
189
- selectedCdDvdDrive.value = 'clientDevice'
190
- }
191
- isShowFileModal.value = false
192
- }
193
- const onSelectFile = (file: UI_I_FileTreeNode): void => {
194
- cdDvdMedia.value = file.path
195
- }
196
- const fileTypes = computed<UI_I_OptionItem[]>(() =>
197
- fileTypesFunc(localization.value)
198
- )
199
-
200
- const onRemoveCdDvdDrive = (): void => {
201
- emits('remove')
202
- }
203
- const onRollBackCdDvdDrive = (): void => {
204
- emits('roll-back')
205
- }
206
-
207
- const cdDvdMedia = ref<string>('')
208
- // const bus = ref<string>('ide')
209
- const bus = ref<string>('sata') // PNCWEB-384
210
-
211
- const deleteFilesFromDatastore = ref<boolean>(false)
212
-
213
- watch(
214
- [cdDvdMedia, bus, deleteFilesFromDatastore, () => props.type],
215
- () => {
216
- emits('send-data', {
217
- create: props.cdDvdDrive.create,
218
- attach: props.cdDvdDrive.attach,
219
- source: cdDvdMedia.value,
220
- size: 0,
221
- bus: bus.value,
222
- device_type: 'cdrom',
223
- provision_type: 'thick',
224
- disk_mode: 'dependent',
225
- sharing: false,
226
- read_only: true,
227
- shares: 0,
228
- cache: 'none',
229
- io: 'native',
230
- limit_iops: 0,
231
- discard: 'unmap',
232
- target: props.cdDvdDrive.target,
233
- boot_order: props.cdDvdDrive.boot_order,
234
- detach: props.type === 'removed',
235
- remove: props.type === 'removed' && deleteFilesFromDatastore.value, // Проверяем если удалили диск и указали Delete files from datastore
236
- })
237
- },
238
- { immediate: true }
239
- )
240
-
241
- // Добавляем данные для редактирования
242
- watch(
243
- () => props.cdDvdDrive,
244
- (newValue) => {
245
- if (newValue.source !== '') {
246
- selectedCdDvdDrive.value = 'datastoreIsoFile'
247
- cdDvdMedia.value = newValue.source
248
- }
249
- if (newValue.bus !== '') {
250
- bus.value = newValue.bus
251
- }
252
- },
253
- { immediate: true }
254
- )
255
- watch(
256
- isRunning,
257
- (newValue) => {
258
- if (newValue && props.type === 'new') {
259
- bus.value = 'virtio'
260
- }
261
- },
262
- { immediate: true }
263
- )
264
- </script>
265
-
266
- <style lang="scss" scoped></style>
1
+ <template>
2
+ <div class="hardware-cd-dvd-drive">
3
+ <atoms-stack-block
4
+ :has-children="true"
5
+ :is-roll-back="props.type === 'removed'"
6
+ :removable="isRemovable"
7
+ @remove="onRemoveCdDvdDrive"
8
+ @roll-back="onRollBackCdDvdDrive"
9
+ >
10
+ <template #stackBlockKey>
11
+ <div
12
+ :id="`vm-wizard-toggle-block-cd-dvd-drive-${props.index}`"
13
+ :data-id="`vm-wizard-toggle-block-cd-dvd-drive-${props.index}`"
14
+ class="vm-wizard-toggle-block-cd-dvd-drive vm-wizard-toggle-block-hard-disk"
15
+ >
16
+ <span>{{ label }}</span>
17
+ </div>
18
+ </template>
19
+ <template #stackBlockContent>
20
+ <div class="flex-align-center flex-space-between">
21
+ <template v-if="props.type === 'removed'">
22
+ <span>{{ localization.deviceWillRemoved }}</span>
23
+ <div class="flex-align-center" @click.stop>
24
+ <input
25
+ :id="`cd-dvd-delete-files-from-datastore-${props.index}`"
26
+ v-model="deleteFilesFromDatastore"
27
+ :data-id="`cd-dvd-delete-files-from-datastore-${props.index}`"
28
+ :disabled="props.disabled"
29
+ type="checkbox"
30
+ class="pointer"
31
+ @click.stop
32
+ />
33
+ <label
34
+ :for="`cd-dvd-delete-files-from-datastore-${props.index}`"
35
+ :class="[
36
+ 'label-text-normal pointer',
37
+ props.disabled && 'div-disabled',
38
+ ]"
39
+ >{{ localization.deleteFilesFromDatastore }}</label
40
+ >
41
+ </div>
42
+ </template>
43
+ <template v-else>
44
+ <div class="select">
45
+ <select
46
+ id="vm-wizard-cd-dvd-drive-field"
47
+ v-model="selectedCdDvdDrive"
48
+ :data-id="`vm-wizard-cd-dvd-drive-field-${props.index}`"
49
+ class="vm-wizard-cd-dvd-drive-field input-text-color"
50
+ @click.stop
51
+ @change="changeCdDvdDrive"
52
+ >
53
+ <option
54
+ v-for="(item, key) in cdDvdDriveOptions"
55
+ :key="key"
56
+ :value="item.value"
57
+ >
58
+ {{ item.text }}
59
+ </option>
60
+ </select>
61
+ </div>
62
+ </template>
63
+ </div>
64
+ </template>
65
+ <template #stackChildren>
66
+ <common-vm-actions-common-customize-hardware-virtual-hardware-cd-dvd-drive-media
67
+ v-if="selectedCdDvdDrive === 'datastoreIsoFile'"
68
+ v-model:cd-dvd-media="cdDvdMedia"
69
+ @browse="isShowFileModal = true"
70
+ />
71
+
72
+ <!-- :short-options="props.type === 'edit'" // поменял из-за задачки PNCWEB-384-->
73
+ <common-vm-actions-common-customize-hardware-virtual-hardware-bus
74
+ v-model:bus="bus"
75
+ :index="indexByHardDisks"
76
+ :validation-type="busValidationType"
77
+ :error-validation-fields="props.errorValidationFields"
78
+ :disabled="isRunning"
79
+ :test-id="`vm-wizard-cd-dvd-bus-field-${props.index}`"
80
+ short-options
81
+ component-type="disk_devices"
82
+ @remove-error-by-title="emits('remove-error-by-title', $event)"
83
+ />
84
+ </template>
85
+ </atoms-stack-block>
86
+
87
+ <Teleport to="body">
88
+ <common-vm-actions-common-customize-hardware-virtual-hardware-browse-view
89
+ v-if="isShowFileModal"
90
+ :show="isShowFileModal"
91
+ :file-types="fileTypes"
92
+ :nodes="props.nodes"
93
+ :files="props.files"
94
+ @submit="onSelectFile"
95
+ @get-storage="emits('get-storage', $event)"
96
+ @get-folders-or-files="emits('get-folders-or-files', $event)"
97
+ @get-active-device-child="emits('get-active-device-child', $event)"
98
+ @show-datastore-child="emits('show-datastore-child', $event)"
99
+ @hide="onHideFileModal"
100
+ />
101
+ </Teleport>
102
+ </div>
103
+ </template>
104
+
105
+ <script lang="ts" setup>
106
+ import { UI_I_FileTreeNode } from '~/components/lib/models/interfaces'
107
+ import { UI_I_TablePayload } from '~/lib/models/table/interfaces'
108
+ import { UI_T_CdDvdDrive } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/lib/models/types'
109
+ import { UI_I_SendDataNewCdDvdDrive } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/interfaces'
110
+ import {
111
+ UI_I_Localization,
112
+ UI_I_HTMLSelectElement,
113
+ } from '~/lib/models/interfaces'
114
+ import { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
115
+ import { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
116
+ import { UI_I_FolderOrFileTreePayload } from '~/lib/models/store/storage/interfaces'
117
+ import { UI_T_CdDvdType } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
118
+ import { cdDvdDriveOptionsFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/lib/config/options'
119
+ import { fileTypesFunc } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/lib/config/fileTypes'
120
+
121
+ const props = defineProps<{
122
+ hardDisksCount: number
123
+ index: number
124
+ cdDvdDrive: UI_I_SendDataNewCdDvdDrive
125
+ nodes: UI_I_FileTreeNode[]
126
+ files: UI_I_FileTreeNode[]
127
+ errorValidationFields: UI_I_ErrorValidationField<string>[]
128
+ type: UI_T_CdDvdType
129
+ isEdit: boolean
130
+ state?: string | number
131
+ }>()
132
+
133
+ const emits = defineEmits<{
134
+ (event: 'send-data', value: UI_I_SendDataNewCdDvdDrive): void
135
+ (event: 'remove'): void
136
+ (event: 'roll-back'): void
137
+ (event: 'remove-error-by-title', value: string): void
138
+ (event: 'get-storage', value: UI_I_TablePayload): void
139
+ (event: 'get-folders-or-files', value: UI_I_FolderOrFileTreePayload): void
140
+ (event: 'get-active-device-child', value: UI_I_FileTreeNode): void
141
+ (event: 'show-datastore-child', value: UI_I_FileTreeNode): void
142
+ }>()
143
+
144
+ const localization = computed<UI_I_Localization>(() => useLocal())
145
+
146
+ const isRunning = computed<boolean>(() => {
147
+ return props.state === 2
148
+ })
149
+
150
+ const isRemovable = computed<boolean>(() => {
151
+ return (
152
+ !props.isEdit ||
153
+ !isRunning.value ||
154
+ (isRunning.value && bus.value === 'virtio')
155
+ )
156
+ })
157
+
158
+ const indexByHardDisks = computed<number>(
159
+ () => props.index + props.hardDisksCount
160
+ )
161
+
162
+ const label = computed<string>(() => {
163
+ if (props.type === 'edit' || props.type === 'removed')
164
+ // 2 так как из-под капота создается еще один cd/dvd driver
165
+ return `${localization.value.cdDvdDrive} ${props.index + 2}`
166
+
167
+ return `${localization.value.newCdDvdDrive} *`
168
+ })
169
+
170
+ const busValidationType = computed<string>(
171
+ () => `disk_devices[${indexByHardDisks}].bus`
172
+ )
173
+
174
+ const selectedCdDvdDrive = ref<UI_T_CdDvdDrive>('clientDevice')
175
+ const cdDvdDriveOptions = ref<UI_I_OptionItem[]>(
176
+ cdDvdDriveOptionsFunc(localization.value)
177
+ )
178
+ const changeCdDvdDrive = (event: UI_I_HTMLSelectElement): void => {
179
+ const isDatastoreIsoFile = event.target.value === 'datastoreIsoFile'
180
+ if (!isDatastoreIsoFile) {
181
+ cdDvdMedia.value = ''
182
+ return
183
+ }
184
+
185
+ isShowFileModal.value = true
186
+ }
187
+ const isShowFileModal = ref<boolean>(false)
188
+ const onHideFileModal = (): void => {
189
+ if (!cdDvdMedia.value) {
190
+ selectedCdDvdDrive.value = 'clientDevice'
191
+ }
192
+ isShowFileModal.value = false
193
+ }
194
+ const onSelectFile = (file: UI_I_FileTreeNode): void => {
195
+ cdDvdMedia.value = file.path
196
+ }
197
+ const fileTypes = computed<UI_I_OptionItem[]>(() =>
198
+ fileTypesFunc(localization.value)
199
+ )
200
+
201
+ const onRemoveCdDvdDrive = (): void => {
202
+ emits('remove')
203
+ }
204
+ const onRollBackCdDvdDrive = (): void => {
205
+ emits('roll-back')
206
+ }
207
+
208
+ const cdDvdMedia = ref<string>('')
209
+ // const bus = ref<string>('ide')
210
+ const bus = ref<string>('sata') // PNCWEB-384
211
+
212
+ const deleteFilesFromDatastore = ref<boolean>(false)
213
+
214
+ watch(
215
+ [cdDvdMedia, bus, deleteFilesFromDatastore, () => props.type],
216
+ () => {
217
+ emits('send-data', {
218
+ create: props.cdDvdDrive.create,
219
+ attach: props.cdDvdDrive.attach,
220
+ source: cdDvdMedia.value,
221
+ size: 0,
222
+ bus: bus.value,
223
+ device_type: 'cdrom',
224
+ provision_type: 'thick',
225
+ disk_mode: 'dependent',
226
+ sharing: false,
227
+ read_only: true,
228
+ shares: 0,
229
+ cache: 'none',
230
+ io: 'native',
231
+ limit_iops: 0,
232
+ discard: 'unmap',
233
+ target: props.cdDvdDrive.target,
234
+ boot_order: props.cdDvdDrive.boot_order,
235
+ detach: props.type === 'removed',
236
+ remove: props.type === 'removed' && deleteFilesFromDatastore.value, // Проверяем если удалили диск и указали Delete files from datastore
237
+ })
238
+ },
239
+ { immediate: true }
240
+ )
241
+
242
+ // Добавляем данные для редактирования
243
+ watch(
244
+ () => props.cdDvdDrive,
245
+ (newValue) => {
246
+ if (newValue.source !== '') {
247
+ selectedCdDvdDrive.value = 'datastoreIsoFile'
248
+ cdDvdMedia.value = newValue.source
249
+ }
250
+ if (newValue.bus !== '') {
251
+ bus.value = newValue.bus
252
+ }
253
+ },
254
+ { immediate: true }
255
+ )
256
+ watch(
257
+ isRunning,
258
+ (newValue) => {
259
+ if (newValue && props.type === 'new') {
260
+ bus.value = 'virtio'
261
+ }
262
+ },
263
+ { immediate: true }
264
+ )
265
+ </script>
266
+
267
+ <style lang="scss" scoped></style>