bfg-common 1.4.163 → 1.4.164

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.
@@ -1,253 +1,253 @@
1
- <template>
2
- <div class="vertical-flex-container chart-option-objects-split">
3
- <span class="chart-options-grid-title">
4
- {{ localization.inventoryMonitor.selectObjectForChart }}:
5
- </span>
6
- <div class="flex-to-absolute-positioning-container">
7
- <div class="flex-to-absolute-positioning-container-inner">
8
- <atoms-table-data-grid
9
- v-model:selected-row="selectedRow"
10
- v-model:column-keys="columnItems"
11
- v-model:page-size="pagination.pageSize"
12
- v-model:page="pagination.page"
13
- :type="tableType"
14
- class="data-table"
15
- test-id="object-table"
16
- :loading="props.loading"
17
- :head-items="headItems"
18
- :body-items="bodyItems"
19
- :total-items="bodyItems.length"
20
- :total-pages="1"
21
- hide-footer
22
- server-off
23
- >
24
- </atoms-table-data-grid>
25
- </div>
26
- </div>
27
- </div>
28
- </template>
29
-
30
- <script setup lang="ts">
31
- import type {
32
- UI_I_HeadItem,
33
- UI_I_BodyItem,
34
- UI_I_ColumnKey,
35
- } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
36
- import type { UI_I_Localization } from '~/lib/models/interfaces'
37
- import type { UI_I_Pagination } from '~/lib/models/table/interfaces'
38
- import type { UI_I_AdvancedTargetObject } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/models/interfaces'
39
- import type { UI_I_ObjectItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/models/interfaces'
40
- import type { UI_T_DataGridType } from '~/components/atoms/table/dataGrid/lib/models/types'
41
- import type { UI_T_AdvancedType } from '~/components/common/monitor/advanced/lib/models/types'
42
- import type {
43
- UI_T_ChartHost,
44
- UI_T_ChartVm,
45
- } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/types'
46
- import * as table from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/config/objectTable'
47
-
48
- const props = defineProps<{
49
- type: UI_T_AdvancedType
50
- chart: UI_T_ChartHost | UI_T_ChartVm
51
- totalCores: number
52
- hostId: string
53
- selectedMetricsKeys: number[]
54
- totalMetricItems: number
55
- selectedObjects: string
56
- loading: boolean
57
- currentItems: UI_I_ObjectItem[]
58
- }>()
59
-
60
- const emits = defineEmits<{
61
- (event: 'select-objects', value: string): void
62
- }>()
63
-
64
- const localization = computed<UI_I_Localization>(() => useLocal())
65
-
66
- const tableType = computed<UI_T_DataGridType>(() =>
67
- ['disk', 'network'].includes(props.chart) ? 'radio' : 'checkbox'
68
- )
69
-
70
- const selectedRow = ref<number[] | number>([])
71
- const pagination = ref<UI_I_Pagination>({
72
- page: 1,
73
- pageSize: 35,
74
- })
75
-
76
- const headItems = computed<UI_I_HeadItem[]>(() =>
77
- table.headItems(localization.value)
78
- )
79
- const columnItems = computed<UI_I_ColumnKey[]>(() =>
80
- table.columnKeys(localization.value)
81
- )
82
-
83
- const bodyItems = ref<UI_I_BodyItem[][]>([])
84
-
85
- let items: UI_I_AdvancedTargetObject[] = []
86
- let firstRequest = false
87
- const getTotalCores = (): void => {
88
- if (
89
- props.selectedMetricsKeys.includes(1) &&
90
- !props.totalCores &&
91
- !firstRequest
92
- ) {
93
- firstRequest = true
94
- }
95
- }
96
- watch(
97
- () => props.selectedMetricsKeys,
98
- () => {
99
- getTotalCores()
100
- },
101
- { deep: true }
102
- )
103
- watch(
104
- () => [
105
- props.type,
106
- props.chart,
107
- props.totalCores,
108
- props.hostId,
109
- props.selectedMetricsKeys,
110
- props.currentItems,
111
- ],
112
- (newValue) => {
113
- items = []
114
- selectedRow.value = []
115
-
116
- if (newValue[0] === 'host' && newValue[1] === 'cpu') {
117
- if (newValue[4].includes(0)) {
118
- items.push({
119
- id: 'total',
120
- target_object: newValue[3],
121
- })
122
- }
123
- if (newValue[4].includes(1)) {
124
- for (let i = 0; i < newValue[2]; i++) {
125
- items.push({
126
- id: 'core' + i,
127
- target_object: 'core' + i,
128
- })
129
- }
130
- }
131
- if (newValue[4].includes(2)) {
132
- for (let i = 0; i < newValue[2]; i++) {
133
- items.push({
134
- id: 'core' + i + 'MHz',
135
- target_object: 'core' + i + 'MHz',
136
- })
137
- }
138
- }
139
- if (newValue[4].includes(3)) {
140
- items.push({
141
- id: 'totalMHz',
142
- target_object: 'totalMHz',
143
- })
144
- }
145
- if (newValue[4].includes(4)) {
146
- items.push({
147
- id: 'averageMHz',
148
- target_object: 'averageMHz',
149
- })
150
- }
151
- } else if (
152
- newValue[0] === 'host' &&
153
- ['disk', 'network'].includes(newValue[1])
154
- ) {
155
- let newItems = []
156
-
157
- if (newValue[1] === 'network')
158
- newItems.push({
159
- id: 'total',
160
- target_object: localization.value.common.total.toLowerCase(),
161
- })
162
-
163
- newItems = [...newItems, ...props.currentItems]
164
-
165
- items = newItems
166
- }
167
-
168
- bodyItems.value = table.bodyItems(items)
169
- },
170
- { immediate: true, deep: true }
171
- )
172
-
173
- watch(
174
- selectedRow,
175
- (newValue) => {
176
- const selectedItems: string[] = []
177
-
178
- if (['disk', 'network'].includes(props.chart)) {
179
- selectedItems.push(items[newValue]?.target_object)
180
- } else
181
- newValue.forEach((key) => {
182
- selectedItems.push(items[key].id)
183
- })
184
-
185
- const selectedNames =
186
- items.length === newValue.length &&
187
- props.selectedMetricsKeys.length === props.totalMetricItems
188
- ? '*'
189
- : selectedItems.join(', ')
190
-
191
- emits('select-objects', selectedNames)
192
- },
193
- { deep: true }
194
- )
195
-
196
- watch(
197
- () => [props.selectedObjects, bodyItems.value],
198
- ([selected, all]) => {
199
- if (!all.length) return
200
-
201
- if (props.type === 'host' && props.chart === 'cpu') {
202
- if (selected === '*') {
203
- selectedRow.value = all.map((item) => item[0].id)
204
- } else {
205
- const selectedNames = selected.split(', ')
206
- const selectedKeys: number[] = []
207
- all.forEach((item) => {
208
- if (selectedNames.includes('total')) selectedKeys.push(0)
209
- if (selectedNames.includes(`core${item[0].text}`))
210
- selectedKeys.push(item[0].id)
211
- })
212
- selectedRow.value = selectedKeys
213
- }
214
- } else if (
215
- props.type === 'host' &&
216
- ['disk', 'network'].includes(props.chart)
217
- ) {
218
- if (selected) {
219
- const selectedId = all.find((item) => item[0].text === selected)?.[0]
220
- ?.id
221
- typeof selectedId === 'number' && (selectedRow.value = selectedId)
222
- }
223
- }
224
- },
225
- { immediate: true }
226
- )
227
- </script>
228
-
229
- <style scoped lang="scss">
230
- .chart-option-objects-split {
231
- flex: 1;
232
-
233
- .chart-options-grid-title {
234
- display: block;
235
- margin-bottom: -20px;
236
- }
237
- .flex-to-absolute-positioning-container {
238
- height: 100%;
239
- max-height: 204px;
240
- .flex-to-absolute-positioning-container-inner {
241
- height: inherit;
242
-
243
- .data-table {
244
- height: inherit;
245
-
246
- :deep(.datagrid-outer-wrapper) {
247
- height: inherit;
248
- }
249
- }
250
- }
251
- }
252
- }
253
- </style>
1
+ <template>
2
+ <div class="vertical-flex-container chart-option-objects-split">
3
+ <span class="chart-options-grid-title">
4
+ {{ localization.inventoryMonitor.selectObjectForChart }}:
5
+ </span>
6
+ <div class="flex-to-absolute-positioning-container">
7
+ <div class="flex-to-absolute-positioning-container-inner">
8
+ <atoms-table-data-grid
9
+ v-model:selected-row="selectedRow"
10
+ v-model:column-keys="columnItems"
11
+ v-model:page-size="pagination.pageSize"
12
+ v-model:page="pagination.page"
13
+ :type="tableType"
14
+ class="data-table"
15
+ test-id="object-table"
16
+ :loading="props.loading"
17
+ :head-items="headItems"
18
+ :body-items="bodyItems"
19
+ :total-items="bodyItems.length"
20
+ :total-pages="1"
21
+ hide-footer
22
+ server-off
23
+ >
24
+ </atoms-table-data-grid>
25
+ </div>
26
+ </div>
27
+ </div>
28
+ </template>
29
+
30
+ <script setup lang="ts">
31
+ import type {
32
+ UI_I_HeadItem,
33
+ UI_I_BodyItem,
34
+ UI_I_ColumnKey,
35
+ } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
36
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
37
+ import type { UI_I_Pagination } from '~/lib/models/table/interfaces'
38
+ import type { UI_I_AdvancedTargetObject } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/models/interfaces'
39
+ import type { UI_I_ObjectItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/models/interfaces'
40
+ import type { UI_T_DataGridType } from '~/components/atoms/table/dataGrid/lib/models/types'
41
+ import type { UI_T_AdvancedType } from '~/components/common/monitor/advanced/lib/models/types'
42
+ import type {
43
+ UI_T_ChartHost,
44
+ UI_T_ChartVm,
45
+ } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/types'
46
+ import * as table from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/config/objectTable'
47
+
48
+ const props = defineProps<{
49
+ type: UI_T_AdvancedType
50
+ chart: UI_T_ChartHost | UI_T_ChartVm
51
+ totalCores: number
52
+ hostId: string
53
+ selectedMetricsKeys: number[]
54
+ totalMetricItems: number
55
+ selectedObjects: string
56
+ loading: boolean
57
+ currentItems: UI_I_ObjectItem[]
58
+ }>()
59
+
60
+ const emits = defineEmits<{
61
+ (event: 'select-objects', value: string): void
62
+ }>()
63
+
64
+ const localization = computed<UI_I_Localization>(() => useLocal())
65
+
66
+ const tableType = computed<UI_T_DataGridType>(() =>
67
+ ['disk', 'network'].includes(props.chart) ? 'radio' : 'checkbox'
68
+ )
69
+
70
+ const selectedRow = ref<number[] | number>([])
71
+ const pagination = ref<UI_I_Pagination>({
72
+ page: 1,
73
+ pageSize: 35,
74
+ })
75
+
76
+ const headItems = computed<UI_I_HeadItem[]>(() =>
77
+ table.headItems(localization.value)
78
+ )
79
+ const columnItems = computed<UI_I_ColumnKey[]>(() =>
80
+ table.columnKeys(localization.value)
81
+ )
82
+
83
+ const bodyItems = ref<UI_I_BodyItem[][]>([])
84
+
85
+ let items: UI_I_AdvancedTargetObject[] = []
86
+ let firstRequest = false
87
+ const getTotalCores = (): void => {
88
+ if (
89
+ props.selectedMetricsKeys.includes(1) &&
90
+ !props.totalCores &&
91
+ !firstRequest
92
+ ) {
93
+ firstRequest = true
94
+ }
95
+ }
96
+ watch(
97
+ () => props.selectedMetricsKeys,
98
+ () => {
99
+ getTotalCores()
100
+ },
101
+ { deep: true }
102
+ )
103
+ watch(
104
+ () => [
105
+ props.type,
106
+ props.chart,
107
+ props.totalCores,
108
+ props.hostId,
109
+ props.selectedMetricsKeys,
110
+ props.currentItems,
111
+ ],
112
+ (newValue) => {
113
+ items = []
114
+ selectedRow.value = []
115
+
116
+ if (newValue[0] === 'host' && newValue[1] === 'cpu') {
117
+ if (newValue[4].includes(0)) {
118
+ items.push({
119
+ id: 'total',
120
+ target_object: newValue[3],
121
+ })
122
+ }
123
+ if (newValue[4].includes(1)) {
124
+ for (let i = 0; i < newValue[2]; i++) {
125
+ items.push({
126
+ id: 'core' + i,
127
+ target_object: 'core' + i,
128
+ })
129
+ }
130
+ }
131
+ if (newValue[4].includes(2)) {
132
+ for (let i = 0; i < newValue[2]; i++) {
133
+ items.push({
134
+ id: 'core' + i + 'MHz',
135
+ target_object: 'core' + i + 'MHz',
136
+ })
137
+ }
138
+ }
139
+ if (newValue[4].includes(3)) {
140
+ items.push({
141
+ id: 'totalMHz',
142
+ target_object: 'totalMHz',
143
+ })
144
+ }
145
+ if (newValue[4].includes(4)) {
146
+ items.push({
147
+ id: 'averageMHz',
148
+ target_object: 'averageMHz',
149
+ })
150
+ }
151
+ } else if (
152
+ newValue[0] === 'host' &&
153
+ ['disk', 'network'].includes(newValue[1])
154
+ ) {
155
+ let newItems = []
156
+
157
+ if (newValue[1] === 'network')
158
+ newItems.push({
159
+ id: 'total',
160
+ target_object: localization.value.common.total.toLowerCase(),
161
+ })
162
+
163
+ newItems = [...newItems, ...props.currentItems]
164
+
165
+ items = newItems
166
+ }
167
+
168
+ bodyItems.value = table.bodyItems(items)
169
+ },
170
+ { immediate: true, deep: true }
171
+ )
172
+
173
+ watch(
174
+ selectedRow,
175
+ (newValue) => {
176
+ const selectedItems: string[] = []
177
+
178
+ if (['disk', 'network'].includes(props.chart)) {
179
+ selectedItems.push(items[newValue]?.target_object)
180
+ } else
181
+ newValue.forEach((key) => {
182
+ selectedItems.push(items[key].id)
183
+ })
184
+
185
+ const selectedNames =
186
+ items.length === newValue.length &&
187
+ props.selectedMetricsKeys.length === props.totalMetricItems
188
+ ? '*'
189
+ : selectedItems.join(', ')
190
+
191
+ emits('select-objects', selectedNames)
192
+ },
193
+ { deep: true }
194
+ )
195
+
196
+ watch(
197
+ () => [props.selectedObjects, bodyItems.value],
198
+ ([selected, all]) => {
199
+ if (!all.length) return
200
+
201
+ if (props.type === 'host' && props.chart === 'cpu') {
202
+ if (selected === '*') {
203
+ selectedRow.value = all.map((item) => item[0].id)
204
+ } else {
205
+ const selectedNames = selected.split(', ')
206
+ const selectedKeys: number[] = []
207
+ all.forEach((item) => {
208
+ if (selectedNames.includes('total')) selectedKeys.push(0)
209
+ if (selectedNames.includes(`core${item[0].text}`))
210
+ selectedKeys.push(item[0].id)
211
+ })
212
+ selectedRow.value = selectedKeys
213
+ }
214
+ } else if (
215
+ props.type === 'host' &&
216
+ ['disk', 'network'].includes(props.chart)
217
+ ) {
218
+ if (selected) {
219
+ const selectedId = all.find((item) => item[0].text === selected)?.[0]
220
+ ?.id
221
+ typeof selectedId === 'number' && (selectedRow.value = selectedId)
222
+ }
223
+ }
224
+ },
225
+ { immediate: true }
226
+ )
227
+ </script>
228
+
229
+ <style scoped lang="scss">
230
+ .chart-option-objects-split {
231
+ flex: 1;
232
+
233
+ .chart-options-grid-title {
234
+ display: block;
235
+ margin-bottom: -20px;
236
+ }
237
+ .flex-to-absolute-positioning-container {
238
+ height: 100%;
239
+ max-height: 204px;
240
+ .flex-to-absolute-positioning-container-inner {
241
+ height: inherit;
242
+
243
+ .data-table {
244
+ height: inherit;
245
+
246
+ :deep(.datagrid-outer-wrapper) {
247
+ height: inherit;
248
+ }
249
+ }
250
+ }
251
+ }
252
+ }
253
+ </style>