bfg-common 1.2.136 → 1.2.138

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.
@@ -82,7 +82,7 @@
82
82
  ]"
83
83
  @click="sortTable(item.sortColumn)"
84
84
  >
85
- <slot name="th" :key="key" :item="item">
85
+ <slot :key="key" name="th" :item="item">
86
86
  <span
87
87
  :title="item.text"
88
88
  :style="{
@@ -204,7 +204,7 @@
204
204
  },
205
205
  ]"
206
206
  >
207
- <slot name="type" :key="key" :item="item">
207
+ <slot :key="key" name="type" :item="item">
208
208
  <div
209
209
  :class="`clr-${props.type}-wrapper flex-justify-center flex-align-center`"
210
210
  >
@@ -479,7 +479,7 @@ const emits = defineEmits<{
479
479
  (event: 'update:selected-row', value: UI_T_SelectedRow): void
480
480
  (event: 'update:page-size', value: number): void
481
481
  (event: 'update:page', value: number): void
482
- (event: 'filtering', value: any): void
482
+ (event: 'filtering', value: string[][]): void
483
483
  (event: 'sorting', value: [string, boolean]): void
484
484
  (event: 'change', value: any): void
485
485
  (event: 'row-detail', value: number): void
@@ -660,11 +660,10 @@ const sortTable = (sortName: string): void => {
660
660
  const filterShow = ref<boolean[]>([])
661
661
  const filterTerm = ref<string[]>([])
662
662
  const filtering = (): void => {
663
- const filter = headItemsPresent.value
664
- .filter((_, key) => filterTerm.value[key])
665
- .map((item, key) => {
666
- return [item.key, filterTerm.value[key]]
667
- })
663
+ const filter: string[][] = []
664
+ headItemsPresent.value.forEach((item, key) => {
665
+ if (filterTerm.value[key]) filter.push([item.key, filterTerm.value[key]])
666
+ })
668
667
 
669
668
  emits('filtering', filter)
670
669
  }
@@ -0,0 +1,9 @@
1
+ export interface UI_I_VmPowerActions {
2
+ hard_stop: boolean
3
+ power_off: boolean
4
+ power_on: boolean
5
+ reset: boolean
6
+ restart_guest: boolean
7
+ shutdown_guest: boolean
8
+ suspend: boolean
9
+ }
@@ -0,0 +1,55 @@
1
+ import type { API_UI_T_VmState } from '~/models/store/types'
2
+ import type { UI_I_VmPowerActions } from '~/components/common/vm/models/interfaces'
3
+
4
+ export const getPowerActionsByState = (
5
+ state: API_UI_T_VmState
6
+ ): UI_I_VmPowerActions => {
7
+ const powerActions = {
8
+ hard_stop: false,
9
+ power_off: false,
10
+ power_on: false,
11
+ reset: false,
12
+ restart_guest: false,
13
+ shutdown_guest: false,
14
+ suspend: false,
15
+ }
16
+ switch (state) {
17
+ case 0: // Unknown
18
+ powerActions.power_on = true
19
+ powerActions.hard_stop = true
20
+ break
21
+ case 1: // Powered off
22
+ powerActions.power_on = true
23
+ break
24
+ case 2: // Powered on
25
+ powerActions.power_off = true
26
+ powerActions.suspend = true
27
+ powerActions.reset = true
28
+ powerActions.hard_stop = true
29
+ powerActions.shutdown_guest = true
30
+ powerActions.restart_guest = true
31
+ break
32
+ case 3: // Suspended
33
+ case 4: // Error
34
+ case 5: // Warning
35
+ powerActions.power_on = true
36
+ powerActions.hard_stop = true
37
+ break
38
+ case 6: // Pending
39
+ powerActions.hard_stop = true
40
+ break
41
+ case 7: // Paused
42
+ powerActions.power_on = true
43
+ powerActions.hard_stop = true
44
+ break
45
+ case 8: // Blocked
46
+ case 9: // Shutting down
47
+ case 10: // Shut off
48
+ powerActions.hard_stop = true
49
+ break
50
+ default:
51
+ powerActions.hard_stop = true
52
+ }
53
+
54
+ return powerActions
55
+ }
@@ -0,0 +1,61 @@
1
+ <template>
2
+ <div class="tree-view">
3
+ <atoms-loader-pre-loader
4
+ v-show="loading"
5
+ id="loader"
6
+ class="absolute-center tree-view__loading"
7
+ :show="true"
8
+ />
9
+ <common-recursion-tree
10
+ :nodes="props.computeResourceTree"
11
+ class="recursion-tree"
12
+ @get-nodes="onShowNodes"
13
+ @select-node="onSelectNode"
14
+ @contextmenu.prevent
15
+ />
16
+ </div>
17
+ </template>
18
+
19
+ <script setup lang="ts">
20
+ import type { UI_I_TreeNode } from '~/node_modules/bfg-common/components/common/recursionTree/models/interfaces'
21
+
22
+ const props = defineProps<{
23
+ modelValue: UI_I_TreeNode | null
24
+ computeResourceTree: UI_I_TreeNode[]
25
+ }>()
26
+
27
+ const emits = defineEmits<{
28
+ (event: 'update:modelValue', value: UI_I_TreeNode): void
29
+ (
30
+ event: 'get-compute-resource-tree',
31
+ value: { id: string | number; cb: () => void }
32
+ ): void
33
+ (event: 'show-compute-resource-tree', value: UI_I_TreeNode): void
34
+ (event: 'select-compute-resource-tree', value: UI_I_TreeNode): void
35
+ (event: 'clear-compute-resource-tree'): void
36
+ }>()
37
+
38
+ const loading = ref<boolean>(false)
39
+ const onShowNodes = (event: any): void => {
40
+ emits('show-compute-resource-tree', event)
41
+ }
42
+ const onSelectNode = (node: UI_I_TreeNode): void => {
43
+ emits('select-compute-resource-tree', node)
44
+
45
+ emits('update:modelValue', node)
46
+ }
47
+ </script>
48
+
49
+ <style scoped lang="scss">
50
+ .tree-view {
51
+ &__loading {
52
+ :deep(.spinner.spinner-inverse) {
53
+ position: static;
54
+ width: 45px;
55
+ height: 45px;
56
+ min-width: 45px;
57
+ min-height: 45px;
58
+ }
59
+ }
60
+ }
61
+ </style>
@@ -4,8 +4,8 @@
4
4
  <div class="flex-align-center compatibility__content">
5
5
  <template v-if="!props.loading">
6
6
  <div class="compatibility__message">
7
- <div class="icon icon-status-ok" />
8
- <span>{{ localization.compatibilityChecksSucceeded }}</span>
7
+ <div :class="['icon', iconStatus]" />
8
+ <span>{{ validationText }}</span>
9
9
  </div>
10
10
  </template>
11
11
  </div>
@@ -14,10 +14,13 @@
14
14
 
15
15
  <script lang="ts" setup>
16
16
  import type { UI_I_Localization } from '~/models/interfaces'
17
+ import { UI_E_ValidationCompatibilityStatusIcon } from '~/components/common/wizards/vm/common/validation/models/enums'
17
18
 
18
19
  const props = withDefaults(
19
20
  defineProps<{
20
21
  loading?: boolean
22
+ text: string
23
+ status: 'Error' | 'Success' | 'Warning'
21
24
  }>(),
22
25
  {
23
26
  loading: true,
@@ -25,6 +28,12 @@ const props = withDefaults(
25
28
  )
26
29
 
27
30
  const localization = computed<UI_I_Localization>(() => useLocal())
31
+
32
+ const iconStatus = computed<string>(
33
+ () => UI_E_ValidationCompatibilityStatusIcon[props.status]
34
+ )
35
+
36
+ const validationText = computed<string>(() => localization.value[props.text])
28
37
  </script>
29
38
 
30
39
  <style lang="scss" scoped>
@@ -0,0 +1,5 @@
1
+ export enum UI_E_ValidationCompatibilityStatusIcon {
2
+ Success = 'icon-status-ok',
3
+ Error = 'vsphere-icon-status-error',
4
+ Warning = 'vsphere-icon-status-warning',
5
+ }
@@ -34,6 +34,8 @@
34
34
 
35
35
  <common-wizards-vm-migrate-select-compute-resource
36
36
  v-show="currentBlockId === 'select-compute-resource'"
37
+ :migrate-type="vmMigrateType"
38
+ :compute-resource-tree="props.computeResourceTree"
37
39
  />
38
40
 
39
41
  <common-wizards-vm-migrate-select-storage
@@ -71,6 +73,7 @@ import type { UI_I_TablePayload } from '~/models/store/interfaces'
71
73
  import type { UI_I_DatastoreTableItem } from '~/models/store/storage/interfaces'
72
74
  import type { UI_I_VmSettings } from '~/models/store/vm/interfaces'
73
75
  import type { UI_T_VmMigrateType } from '~/components/common/wizards/vm/migrate/models/types'
76
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/models/interfaces'
74
77
  import type { UI_I_StorageConfigurePerDiskItem } from '~/components/common/wizards/vm/migrate/select/storage/table/disk/models/interfaces'
75
78
  import type { UI_I_TableInfoItem } from '~/components/atoms/table/info/models/interfaces'
76
79
  import type { UI_I_SelectStorageReadyData } from '~/components/common/wizards/vm/migrate/select/storage/models/interfaces'
@@ -86,6 +89,7 @@ const props = defineProps<{
86
89
  getDatastoreTableFunc: (payload: UI_I_TablePayload) => Promise<void>
87
90
  datastore: UI_I_DatastoreTableItem[]
88
91
  configurePerDisks: UI_I_StorageConfigurePerDiskItem[]
92
+ computeResourceTree?: UI_I_TreeNode
89
93
  readyCompleteTableInfo?: any // пока так потом если будет нужен изменит или удалить
90
94
  finishFunc: any
91
95
  }>()
@@ -1,33 +1,141 @@
1
1
  <template>
2
2
  <div class="compute-resource">
3
- <atoms-tabs
4
- v-model="activeTab"
5
- test-id="migrate-select-storage-tabs"
6
- :items="selectStorageTabs"
7
- size="small"
8
- class="compute-resource__tabs"
9
- />
3
+ <div
4
+ v-if="props.migrateType === 'resource-storage'"
5
+ class="tree-view-wrap mt-1"
6
+ >
7
+ <common-wizards-vm-common-compute-resource-tree-view
8
+ v-model="computeResourceDataLocal.selectedNode"
9
+ :compute-resource-tree="nodes"
10
+ @show-compute-resource-tree="onShowComputeResourceTree"
11
+ @select-compute-resource-tree="onSelectComputeResourceTree"
12
+ />
13
+ </div>
14
+
15
+ <template v-else>
16
+ <atoms-tabs
17
+ v-model="activeTab"
18
+ test-id="migrate-select-storage-tabs"
19
+ :items="selectStorageTabs"
20
+ size="small"
21
+ class="compute-resource__tabs"
22
+ />
10
23
 
11
- <common-wizards-vm-common-validation-compatibility />
24
+ <common-wizards-vm-migrate-select-compute-resource-table-view
25
+ v-model:selected-data="selectedData"
26
+ :data-table="[]"
27
+ :type="activeTab"
28
+ />
29
+ </template>
30
+
31
+ <common-wizards-vm-common-validation-compatibility
32
+ :loading="!computeResourceDataLocal.selectedNode"
33
+ :status="compatibilityText[0]"
34
+ :text="compatibilityText[1]"
35
+ />
12
36
  </div>
13
37
  </template>
14
38
 
15
39
  <script lang="ts" setup>
16
40
  import type { UI_I_Localization } from '~/models/interfaces'
17
41
  import type { UI_I_CollapseNavItem } from '~/components/atoms/collapse/models/interfaces'
42
+ import type { UI_I_TreeNode } from '~/components/common/recursionTree/models/interfaces'
18
43
  import type { UI_T_SelectComputeResourceTabType } from '~/components/common/wizards/vm/migrate/select/storage/models/types'
44
+ import type { UI_T_VmMigrateType } from '~/components/common/wizards/vm/migrate/models/types'
19
45
  import { vmMigrateComputeResourceTabsFunc } from '~/components/common/wizards/vm/migrate/select/computeResource/config/tabsPannel'
20
46
 
47
+ const props = defineProps<{
48
+ migrateType: UI_T_VmMigrateType
49
+ computeResourceTree: UI_I_TreeNode
50
+ }>()
51
+
21
52
  const localization = computed<UI_I_Localization>(() => useLocal())
53
+ const { $recursion } = useNuxtApp()
22
54
 
23
55
  const activeTab = ref<UI_T_SelectComputeResourceTabType>('host')
24
56
  const selectStorageTabs = computed<UI_I_CollapseNavItem[]>(() =>
25
57
  vmMigrateComputeResourceTabsFunc(localization.value)
26
58
  )
59
+
60
+ const computeResourceDataLocal = ref<any>({
61
+ selectedNode: null,
62
+ })
63
+
64
+ const nodes = ref<UI_I_TreeNode[]>([])
65
+
66
+ watch(
67
+ props.computeResourceTree,
68
+ (newValue) => {
69
+ if (nodes.value.length) return
70
+
71
+ nodes.value = useDeepCopy([newValue])
72
+ },
73
+ { immediate: true, deep: true }
74
+ )
75
+
76
+ const onShowComputeResourceTree = ({
77
+ node,
78
+ cb,
79
+ }: {
80
+ node: UI_I_TreeNode
81
+ cb: () => void
82
+ }): void => {
83
+ $recursion.findAndShow(
84
+ nodes.value,
85
+ [node.id, node.type],
86
+ ['id', 'type'],
87
+ 'nodes'
88
+ )
89
+ cb()
90
+ }
91
+ const onSelectComputeResourceTree = (node: UI_I_TreeNode): void => {
92
+ $recursion.findAndActivate(
93
+ nodes.value,
94
+ [node.type, node.id],
95
+ ['type', 'id'],
96
+ 'nodes'
97
+ )
98
+ }
99
+ const compatibilityText = computed<[string, string]>(() => {
100
+ const { selectedNode } = computeResourceDataLocal.value
101
+
102
+ if (!selectedNode) return ['Success', '']
103
+
104
+ let res: [string, string] = ['Success', 'compatibilityChecksSucceeded']
105
+
106
+ if (selectedNode.type === 'datacenter' || selectedNode.type === 'folder') {
107
+ res = ['Error', 'selectValidClusterOrHostDestination']
108
+ }
109
+ if (selectedNode.type === 'cluster') {
110
+ const hasHost = !!selectedNode.nodes.length
111
+ if (!hasHost) {
112
+ res = ['Error', 'clusterNotContainAnyHosts']
113
+ }
114
+ }
115
+
116
+ if (selectedNode.type === 'host') {
117
+ if (selectedNode.state === 'Error') {
118
+ // TODO check Maintenance Mode
119
+ res = ['Error', 'selectedHostDisconnectedMaintenanceMode']
120
+ }
121
+ }
122
+
123
+ return res
124
+ })
125
+
126
+ const selectedData = ref([])
27
127
  </script>
28
128
 
29
129
  <style lang="scss" scoped>
30
130
  .compute-resource {
131
+ .tree-view-wrap {
132
+ max-height: 250px;
133
+ min-height: 200px;
134
+ position: relative;
135
+ border: 1px solid #000;
136
+ padding: 5px 0 0 5px;
137
+ overflow: auto;
138
+ }
31
139
  &__tabs {
32
140
  width: 100%;
33
141
  :deep(.nav) {
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <div class="table-wrap">
3
+ <atoms-table-data-grid
4
+ v-model:selected-row="selectedRow"
5
+ v-model:column-keys="columnKeys"
6
+ v-model:page-size="pagination.pageSize"
7
+ v-model:page="pagination.page"
8
+ type="checkbox"
9
+ :head-items="headItems"
10
+ :body-items="bodyItems"
11
+ :total-items="bodyItems.length"
12
+ :total-pages="1"
13
+ server-off
14
+ hide-footer
15
+ hide-page-size
16
+ @sorting="sorting"
17
+ >
18
+ </atoms-table-data-grid>
19
+ </div>
20
+ </template>
21
+
22
+ <script lang="ts" setup>
23
+ import type { UI_I_Pagination, UI_I_Localization } from '~/models/interfaces'
24
+ import type {
25
+ UI_I_ColumnKey,
26
+ UI_I_HeadItem,
27
+ UI_I_BodyItem,
28
+ } from '~/components/atoms/table/dataGrid/models/interfaces'
29
+ import type { UI_I_StorageConfigurePerDiskItem } from '~/components/common/wizards/vm/migrate/select/storage/table/disk/models/interfaces'
30
+ import type { UI_T_SelectComputeResourceTabType } from '~/components/common/wizards/vm/migrate/select/storage/models/types'
31
+ import * as hostTable from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/config/hostTable'
32
+ import * as clusterTable from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/config/clusterTable'
33
+ import * as resourcePoolTable from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/config/resourcePoolTable'
34
+ import * as vAppsTable from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/config/vappsTable'
35
+
36
+ const props = defineProps<{
37
+ selectedData: number[]
38
+ dataTable: UI_I_StorageConfigurePerDiskItem[]
39
+ type: UI_T_SelectComputeResourceTabType
40
+ }>()
41
+ const emits = defineEmits<{
42
+ (event: 'update:selected-data', value: number[] | null): void
43
+ }>()
44
+
45
+ const localization = computed<UI_I_Localization>(() => useLocal())
46
+
47
+ const table: any = {
48
+ host: hostTable,
49
+ cluster: clusterTable,
50
+ 'resource-pool': resourcePoolTable,
51
+ 'v-apps': vAppsTable,
52
+ }
53
+
54
+ const headItems = computed<UI_I_HeadItem[]>(() =>
55
+ table[props.type].headItems(localization.value)
56
+ )
57
+ const columnKeys = computed<UI_I_ColumnKey[]>(() =>
58
+ table[props.type].columnKeys(localization.value)
59
+ )
60
+ watch(localization, () => {
61
+ columnKeys.value = table[props.type].columnKeys(localization.value)
62
+ })
63
+
64
+ const bodyItems = computed<UI_I_BodyItem[][]>(() => {
65
+ return table[props.type].bodyItems(props.dataTable)
66
+ })
67
+
68
+ const sort = ref<string | null>(null)
69
+ const pagination = ref<UI_I_Pagination>({
70
+ page: 1,
71
+ pageSize: 100,
72
+ })
73
+
74
+ const sorting = (data: [string, boolean]): void => {
75
+ const [column, status] = data
76
+ const direction = status ? 'asc' : 'desc'
77
+ sort.value = `${column}.${direction}`
78
+ }
79
+
80
+ const selectedRow = computed<number[]>({
81
+ get() {
82
+ return props.selectedData
83
+ },
84
+ set(newValue: number[]) {
85
+ emits('update:selected-data', newValue)
86
+ },
87
+ })
88
+ </script>
89
+
90
+ <style lang="scss" scoped></style>
@@ -0,0 +1,114 @@
1
+ import type {
2
+ UI_I_ColumnKey,
3
+ UI_I_HeadItem,
4
+ UI_I_BodyItem,
5
+ } from '~/components/atoms/table/dataGrid/models/interfaces'
6
+ import type { UI_I_Localization } from '~/models/interfaces'
7
+ import type {
8
+ I_Clusters,
9
+ I_TableIconColumnData,
10
+ } from '~/components/templates/inventory/mainBlock/tablesView/models/interfaces'
11
+ import { E_StatusEnum } from '~/components/templates/inventory/treeView/models/enums'
12
+ import { columnKeys as getColumnKeys } from '~/components/templates/inventory/mainBlock/tablesView/config/columnKeys'
13
+ import { headItems as getHeadItems } from '~/components/templates/inventory/mainBlock/tablesView/config/headItems'
14
+ import { clusterTableItemKeys } from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/config/tableKeys'
15
+
16
+ const getItems = (
17
+ localization: UI_I_Localization
18
+ ): [string, boolean, string, string][] => {
19
+ return [
20
+ [localization.name, true, '180px', clusterTableItemKeys[0]],
21
+ [localization.availableCpu, true, '180px', clusterTableItemKeys[1]],
22
+ [localization.availableMemory, true, '180px', clusterTableItemKeys[2]],
23
+ [localization.availableStorage, true, '180px', clusterTableItemKeys[3]],
24
+ [localization.vSphere_DRS, true, '180px', clusterTableItemKeys[4]],
25
+ [localization.vSphere_HA, true, '180px', clusterTableItemKeys[5]],
26
+ [localization.totalCpu, false, '180px', clusterTableItemKeys[6]],
27
+ [localization.totalMemory, false, '180px', clusterTableItemKeys[7]],
28
+ [localization.totalStorage, false, '180px', clusterTableItemKeys[8]],
29
+ [localization.vms, false, '180px', clusterTableItemKeys[9]],
30
+ [localization.hosts, false, '180px', clusterTableItemKeys[10]],
31
+ [localization.cpus, false, '180px', clusterTableItemKeys[11]],
32
+ [localization.datastores, false, '180px', clusterTableItemKeys[12]],
33
+ [localization.vSAN, false, '180px', clusterTableItemKeys[13]],
34
+ [localization.vc, false, '180px', clusterTableItemKeys[14]],
35
+ [localization.evcCpuMode, true, '180px', clusterTableItemKeys[15]],
36
+ [localization.evcGraphicsMode, true, '240px', clusterTableItemKeys[16]],
37
+ ]
38
+ }
39
+
40
+ export const columnKeys = (
41
+ localization: UI_I_Localization
42
+ ): UI_I_ColumnKey[] => {
43
+ return getColumnKeys(getItems(localization))
44
+ }
45
+
46
+ export const headItems = (localization: UI_I_Localization): UI_I_HeadItem[] => {
47
+ return getHeadItems(getItems(localization))
48
+ }
49
+
50
+ export const bodyItems = (data: I_Clusters[]): UI_I_BodyItem[][] => {
51
+ const { $binary } = useNuxtApp()
52
+
53
+ const bodyItems: UI_I_BodyItem[][] = []
54
+ data.forEach((cluster, key) => {
55
+ const clusterData: I_TableIconColumnData = {
56
+ iconClassName: E_StatusEnum.cluster_Normal,
57
+ name: cluster.name,
58
+ // @ts-ignore TODO id надо для перехода, пока что так оставить чтобы нигде не ломалось потом поправить для всех
59
+ id: cluster.id,
60
+ nav: 'h',
61
+ type: 'cluster',
62
+ isLink: true,
63
+ }
64
+ bodyItems.push([
65
+ {
66
+ key: 'icon',
67
+ text: cluster[clusterTableItemKeys[0]],
68
+ data: clusterData,
69
+ id: key,
70
+ },
71
+ {
72
+ key: 'col2',
73
+ text: $binary.roundHz(cluster[clusterTableItemKeys[1]]),
74
+ id: key,
75
+ },
76
+ {
77
+ key: 'col3',
78
+ text: $binary.round(cluster[clusterTableItemKeys[2]]),
79
+ id: key,
80
+ },
81
+ {
82
+ key: 'col4',
83
+ text: $binary.round(cluster[clusterTableItemKeys[3]]),
84
+ id: key,
85
+ },
86
+ { key: 'col5', text: cluster[clusterTableItemKeys[4]], id: key },
87
+ { key: 'col6', text: cluster[clusterTableItemKeys[5]], id: key },
88
+ {
89
+ key: 'col7',
90
+ text: $binary.roundHz(cluster[clusterTableItemKeys[6]]),
91
+ id: key,
92
+ },
93
+ {
94
+ key: 'col8',
95
+ text: $binary.round(cluster[clusterTableItemKeys[7]]),
96
+ id: key,
97
+ },
98
+ {
99
+ key: 'col9',
100
+ text: $binary.round(cluster[clusterTableItemKeys[8]]),
101
+ id: key,
102
+ },
103
+ { key: 'col10', text: cluster[clusterTableItemKeys[9]], id: key },
104
+ { key: 'col11', text: cluster[clusterTableItemKeys[10]], id: key },
105
+ { key: 'col12', text: cluster[clusterTableItemKeys[11]], id: key },
106
+ { key: 'col13', text: cluster[clusterTableItemKeys[12]], id: key },
107
+ { key: 'col14', text: cluster[clusterTableItemKeys[13]], id: key },
108
+ { key: 'col15', text: cluster[clusterTableItemKeys[14]], id: key },
109
+ { key: 'col16', text: cluster[clusterTableItemKeys[15]], id: key },
110
+ { key: 'col17', text: cluster[clusterTableItemKeys[16]], id: key },
111
+ ])
112
+ })
113
+ return bodyItems
114
+ }
@@ -0,0 +1,141 @@
1
+ import type {
2
+ UI_I_ColumnKey,
3
+ UI_I_HeadItem,
4
+ UI_I_BodyItem,
5
+ } from '~/components/atoms/table/dataGrid/models/interfaces'
6
+ import type { UI_I_Localization } from '~/models/interfaces'
7
+ import {
8
+ constructColumnKey,
9
+ constructHeadItem,
10
+ } from '~/components/atoms/table/dataGrid/utils/constructDataTable'
11
+ import {
12
+ hostIconByState,
13
+ hostLocalizationByState,
14
+ } from '~/components/common/config/states'
15
+ // import type { I_TableIconColumnData } from '~/components/templates/inventory/mainBlock/tablesView/models/interfaces'
16
+ // import type { API_I_HostTableItem } from '~/models/store/inventory/host/interfaces'
17
+ import { E_StatusEnum } from '~/components/templates/inventory/treeView/models/enums'
18
+ import { hostTableItemKeys } from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/config/tableKeys'
19
+
20
+ const getItems = (
21
+ localization: UI_I_Localization
22
+ ): [string, boolean, string, string][] => {
23
+ return [
24
+ [localization.name, true, '180px', hostTableItemKeys[0]],
25
+ [localization.state, true, '96px', hostTableItemKeys[1]],
26
+ [localization.cluster, true, '180px', hostTableItemKeys[2]],
27
+ [localization.faultDomain, true, '180px', hostTableItemKeys[3]],
28
+ [`${localization.consumedCpu} %`, true, '180px', hostTableItemKeys[4]],
29
+ [`${localization.consumedMemory} %`, true, '180px', hostTableItemKeys[5]],
30
+ [localization.haState, true, '180px', hostTableItemKeys[6]],
31
+ [localization.uptime, true, '180px', hostTableItemKeys[7]],
32
+ [localization.certificateValidTo, false, '180px', hostTableItemKeys[8]],
33
+ [
34
+ `${localization.memorySize} (${localization.mb})`,
35
+ false,
36
+ '180px',
37
+ hostTableItemKeys[9],
38
+ ],
39
+ [localization.cpus, false, '180px', hostTableItemKeys[10]],
40
+ [localization.nics, false, '180px', hostTableItemKeys[11]],
41
+ [localization.version, false, '180px', hostTableItemKeys[12]],
42
+ [localization.alarmActions, false, '180px', hostTableItemKeys[13]],
43
+ ]
44
+ }
45
+
46
+ export const columnKeys = (
47
+ localization: UI_I_Localization
48
+ ): UI_I_ColumnKey[] => {
49
+ const result: UI_I_ColumnKey[] = []
50
+ getItems(localization).forEach((item, i) => {
51
+ const col =
52
+ i === 0 ? 'icon' : i === 5 || i === 6 ? 'progress' : `col${i + 1}`
53
+ result.push(constructColumnKey(col, item[0], item[1]))
54
+ })
55
+ return result
56
+ }
57
+
58
+ export const headItems = (localization: UI_I_Localization): UI_I_HeadItem[] => {
59
+ const result: UI_I_HeadItem[] = []
60
+ getItems(localization).forEach((item, i) => {
61
+ const col =
62
+ i === 0 ? 'icon' : i === 5 || i === 6 ? 'progress' : `col${i + 1}`
63
+ result.push(constructHeadItem(col, item[0], item[3], false, item[2]))
64
+ })
65
+ return result
66
+ }
67
+
68
+ export const bodyItems = (
69
+ data: API_I_HostTableItem[],
70
+ localization: UI_I_Localization
71
+ ): UI_I_BodyItem[][] => {
72
+ const { $number } = useNuxtApp()
73
+
74
+ const bodyItems: UI_I_BodyItem[][] = []
75
+ data.forEach((host, key) => {
76
+ const hostData: any = {
77
+ iconClassName: `vsphere-icon-${hostIconByState[host.state]}`,
78
+ name: host.name,
79
+ // @ts-ignore TODO id надо для перехода, пока что так оставить чтобы нигде не ломалось потом поправить для всех
80
+ id: host.name,
81
+ nav: 'h',
82
+ type: 'host',
83
+ isLink: true,
84
+ }
85
+
86
+ const clusterData: any = {
87
+ iconClassName: E_StatusEnum.cluster_Normal,
88
+ name: host.cluster,
89
+ nav: 'h',
90
+ type: 'cluster',
91
+ isLink: true,
92
+ }
93
+ bodyItems.push([
94
+ {
95
+ key: 'icon',
96
+ text: host[hostTableItemKeys[0]],
97
+ data: hostData,
98
+ id: key,
99
+ },
100
+ {
101
+ key: 'col2',
102
+ text: localization[hostLocalizationByState[host[hostTableItemKeys[1]]]],
103
+ id: key,
104
+ },
105
+ {
106
+ key: 'col3',
107
+ text: host[hostTableItemKeys[2]],
108
+ data: clusterData,
109
+ id: key,
110
+ },
111
+ { key: 'col4', text: host[hostTableItemKeys[3]], id: key },
112
+ {
113
+ key: 'progress',
114
+ text: `${host[hostTableItemKeys[4]].toFixed(2)}%`,
115
+ data: host[hostTableItemKeys[4]],
116
+ id: key,
117
+ },
118
+ {
119
+ key: 'progress',
120
+ text: `${host[hostTableItemKeys[5]].toFixed(2)}%`,
121
+ data: host[hostTableItemKeys[5]],
122
+ id: key,
123
+ },
124
+ { key: 'col7', text: host[hostTableItemKeys[6]], id: key },
125
+ { key: 'col8', text: host[hostTableItemKeys[7]], id: key },
126
+ { key: 'col9', text: host[hostTableItemKeys[8]], id: key },
127
+ {
128
+ key: 'col10',
129
+ text: `${$number.format(host[hostTableItemKeys[9]], 'en')} ${
130
+ localization.mb
131
+ }`,
132
+ id: key,
133
+ },
134
+ { key: 'col11', text: host[hostTableItemKeys[10]], id: key },
135
+ { key: 'col12', text: host[hostTableItemKeys[11]], id: key },
136
+ { key: 'col13', text: host[hostTableItemKeys[12]], id: key },
137
+ { key: 'col14', text: host[hostTableItemKeys[13]], id: key },
138
+ ])
139
+ })
140
+ return bodyItems
141
+ }
@@ -0,0 +1,115 @@
1
+ import type {
2
+ UI_I_ColumnKey,
3
+ UI_I_HeadItem,
4
+ UI_I_BodyItem,
5
+ } from '~/components/atoms/table/dataGrid/models/interfaces'
6
+ import type { UI_I_Localization } from '~/models/interfaces'
7
+ import {
8
+ constructColumnKey,
9
+ constructHeadItem,
10
+ } from '~/components/atoms/table/dataGrid/utils/constructDataTable'
11
+ import { resourcePoolsTableItemKeys } from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/config/tableKeys'
12
+
13
+ const getItems = (
14
+ localization: UI_I_Localization
15
+ ): [string, boolean, string, string][] => {
16
+ return [
17
+ [localization.name, true, '90px', resourcePoolsTableItemKeys[0]],
18
+ [
19
+ localization.cpuReservationMhz,
20
+ true,
21
+ '180px',
22
+ resourcePoolsTableItemKeys[0],
23
+ ],
24
+ [localization.cpuLimitMhz, true, '180px', resourcePoolsTableItemKeys[0]],
25
+ [
26
+ localization.cpuAllocationType,
27
+ true,
28
+ '180px',
29
+ resourcePoolsTableItemKeys[0],
30
+ ],
31
+ [localization.cpuShares, true, '180px', resourcePoolsTableItemKeys[1]],
32
+ [localization.cpuSharesValue, true, '180px', resourcePoolsTableItemKeys[2]],
33
+ [
34
+ localization.memoryReservationMb,
35
+ true,
36
+ '180px',
37
+ resourcePoolsTableItemKeys[2],
38
+ ],
39
+ [localization.memoryLimitMb, true, '180px', resourcePoolsTableItemKeys[2]],
40
+ [
41
+ localization.memoryAllocationType,
42
+ true,
43
+ '180px',
44
+ resourcePoolsTableItemKeys[2],
45
+ ],
46
+ [localization.memoryShares, true, '180px', resourcePoolsTableItemKeys[3]],
47
+ [
48
+ localization.memorySharesValue,
49
+ true,
50
+ '180px',
51
+ resourcePoolsTableItemKeys[4],
52
+ ],
53
+ [localization.vc, true, '90px', resourcePoolsTableItemKeys[5]],
54
+ ]
55
+ }
56
+
57
+ export const columnKeys = (
58
+ localization: UI_I_Localization
59
+ ): UI_I_ColumnKey[] => {
60
+ const result: UI_I_ColumnKey[] = []
61
+ getItems(localization).forEach((item, i) => {
62
+ result.push(constructColumnKey(`col${i}`, item[0], item[1]))
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
+ result.push(constructHeadItem(`col${i}`, item[0], item[3], false, item[2]))
71
+ })
72
+ return result
73
+ }
74
+
75
+ export const bodyItems = (data: any[]): UI_I_BodyItem[][] => {
76
+ const { $binary } = useNuxtApp()
77
+ const bodyItems: UI_I_BodyItem[][] = []
78
+ data.forEach((vapp, key) => {
79
+ bodyItems.push([
80
+ {
81
+ key: 'col0',
82
+ text: vapp[resourcePoolsTableItemKeys[0]],
83
+ id: key,
84
+ },
85
+ {
86
+ key: 'col1',
87
+ text: $binary.roundHz(vapp[resourcePoolsTableItemKeys[1]]),
88
+ id: key,
89
+ },
90
+ {
91
+ key: 'col2',
92
+ text: $binary.roundHz(vapp[resourcePoolsTableItemKeys[2]]),
93
+ id: key,
94
+ },
95
+ { key: 'col3', text: vapp[resourcePoolsTableItemKeys[3]], id: key },
96
+ { key: 'col4', text: vapp[resourcePoolsTableItemKeys[4]], id: key },
97
+ { key: 'col5', text: vapp[resourcePoolsTableItemKeys[5]], id: key },
98
+ {
99
+ key: 'col6',
100
+ text: $binary.round(vapp[resourcePoolsTableItemKeys[6]]),
101
+ id: key,
102
+ },
103
+ {
104
+ key: 'col7',
105
+ text: $binary.round(vapp[resourcePoolsTableItemKeys[7]]),
106
+ id: key,
107
+ },
108
+ { key: 'col8', text: vapp[resourcePoolsTableItemKeys[8]], id: key },
109
+ { key: 'col9', text: vapp[resourcePoolsTableItemKeys[9]], id: key },
110
+ { key: 'col10', text: vapp[resourcePoolsTableItemKeys[10]], id: key },
111
+ { key: 'col11', text: vapp[resourcePoolsTableItemKeys[11]], id: key },
112
+ ])
113
+ })
114
+ return bodyItems
115
+ }
@@ -0,0 +1,65 @@
1
+ import type {
2
+ T_HostTableTuple,
3
+ T_ClusterTableTuple,
4
+ T_VAppsTableTuple,
5
+ T_ResourcePoolTableTuple,
6
+ } from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/models/types'
7
+
8
+ export const hostTableItemKeys: T_HostTableTuple = [
9
+ 'name',
10
+ 'state',
11
+ 'cluster',
12
+ 'fault_domain',
13
+ 'consumed_cpu',
14
+ 'consumed_mem',
15
+ 'ha_state',
16
+ 'uptime',
17
+ 'cert_valid_to',
18
+ 'mem_size',
19
+ 'cpus',
20
+ 'nics',
21
+ 'version',
22
+ 'alarm_action',
23
+ ]
24
+ export const clusterTableItemKeys: T_ClusterTableTuple = [
25
+ 'name',
26
+ 'available_cpu',
27
+ 'available_memory',
28
+ 'available_storage',
29
+ 'drs',
30
+ 'ha',
31
+ 'total_cpu',
32
+ 'total_memory',
33
+ 'total_storage',
34
+ 'vms',
35
+ 'hosts',
36
+ 'cpus',
37
+ 'datastores',
38
+ 'vsan',
39
+ 'vc',
40
+ 'evc_cpu_mode',
41
+ 'evc_graphics_mode',
42
+ ]
43
+ export const vAppsTableItemKeys: T_VAppsTableTuple = [
44
+ 'name',
45
+ 'cpu_shares',
46
+ 'cpu_shares_val',
47
+ 'memory_shares',
48
+ 'memory_shares_val',
49
+ 'managed_by',
50
+ ]
51
+
52
+ export const resourcePoolsTableItemKeys: T_ResourcePoolTableTuple = [
53
+ 'name',
54
+ 'cpu_reservation',
55
+ 'cpu_limit',
56
+ 'cpu_allocation_type',
57
+ 'cpu_shares',
58
+ 'cpu_shares_val',
59
+ 'memory_reservation',
60
+ 'memory_limit',
61
+ 'memory_allocation_type',
62
+ 'memory_shares',
63
+ 'memory_shares_val',
64
+ 'vc',
65
+ ]
@@ -0,0 +1,66 @@
1
+ import {
2
+ UI_I_ColumnKey,
3
+ UI_I_HeadItem,
4
+ UI_I_BodyItem,
5
+ } from '~/components/atoms/table/dataGrid/models/interfaces'
6
+ import type { UI_I_Localization } from '~/models/interfaces'
7
+ // import {
8
+ // I_TableIconColumnData,
9
+ // I_Vapps,
10
+ // } from '~/components/templates/inventory/mainBlock/tablesView/models/interfaces'
11
+ import { E_StatusEnum } from '~/components/templates/inventory/treeView/models/enums'
12
+ import { columnKeys as getColumnKeys } from '~/components/templates/inventory/mainBlock/tablesView/config/columnKeys'
13
+ import { headItems as getHeadItems } from '~/components/templates/inventory/mainBlock/tablesView/config/headItems'
14
+ import { vAppsTableItemKeys } from '~/components/common/wizards/vm/migrate/select/computeResource/tableView/config/tableKeys'
15
+
16
+ const getItems = (
17
+ localization: UI_I_Localization
18
+ ): [string, boolean, string, string][] => {
19
+ return [
20
+ [localization.name, true, '180px', vAppsTableItemKeys[0]],
21
+ [localization.cpuShares, true, '180px', vAppsTableItemKeys[1]],
22
+ [localization.cpuSharesValue, true, '180px', vAppsTableItemKeys[2]],
23
+ [localization.memoryShares, true, '180px', vAppsTableItemKeys[3]],
24
+ [localization.memorySharesValue, true, '180px', vAppsTableItemKeys[4]],
25
+ [localization.managedBy, true, '180px', vAppsTableItemKeys[5]],
26
+ ]
27
+ }
28
+
29
+ export const columnKeys = (
30
+ localization: UI_I_Localization
31
+ ): UI_I_ColumnKey[] => {
32
+ return getColumnKeys(getItems(localization))
33
+ }
34
+
35
+ export const headItems = (localization: UI_I_Localization): UI_I_HeadItem[] => {
36
+ return getHeadItems(getItems(localization))
37
+ }
38
+
39
+ export const bodyItems = (data: any[]): UI_I_BodyItem[][] => {
40
+ const bodyItems: UI_I_BodyItem[][] = []
41
+ data.forEach((vapp, key) => {
42
+ const nameData: any = {
43
+ iconClassName: E_StatusEnum.vmtemplate_Normal,
44
+ name: vapp.name,
45
+ // @ts-ignore TODO id надо для перехода, пока что так оставить чтобы нигде не ломалось потом поправить для всех
46
+ id: vapp.id,
47
+ nav: 'v',
48
+ type: 'vmtemplate',
49
+ isLink: true,
50
+ }
51
+ bodyItems.push([
52
+ {
53
+ key: 'icon',
54
+ text: vapp[vAppsTableItemKeys[0]],
55
+ data: nameData,
56
+ id: key,
57
+ },
58
+ { key: 'col2', text: vapp[vAppsTableItemKeys[1]], id: key },
59
+ { key: 'col3', text: vapp[vAppsTableItemKeys[2]], id: key },
60
+ { key: 'col4', text: vapp[vAppsTableItemKeys[3]], id: key },
61
+ { key: 'col5', text: vapp[vAppsTableItemKeys[4]], id: key },
62
+ { key: 'col6', text: vapp[vAppsTableItemKeys[5]], id: key },
63
+ ])
64
+ })
65
+ return bodyItems
66
+ }
@@ -0,0 +1,60 @@
1
+ export type T_HostTableTuple = [
2
+ 'name',
3
+ 'state',
4
+ 'cluster',
5
+ 'fault_domain',
6
+ 'consumed_cpu',
7
+ 'consumed_mem',
8
+ 'ha_state',
9
+ 'uptime',
10
+ 'cert_valid_to',
11
+ 'mem_size',
12
+ 'cpus',
13
+ 'nics',
14
+ 'version',
15
+ 'alarm_action'
16
+ ]
17
+
18
+ export type T_ClusterTableTuple = [
19
+ 'name',
20
+ 'available_cpu',
21
+ 'available_memory',
22
+ 'available_storage',
23
+ 'drs',
24
+ 'ha',
25
+ 'total_cpu',
26
+ 'total_memory',
27
+ 'total_storage',
28
+ 'vms',
29
+ 'hosts',
30
+ 'cpus',
31
+ 'datastores',
32
+ 'vsan',
33
+ 'vc',
34
+ 'evc_cpu_mode',
35
+ 'evc_graphics_mode'
36
+ ]
37
+
38
+ export type T_VAppsTableTuple = [
39
+ 'name',
40
+ 'cpu_shares',
41
+ 'cpu_shares_val',
42
+ 'memory_shares',
43
+ 'memory_shares_val',
44
+ 'managed_by'
45
+ ]
46
+
47
+ export type T_ResourcePoolTableTuple = [
48
+ 'name',
49
+ 'cpu_reservation',
50
+ 'cpu_limit',
51
+ 'cpu_allocation_type',
52
+ 'cpu_shares',
53
+ 'cpu_shares_val',
54
+ 'memory_reservation',
55
+ 'memory_limit',
56
+ 'memory_allocation_type',
57
+ 'memory_shares',
58
+ 'memory_shares_val',
59
+ 'vc'
60
+ ]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.2.136",
4
+ "version": "1.2.138",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",