bfg-common 1.1.76 → 1.1.78

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.
Files changed (82) hide show
  1. package/components/atoms/alert/Notification.vue +167 -167
  2. package/components/atoms/autocomplete/Autocomplete.vue +236 -236
  3. package/components/atoms/datepicker/Datepicker.vue +612 -612
  4. package/components/atoms/list/SelectList.vue +62 -62
  5. package/components/atoms/nav/NavBar.vue +116 -116
  6. package/components/atoms/nav/VerticalNavBar.vue +89 -89
  7. package/components/atoms/notificationBar/NotificationBar.vue +175 -175
  8. package/components/atoms/perPage/PerPage.vue +52 -52
  9. package/components/atoms/popup/SimplePopup.vue +90 -90
  10. package/components/atoms/step/VerticalStep.vue +104 -104
  11. package/components/atoms/switch/Switch.vue +107 -107
  12. package/components/atoms/table/dataGrid/DataGridColumnSwitch.vue +206 -206
  13. package/components/atoms/table/dataGrid/DataGridPage.vue +189 -189
  14. package/components/atoms/tabs/Tabs.vue +189 -189
  15. package/components/atoms/tooltip/Signpost.vue +224 -224
  16. package/components/common/adapterManager/AddAdapterWarningModal.vue +82 -82
  17. package/components/common/adapterManager/NoActiveAdaptersModal.vue +62 -62
  18. package/components/common/adapterManager/NoConnectedActiveAdaptersModal.vue +62 -62
  19. package/components/common/browse/Browse.vue +182 -182
  20. package/components/common/browse/blocks/Title.vue +66 -66
  21. package/components/common/diagramMain/Diagram.vue +186 -186
  22. package/components/common/diagramMain/DiagramMain.vue +986 -986
  23. package/components/common/diagramMain/adapter/AdapterItem.vue +227 -227
  24. package/components/common/diagramMain/adapter/AdapterItems.vue +57 -57
  25. package/components/common/diagramMain/modals/editSettings/tabs/port/IpvFourSettings.vue +339 -339
  26. package/components/common/diagramMain/modals/editSettings/tabs/port/PortProperties.vue +202 -202
  27. package/components/common/diagramMain/modals/remove/RemoveModal.vue +226 -226
  28. package/components/common/diagramMain/network/Contents.vue +238 -238
  29. package/components/common/feedback/Buttons.vue +232 -232
  30. package/components/common/feedback/Message.vue +468 -468
  31. package/components/common/feedback/VisitPortal.vue +54 -54
  32. package/components/common/help/navbar/left/Left.vue +159 -159
  33. package/components/common/help/navbar/left/utils/constructAccordion.ts +27 -27
  34. package/components/common/mainNavigationPanel/MainNavigationPanel.vue +359 -359
  35. package/components/common/modals/Rename.vue +165 -165
  36. package/components/common/monitor/advanced/Advanced.vue +214 -221
  37. package/components/common/monitor/advanced/tools/Tools.vue +422 -441
  38. package/components/common/monitor/advanced/tools/chartOptionsModal/ChartOptionsModal.vue +452 -424
  39. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/Counters.vue +93 -86
  40. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/Table.vue +130 -121
  41. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/config/utils.ts +689 -688
  42. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/Timespan.vue +76 -73
  43. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/Object.vue +176 -129
  44. package/components/common/monitor/advanced/tools/chartOptionsModal/models/models.ts +19 -0
  45. package/components/common/perPage/PerPage.vue +51 -51
  46. package/components/common/recursionTree/RecursionTree.vue +201 -201
  47. package/components/common/vm/actions/add/config/capabilities.ts +777 -777
  48. package/components/common/vm/actions/add/customizeHardware/virtualHardware/VirtualHardware.vue +646 -646
  49. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +246 -246
  50. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/Cpu.vue +375 -375
  51. package/components/common/vm/actions/add/customizeHardware/virtualHardware/limit/Limit.vue +234 -234
  52. package/components/common/vm/actions/add/customizeHardware/virtualHardware/limit/config/options.ts +28 -28
  53. package/components/common/vm/actions/add/customizeHardware/virtualHardware/memory/Memory.vue +316 -316
  54. package/components/common/vm/actions/add/customizeHardware/virtualHardware/memory/config/memoryOptions.ts +35 -35
  55. package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +445 -445
  56. package/components/common/vm/actions/add/customizeHardware/virtualHardware/reservation/Reservation.vue +235 -235
  57. package/components/common/vm/actions/add/customizeHardware/virtualHardware/videoCard/VideoCard.vue +177 -177
  58. package/components/common/vm/actions/add/customizeHardware/vmoptions/bootOptions/order/Order.vue +197 -197
  59. package/components/common/vm/actions/add/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +180 -180
  60. package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/CopyPaste.vue +51 -51
  61. package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +55 -55
  62. package/components/common/vm/actions/add/select/storage/config/config.ts +154 -154
  63. package/components/common/wizards/datastore/add/nfs/configuration/Configuration.vue +373 -373
  64. package/components/common/wizards/datastore/add/nfs/configuration/serversList/ServersList.vue +123 -123
  65. package/components/common/wizards/datastore/add/nfs/kerberosAuthentication/KerberosAuthentication.vue +54 -54
  66. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/hostTable/HostTable.vue +131 -131
  67. package/components/common/wizards/datastore/add/sharedStorm/partitionConfiguration/PartitionConfiguration.vue +230 -230
  68. package/models/store/interfaces.ts +37 -37
  69. package/models/store/storage/interfaces.ts +32 -32
  70. package/models/store/types.ts +32 -32
  71. package/modules/fixContentBuild/utils/methods.ts +114 -114
  72. package/package.json +1 -1
  73. package/public/spice-console/application/codec.js +257 -257
  74. package/public/spice-console/lib/rasterEngine.js +907 -907
  75. package/public/spice-console/network/spicechannel.js +369 -369
  76. package/public/spice-console-minify/lib/decoder/dixie.min.js +4 -4
  77. package/public/spice-console-minify/lib/jgestures.min.js +24 -24
  78. package/public/spice-console-minify/lib/jquery-2.0.3.min.js +24 -24
  79. package/public/spice-console-minify/lib/jquery-mousewheel.min.js +11 -11
  80. package/public/spice-console-minify/lib/jquery-visibility.min.js +1 -1
  81. package/public/spice-console-minify/lib/lodash.4.0.0.min.js +5 -5
  82. package/utils/contentBuild.ts +34 -34
@@ -1,424 +1,452 @@
1
- <template>
2
- <div class="chart-options-modal">
3
- <atoms-modal
4
- width="1150px"
5
- :show="true"
6
- :title="localization.chartOptions"
7
- @hide="onHide"
8
- @submit="onSubmit"
9
- >
10
- <template #modalBody>
11
- <common-monitor-advanced-tools-chart-options-modal-notification
12
- v-show="isShowAlerts"
13
- :alerts="alerts"
14
- @remove="onRemoveAlerts"
15
- />
16
- <div>
17
- <common-monitor-advanced-tools-chart-options-modal-actions
18
- :is-disabled-save="!selectedRows.length"
19
- :options-names="optionsNames"
20
- :selected-chart-option-name="localSelectedChartOptionName"
21
- @save="onSaveOptions"
22
- @check-validation="checkValidations"
23
- @select-local-option-name="onSelectLocalOptionName"
24
- @delete-chart-name="onDeleteChartName"
25
- />
26
-
27
- <div class="horizontal-flex-container chart-options-content">
28
- <common-monitor-advanced-tools-chart-options-modal-metrics
29
- v-model:selected-metric="selectedMetric"
30
- :metrics-items="metricsItems"
31
- />
32
- <common-monitor-advanced-tools-chart-options-modal-counters
33
- :chart="selectedMetric"
34
- :language="props.language"
35
- :type="props.type"
36
- :selected-keys="localSelectedCountersKeys"
37
- :selected-chart-type="localSelectedChartType"
38
- :selected-timespan-type="localSelectedTimespanType"
39
- :units-count="localUnitsCount"
40
- :period-type="localPeriodType"
41
- :selected-custom-time="localCustomTime"
42
- :custom-date-from="props.customDateFrom"
43
- :custom-date-to="props.customDateTo"
44
- :custom-time-from="props.customTimeFrom"
45
- :custom-time-to="props.customTimeTo"
46
- :total-cores="props.totalCores"
47
- :host-id="props.hostId"
48
- @select-row="selectedRows = $event"
49
- @update-chart-type="selectedChartTypeLocal = $event"
50
- @update-custom-time="localCustomTime = $event"
51
- @update-timespan-type="timespanType = $event"
52
- @update-unit-count="unitCount = $event"
53
- @update-period-type="localPeriodType = $event"
54
- @update-custom-date-from="onUpdateCustomDateFrom"
55
- @update-custom-date-to="onUpdateCustomDateTo"
56
- @update-custom-time-from="onUpdateCustomTimeFrom"
57
- @update-custom-time-to="onUpdateCustomTimeTo"
58
- />
59
- </div>
60
- </div>
61
- </template>
62
- </atoms-modal>
63
- </div>
64
- </template>
65
-
66
- <script setup lang="ts">
67
- import { UI_I_Localization } from '~/models/interfaces'
68
- import { UI_T_AdvancedType } from '~/components/common/monitor/advanced/models/types'
69
- import { UI_I_VerticalTabs } from '~/components/atoms/tabs/models/interfaces'
70
- import { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/models/interfaces'
71
- import {
72
- T_ChartHost,
73
- T_ChartVm,
74
- } from '~/components/common/monitor/advanced/tools/chartOptionsModal/models/types'
75
- import { metricsFunc } from '~/components/common/monitor/advanced/tools/chartOptionsModal/metrics/config/optionsMetrics'
76
- import { getCurrentOptionsStorageFunc } from '~/components/common/monitor/advanced/tools/config/advancedToolbar'
77
- import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/config/dateChecker'
78
-
79
- const props = defineProps<{
80
- type: UI_T_AdvancedType
81
- language: string
82
- selectedCountersKeys: number[]
83
- selectedMetric: T_ChartHost | T_ChartVm
84
- selectedChartType: string
85
- selectedTimespanType: string
86
- unitsCount: number
87
- periodType: string
88
- selectedCustomTime: string
89
- selectedChartOptionName: string
90
- customDateFrom: string
91
- customDateTo: string
92
- customTimeFrom: string
93
- customTimeTo: string
94
- totalCores: number
95
- hostId: string
96
- }>()
97
-
98
- const emits = defineEmits<{
99
- (event: 'hide'): void
100
- (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
101
- (event: 'select-metric', value: string): void
102
- (event: 'update-chart-type', value: string): void
103
- (event: 'update-timespan-type', value: string): void
104
- (event: 'update-unit-count', value: number): void
105
- (event: 'update-period-type', value: string): void
106
- (event: 'update-custom-time', value: string): void
107
- (event: 'select-chart-name', value: string): void
108
- (event: 'delete-option'): void
109
- (event: 'save-option-name'): void
110
- (event: 'update-custom-date-from', value: string): void
111
- (event: 'update-custom-date-to', value: string): void
112
- (event: 'update-custom-time-from', value: string): void
113
- (event: 'update-custom-time-to', value: string): void
114
- (event: 'submit-options', value: string): void
115
- (event: 'select-objects', value: string): void
116
- }>()
117
-
118
- const routeType = '' + useRoute().params.type
119
-
120
- const localization = computed<UI_I_Localization>(() => useLocal())
121
-
122
- const localCustomDateFrom = ref<string>('')
123
- const onUpdateCustomDateFrom = (value: string): void => {
124
- localCustomDateFrom.value = value
125
- }
126
- const localCustomDateTo = ref<string>('')
127
- const onUpdateCustomDateTo = (value: string): void => {
128
- localCustomDateTo.value = value
129
- }
130
- const localCustomTimeFrom = ref<string>('')
131
- const onUpdateCustomTimeFrom = (value: string): void => {
132
- localCustomTimeFrom.value = value
133
- }
134
- const localCustomTimeTo = ref<string>('')
135
- const onUpdateCustomTimeTo = (value: string): void => {
136
- localCustomTimeTo.value = value
137
- }
138
-
139
- const metricsItems = computed<UI_I_VerticalTabs[]>(() =>
140
- metricsFunc(localization.value, props.type)
141
- )
142
- const selectedMetric = ref<T_ChartHost | T_ChartVm>(
143
- props.selectedMetric || '' + metricsItems.value[0]?.value
144
- )
145
-
146
- const localSelectedCountersKeys = ref<number[]>([])
147
- watch(
148
- () => props.selectedCountersKeys,
149
- (newValue) => {
150
- localSelectedCountersKeys.value = newValue
151
- },
152
- { immediate: true, deep: true }
153
- )
154
-
155
- const localSelectedChartType = ref<string>('')
156
- watch(
157
- () => props.selectedChartType,
158
- (newValue) => {
159
- localSelectedChartType.value = newValue
160
- },
161
- { immediate: true }
162
- )
163
-
164
- const localSelectedTimespanType = ref<string>('')
165
- watch(
166
- () => props.selectedTimespanType,
167
- (newValue) => {
168
- localSelectedTimespanType.value = newValue
169
- },
170
- { immediate: true }
171
- )
172
-
173
- const localUnitsCount = ref<number>(0)
174
- watch(
175
- () => props.unitsCount,
176
- (newValue) => {
177
- localUnitsCount.value = newValue
178
- },
179
- { immediate: true }
180
- )
181
-
182
- const localPeriodType = ref<string>('')
183
- watch(
184
- () => props.periodType,
185
- (newValue) => {
186
- localPeriodType.value = newValue
187
- },
188
- { immediate: true }
189
- )
190
-
191
- const localCustomTime = ref<string>('')
192
- watch(
193
- () => props.selectedCustomTime,
194
- (newValue) => {
195
- localCustomTime.value = newValue
196
- },
197
- { immediate: true }
198
- )
199
-
200
- const isShowAlerts = ref<boolean>(false)
201
- const alerts = ref<string[]>([''])
202
-
203
- const onRemoveAlerts = (): void => {
204
- isShowAlerts.value = false
205
- alerts.value = []
206
- }
207
-
208
- const onHide = (): void => {
209
- emits('hide')
210
- }
211
-
212
- const selectedRows = ref<UI_I_AdvancedCounterItem[]>([])
213
- const selectedChartTypeLocal = ref<string>('')
214
-
215
- const checkValidations = (): boolean => {
216
- const checkDateResult = checkDateFunc(
217
- localization.value,
218
- localCustomDateFrom.value,
219
- localCustomDateTo.value,
220
- localCustomTimeFrom.value,
221
- localCustomTimeTo.value
222
- )
223
-
224
- if (!selectedRows.value.length) {
225
- alerts.value = [localization.value.noCountersSelected]
226
- isShowAlerts.value = true
227
- return false
228
- } else if (
229
- timespanType.value === 'custom_interval' &&
230
- localPeriodType.value === 'period' &&
231
- checkDateResult !== '' &&
232
- typeof checkDateResult === 'string'
233
- ) {
234
- alerts.value = [checkDateResult]
235
- isShowAlerts.value = true
236
- return false
237
- }
238
-
239
- return true
240
- }
241
-
242
- const localSelectedChartOptionName = ref<string>('')
243
- watch(
244
- () => props.selectedChartOptionName,
245
- (newValue) => {
246
- localSelectedChartOptionName.value = newValue
247
- },
248
- { immediate: true }
249
- )
250
-
251
- const selectedLocalOptionName = ref<string>('')
252
-
253
- const selectedObjects = ref<string>('')
254
-
255
- const onSubmit = (): void => {
256
- if (!checkValidations()) return
257
-
258
- if (['select_options', 'default'].includes(selectedLocalOptionName.value))
259
- selectedLocalOptionName.value = 'custom'
260
-
261
- onSaveOptions(selectedLocalOptionName.value)
262
-
263
- // emits('select-chart-name', selectedLocalOptionName.value) +
264
- // emits('select-metric', selectedMetric.value) +
265
- // emits('select-row', selectedRows.value) +
266
- // emits('update-timespan-type', timespanType.value) +
267
- // emits('update-period-type', localPeriodType.value) +
268
- // emits('update-unit-count', unitCount.value) +
269
- // emits('update-custom-time', localCustomTime.value) +
270
- // emits('update-custom-date-from', localCustomDateFrom.value) +
271
- // emits('update-custom-date-to', localCustomDateTo.value) +
272
- // emits('update-custom-time-from', localCustomTimeFrom.value) +
273
- // emits('update-custom-time-to', localCustomTimeTo.value) +
274
- // emits('update-chart-type', selectedChartTypeLocal.value) +
275
- // emits('submit-options')
276
-
277
- const savedObject = {
278
- optionName: selectedLocalOptionName.value,
279
- metric: selectedMetric.value,
280
- counters: selectedRows.value,
281
- timespanType: timespanType.value,
282
- periodType: localPeriodType.value,
283
- unitCount: unitCount.value,
284
- localTimespanType: localCustomTime.value,
285
- dateFrom: localCustomDateFrom.value,
286
- timeFrom: localCustomTimeFrom.value,
287
- dateTo: localCustomDateTo.value,
288
- timeTo: localCustomTimeTo.value,
289
- chartType: selectedChartTypeLocal.value,
290
- objects: selectedObjects.value,
291
- }
292
-
293
- emits('submit-options', savedObject)
294
- onHide()
295
- }
296
-
297
- const timespanType = ref<string>('')
298
- const unitCount = ref<number>(1)
299
-
300
- const optionsNames = ref<string[]>([])
301
-
302
- const onSaveOptions = (name: string): void => {
303
- const counters = selectedRows.value.map((item) => {
304
- return {
305
- id: item.id,
306
- name: item.nameEn,
307
- }
308
- })
309
- let chartType = 'line_graph'
310
- if (selectedChartTypeLocal.value === 'spline') chartType = 'line_graph'
311
- else if (selectedChartTypeLocal.value === 'area') chartType = 'stacked_graph'
312
-
313
- const saveOptionsData = {
314
- routeType,
315
- chartType,
316
- counters,
317
- metric: selectedMetric.value,
318
- timespan: {
319
- periodType: localPeriodType.value,
320
- units: localCustomTime.value,
321
- unitsCount: unitCount.value,
322
- type: timespanType.value,
323
- },
324
- }
325
- useLocalStorage(`${name}ChartOptions`, saveOptionsData, false)
326
- optionsNames.value = getCurrentOptionsStorageFunc(routeType)
327
- localSelectedChartOptionName.value = name
328
- emits('save-option-name')
329
- }
330
-
331
- const setSelectOptions = (): void => {
332
- selectedMetric.value = props.selectedMetric || metricsItems.value[0]?.value
333
- localSelectedCountersKeys.value = props.selectedCountersKeys
334
- localSelectedChartType.value = props.selectedChartType
335
- localSelectedTimespanType.value = props.selectedTimespanType
336
- localUnitsCount.value = props.unitsCount
337
- localPeriodType.value = props.periodType
338
- localCustomTime.value = props.selectedCustomTime
339
- }
340
-
341
- const setDefaultOptions = (): void => {
342
- selectedMetric.value = metricsItems.value[0]?.value
343
- localSelectedCountersKeys.value = []
344
- localSelectedChartType.value = 'spline'
345
- localSelectedTimespanType.value = ''
346
- localUnitsCount.value = 0
347
- localPeriodType.value = ''
348
- localCustomTime.value = ''
349
- }
350
-
351
- const setCustomOptions = (name: string): void => {
352
- const selectedValue = useLocalStorage(name + 'ChartOptions', undefined, false)
353
-
354
- if (selectedValue.routeType !== routeType) return
355
-
356
- let currentChartType = ''
357
- if (selectedValue.chartType === 'line_graph') currentChartType = 'spline'
358
- else if (selectedValue.chartType === 'stacked_graph')
359
- currentChartType = 'area'
360
-
361
- selectedMetric.value = selectedValue.metric
362
- localSelectedCountersKeys.value = selectedValue.counters.map(
363
- (item) => item.id
364
- )
365
- localSelectedChartType.value = currentChartType
366
- localSelectedTimespanType.value = selectedValue.timespan.type
367
- localUnitsCount.value = selectedValue.timespan.unitsCount
368
- localPeriodType.value = selectedValue.timespan.periodType
369
- localCustomTime.value = selectedValue.timespan.units
370
- }
371
-
372
- const onSelectLocalOptionName = (name: string): void => {
373
- selectedLocalOptionName.value = name
374
-
375
- if (optionsNames.value.includes(name)) setCustomOptions(name)
376
- else if (name === 'default') setDefaultOptions()
377
- else if (name === 'select_options') setSelectOptions()
378
- }
379
-
380
- watch(
381
- localSelectedChartOptionName,
382
- (newValue) => {
383
- if (!newValue) return
384
-
385
- setCustomOptions(newValue)
386
- },
387
- { immediate: true }
388
- )
389
-
390
- const onDeleteChartName = (name: string): void => {
391
- window.localStorage.removeItem(name + 'ChartOptions')
392
- optionsNames.value = getCurrentOptionsStorageFunc(routeType)
393
- setSelectOptions()
394
- emits('delete-option')
395
- }
396
-
397
- onMounted(() => {
398
- optionsNames.value = getCurrentOptionsStorageFunc(routeType)
399
- })
400
- </script>
401
-
402
- <style scoped lang="scss">
403
- .chart-options-modal {
404
- .loader-on :deep(.modal-body) {
405
- display: flex;
406
- align-items: center;
407
- justify-content: center;
408
- }
409
- :deep(.modal-title) {
410
- text-transform: capitalize;
411
- }
412
-
413
- #loader {
414
- min-height: 90px;
415
- text-align: center;
416
- }
417
-
418
- .chart-options-content {
419
- display: flex;
420
- flex-direction: row;
421
- flex-basis: 90%;
422
- }
423
- }
424
- </style>
1
+ <template>
2
+ <div class="chart-options-modal">
3
+ <atoms-modal
4
+ width="1150px"
5
+ :show="true"
6
+ :title="localization.chartOptions"
7
+ :disabled-submit="isDisabledSubmit"
8
+ @hide="onHide"
9
+ @submit="onSubmit"
10
+ >
11
+ <template #modalBody>
12
+ <common-monitor-advanced-tools-chart-options-modal-notification
13
+ v-show="isShowAlerts"
14
+ :alerts="alerts"
15
+ @remove="onRemoveAlerts"
16
+ />
17
+ <div>
18
+ <common-monitor-advanced-tools-chart-options-modal-actions
19
+ :is-disabled-save="!selectedRows.length"
20
+ :options-names="optionsNames"
21
+ :selected-chart-option-name="localSelectedChartOptionName"
22
+ @save="onSaveOptions"
23
+ @check-validation="checkValidations"
24
+ @select-local-option-name="onSelectLocalOptionName"
25
+ @delete-chart-name="onDeleteChartName"
26
+ />
27
+
28
+ <div class="horizontal-flex-container chart-options-content">
29
+ <common-monitor-advanced-tools-chart-options-modal-metrics
30
+ v-model:selected-metric="selectedMetric"
31
+ :metrics-items="metricsItems"
32
+ />
33
+ <common-monitor-advanced-tools-chart-options-modal-counters
34
+ :chart="selectedMetric"
35
+ :language="props.language"
36
+ :type="props.type"
37
+ :selected-keys="localSelectedCountersKeys"
38
+ :selected-chart-type="localSelectedChartType"
39
+ :selected-timespan-type="localSelectedTimespanType"
40
+ :units-count="localUnitsCount"
41
+ :period-type="localPeriodType"
42
+ :selected-custom-time="localCustomTime"
43
+ :custom-date-from="props.customDateFrom"
44
+ :custom-date-to="props.customDateTo"
45
+ :custom-time-from="props.customTimeFrom"
46
+ :custom-time-to="props.customTimeTo"
47
+ :total-cores="props.totalCores"
48
+ :host-id="props.hostId"
49
+ :selected-metrics-keys="selectedMetricsKeys"
50
+ :selected-objects="props.selectedObjects"
51
+ @select-row="selectedRows = $event"
52
+ @update-chart-type="selectedChartTypeLocal = $event"
53
+ @update-custom-time="localCustomTime = $event"
54
+ @update-timespan-type="timespanType = $event"
55
+ @update-unit-count="unitCount = $event"
56
+ @update-period-type="localPeriodType = $event"
57
+ @update-custom-date-from="onUpdateCustomDateFrom"
58
+ @update-custom-date-to="onUpdateCustomDateTo"
59
+ @update-custom-time-from="onUpdateCustomTimeFrom"
60
+ @update-custom-time-to="onUpdateCustomTimeTo"
61
+ @select-objects="localSelectedObjects = $event"
62
+ />
63
+ </div>
64
+ </div>
65
+ </template>
66
+ </atoms-modal>
67
+ </div>
68
+ </template>
69
+
70
+ <script setup lang="ts">
71
+ import { UI_I_Localization } from '~/models/interfaces'
72
+ import { UI_T_AdvancedType } from '~/components/common/monitor/advanced/models/types'
73
+ import { UI_I_VerticalTabs } from '~/components/atoms/tabs/models/interfaces'
74
+ import { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/models/interfaces'
75
+ import {
76
+ T_ChartHost,
77
+ T_ChartVm,
78
+ } from '~/components/common/monitor/advanced/tools/chartOptionsModal/models/types'
79
+ import { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/models/models'
80
+ import { metricsFunc } from '~/components/common/monitor/advanced/tools/chartOptionsModal/metrics/config/optionsMetrics'
81
+ import { getCurrentOptionsStorageFunc } from '~/components/common/monitor/advanced/tools/config/advancedToolbar'
82
+ import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/config/dateChecker'
83
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/config/getValidDateByOption'
84
+
85
+ const props = defineProps<{
86
+ type: UI_T_AdvancedType
87
+ language: string
88
+ selectedCountersKeys: number[]
89
+ selectedMetric: T_ChartHost | T_ChartVm
90
+ selectedChartType: string
91
+ selectedTimespanType: string
92
+ unitsCount: number
93
+ periodType: string
94
+ selectedCustomTime: string
95
+ selectedChartOptionName: string
96
+ customDateFrom: string
97
+ customDateTo: string
98
+ customTimeFrom: string
99
+ customTimeTo: string
100
+ totalCores: number
101
+ hostId: string
102
+ selectedObjects: string
103
+ }>()
104
+
105
+ const emits = defineEmits<{
106
+ (event: 'hide'): void
107
+ (event: 'delete-option'): void
108
+ (event: 'save-option-name'): void
109
+ (event: 'submit-options', value: UI_I_OptionsForm): void
110
+ (event: 'select-objects', value: string): void
111
+ }>()
112
+
113
+ const routeType = '' + useRoute().params.type
114
+
115
+ const localization = computed<UI_I_Localization>(() => useLocal())
116
+
117
+ const localCustomDateFrom = ref<string>('')
118
+ const onUpdateCustomDateFrom = (value: string): void => {
119
+ localCustomDateFrom.value = value
120
+ }
121
+ const localCustomDateTo = ref<string>('')
122
+ const onUpdateCustomDateTo = (value: string): void => {
123
+ localCustomDateTo.value = value
124
+ }
125
+ const localCustomTimeFrom = ref<string>('')
126
+ const onUpdateCustomTimeFrom = (value: string): void => {
127
+ localCustomTimeFrom.value = value
128
+ }
129
+ const localCustomTimeTo = ref<string>('')
130
+ const onUpdateCustomTimeTo = (value: string): void => {
131
+ localCustomTimeTo.value = value
132
+ }
133
+
134
+ const metricsItems = computed<UI_I_VerticalTabs[]>(() =>
135
+ metricsFunc(localization.value, props.type)
136
+ )
137
+ const selectedMetric = ref<T_ChartHost | T_ChartVm>(
138
+ props.selectedMetric || '' + metricsItems.value[0]?.value
139
+ )
140
+
141
+ const localSelectedCountersKeys = ref<number[]>([])
142
+ watch(
143
+ () => props.selectedCountersKeys,
144
+ (newValue) => {
145
+ localSelectedCountersKeys.value = newValue
146
+ },
147
+ { immediate: true, deep: true }
148
+ )
149
+
150
+ const localSelectedChartType = ref<string>('')
151
+ watch(
152
+ () => props.selectedChartType,
153
+ (newValue) => {
154
+ localSelectedChartType.value = newValue
155
+ },
156
+ { immediate: true }
157
+ )
158
+
159
+ const localSelectedTimespanType = ref<string>('')
160
+ watch(
161
+ () => props.selectedTimespanType,
162
+ (newValue) => {
163
+ localSelectedTimespanType.value = newValue
164
+ },
165
+ { immediate: true }
166
+ )
167
+
168
+ const localUnitsCount = ref<number>(0)
169
+ watch(
170
+ () => props.unitsCount,
171
+ (newValue) => {
172
+ localUnitsCount.value = newValue
173
+ },
174
+ { immediate: true }
175
+ )
176
+
177
+ const localPeriodType = ref<string>('')
178
+ watch(
179
+ () => props.periodType,
180
+ (newValue) => {
181
+ localPeriodType.value = newValue
182
+ },
183
+ { immediate: true }
184
+ )
185
+
186
+ const localCustomTime = ref<string>('')
187
+ watch(
188
+ () => props.selectedCustomTime,
189
+ (newValue) => {
190
+ localCustomTime.value = newValue
191
+ },
192
+ { immediate: true }
193
+ )
194
+
195
+ const isShowAlerts = ref<boolean>(false)
196
+ const alerts = ref<string[]>([''])
197
+
198
+ const onRemoveAlerts = (): void => {
199
+ isShowAlerts.value = false
200
+ alerts.value = []
201
+ }
202
+
203
+ const onHide = (): void => {
204
+ emits('hide')
205
+ }
206
+
207
+ const selectedRows = ref<UI_I_AdvancedCounterItem[]>([])
208
+ const selectedMetricsKeys = computed<number[]>(() =>
209
+ selectedRows.value.map((item) => item.id)
210
+ )
211
+ const selectedChartTypeLocal = ref<string>('')
212
+
213
+ const checkValidations = (): boolean => {
214
+ const checkDateResult = checkDateFunc(
215
+ localization.value,
216
+ localCustomDateFrom.value,
217
+ localCustomDateTo.value,
218
+ localCustomTimeFrom.value,
219
+ localCustomTimeTo.value
220
+ )
221
+
222
+ if (!selectedRows.value.length) {
223
+ alerts.value = [localization.value.noCountersSelected]
224
+ isShowAlerts.value = true
225
+ return false
226
+ } else if (
227
+ timespanType.value === 'custom_interval' &&
228
+ localPeriodType.value === 'period' &&
229
+ checkDateResult !== '' &&
230
+ typeof checkDateResult === 'string'
231
+ ) {
232
+ alerts.value = [checkDateResult]
233
+ isShowAlerts.value = true
234
+ return false
235
+ }
236
+
237
+ return true
238
+ }
239
+
240
+ const localSelectedChartOptionName = ref<string>('')
241
+ watch(
242
+ () => props.selectedChartOptionName,
243
+ (newValue) => {
244
+ localSelectedChartOptionName.value = newValue
245
+ },
246
+ { immediate: true }
247
+ )
248
+
249
+ const selectedLocalOptionName = ref<string>('')
250
+
251
+ const localSelectedObjects = ref<string>('')
252
+
253
+ const currentFieldsByArray = (data: []): string => {
254
+ const result: string[] = []
255
+ data.forEach((item) => {
256
+ result.push(item.name)
257
+ })
258
+ return result.join(',')
259
+ }
260
+
261
+ const onSubmit = (): void => {
262
+ if (!checkValidations()) return
263
+
264
+ if (['select_options', 'default'].includes(selectedLocalOptionName.value))
265
+ selectedLocalOptionName.value = 'custom'
266
+
267
+ onSaveOptions(selectedLocalOptionName.value)
268
+
269
+ const currentFields =
270
+ localSelectedObjects.value || currentFieldsByArray(selectedRows.value)
271
+
272
+ const validPeriod = getValidDateByOptionFunc(
273
+ timespanType.value,
274
+ null,
275
+ unitCount.value,
276
+ localCustomTime.value
277
+ ).map((item) => Math.round(item / 1000))
278
+
279
+ if (
280
+ timespanType.value === 'custom_interval' &&
281
+ localPeriodType.value === 'period'
282
+ ) {
283
+ const checkDateResult = checkDateFunc(
284
+ localization.value,
285
+ localCustomDateFrom.value,
286
+ localCustomDateTo.value,
287
+ localCustomTimeFrom.value,
288
+ localCustomTimeTo.value
289
+ )
290
+ if (Array.isArray(checkDateResult)) {
291
+ validPeriod[0] = Math.round(checkDateResult[0] / 1000)
292
+ validPeriod[1] = Math.round(checkDateResult[1] / 1000)
293
+ }
294
+ }
295
+
296
+ const savedObject = {
297
+ fields: currentFields,
298
+ optionName: selectedLocalOptionName.value,
299
+ metric: selectedMetric.value,
300
+ counters: selectedRows.value,
301
+ timespanType: timespanType.value,
302
+ periodType: localPeriodType.value,
303
+ unitCount: unitCount.value,
304
+ localTimespanType: localCustomTime.value,
305
+ dateFrom: localCustomDateFrom.value,
306
+ timeFrom: localCustomTimeFrom.value,
307
+ dateTo: localCustomDateTo.value,
308
+ timeTo: localCustomTimeTo.value,
309
+ chartType: selectedChartTypeLocal.value,
310
+ objects: localSelectedObjects.value,
311
+ periodValue: validPeriod,
312
+ }
313
+
314
+ emits('submit-options', savedObject)
315
+ onHide()
316
+ }
317
+
318
+ const timespanType = ref<string>('')
319
+ const unitCount = ref<number>(1)
320
+
321
+ const optionsNames = ref<string[]>([])
322
+
323
+ const onSaveOptions = (name: string): void => {
324
+ const counters = selectedRows.value.map((item) => {
325
+ return {
326
+ id: item.id,
327
+ name: item.nameEn,
328
+ }
329
+ })
330
+ let chartType = 'line_graph'
331
+ if (selectedChartTypeLocal.value === 'spline') chartType = 'line_graph'
332
+ else if (selectedChartTypeLocal.value === 'area') chartType = 'stacked_graph'
333
+
334
+ const saveOptionsData = {
335
+ routeType,
336
+ chartType,
337
+ counters,
338
+ metric: selectedMetric.value,
339
+ timespan: {
340
+ periodType: localPeriodType.value,
341
+ units: localCustomTime.value,
342
+ unitsCount: unitCount.value,
343
+ type: timespanType.value,
344
+ },
345
+ }
346
+ useLocalStorage(`${name}ChartOptions`, saveOptionsData, false)
347
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType)
348
+ localSelectedChartOptionName.value = name
349
+ emits('save-option-name')
350
+ }
351
+
352
+ const setSelectOptions = (): void => {
353
+ selectedMetric.value = props.selectedMetric || metricsItems.value[0]?.value
354
+ localSelectedCountersKeys.value = props.selectedCountersKeys
355
+ localSelectedChartType.value = props.selectedChartType
356
+ localSelectedTimespanType.value = props.selectedTimespanType
357
+ localUnitsCount.value = props.unitsCount
358
+ localPeriodType.value = props.periodType
359
+ localCustomTime.value = props.selectedCustomTime
360
+ }
361
+
362
+ const setDefaultOptions = (): void => {
363
+ selectedMetric.value = metricsItems.value[0]?.value
364
+ localSelectedCountersKeys.value = []
365
+ localSelectedChartType.value = 'spline'
366
+ localSelectedTimespanType.value = ''
367
+ localUnitsCount.value = 0
368
+ localPeriodType.value = ''
369
+ localCustomTime.value = ''
370
+ }
371
+
372
+ const setCustomOptions = (name: string): void => {
373
+ const selectedValue = useLocalStorage(name + 'ChartOptions', undefined, false)
374
+
375
+ if (selectedValue.routeType !== routeType) return
376
+
377
+ let currentChartType = ''
378
+ if (selectedValue.chartType === 'line_graph') currentChartType = 'spline'
379
+ else if (selectedValue.chartType === 'stacked_graph')
380
+ currentChartType = 'area'
381
+
382
+ selectedMetric.value = selectedValue.metric
383
+ localSelectedCountersKeys.value = selectedValue.counters.map(
384
+ (item) => item.id
385
+ )
386
+ localSelectedChartType.value = currentChartType
387
+ localSelectedTimespanType.value = selectedValue.timespan.type
388
+ localUnitsCount.value = selectedValue.timespan.unitsCount
389
+ localPeriodType.value = selectedValue.timespan.periodType
390
+ localCustomTime.value = selectedValue.timespan.units
391
+ }
392
+
393
+ const onSelectLocalOptionName = (name: string): void => {
394
+ selectedLocalOptionName.value = name
395
+
396
+ if (optionsNames.value.includes(name)) setCustomOptions(name)
397
+ else if (name === 'default') setDefaultOptions()
398
+ else if (name === 'select_options') setSelectOptions()
399
+ }
400
+
401
+ watch(
402
+ localSelectedChartOptionName,
403
+ (newValue) => {
404
+ if (!newValue) return
405
+
406
+ setCustomOptions(newValue)
407
+ },
408
+ { immediate: true }
409
+ )
410
+
411
+ const onDeleteChartName = (name: string): void => {
412
+ window.localStorage.removeItem(name + 'ChartOptions')
413
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType)
414
+ setSelectOptions()
415
+ emits('delete-option')
416
+ }
417
+
418
+ const isDisabledSubmit = computed<boolean>(
419
+ () =>
420
+ props.type === 'host' &&
421
+ selectedMetric.value === 'cpu' &&
422
+ !localSelectedObjects.value
423
+ )
424
+
425
+ onMounted(() => {
426
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType)
427
+ })
428
+ </script>
429
+
430
+ <style scoped lang="scss">
431
+ .chart-options-modal {
432
+ .loader-on :deep(.modal-body) {
433
+ display: flex;
434
+ align-items: center;
435
+ justify-content: center;
436
+ }
437
+ :deep(.modal-title) {
438
+ text-transform: capitalize;
439
+ }
440
+
441
+ #loader {
442
+ min-height: 90px;
443
+ text-align: center;
444
+ }
445
+
446
+ .chart-options-content {
447
+ display: flex;
448
+ flex-direction: row;
449
+ flex-basis: 90%;
450
+ }
451
+ }
452
+ </style>