bfg-common 1.4.363 → 1.4.365

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.
@@ -202,8 +202,8 @@ const navItems = computed<UI_I_CollapseNavItem[]>(() =>
202
202
  const selectedNavItem = ref<number>(0)
203
203
  watch(
204
204
  () => props.selectedNavItem,
205
- (n) => {
206
- selectedNavItem.value = n
205
+ (newValue) => {
206
+ selectedNavItem.value = newValue
207
207
  }
208
208
  )
209
209
 
@@ -28,7 +28,7 @@
28
28
  <div class="flex-align-center flex-space-between mr-1">
29
29
  <template v-if="props.type === 'removed'">
30
30
  <span>{{ localization.common.deviceWillRemoved }}</span>
31
- <div @click.stop class="flex-align-center">
31
+ <div class="flex-align-center" @click.stop>
32
32
  <input
33
33
  :id="`hard-disk-delete-files-from-datastore-${props.index}`"
34
34
  v-model="deleteFilesFromDatastore"
@@ -355,7 +355,7 @@ watch(
355
355
  cache,
356
356
  bus,
357
357
  deleteFilesFromDatastore,
358
- () => props.type,
358
+ (): void => props.type,
359
359
  ],
360
360
  () => {
361
361
  const limitIopsLocal =
@@ -1,173 +1,172 @@
1
- <template>
2
- <div class="">
3
- <atoms-stack-block :has-children="false">
4
- <template #stackBlockKey>
5
- {{ localization.common.location }}
6
- </template>
7
- <template #stackBlockContent>
8
- <atoms-tooltip-error
9
- :has-error="!!apiError"
10
- :selector="`.vm-wizard-disk-device-target-field-${props.index}`"
11
- @remove="onRemoveValidationError"
12
- >
13
- <template #elem>
14
- <div class="select">
15
- <select
16
- :id="`vm-wizard-disk-device-target-field-${props.index}`"
17
- v-model="selectedLocation"
18
- :data-id="`vm-wizard-disk-device-target-field-${props.index}`"
19
- :class="`vm-wizard-disk-device-target-field-${props.index}`"
20
- @change="changeLocation"
21
- >
22
- <option
23
- v-for="(item, key) in locationOptions"
24
- :key="key"
25
- :value="item.value"
26
- >
27
- {{ item.text }}
28
- </option>
29
- </select>
30
- </div>
31
- </template>
32
- <template #content>{{ apiError }}</template>
33
- </atoms-tooltip-error>
34
- </template>
35
- </atoms-stack-block>
36
-
37
- <Teleport to="body">
38
- <atoms-modal
39
- class="storage-modal"
40
- :show="storageModalIsShow"
41
- :title="localization.common.selectStorage"
42
- @submit="onSubmitStorageModal"
43
- @hide="onHideStorageModal"
44
- >
45
- <template #modalBody>
46
- <span>{{
47
- localization.common.followingDatastoresAccessibleDestinationResourceThatSelected
48
- }}</span>
49
- <common-vm-actions-common-select-storage
50
- :storage-submit="storageSubmit"
51
- :datastore="props.datastore"
52
- :get-datastore-table-func="props.getDatastoreTableFunc"
53
- hide-compatibility
54
- @submit="changeStorage"
55
- />
56
- </template>
57
- </atoms-modal>
58
- </Teleport>
59
- </div>
60
- </template>
61
-
62
- <script setup lang="ts">
63
- import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
64
- import type {
65
- UI_I_Localization,
66
- UI_I_HTMLSelectElement,
67
- } from '~/lib/models/interfaces'
68
- import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
69
- import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
70
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
71
-
72
- const localization = computed<UI_I_Localization>(() => useLocal())
73
-
74
- const props = defineProps<{
75
- location: UI_I_DatastoreTableItem | null
76
- index: number
77
- errorValidationFields: UI_I_ErrorValidationField<string>[]
78
- datastore: UI_I_DatastoreTableItem[]
79
- getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
80
- }>()
81
- const emits = defineEmits<{
82
- (event: 'change', value: UI_I_DatastoreTableItem): void
83
- (event: 'remove-error-by-title', value: string): void
84
- }>()
85
-
86
- const selectedLocation = ref<string>(props.location?.id || '')
87
-
88
- const storages = ref<UI_I_DatastoreTableItem[]>([])
89
- const addStorage = (storage: UI_I_DatastoreTableItem): void => {
90
- const hasStorage = storages.value.some((item) => item.id === storage.id)
91
- if (hasStorage) {
92
- return
93
- }
94
-
95
- storages.value.push(storage)
96
- }
97
- const locationOptions = ref<UI_I_OptionItem[]>([])
98
-
99
- watch(
100
- () => props.location,
101
- (newValue) => {
102
- if (locationOptions.value.length || !newValue) {
103
- return
104
- }
105
-
106
- locationOptions.value = [
107
- { text: localization.value.common.storeWithVirtualMachine, value: newValue.id },
108
- { text: `${localization.value.common.browse}...`, value: -1 },
109
- ]
110
- selectedLocation.value = newValue.id
111
- storages.value.push(newValue)
112
- addStorage(newValue)
113
- },
114
- { immediate: true }
115
- )
116
-
117
- const storageSubmit = ref<number>(0)
118
- const onSubmitStorageModal = (): void => {
119
- storageSubmit.value++
120
- }
121
- const storageModalIsShow = ref<boolean>(false)
122
- const changeStorage = (storage: UI_I_DatastoreTableItem): void => {
123
- locationOptions.value = [
124
- locationOptions.value[0],
125
- { text: storage.name, value: storage.id },
126
- // @ts-ignore
127
- locationOptions.value.at(-1),
128
- ]
129
-
130
- selectedLocation.value = storage.id
131
- emits('change', storage)
132
- addStorage(storage)
133
- onHideStorageModal()
134
- }
135
- const onHideStorageModal = (): void => {
136
- storageModalIsShow.value = false
137
- }
138
- const changeLocation = (event: UI_I_HTMLSelectElement): void => {
139
- const value = +event.target.value
140
- if (value === -1) {
141
- storageModalIsShow.value = true
142
- return
143
- }
144
-
145
- selectedLocation.value = event.target.value
146
- const storage = storages.value.find((item) => item.id === event.target.value)
147
- storage && emits('change', storage)
148
- }
149
-
150
- const typeError = computed<string>(
151
- () => `disk_devices[${props.index}].location`
152
- )
153
-
154
- const apiError = computed<string>(() => {
155
- return (
156
- props.errorValidationFields?.find(
157
- (message) => message.field === typeError.value
158
- )?.error_message || ''
159
- )
160
- })
161
-
162
- const onRemoveValidationError = (): void => {
163
- emits('remove-error-by-title', typeError.value)
164
- }
165
- </script>
166
-
167
- <style scoped lang="scss">
168
- .storage-modal {
169
- :deep(.modal-dialog) {
170
- width: 864px;
171
- }
172
- }
173
- </style>
1
+ <template>
2
+ <div class="">
3
+ <atoms-stack-block :has-children="false">
4
+ <template #stackBlockKey>
5
+ {{ localization.common.location }}
6
+ </template>
7
+ <template #stackBlockContent>
8
+ <atoms-tooltip-error
9
+ :has-error="!!apiError"
10
+ :selector="`.vm-wizard-disk-device-target-field-${props.index}`"
11
+ @remove="onRemoveValidationError"
12
+ >
13
+ <template #elem>
14
+ <div class="select">
15
+ <select
16
+ :id="`vm-wizard-disk-device-target-field-${props.index}`"
17
+ v-model="selectedLocation"
18
+ :data-id="`vm-wizard-disk-device-target-field-${props.index}`"
19
+ :class="`vm-wizard-disk-device-target-field-${props.index}`"
20
+ @change="changeLocation"
21
+ >
22
+ <option
23
+ v-for="(item, key) in locationOptions"
24
+ :key="key"
25
+ :value="item.value"
26
+ >
27
+ {{ item.text }}
28
+ </option>
29
+ </select>
30
+ </div>
31
+ </template>
32
+ <template #content>{{ apiError }}</template>
33
+ </atoms-tooltip-error>
34
+ </template>
35
+ </atoms-stack-block>
36
+
37
+ <Teleport to="body">
38
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-hard-disk-location-storage-modal-new
39
+ v-if="isNewView"
40
+ :storage-modal-is-show="storageModalIsShow"
41
+ :datastore="props.datastore"
42
+ @change-storage="onChangeStorage"
43
+ @hide="onHideStorageModal"
44
+ @submit="onSubmitStorageModal"
45
+ />
46
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-hard-disk-location-storage-modal-old
47
+ v-else
48
+ :storage-modal-is-show="storageModalIsShow"
49
+ :storage-submit="storageSubmit"
50
+ :datastore="props.datastore"
51
+ :get-datastore-table-func="props.getDatastoreTableFunc"
52
+ @change-storage="onChangeStorage"
53
+ @hide="onHideStorageModal"
54
+ @submit="onSubmitStorageModal"
55
+ />
56
+ </Teleport>
57
+ </div>
58
+ </template>
59
+
60
+ <script setup lang="ts">
61
+ import type {
62
+ UI_I_HTMLSelectElement,
63
+ UI_I_Localization,
64
+ } from '~/lib/models/interfaces'
65
+ import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
66
+ import type { UI_I_ErrorValidationField } from '~/lib/models/store/interfaces'
67
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
68
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
69
+
70
+ const localization = computed<UI_I_Localization>(() => useLocal())
71
+
72
+ const props = defineProps<{
73
+ location: UI_I_DatastoreTableItem | null
74
+ index: number
75
+ errorValidationFields: UI_I_ErrorValidationField<string>[]
76
+ datastore: UI_I_DatastoreTableItem[]
77
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
78
+ }>()
79
+ const emits = defineEmits<{
80
+ (event: 'change', value: UI_I_DatastoreTableItem): void
81
+ (event: 'remove-error-by-title', value: string): void
82
+ }>()
83
+
84
+ const { $store }: any = useNuxtApp()
85
+
86
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
87
+
88
+ const selectedLocation = ref<string>(props.location?.id || '')
89
+
90
+ const storages = ref<UI_I_DatastoreTableItem[]>([])
91
+ const addStorage = (storage: UI_I_DatastoreTableItem): void => {
92
+ const hasStorage = storages.value.some((item) => item.id === storage.id)
93
+ if (hasStorage) {
94
+ return
95
+ }
96
+
97
+ storages.value.push(storage)
98
+ }
99
+ const locationOptions = ref<UI_I_OptionItem[]>([])
100
+
101
+ watch(
102
+ () => props.location,
103
+ (newValue) => {
104
+ if (locationOptions.value.length || !newValue) {
105
+ return
106
+ }
107
+
108
+ locationOptions.value = [
109
+ {
110
+ text: localization.value.common.storeWithVirtualMachine,
111
+ value: newValue.id,
112
+ },
113
+ { text: `${localization.value.common.browse}...`, value: -1 },
114
+ ]
115
+ selectedLocation.value = newValue.id
116
+ storages.value.push(newValue)
117
+ addStorage(newValue)
118
+ },
119
+ { immediate: true }
120
+ )
121
+
122
+ const storageSubmit = ref<number>(0)
123
+ const onSubmitStorageModal = (): void => {
124
+ storageSubmit.value++
125
+ }
126
+ const storageModalIsShow = ref<boolean>(false)
127
+ const onHideStorageModal = (): void => {
128
+ storageModalIsShow.value = false
129
+ }
130
+ const onChangeStorage = (storage: UI_I_DatastoreTableItem): void => {
131
+ locationOptions.value = [
132
+ locationOptions.value[0],
133
+ { text: storage.name, value: storage.id },
134
+ // @ts-ignore
135
+ locationOptions.value.at(-1),
136
+ ]
137
+
138
+ selectedLocation.value = storage.id
139
+ emits('change', storage)
140
+ addStorage(storage)
141
+ onHideStorageModal()
142
+ }
143
+ const changeLocation = (event: UI_I_HTMLSelectElement): void => {
144
+ const value = +event.target.value
145
+ if (value === -1) {
146
+ storageModalIsShow.value = true
147
+ return
148
+ }
149
+
150
+ selectedLocation.value = event.target.value
151
+ const storage = storages.value.find((item) => item.id === event.target.value)
152
+ storage && emits('change', storage)
153
+ }
154
+
155
+ const typeError = computed<string>(
156
+ () => `disk_devices[${props.index}].location`
157
+ )
158
+
159
+ const apiError = computed<string>(() => {
160
+ return (
161
+ props.errorValidationFields?.find(
162
+ (message) => message.field === typeError.value
163
+ )?.error_message || ''
164
+ )
165
+ })
166
+
167
+ const onRemoveValidationError = (): void => {
168
+ emits('remove-error-by-title', typeError.value)
169
+ }
170
+ </script>
171
+
172
+ <style scoped lang="scss"></style>
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <atoms-modal
3
+ class="storage-modal-old"
4
+ :show="props.storageModalIsShow"
5
+ :title="localization.common.selectStorage"
6
+ @submit="emits('submit')"
7
+ @hide="emits('hide')"
8
+ >
9
+ <template #modalBody>
10
+ <span>{{
11
+ localization.common
12
+ .followingDatastoresAccessibleDestinationResourceThatSelected
13
+ }}</span>
14
+ <common-vm-actions-common-select-storage
15
+ :storage-submit="props.storageSubmit"
16
+ :datastore="props.datastore"
17
+ :get-datastore-table-func="props.getDatastoreTableFunc"
18
+ hide-compatibility
19
+ @submit="emits('change-storage', $event)"
20
+ />
21
+ </template>
22
+ </atoms-modal>
23
+ </template>
24
+
25
+ <script setup lang="ts">
26
+ import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
27
+ import type { UI_I_TablePayload } from '~/lib/models/table/interfaces'
28
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
29
+
30
+ const props = defineProps<{
31
+ storageModalIsShow: boolean
32
+ storageSubmit: number
33
+ datastore: UI_I_DatastoreTableItem[]
34
+ getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
35
+ }>()
36
+
37
+ const emits = defineEmits<{
38
+ (event: 'change-storage', value: UI_I_DatastoreTableItem): void
39
+ (event: 'submit'): void
40
+ (event: 'hide'): void
41
+ }>()
42
+
43
+ const localization = computed<UI_I_Localization>(() => useLocal())
44
+ </script>
45
+
46
+ <style scoped lang="scss">
47
+ .storage-modal-old {
48
+ :deep(.modal-dialog) {
49
+ width: 864px;
50
+ }
51
+ }
52
+ </style>
@@ -0,0 +1,175 @@
1
+ <template>
2
+ <ui-modal
3
+ v-if="props.storageModalIsShow"
4
+ show
5
+ :title="localization.common.selectStorage"
6
+ :texts="texts"
7
+ test-id="storage-modal-new"
8
+ size="md"
9
+ @hide="emits('hide')"
10
+ @submit="onSubmit"
11
+ >
12
+ <template #content>
13
+ <div class="select-storage-modal-container">
14
+ <span class="description-text">{{
15
+ localization.common
16
+ .followingDatastoresAccessibleDestinationResourceThatSelected
17
+ }}</span>
18
+ <ui-data-table
19
+ test-id="select-storage-data-table"
20
+ :data="data"
21
+ :options="tableOptions"
22
+ :loading="loading"
23
+ server-off
24
+ :default-layout="false"
25
+ @select-row="onSelectRow"
26
+ />
27
+ </div>
28
+ </template>
29
+ <template #footerLeftContent>
30
+ <span></span>
31
+ </template>
32
+ </ui-modal>
33
+ </template>
34
+
35
+ <script setup lang="ts">
36
+ import type { UI_I_ModalTexts } from '~/node_modules/bfg-uikit/components/ui/modal/models/interfaces'
37
+ import type { UI_I_DataTable } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
38
+ import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
39
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
40
+ import { datastoreLocalizationByState } from '~/components/common/lib/config/states'
41
+ import {
42
+ tableDataFunc,
43
+ tableOptions,
44
+ } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/newHardDisk/location/storageModalNew/lib/config/table'
45
+
46
+ const props = defineProps<{
47
+ storageModalIsShow: boolean
48
+ // storageSubmit: number
49
+ datastore: UI_I_DatastoreTableItem[]
50
+ // getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
51
+ }>()
52
+
53
+ const emits = defineEmits<{
54
+ (event: 'change-storage', value: UI_I_DatastoreTableItem): void
55
+ (event: 'submit'): void
56
+ (event: 'hide'): void
57
+ }>()
58
+
59
+ const localization = computed<UI_I_Localization>(() => useLocal())
60
+
61
+ const texts = ref<UI_I_ModalTexts>({
62
+ button2: localization.value.common.select,
63
+ })
64
+
65
+ const loading = ref<boolean>(true)
66
+
67
+ const data = ref<UI_I_DataTable>(tableDataFunc(localization.value))
68
+
69
+ watch(
70
+ () => props.datastore,
71
+ (newValue) => {
72
+ if (!newValue.length || data.value.body.length) return
73
+
74
+ const { $binary } = useNuxtApp()
75
+
76
+ newValue.forEach((item, key) => {
77
+ const state =
78
+ localization.value.inventorySummary[
79
+ datastoreLocalizationByState[item.state]
80
+ ]
81
+ data.value.body.push({
82
+ row: key,
83
+ collapse: false,
84
+ isHiddenCollapse: false,
85
+ collapseToggle: false,
86
+ data: [
87
+ {
88
+ key: item.id,
89
+ col: 0,
90
+ text: item.name,
91
+ },
92
+ {
93
+ col: 1,
94
+ text: state,
95
+ },
96
+ { col: 2, text: $binary.round(item.capacity.capacity_mb) },
97
+ {
98
+ col: 3,
99
+ text: $binary.round(item.capacity.provisioned_mb.toString()),
100
+ },
101
+ {
102
+ col: 4,
103
+ text: $binary.round(item.capacity.free_mb.toString()),
104
+ },
105
+ {
106
+ col: 5,
107
+ text: $binary.round(item.capacity.used_mb.toString()),
108
+ },
109
+ {
110
+ col: 6,
111
+ text: item.type_text,
112
+ },
113
+ {
114
+ col: 7,
115
+ text: item.thin_provisioning
116
+ ? localization.value.common.yes
117
+ : localization.value.common.no,
118
+ },
119
+ {
120
+ col: 8,
121
+ text: item.access_mode,
122
+ },
123
+ {
124
+ col: 9,
125
+ text: item.hardware_acceleration,
126
+ },
127
+ {
128
+ col: 10,
129
+ text: item.drive_type,
130
+ },
131
+ {
132
+ col: 11,
133
+ text: item.device,
134
+ },
135
+ {
136
+ col: 12,
137
+ text: item.storage_io_control,
138
+ },
139
+ ],
140
+ })
141
+ })
142
+ loading.value = false
143
+ },
144
+ { immediate: true, deep: true }
145
+ )
146
+
147
+ const onSelectRow = (selectedData: UI_I_DataTable): void => {
148
+ const selectedId = selectedData[0]?.data[0]?.key
149
+ const selectedItem = props.datastore.find((item) => (item.id = selectedId))
150
+
151
+ selectedItem && emits('change-storage', selectedItem)
152
+ }
153
+
154
+ const onSubmit = (): void => {
155
+ emits('submit')
156
+ emits('hide')
157
+ }
158
+ </script>
159
+
160
+ <style scoped lang="scss">
161
+ .select-storage-modal-container {
162
+ display: flex;
163
+ flex-direction: column;
164
+ grid-gap: 12px;
165
+ padding-left: 32px;
166
+ padding-bottom: 5px;
167
+
168
+ .description-text {
169
+ font-size: 12px;
170
+ font-weight: 400;
171
+ line-height: 14.52px;
172
+ color: #9da6ad;
173
+ }
174
+ }
175
+ </style>