bfg-common 1.1.18 → 1.1.20

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.
@@ -20,11 +20,13 @@
20
20
  :selected-metric="props.selectedMetric"
21
21
  :disabled-period="props.disabledPeriod"
22
22
  :disabled-view="props.disabledView"
23
+ :selected-chart-type="props.selectedChartType"
23
24
  @update-tools="onUpdateTools"
24
25
  @exporting="onExporting"
25
26
  @open-advanced-page="onGetEmptyPage"
26
27
  @select-row="emits('select-row', $event)"
27
28
  @select-metric="emits('select-metric', $event)"
29
+ @update-chart-type="emits('update-chart-type', $event)"
28
30
  />
29
31
 
30
32
  <div v-show="!props.data" class="empty-container">
@@ -45,6 +47,7 @@
45
47
  :formatted-datetime="props.formattedDatetime"
46
48
  :get-date-format="props.getDateFormat"
47
49
  :language="props.language"
50
+ :selected-chart-type="props.selectedChartType"
48
51
  />
49
52
  <div class="datatable">
50
53
  <common-monitor-advanced-table
@@ -83,6 +86,7 @@ const props = defineProps<{
83
86
  getDateFormat: any
84
87
  selectedCountersKeys: number[]
85
88
  selectedMetric: T_ChartHost | T_ChartVm
89
+ selectedChartType: string
86
90
  disabledPeriod?: boolean
87
91
  disabledView?: boolean
88
92
  }>()
@@ -93,6 +97,7 @@ const emits = defineEmits<{
93
97
  (event: 'update-selected-row', value: number[]): void
94
98
  (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
95
99
  (event: 'select-metric', value: string): void
100
+ (event: 'update-chart-type', value: string): void
96
101
  }>()
97
102
 
98
103
  const localization = computed<UI_I_Localization>(() => useLocal())
@@ -33,6 +33,7 @@ const props = defineProps<{
33
33
  formattedDatetime: any
34
34
  getDateFormat: any
35
35
  language: string
36
+ selectedChartType: string
36
37
  }>()
37
38
 
38
39
  const chartData = ref<I_LineGraph | null>(null)
@@ -62,7 +63,7 @@ const startChart = (): void => {
62
63
  true,
63
64
  false,
64
65
  false,
65
- '',
66
+ props.selectedChartType,
66
67
  '',
67
68
  0,
68
69
  chartCallback,
@@ -99,6 +100,14 @@ watch(
99
100
  }
100
101
  )
101
102
 
103
+ watch(
104
+ () => props.selectedChartType,
105
+ () => {
106
+ startChart()
107
+ },
108
+ { immediate: true }
109
+ )
110
+
102
111
  const chartsView = ref(null)
103
112
  const { width } = useElementSize(chartsView)
104
113
 
@@ -87,9 +87,11 @@
87
87
  :language="props.language"
88
88
  :selected-counters-keys="props.selectedCountersKeys"
89
89
  :selected-metric="props.selectedMetric"
90
+ :selected-chart-type="props.selectedChartType"
90
91
  @hide="isShowModal = false"
91
92
  @select-row="emits('select-row', $event)"
92
93
  @select-metric="emits('select-metric', $event)"
94
+ @update-chart-type="emits('update-chart-type', $event)"
93
95
  />
94
96
  </template>
95
97
 
@@ -118,6 +120,7 @@ const props = defineProps<{
118
120
  language: string
119
121
  selectedCountersKeys: number[]
120
122
  selectedMetric: T_ChartHost | T_ChartVm
123
+ selectedChartType: string
121
124
  disabledPeriod?: boolean
122
125
  disabledView?: boolean
123
126
  }>()
@@ -128,6 +131,7 @@ const emits = defineEmits<{
128
131
  (event: 'open-advanced-page'): void
129
132
  (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
130
133
  (event: 'select-metric', value: string): void
134
+ (event: 'update-chart-type', value: string): void
131
135
  }>()
132
136
 
133
137
  const localization = computed<UI_I_Localization>(() => useLocal())
@@ -26,7 +26,9 @@
26
26
  :language="props.language"
27
27
  :type="props.type"
28
28
  :selected-keys="props.selectedCountersKeys"
29
+ :selected-chart-type="props.selectedChartType"
29
30
  @select-row="selectedRows = $event"
31
+ @update-chart-type="selectedChartType = $event"
30
32
  />
31
33
  </div>
32
34
  </div>
@@ -51,12 +53,14 @@ const props = defineProps<{
51
53
  language: string
52
54
  selectedCountersKeys: number[]
53
55
  selectedMetric: T_ChartHost | T_ChartVm
56
+ selectedChartType: string
54
57
  }>()
55
58
 
56
59
  const emits = defineEmits<{
57
60
  (event: 'hide'): void
58
61
  (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
59
62
  (event: 'select-metric', value: string): void
63
+ (event: 'update-chart-type', value: string): void
60
64
  }>()
61
65
 
62
66
  const localization = computed<UI_I_Localization>(() => useLocal())
@@ -81,6 +85,7 @@ const onHide = (): void => {
81
85
  }
82
86
 
83
87
  const selectedRows = ref<UI_I_AdvancedCounterItem[]>([])
88
+ const selectedChartType = ref<string>('')
84
89
 
85
90
  const checkValidations = (): boolean => {
86
91
  if (selectedRows.value.length) return true
@@ -96,6 +101,7 @@ const onSave = (): void => {
96
101
 
97
102
  emits('select-metric', selectedMetric.value)
98
103
  emits('select-row', selectedRows.value)
104
+ emits('update-chart-type', selectedChartType.value)
99
105
  onHide()
100
106
  }
101
107
  </script>
@@ -9,6 +9,8 @@
9
9
  <common-monitor-advanced-tools-chart-options-modal-counters-timespan
10
10
  :language="props.language"
11
11
  :selected="selectedOptions"
12
+ :selected-chart-type="props.selectedChartType"
13
+ @update-chart-type="emits('update-chart-type', $event)"
12
14
  />
13
15
  </div>
14
16
  </template>
@@ -29,10 +31,12 @@ const props = defineProps<{
29
31
  chart: T_ChartHost | T_ChartVm
30
32
  type: UI_T_AdvancedType
31
33
  selectedKeys: number[]
34
+ selectedChartType: string
32
35
  }>()
33
36
 
34
37
  const emits = defineEmits<{
35
38
  (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
39
+ (event: 'update-chart-type', value: string): void
36
40
  }>()
37
41
 
38
42
  const selectedOptions = ref<UI_I_AdvancedTargetObject[][]>([])
@@ -2,6 +2,8 @@
2
2
  <div class="timespan-objects-section-direction flex horizontal">
3
3
  <common-monitor-advanced-tools-chart-options-modal-counters-timespan-form
4
4
  :language="props.language"
5
+ :selected-chart-type="props.selectedChartType"
6
+ @update-chart-type="emits('update-chart-type', $event)"
5
7
  />
6
8
  <common-monitor-advanced-tools-chart-options-modal-counters-timespan-object
7
9
  :selected="props.selected"
@@ -15,6 +17,11 @@ import { UI_I_AdvancedTargetObject } from '~/components/common/monitor/advanced/
15
17
  const props = defineProps<{
16
18
  selected: UI_I_AdvancedTargetObject[][]
17
19
  language: string
20
+ selectedChartType: string
21
+ }>()
22
+
23
+ const emits = defineEmits<{
24
+ (event: 'update-chart-type', value: string): void
18
25
  }>()
19
26
  </script>
20
27
 
@@ -188,7 +188,7 @@
188
188
  >{{ localization.chartType }}:</label
189
189
  >
190
190
  <div class="select">
191
- <select id="chart-type-select" v-model="selectedChartType">
191
+ <select id="chart-type-select" v-model="chartType">
192
192
  <option
193
193
  v-for="(item, index) in chartTypeOptions"
194
194
  :key="index"
@@ -216,6 +216,11 @@ import {
216
216
 
217
217
  const props = defineProps<{
218
218
  language: string
219
+ selectedChartType: string
220
+ }>()
221
+
222
+ const emits = defineEmits<{
223
+ (event: 'update-chart-type', value: string): void
219
224
  }>()
220
225
 
221
226
  const { $formattedDate, $isDate, $getTimeFormat, $getUnixByDate } = useNuxtApp()
@@ -236,11 +241,38 @@ const customTimeOptions = computed<UI_I_OptionItem[]>(() =>
236
241
  customTimeFunc(localization.value)
237
242
  )
238
243
 
239
- const selectedChartType = ref<string>('line_graph')
244
+ const chartType = ref<string>('line_graph')
240
245
  const chartTypeOptions = computed<UI_I_OptionItem[]>(() =>
241
246
  chartTypeFunc(localization.value)
242
247
  )
243
248
 
249
+ const setCurrentChartType = (): void => {
250
+ const selected = props.selectedChartType
251
+ let result = 'line_graph'
252
+
253
+ if (selected === 'spline') result = 'line_graph'
254
+ else if (selected === 'area') result = 'stacked_graph'
255
+
256
+ chartType.value = result
257
+ }
258
+
259
+ watch(
260
+ () => props.selectedChartType,
261
+ () => {
262
+ setCurrentChartType()
263
+ },
264
+ { immediate: true }
265
+ )
266
+
267
+ watch(chartType, (newValue) => {
268
+ let currentValue = 'spline'
269
+
270
+ if (newValue === 'line_graph') currentValue = 'spline'
271
+ else if (newValue === 'stacked_graph') currentValue = 'area'
272
+
273
+ emits('update-chart-type', currentValue)
274
+ })
275
+
244
276
  const yesterday = new Date().setDate(new Date().getDate() - 1)
245
277
  const dateFrom = ref<number>(yesterday)
246
278
  const dateTo = ref<number>(new Date().getTime())
@@ -1,148 +1,154 @@
1
- import { UI_I_DatastoreTableItem } from '~/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/models/interfaces'
7
- import type { UI_I_Localization } from '~/models/interfaces'
8
- import { UI_T_StorageColumnKeys } from '~/components/common/vm/actions/add/select/storage/models/types'
9
- import {
10
- constructColumnKey,
11
- constructHeadItem,
12
- } from '~/components/atoms/table/dataGrid/utils/constructDataTable'
13
-
14
- export const storageTableKeys: UI_T_StorageColumnKeys = [
15
- 'name',
16
- 'state',
17
- 'capacity_mb',
18
- 'provisioned_mb',
19
- 'free_mb',
20
- 'used_mb',
21
- 'type_text',
22
- 'thin_provisioning',
23
- 'access_mode',
24
- 'hardware_acceleration',
25
- 'drive_type',
26
- 'device',
27
- 'storage_io_control',
28
- ]
29
-
30
- const getItems = (
31
- localization: UI_I_Localization
32
- ): [string, boolean, string, string][] => {
33
- return [
34
- [localization.name, true, '96px', storageTableKeys[0]],
35
- [localization.state, true, '138px', storageTableKeys[1]],
36
- [localization.capacity, true, '110px', storageTableKeys[2]],
37
- [localization.provisioned, true, '128px', storageTableKeys[3]],
38
- [localization.free, true, '110px', storageTableKeys[4]],
39
- [localization.used, true, '110px', storageTableKeys[5]],
40
- [localization.type, true, '110px', storageTableKeys[6]],
41
- [localization.thinProvisioning, true, '132px', storageTableKeys[7]],
42
- [localization.access, true, '110px', storageTableKeys[8]],
43
- [localization.hardwareAcceleration, true, '134px', storageTableKeys[9]],
44
- [localization.driverType, true, '110px', storageTableKeys[10]],
45
- [localization.device, true, '110px', storageTableKeys[11]],
46
- [localization.storageIoControl, true, '110px', storageTableKeys[12]],
47
- ]
48
- }
49
-
50
- export const columnKeys = (
51
- localization: UI_I_Localization
52
- ): UI_I_ColumnKey[] => {
53
- const result: UI_I_ColumnKey[] = []
54
- getItems(localization).forEach((item, i) => {
55
- const col = i === 0 ? 'icon' : `col${i}`
56
- result.push(constructColumnKey(col, item[0], item[1]))
57
- })
58
- return result
59
- }
60
-
61
- export const headItems = (localization: UI_I_Localization): UI_I_HeadItem[] => {
62
- const result: UI_I_HeadItem[] = []
63
- getItems(localization).forEach((item, i) => {
64
- const col = i === 0 ? 'icon' : `col${i}`
65
- result.push(constructHeadItem(col, item[0], item[3], true, item[2]))
66
- })
67
- return result
68
- }
69
-
70
- export const bodyItems = (
71
- data: UI_I_DatastoreTableItem[],
72
- localization: UI_I_Localization
73
- ): UI_I_BodyItem[][] => {
74
- const bodyItems: UI_I_BodyItem[][] = []
75
- const { $binary } = useNuxtApp()
76
-
77
- data.forEach((storage: UI_I_DatastoreTableItem, key: number) => {
78
- bodyItems.push([
79
- {
80
- key: 'icon',
81
- text: storage[storageTableKeys[0]].toString(),
82
- data: 'vsphere-icon-datastore',
83
- id: key,
84
- },
85
- {
86
- key: 'col1',
87
- text: storage[storageTableKeys[1]].text,
88
- id: key,
89
- },
90
- {
91
- key: 'col2',
92
- text: $binary.round(storage.capacity[storageTableKeys[2]]),
93
- id: key,
94
- },
95
- {
96
- key: 'col3',
97
- text: $binary.round(storage.capacity[storageTableKeys[3]].toString()),
98
- id: key,
99
- },
100
- {
101
- key: 'col4',
102
- text: $binary.round(storage.capacity[storageTableKeys[4]].toString()),
103
- id: key,
104
- },
105
- {
106
- key: 'col5',
107
- text: $binary.round(storage.capacity[storageTableKeys[5]].toString()),
108
- id: key,
109
- },
110
- {
111
- key: 'col6',
112
- text: storage[storageTableKeys[6]].toString(),
113
- id: key,
114
- },
115
- {
116
- key: 'col7',
117
- text: storage[storageTableKeys[7]] ? localization.yes : localization.no,
118
- id: key,
119
- },
120
- {
121
- key: 'col8',
122
- text: storage[storageTableKeys[8]].toString(),
123
- id: key,
124
- },
125
- {
126
- key: 'col9',
127
- text: storage[storageTableKeys[9]].toString(),
128
- id: key,
129
- },
130
- {
131
- key: 'col10',
132
- text: storage[storageTableKeys[10]].toString(),
133
- id: key,
134
- },
135
- {
136
- key: 'col11',
137
- text: storage[storageTableKeys[11]].toString(),
138
- id: key,
139
- },
140
- {
141
- key: 'col12',
142
- text: storage[storageTableKeys[12]].toString(),
143
- id: key,
144
- },
145
- ])
146
- })
147
- return bodyItems
148
- }
1
+ import { UI_I_DatastoreTableItem } from '~/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/models/interfaces'
7
+ import type { UI_I_Localization } from '~/models/interfaces'
8
+ import { UI_T_StorageColumnKeys } from '~/components/common/vm/actions/add/select/storage/models/types'
9
+ import {
10
+ constructColumnKey,
11
+ constructHeadItem,
12
+ } from '~/components/atoms/table/dataGrid/utils/constructDataTable'
13
+ import {
14
+ datastoreIconByState,
15
+ datastoreLocalizationByState,
16
+ } from '~/components/common/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.name, true, '96px', storageTableKeys[0]],
39
+ [localization.state, true, '138px', storageTableKeys[1]],
40
+ [localization.capacity, true, '110px', storageTableKeys[2]],
41
+ [localization.provisioned, true, '128px', storageTableKeys[3]],
42
+ [localization.free, true, '110px', storageTableKeys[4]],
43
+ [localization.used, true, '110px', storageTableKeys[5]],
44
+ [localization.type, true, '110px', storageTableKeys[6]],
45
+ [localization.thinProvisioning, true, '132px', storageTableKeys[7]],
46
+ [localization.access, true, '110px', storageTableKeys[8]],
47
+ [localization.hardwareAcceleration, true, '134px', storageTableKeys[9]],
48
+ [localization.driverType, true, '110px', storageTableKeys[10]],
49
+ [localization.device, true, '110px', storageTableKeys[11]],
50
+ [localization.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(constructColumnKey(col, item[0], item[1]))
61
+ })
62
+ return result
63
+ }
64
+
65
+ export const headItems = (localization: UI_I_Localization): UI_I_HeadItem[] => {
66
+ const result: UI_I_HeadItem[] = []
67
+ getItems(localization).forEach((item, i) => {
68
+ const col = i === 0 ? 'icon' : `col${i}`
69
+ result.push(constructHeadItem(col, item[0], item[3], true, item[2]))
70
+ })
71
+ return result
72
+ }
73
+
74
+ export const bodyItems = (
75
+ data: UI_I_DatastoreTableItem[],
76
+ localization: UI_I_Localization
77
+ ): UI_I_BodyItem[][] => {
78
+ const bodyItems: UI_I_BodyItem[][] = []
79
+ const { $binary } = useNuxtApp()
80
+
81
+ data.forEach((storage: UI_I_DatastoreTableItem, key: number) => {
82
+ const state =
83
+ localization[datastoreLocalizationByState[storage[storageTableKeys[1]]]]
84
+ bodyItems.push([
85
+ {
86
+ key: 'icon',
87
+ text: storage[storageTableKeys[0]].toString(),
88
+ data: `vsphere-icon-${datastoreIconByState[storage.state]}`,
89
+ id: key,
90
+ },
91
+ {
92
+ key: 'col1',
93
+ text: state,
94
+ id: key,
95
+ },
96
+ {
97
+ key: 'col2',
98
+ text: $binary.round(storage.capacity[storageTableKeys[2]]),
99
+ id: key,
100
+ },
101
+ {
102
+ key: 'col3',
103
+ text: $binary.round(storage.capacity[storageTableKeys[3]].toString()),
104
+ id: key,
105
+ },
106
+ {
107
+ key: 'col4',
108
+ text: $binary.round(storage.capacity[storageTableKeys[4]].toString()),
109
+ id: key,
110
+ },
111
+ {
112
+ key: 'col5',
113
+ text: $binary.round(storage.capacity[storageTableKeys[5]].toString()),
114
+ id: key,
115
+ },
116
+ {
117
+ key: 'col6',
118
+ text: storage[storageTableKeys[6]].toString(),
119
+ id: key,
120
+ },
121
+ {
122
+ key: 'col7',
123
+ text: storage[storageTableKeys[7]] ? localization.yes : localization.no,
124
+ id: key,
125
+ },
126
+ {
127
+ key: 'col8',
128
+ text: storage[storageTableKeys[8]].toString(),
129
+ id: key,
130
+ },
131
+ {
132
+ key: 'col9',
133
+ text: storage[storageTableKeys[9]].toString(),
134
+ id: key,
135
+ },
136
+ {
137
+ key: 'col10',
138
+ text: storage[storageTableKeys[10]].toString(),
139
+ id: key,
140
+ },
141
+ {
142
+ key: 'col11',
143
+ text: storage[storageTableKeys[11]].toString(),
144
+ id: key,
145
+ },
146
+ {
147
+ key: 'col12',
148
+ text: storage[storageTableKeys[12]].toString(),
149
+ id: key,
150
+ },
151
+ ])
152
+ })
153
+ return bodyItems
154
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.1.18",
4
+ "version": "1.1.20",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",