bfg-common 1.4.105 → 1.4.106

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.
@@ -123,7 +123,7 @@ const alertMessages = computed<string[][]>(() => wizard.alertMessages.value)
123
123
  const form = ref<UI_I_MigrateFormLocal>({
124
124
  migrate_type: props.project === 'procurator' ? 'storage' : 'resource',
125
125
  disk_format: 0,
126
- storage: '',
126
+ storage: null,
127
127
  })
128
128
 
129
129
  const validationFunc = async (
@@ -8,7 +8,7 @@ import type { UI_T_VmMigrateType } from '~/components/common/wizards/vmNew/migra
8
8
  export interface UI_I_MigrateFormLocal {
9
9
  migrate_type: UI_T_VmMigrateType
10
10
  disk_format: number
11
- storage: string
11
+ storage: any
12
12
  }
13
13
 
14
14
  export interface UI_I_ChangeStepsSchemes {
@@ -33,7 +33,6 @@
33
33
  :datastore="props.datastore"
34
34
  :connected-storage-id="connectedStorageId"
35
35
  :is-hide-select-disk-format="isHideSelectDiskFormat"
36
- @update-selected-datastore="selectStorageDataLocal.storage = $event"
37
36
  >
38
37
  <template v-if="isShowSelectedPerDisks" #buttonConfirm>
39
38
  <button
@@ -56,7 +55,7 @@
56
55
  />
57
56
 
58
57
  <common-wizards-vm-common-validation-compatibility
59
- :loading="!selectStorageDataLocal.storage"
58
+ :loading="!model.storage"
60
59
  :status="'Success'"
61
60
  text="compatibilityChecksSucceeded"
62
61
  />
@@ -70,10 +69,7 @@ import type { UI_I_CollapseNavItem } from '~/components/atoms/collapse/lib/model
70
69
  import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
71
70
  import type { UI_T_VmMigrateSelectStorageTab } from '~/components/common/wizards/vm/migrate/select/storage/lib/models/types'
72
71
  import type { UI_I_StorageConfigurePerDiskItem } from '~/components/common/wizards/vm/migrate/select/storage/table/disk/lib/models/interfaces'
73
- import type {
74
- UI_I_SelectStorageDataLocal,
75
- UI_I_SelectStorageReadyData,
76
- } from '~/components/common/wizards/vm/migrate/select/storage/lib/models/interfaces'
72
+ import type { UI_I_SelectStorageReadyData } from '~/components/common/wizards/vm/migrate/select/storage/lib/models/interfaces'
77
73
  import type { UI_I_MigrateFormLocal } from '~/components/common/wizards/vmNew/migrate/lib/models/interfaces'
78
74
  import { vmMigrateSelectStorageTabsFunc } from '~/components/common/wizards/vm/migrate/select/storage/lib/config/tabsPannel'
79
75
 
@@ -98,10 +94,6 @@ const selectStorageTabs = computed<UI_I_CollapseNavItem[]>(() =>
98
94
  vmMigrateSelectStorageTabsFunc(localization.value)
99
95
  )
100
96
 
101
- const selectStorageDataLocal = ref<UI_I_SelectStorageDataLocal>({
102
- vmDiskFormat: 0,
103
- storage: null,
104
- })
105
97
  const isShowSelectedPerDisks = ref<boolean>(false)
106
98
 
107
99
  const selectedPerDiskKeys = ref<number[]>([])
@@ -141,12 +133,12 @@ const onApplyChanges = (): void => {
141
133
  )!
142
134
 
143
135
  if (selectedDisk) {
144
- const { storage } = selectStorageDataLocal.value
136
+ const { storage, disk_format } = model.value
145
137
 
146
138
  // ;({ name: disk.storage, id: disk.extra.datastore_id } = storage)
147
139
  disk.storage = storage.name
148
140
  disk.extra.datastore_id = storage.id
149
- disk.disk_format = model.value.disk_format
141
+ disk.disk_format = disk_format
150
142
  }
151
143
  })
152
144
 
@@ -165,13 +157,13 @@ const isHideSelectDiskFormat = computed<boolean>(() => {
165
157
  })
166
158
 
167
159
  const checkValidityBlock = (): boolean => {
168
- if (!selectStorageDataLocal.value.storage) {
160
+ if (!model.value.storage) {
169
161
  return false
170
162
  }
171
163
 
172
164
  const isActivePerDiskTab = activeTab.value === 'configure-disk'
173
165
  emits('next-step', {
174
- ...selectStorageDataLocal.value,
166
+ ...model.value,
175
167
  tab: activeTab.value,
176
168
  // ...(isActivePerDiskTab && { configureDisks: props.configurePerDisks }),
177
169
  configureDisks: isActivePerDiskTab
@@ -1,7 +1,5 @@
1
1
  <template>
2
2
  <div class="configure-batch-mode">
3
- {{ model.disk_format }}
4
-
5
3
  <common-select-input
6
4
  v-if="!isHideSelectDiskFormat"
7
5
  v-model="model.disk_format"
@@ -11,10 +9,10 @@
11
9
  />
12
10
 
13
11
  <common-wizards-vm-new-migrate-select-storage-configure-batch-table
12
+ v-model="model.storage"
14
13
  :get-datastore-table-func="props.getDatastoreTableFunc"
15
14
  :datastore="props.datastore"
16
15
  :connected-storage-id="props.connectedStorageId"
17
- @update-selected-datastore="emits('update-selected-datastore', $event)"
18
16
  />
19
17
 
20
18
  <div
@@ -47,10 +45,6 @@ const localization = computed<UI_I_Localization>(() => useLocal())
47
45
  const virtualDiskFormatOptions = computed<UI_I_OptionItem[]>(() =>
48
46
  virtualDiskFormatOptionsFunc()
49
47
  )
50
-
51
- const emits = defineEmits<{
52
- (event: 'update-selected-datastore', value: UI_I_TablePayload): void
53
- }>()
54
48
  </script>
55
49
 
56
50
  <style lang="scss" scoped>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="table-wrap">
3
3
  <atoms-table-data-grid
4
- v-model:selected-row="selectedStorageKey"
4
+ v-model:selected-row="selectedStorageKeyLocal"
5
5
  v-model:column-keys="columnKeys"
6
6
  v-model:page-size="pagination.pageSize"
7
7
  v-model:page="pagination.page"
@@ -14,7 +14,7 @@
14
14
  server-off
15
15
  hide-page-size
16
16
  @sorting="sorting"
17
- @change="changeStorage"
17
+ @change="selectStorageFromTable"
18
18
  >
19
19
  <template #icon="{ item }">
20
20
  <span :class="['datagrid-cell-icon', item.data]" />
@@ -45,13 +45,19 @@ const props = defineProps<{
45
45
  datastore: UI_I_DatastoreTableItem[]
46
46
  connectedStorageId: string | null
47
47
  }>()
48
-
49
- const emits = defineEmits<{
50
- (event: 'update-selected-datastore', value: UI_I_TablePayload): void
51
- }>()
48
+ const modelStorageLocal = defineModel<UI_I_DatastoreTableItem>({
49
+ required: true,
50
+ })
52
51
 
53
52
  const localization = computed<UI_I_Localization>(() => useLocal())
54
53
 
54
+ const selectedStorageKeyLocal = ref<number | null>(null)
55
+ const sort = ref<string | null>(null)
56
+ const pagination = ref<UI_I_Pagination>({
57
+ page: 1,
58
+ pageSize: 100,
59
+ })
60
+
55
61
  const headItems = ref<UI_I_HeadItem[]>(table.headItems(localization.value))
56
62
  const columnKeys = ref<UI_I_ColumnKey[]>(table.columnKeys(localization.value))
57
63
  watch(localization, () => {
@@ -61,22 +67,15 @@ watch(localization, () => {
61
67
  const bodyItems = computed<UI_I_BodyItem[][]>(() => {
62
68
  return table.bodyItems(props.datastore || [], localization.value)
63
69
  })
64
-
65
- const sort = ref<string | null>(null)
66
- const pagination = ref<UI_I_Pagination>({
67
- page: 1,
68
- pageSize: 100,
69
- })
70
-
71
70
  const sorting = (data: [string, boolean]): void => {
72
71
  const [column, status] = data
73
72
  const direction = status ? 'asc' : 'desc'
74
73
  sort.value = `${column}.${direction}`
75
74
 
76
- getStorage()
75
+ InitStorageData()
77
76
  }
78
77
 
79
- const getStorage = async (): Promise<void> => {
78
+ const InitStorageData = async (): Promise<void> => {
80
79
  const payload: UI_I_TablePayload = {
81
80
  pagination: pagination.value,
82
81
  sortBy: sort.value,
@@ -85,31 +84,33 @@ const getStorage = async (): Promise<void> => {
85
84
  }
86
85
 
87
86
  props.getDatastoreTableFunc(payload).then(() => {
88
- // selectedStorageKey.value = null
89
- // setStorageFromProps()
87
+ // selectedStorageKeyLocal.value = null
88
+ // defineDefaultSelectedStorage()
90
89
  })
91
90
  }
92
- getStorage()
91
+ InitStorageData()
93
92
 
94
- const selectedStorageKey = ref<number | null>(null)
95
- const changeStorage = (index: number): void => {
93
+ const selectStorageFromTable = (index: number): void => {
96
94
  if (!props.datastore) return
97
- emits('update-selected-datastore', props.datastore[index])
98
- selectedStorageKey.value = index
95
+
96
+ modelStorageLocal.value = props.datastore[index]
97
+ selectedStorageKeyLocal.value = index
99
98
  }
100
99
 
101
- const setStorageFromProps = (): void => {
102
- if (!props.connectedStorageId) return
103
- props.datastore.forEach((item, index) => {
104
- if (item.id === props.connectedStorageId) changeStorage(index)
105
- })
100
+ const defineDefaultSelectedStorage = (): void => {
101
+ props.datastore.forEach(
102
+ (datastore: UI_I_DatastoreTableItem, index: number) => {
103
+ if (datastore.id === props.connectedStorageId)
104
+ selectStorageFromTable(index)
105
+ }
106
+ )
106
107
  }
107
108
 
108
109
  watch(
109
110
  () => props.connectedStorageId,
110
- (newValue) => {
111
+ (newValue: string) => {
111
112
  if (!props.datastore.length || !newValue) return
112
- setStorageFromProps()
113
+ defineDefaultSelectedStorage()
113
114
  }
114
115
  )
115
116
  </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.105",
4
+ "version": "1.4.106",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -1,179 +0,0 @@
1
- import type { UI_I_DatastoreTableItem } from '~/lib/models/store/storage/interfaces'
2
- import type {
3
- UI_I_ColumnKey,
4
- UI_I_HeadItem,
5
- UI_I_BodyItem,
6
- } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
7
- import type { UI_I_Localization } from '~/lib/models/interfaces'
8
- import type { UI_T_StorageColumnKeys } from '~/components/common/vm/actions/common/select/storage/lib/models/types'
9
- import {
10
- constructColumnKey,
11
- constructHeadItem,
12
- } from '~/components/atoms/table/dataGrid/lib/utils/constructDataTable'
13
- import {
14
- datastoreIconByState,
15
- datastoreLocalizationByState,
16
- } from '~/components/common/lib/config/states'
17
-
18
- export const storageTableKeys: UI_T_StorageColumnKeys = [
19
- 'name',
20
- 'state',
21
- 'capacity_mb',
22
- 'provisioned_mb',
23
- 'free_mb',
24
- 'used_mb',
25
- 'type_text',
26
- 'thin_provisioning',
27
- 'access_mode',
28
- 'hardware_acceleration',
29
- 'drive_type',
30
- 'device',
31
- 'storage_io_control',
32
- ]
33
-
34
- const getItems = (
35
- localization: UI_I_Localization
36
- ): [string, boolean, string, string][] => {
37
- return [
38
- [localization.common.name, true, '96px', storageTableKeys[0]],
39
- [localization.inventorySummary.state, true, '138px', storageTableKeys[1]],
40
- [localization.common.capacity, true, '110px', storageTableKeys[2]],
41
- [localization.common.provisioned, true, '128px', storageTableKeys[3]],
42
- [localization.common.free, true, '110px', storageTableKeys[4]],
43
- [localization.common.used, true, '110px', storageTableKeys[5]],
44
- [localization.common.type, true, '110px', storageTableKeys[6]],
45
- [localization.common.thinProvisioning, true, '132px', storageTableKeys[7]],
46
- [localization.common.access, true, '110px', storageTableKeys[8]],
47
- [localization.common.hardwareAcceleration, true, '134px', storageTableKeys[9]],
48
- [localization.common.driverType, true, '110px', storageTableKeys[10]],
49
- [localization.common.device, true, '110px', storageTableKeys[11]],
50
- [localization.common.storageIoControl, true, '110px', storageTableKeys[12]],
51
- ]
52
- }
53
-
54
- export const columnKeys = (
55
- localization: UI_I_Localization
56
- ): UI_I_ColumnKey[] => {
57
- const result: UI_I_ColumnKey[] = []
58
- getItems(localization).forEach((item, i) => {
59
- const col = i === 0 ? 'icon' : `col${i}`
60
- result.push(
61
- constructColumnKey(col, item[0], item[1], `show-column-${item[3]}`)
62
- )
63
- })
64
- return result
65
- }
66
-
67
- export const headItems = (localization: UI_I_Localization): UI_I_HeadItem[] => {
68
- const result: UI_I_HeadItem[] = []
69
- getItems(localization).forEach((item, i) => {
70
- const col = i === 0 ? 'icon' : `col${i}`
71
- result.push(
72
- constructHeadItem(
73
- col,
74
- item[0],
75
- item[3],
76
- true,
77
- item[2],
78
- undefined,
79
- item[3]
80
- )
81
- )
82
- })
83
- return result
84
- }
85
-
86
- export const bodyItems = (
87
- data: UI_I_DatastoreTableItem[],
88
- localization: UI_I_Localization
89
- ): UI_I_BodyItem[][] => {
90
- const bodyItems: UI_I_BodyItem[][] = []
91
- const { $binary } = useNuxtApp()
92
-
93
- data.forEach((storage: UI_I_DatastoreTableItem, key: number) => {
94
- const state =
95
- localization.common[datastoreLocalizationByState[storage[storageTableKeys[1]]]]
96
- bodyItems.push([
97
- {
98
- key: 'icon',
99
- text: storage[storageTableKeys[0]].toString(),
100
- data: `vsphere-icon-${datastoreIconByState[storage.state]}`,
101
- id: key,
102
- testId: storage[storageTableKeys[0]].toString()
103
- },
104
- {
105
- key: 'col1',
106
- text: state,
107
- id: key,
108
- testId: storage[storageTableKeys[0]].toString()
109
- },
110
- {
111
- key: 'col2',
112
- text: $binary.round(storage.capacity[storageTableKeys[2]]),
113
- id: key,
114
- testId: storage[storageTableKeys[0]].toString()
115
- },
116
- {
117
- key: 'col3',
118
- text: $binary.round(storage.capacity[storageTableKeys[3]].toString()),
119
- id: key,
120
- testId: storage[storageTableKeys[0]].toString()
121
- },
122
- {
123
- key: 'col4',
124
- text: $binary.round(storage.capacity[storageTableKeys[4]].toString()),
125
- id: key,
126
- testId: storage[storageTableKeys[0]].toString()
127
- },
128
- {
129
- key: 'col5',
130
- text: $binary.round(storage.capacity[storageTableKeys[5]].toString()),
131
- id: key,
132
- testId: storage[storageTableKeys[0]].toString()
133
- },
134
- {
135
- key: 'col6',
136
- text: storage[storageTableKeys[6]].toString(),
137
- id: key,
138
- testId: storage[storageTableKeys[0]].toString()
139
- },
140
- {
141
- key: 'col7',
142
- text: storage[storageTableKeys[7]] ? localization.common.yes : localization.common.no,
143
- id: key,
144
- testId: storage[storageTableKeys[0]].toString()
145
- },
146
- {
147
- key: 'col8',
148
- text: storage[storageTableKeys[8]].toString(),
149
- id: key,
150
- testId: storage[storageTableKeys[0]].toString()
151
- },
152
- {
153
- key: 'col9',
154
- text: storage[storageTableKeys[9]].toString(),
155
- id: key,
156
- testId: storage[storageTableKeys[0]].toString()
157
- },
158
- {
159
- key: 'col10',
160
- text: storage[storageTableKeys[10]].toString(),
161
- id: key,
162
- testId: storage[storageTableKeys[0]].toString()
163
- },
164
- {
165
- key: 'col11',
166
- text: storage[storageTableKeys[11]].toString(),
167
- id: key,
168
- testId: storage[storageTableKeys[0]].toString()
169
- },
170
- {
171
- key: 'col12',
172
- text: storage[storageTableKeys[12]].toString(),
173
- id: key,
174
- testId: storage[storageTableKeys[0]].toString()
175
- },
176
- ])
177
- })
178
- return bodyItems
179
- }
@@ -1,15 +0,0 @@
1
- export type UI_T_StorageColumnKeys = [
2
- 'name',
3
- 'state',
4
- 'capacity_mb',
5
- 'provisioned_mb',
6
- 'free_mb',
7
- 'used_mb',
8
- 'type_text',
9
- 'thin_provisioning',
10
- 'access_mode',
11
- 'hardware_acceleration',
12
- 'drive_type',
13
- 'device',
14
- 'storage_io_control',
15
- ]