bfg-common 1.4.723 → 1.4.725

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 (35) hide show
  1. package/assets/localization/local_be.json +5 -2
  2. package/assets/localization/local_en.json +5 -2
  3. package/assets/localization/local_hy.json +5 -2
  4. package/assets/localization/local_kk.json +5 -2
  5. package/assets/localization/local_ru.json +5 -2
  6. package/assets/localization/local_zh.json +5 -2
  7. package/assets/scss/clarity/local_ar.json +2916 -0
  8. package/assets/scss/common/normalize.scss +6 -0
  9. package/components/common/browse/blocks/contents/Files.vue +1 -1
  10. package/components/common/layout/theHeader/lib/models/enums.ts +1 -0
  11. package/components/common/layout/theHeader/userMenu/modals/preferences/changeLanguage/ChangeLanguage.vue +5 -2
  12. package/components/common/mainNavigationPanel/MainNavigationPanelOld.vue +36 -20
  13. package/components/common/monitor/advanced/Advanced.vue +244 -244
  14. package/components/common/monitor/advanced/tools/Tools.vue +447 -447
  15. package/components/common/monitor/advanced/tools/chartOptionsModal/ChartOptionsModal.vue +511 -511
  16. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/Counters.vue +108 -108
  17. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/Timespan.vue +95 -95
  18. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/form/Form.vue +544 -544
  19. package/components/common/monitor/overview/filters/Filters.vue +235 -235
  20. package/components/common/monitor/overview/filters/customIntervalModal/CustomIntervalModal.vue +250 -250
  21. package/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker.ts +62 -62
  22. package/components/common/pages/hardwareHealth/HardwareHealth.vue +213 -213
  23. package/components/common/pages/hardwareHealth/historyTestimony/Graph.vue +456 -456
  24. package/components/common/pages/hardwareHealth/historyTestimony/tools/Tools.vue +387 -387
  25. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/ChartOptionsModal.vue +494 -494
  26. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/Counters.vue +96 -96
  27. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/timespan/Timespan.vue +68 -68
  28. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/timespan/form/Form.vue +544 -544
  29. package/components/common/recursionTree/RecursionTree.vue +29 -18
  30. package/components/common/selectLanguage/lib/config/config.ts +5 -0
  31. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/MediaNew.vue +17 -2
  32. package/components/common/vm/actions/common/customizeHardware/virtualHardware/cdDvdDrive/media/MediaOld.vue +11 -3
  33. package/composables/useLocal.ts +5 -0
  34. package/layouts/auth.vue +1 -0
  35. package/package.json +1 -1
@@ -1,511 +1,511 @@
1
- <template>
2
- <div class="chart-options-modal">
3
- <atoms-modal
4
- width="1150px"
5
- :show="true"
6
- :title="localization.inventoryMonitor.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
- :objects-loading="props.objectsLoading"
52
- :objects-data="props.objectsData"
53
- :valid-date-end="props.validDateEnd"
54
- @select-row="selectedRows = $event"
55
- @update-chart-type="selectedChartTypeLocal = $event"
56
- @update-custom-time="localCustomTime = $event"
57
- @update-timespan-type="timespanType = $event"
58
- @update-unit-count="unitCount = $event"
59
- @update-period-type="localPeriodType = $event"
60
- @update-custom-date-from="onUpdateCustomDateFrom"
61
- @update-custom-date-to="onUpdateCustomDateTo"
62
- @update-custom-time-from="onUpdateCustomTimeFrom"
63
- @update-custom-time-to="onUpdateCustomTimeTo"
64
- @select-objects="localSelectedObjects = $event"
65
- />
66
- </div>
67
- </div>
68
- </template>
69
- </atoms-modal>
70
- </div>
71
- </template>
72
-
73
- <script setup lang="ts">
74
- import type { UI_I_Localization } from '~/lib/models/interfaces'
75
- import type { UI_T_AdvancedType } from '~/components/common/monitor/advanced/lib/models/types'
76
- import type { UI_I_VerticalTabs } from '~/components/atoms/tabs/lib/models/interfaces'
77
- import type { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/models/interfaces'
78
- import type {
79
- UI_T_ChartHost,
80
- UI_T_ChartVm,
81
- } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/types'
82
- import type { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/interfaces'
83
- import type { UI_I_ObjectItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/models/interfaces'
84
- import type { UI_T_Project } from '~/lib/models/types'
85
- import { metricsFunc } from '~/components/common/monitor/advanced/tools/chartOptionsModal/metrics/lib/config/optionsMetrics'
86
- import { getCurrentOptionsStorageFunc } from '~/components/common/monitor/advanced/tools/lib/config/advancedToolbar'
87
- import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
88
- import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
89
- import { checkIsDisabledSubmit } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/utils/checkSubmit'
90
-
91
- const props = defineProps<{
92
- type: UI_T_AdvancedType
93
- language: string
94
- selectedCountersKeys: number[]
95
- selectedMetric: UI_T_ChartHost | UI_T_ChartVm
96
- selectedMetricLocal: UI_T_ChartHost | UI_T_ChartVm
97
- selectedChartType: string
98
- selectedTimespanType: string
99
- unitsCount: number
100
- periodType: string
101
- selectedCustomTime: string
102
- selectedChartOptionName: string
103
- customDateFrom: string
104
- customDateTo: string
105
- customTimeFrom: string
106
- customTimeTo: string
107
- totalCores: number
108
- hostId: string
109
- selectedObjects: string
110
- project: UI_T_Project
111
- objectsLoading: boolean
112
- objectsData: UI_I_ObjectItem[]
113
- validDateEnd: number
114
- formatDate: string
115
- }>()
116
-
117
- const emits = defineEmits<{
118
- (event: 'hide'): void
119
- (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
120
- (event: 'select-metric-local', value: string): void
121
- (event: 'update-chart-type', value: string): void
122
- (event: 'update-timespan-type', value: string): void
123
- (event: 'update-unit-count', value: number): void
124
- (event: 'update-period-type', value: string): void
125
- (event: 'update-custom-time', value: string): void
126
- (event: 'delete-option'): void
127
- (event: 'save-option-name'): void
128
- (event: 'submit-options', value: UI_I_OptionsForm): void
129
- (event: 'select-objects', value: string): void
130
- }>()
131
-
132
- const routeType = '' + useRoute().params.type
133
-
134
- const localization = computed<UI_I_Localization>(() => useLocal())
135
-
136
- const localCustomDateFrom = ref<string>('')
137
- const onUpdateCustomDateFrom = (value: string): void => {
138
- localCustomDateFrom.value = value
139
- }
140
- const localCustomDateTo = ref<string>('')
141
- const onUpdateCustomDateTo = (value: string): void => {
142
- localCustomDateTo.value = value
143
- }
144
- const localCustomTimeFrom = ref<string>('')
145
- const onUpdateCustomTimeFrom = (value: string): void => {
146
- localCustomTimeFrom.value = value
147
- }
148
- const localCustomTimeTo = ref<string>('')
149
- const onUpdateCustomTimeTo = (value: string): void => {
150
- localCustomTimeTo.value = value
151
- }
152
-
153
- const metricsItems = computed<UI_I_VerticalTabs[]>(() =>
154
- metricsFunc(localization.value, props.type)
155
- )
156
- const selectedMetric = ref<UI_T_ChartHost | UI_T_ChartVm>(
157
- props.selectedMetric || '' + metricsItems.value[0]?.value
158
- )
159
-
160
- const localSelectedCountersKeys = ref<number[]>([])
161
- watch(
162
- () => props.selectedCountersKeys,
163
- (newValue) => {
164
- localSelectedCountersKeys.value = newValue
165
- },
166
- { immediate: true, deep: true }
167
- )
168
-
169
- const localSelectedChartType = ref<string>('')
170
- watch(
171
- () => props.selectedChartType,
172
- (newValue) => {
173
- localSelectedChartType.value = newValue
174
- },
175
- { immediate: true }
176
- )
177
-
178
- const localSelectedTimespanType = ref<string>('')
179
- watch(
180
- () => props.selectedTimespanType,
181
- (newValue) => {
182
- localSelectedTimespanType.value = newValue
183
- },
184
- { immediate: true }
185
- )
186
-
187
- const localUnitsCount = ref<number>(0)
188
- watch(
189
- () => props.unitsCount,
190
- (newValue) => {
191
- localUnitsCount.value = newValue
192
- },
193
- { immediate: true }
194
- )
195
-
196
- const localPeriodType = ref<string>('')
197
- watch(
198
- () => props.periodType,
199
- (newValue) => {
200
- localPeriodType.value = newValue
201
- },
202
- { immediate: true }
203
- )
204
-
205
- const localCustomTime = ref<string>('')
206
- watch(
207
- () => props.selectedCustomTime,
208
- (newValue) => {
209
- localCustomTime.value = newValue
210
- },
211
- { immediate: true }
212
- )
213
-
214
- const isShowAlerts = ref<boolean>(false)
215
- const alerts = ref<string[]>([])
216
-
217
- const onRemoveAlerts = (): void => {
218
- isShowAlerts.value = false
219
- alerts.value = []
220
- }
221
-
222
- const onHide = (): void => {
223
- emits('hide')
224
- }
225
-
226
- const selectedRows = ref<UI_I_AdvancedCounterItem[]>([])
227
- const selectedMetricsKeys = computed<number[]>(() =>
228
- selectedRows.value.map((item) => item.id)
229
- )
230
- const selectedChartTypeLocal = ref<string>('')
231
-
232
- const checkValidations = (): boolean => {
233
- const checkDateResult = checkDateFunc(
234
- localization.value,
235
- localCustomDateFrom.value,
236
- localCustomDateTo.value,
237
- localCustomTimeFrom.value,
238
- localCustomTimeTo.value,
239
- props.validDateEnd,
240
- props.formatDate
241
- )
242
-
243
- if (isDisabledSubmit.value) {
244
- alerts.value = [localization.value.inventoryMonitor.noCountersSelected]
245
- isShowAlerts.value = true
246
- return false
247
- } else if (
248
- timespanType.value === 'custom_interval' &&
249
- localPeriodType.value === 'period' &&
250
- checkDateResult !== '' &&
251
- typeof checkDateResult === 'string'
252
- ) {
253
- alerts.value = [checkDateResult]
254
- isShowAlerts.value = true
255
- return false
256
- }
257
-
258
- return true
259
- }
260
-
261
- const localSelectedChartOptionName = ref<string>('')
262
- watch(
263
- () => props.selectedChartOptionName,
264
- (newValue) => {
265
- localSelectedChartOptionName.value = newValue
266
- },
267
- { immediate: true }
268
- )
269
-
270
- const selectedLocalOptionName = ref<string>('')
271
-
272
- const localSelectedObjects = ref<string>('')
273
-
274
- const currentFieldsByArray = (data: UI_I_AdvancedCounterItem[]): string => {
275
- const result: string[] = []
276
-
277
- data.forEach((item) => {
278
- if (props.type === 'vm' && selectedMetric.value === 'network') {
279
- const currentFields = []
280
- const objectArray = localSelectedObjects.value.split(', ')
281
- if (objectArray.length) {
282
- objectArray.forEach((item2) => {
283
- currentFields.push(`${item.nameEn} ${item2}`)
284
- })
285
- } else currentFields.push(item.nameEn)
286
-
287
- result.push(currentFields.join(', '))
288
- } else result.push(item.nameEn)
289
- })
290
-
291
- return result.join(',')
292
- }
293
-
294
- const onSubmit = (): void => {
295
- if (!checkValidations()) return
296
-
297
- if (['select_options', 'default'].includes(selectedLocalOptionName.value))
298
- selectedLocalOptionName.value = 'custom'
299
-
300
- onSaveOptions(selectedLocalOptionName.value)
301
-
302
- // const currentFields =
303
- // localSelectedObjects.value || currentFieldsByArray(selectedRows.value)
304
-
305
- const currentFields = currentFieldsByArray(selectedRows.value)
306
-
307
- const validPeriod = getValidDateByOptionFunc(
308
- timespanType.value,
309
- null,
310
- unitCount.value,
311
- localCustomTime.value
312
- ).map((item) => Math.round(item / 1000))
313
-
314
- if (
315
- timespanType.value === 'custom_interval' &&
316
- localPeriodType.value === 'period'
317
- ) {
318
- const checkDateResult = checkDateFunc(
319
- localization.value,
320
- localCustomDateFrom.value,
321
- localCustomDateTo.value,
322
- localCustomTimeFrom.value,
323
- localCustomTimeTo.value,
324
- props.validDateEnd,
325
- props.formatDate
326
- )
327
- if (Array.isArray(checkDateResult)) {
328
- validPeriod[0] = Math.round(checkDateResult[0] / 1000)
329
- validPeriod[1] = Math.round(checkDateResult[1] / 1000)
330
- }
331
- }
332
-
333
- const savedObject = {
334
- fields: currentFields,
335
- optionName: selectedLocalOptionName.value,
336
- metric: selectedMetric.value,
337
- counters: selectedRows.value,
338
- timespanType: timespanType.value,
339
- periodType: localPeriodType.value,
340
- unitCount: unitCount.value,
341
- localTimespanType: localCustomTime.value,
342
- dateFrom: localCustomDateFrom.value,
343
- timeFrom: localCustomTimeFrom.value,
344
- dateTo: localCustomDateTo.value,
345
- timeTo: localCustomTimeTo.value,
346
- chartType: selectedChartTypeLocal.value,
347
- objects: localSelectedObjects.value,
348
- periodValue: validPeriod,
349
- }
350
-
351
- emits('submit-options', savedObject)
352
- onHide()
353
- }
354
-
355
- const timespanType = ref<string>('')
356
- const unitCount = ref<number>(1)
357
-
358
- const optionsNames = ref<string[]>([])
359
-
360
- const onSaveOptions = (name: string): void => {
361
- const counters = selectedRows.value.map((item) => {
362
- return {
363
- id: item.id,
364
- name: item.nameEn,
365
- }
366
- })
367
- let chartType = 'line_graph'
368
- if (selectedChartTypeLocal.value === 'spline') chartType = 'line_graph'
369
- else if (selectedChartTypeLocal.value === 'area') chartType = 'stacked_graph'
370
-
371
- const saveOptionsData = {
372
- routeType,
373
- chartType,
374
- counters,
375
- metric: selectedMetric.value,
376
- timespan: {
377
- periodType: localPeriodType.value,
378
- units: localCustomTime.value,
379
- unitsCount: unitCount.value,
380
- type: timespanType.value,
381
- },
382
- }
383
- const prefix = props.project === 'sphere'
384
- useLocalStorage(`${name}ChartOptions`, saveOptionsData, prefix)
385
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
386
- localSelectedChartOptionName.value = name
387
- emits('save-option-name')
388
- }
389
-
390
- const setSelectOptions = (): void => {
391
- selectedMetric.value = props.selectedMetric || metricsItems.value[0]?.value
392
- localSelectedCountersKeys.value = props.selectedCountersKeys
393
- localSelectedChartType.value = props.selectedChartType
394
- localSelectedTimespanType.value = props.selectedTimespanType
395
- localUnitsCount.value = props.unitsCount
396
- localPeriodType.value = props.periodType
397
- localCustomTime.value = props.selectedCustomTime
398
- }
399
-
400
- const setDefaultOptions = (): void => {
401
- selectedMetric.value = metricsItems.value[0]?.value
402
- localSelectedCountersKeys.value = []
403
- localSelectedChartType.value = 'spline'
404
- localSelectedTimespanType.value = ''
405
- localUnitsCount.value = 0
406
- localPeriodType.value = ''
407
- localCustomTime.value = ''
408
- }
409
-
410
- const setCustomOptions = (name: string): void => {
411
- const prefix = props.project === 'sphere'
412
- const selectedValue = useLocalStorage(
413
- name + 'ChartOptions',
414
- undefined,
415
- prefix
416
- )
417
-
418
- if (selectedValue.routeType !== routeType) return
419
-
420
- let currentChartType = ''
421
- if (selectedValue.chartType === 'line_graph') currentChartType = 'spline'
422
- else if (selectedValue.chartType === 'stacked_graph')
423
- currentChartType = 'area'
424
-
425
- selectedMetric.value = selectedValue.metric
426
- localSelectedCountersKeys.value = selectedValue.counters.map(
427
- (item) => item.id
428
- )
429
- localSelectedChartType.value = currentChartType
430
- localSelectedTimespanType.value = selectedValue.timespan.type
431
- localUnitsCount.value = selectedValue.timespan.unitsCount
432
- localPeriodType.value = selectedValue.timespan.periodType
433
- localCustomTime.value = selectedValue.timespan.units
434
- }
435
-
436
- const onSelectLocalOptionName = (name: string): void => {
437
- selectedLocalOptionName.value = name
438
-
439
- if (optionsNames.value.includes(name)) setCustomOptions(name)
440
- else if (name === 'default') setDefaultOptions()
441
- else if (name === 'select_options') setSelectOptions()
442
- }
443
-
444
- watch(
445
- localSelectedChartOptionName,
446
- (newValue) => {
447
- if (!newValue) return
448
-
449
- setCustomOptions(newValue)
450
- },
451
- { immediate: true }
452
- )
453
-
454
- const onDeleteChartName = (name: string): void => {
455
- window.localStorage.removeItem(name + 'ChartOptions')
456
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
457
- setSelectOptions()
458
- emits('delete-option')
459
- }
460
-
461
- const isDisabledSubmit = computed<boolean>(() =>
462
- checkIsDisabledSubmit(
463
- props.type,
464
- selectedMetric.value,
465
- selectedRows.value.length,
466
- localSelectedObjects.value
467
- )
468
- )
469
-
470
- watch(
471
- selectedMetric,
472
- (newValue) => {
473
- emits('select-metric-local', newValue)
474
- },
475
- { immediate: true }
476
- )
477
-
478
- onMounted(() => {
479
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
480
- })
481
- </script>
482
-
483
- <style scoped lang="scss">
484
- .chart-options-modal {
485
- .loader-on :deep(.modal-body) {
486
- display: flex;
487
- align-items: center;
488
- justify-content: center;
489
- }
490
- :deep(.modal-title) {
491
- text-transform: capitalize;
492
- }
493
-
494
- #loader {
495
- min-height: 90px;
496
- text-align: center;
497
- }
498
-
499
- .chart-options-content {
500
- display: flex;
501
- flex-direction: row;
502
- flex-basis: 90%;
503
- overflow-y: hidden;
504
- }
505
- }
506
- @media (max-width: 1024px) {
507
- .chart-options-content {
508
- flex-direction: column !important;
509
- }
510
- }
511
- </style>
1
+ <template>
2
+ <div class="chart-options-modal">
3
+ <atoms-modal
4
+ width="1150px"
5
+ :show="true"
6
+ :title="localization.inventoryMonitor.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
+ :objects-loading="props.objectsLoading"
52
+ :objects-data="props.objectsData"
53
+ :valid-date-end="props.validDateEnd"
54
+ @select-row="selectedRows = $event"
55
+ @update-chart-type="selectedChartTypeLocal = $event"
56
+ @update-custom-time="localCustomTime = $event"
57
+ @update-timespan-type="timespanType = $event"
58
+ @update-unit-count="unitCount = $event"
59
+ @update-period-type="localPeriodType = $event"
60
+ @update-custom-date-from="onUpdateCustomDateFrom"
61
+ @update-custom-date-to="onUpdateCustomDateTo"
62
+ @update-custom-time-from="onUpdateCustomTimeFrom"
63
+ @update-custom-time-to="onUpdateCustomTimeTo"
64
+ @select-objects="localSelectedObjects = $event"
65
+ />
66
+ </div>
67
+ </div>
68
+ </template>
69
+ </atoms-modal>
70
+ </div>
71
+ </template>
72
+
73
+ <script setup lang="ts">
74
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
75
+ import type { UI_T_AdvancedType } from '~/components/common/monitor/advanced/lib/models/types'
76
+ import type { UI_I_VerticalTabs } from '~/components/atoms/tabs/lib/models/interfaces'
77
+ import type { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/models/interfaces'
78
+ import type {
79
+ UI_T_ChartHost,
80
+ UI_T_ChartVm,
81
+ } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/types'
82
+ import type { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/interfaces'
83
+ import type { UI_I_ObjectItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/models/interfaces'
84
+ import type { UI_T_Project } from '~/lib/models/types'
85
+ import { metricsFunc } from '~/components/common/monitor/advanced/tools/chartOptionsModal/metrics/lib/config/optionsMetrics'
86
+ import { getCurrentOptionsStorageFunc } from '~/components/common/monitor/advanced/tools/lib/config/advancedToolbar'
87
+ import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
88
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
89
+ import { checkIsDisabledSubmit } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/utils/checkSubmit'
90
+
91
+ const props = defineProps<{
92
+ type: UI_T_AdvancedType
93
+ language: string
94
+ selectedCountersKeys: number[]
95
+ selectedMetric: UI_T_ChartHost | UI_T_ChartVm
96
+ selectedMetricLocal: UI_T_ChartHost | UI_T_ChartVm
97
+ selectedChartType: string
98
+ selectedTimespanType: string
99
+ unitsCount: number
100
+ periodType: string
101
+ selectedCustomTime: string
102
+ selectedChartOptionName: string
103
+ customDateFrom: string
104
+ customDateTo: string
105
+ customTimeFrom: string
106
+ customTimeTo: string
107
+ totalCores: number
108
+ hostId: string
109
+ selectedObjects: string
110
+ project: UI_T_Project
111
+ objectsLoading: boolean
112
+ objectsData: UI_I_ObjectItem[]
113
+ validDateEnd: number
114
+ formatDate: string
115
+ }>()
116
+
117
+ const emits = defineEmits<{
118
+ (event: 'hide'): void
119
+ (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
120
+ (event: 'select-metric-local', value: string): void
121
+ (event: 'update-chart-type', value: string): void
122
+ (event: 'update-timespan-type', value: string): void
123
+ (event: 'update-unit-count', value: number): void
124
+ (event: 'update-period-type', value: string): void
125
+ (event: 'update-custom-time', value: string): void
126
+ (event: 'delete-option'): void
127
+ (event: 'save-option-name'): void
128
+ (event: 'submit-options', value: UI_I_OptionsForm): void
129
+ (event: 'select-objects', value: string): void
130
+ }>()
131
+
132
+ const routeType = '' + useRoute().params.type
133
+
134
+ const localization = computed<UI_I_Localization>(() => useLocal())
135
+
136
+ const localCustomDateFrom = ref<string>('')
137
+ const onUpdateCustomDateFrom = (value: string): void => {
138
+ localCustomDateFrom.value = value
139
+ }
140
+ const localCustomDateTo = ref<string>('')
141
+ const onUpdateCustomDateTo = (value: string): void => {
142
+ localCustomDateTo.value = value
143
+ }
144
+ const localCustomTimeFrom = ref<string>('')
145
+ const onUpdateCustomTimeFrom = (value: string): void => {
146
+ localCustomTimeFrom.value = value
147
+ }
148
+ const localCustomTimeTo = ref<string>('')
149
+ const onUpdateCustomTimeTo = (value: string): void => {
150
+ localCustomTimeTo.value = value
151
+ }
152
+
153
+ const metricsItems = computed<UI_I_VerticalTabs[]>(() =>
154
+ metricsFunc(localization.value, props.type)
155
+ )
156
+ const selectedMetric = ref<UI_T_ChartHost | UI_T_ChartVm>(
157
+ props.selectedMetric || '' + metricsItems.value[0]?.value
158
+ )
159
+
160
+ const localSelectedCountersKeys = ref<number[]>([])
161
+ watch(
162
+ () => props.selectedCountersKeys,
163
+ (newValue) => {
164
+ localSelectedCountersKeys.value = newValue
165
+ },
166
+ { immediate: true, deep: true }
167
+ )
168
+
169
+ const localSelectedChartType = ref<string>('')
170
+ watch(
171
+ () => props.selectedChartType,
172
+ (newValue) => {
173
+ localSelectedChartType.value = newValue
174
+ },
175
+ { immediate: true }
176
+ )
177
+
178
+ const localSelectedTimespanType = ref<string>('')
179
+ watch(
180
+ () => props.selectedTimespanType,
181
+ (newValue) => {
182
+ localSelectedTimespanType.value = newValue
183
+ },
184
+ { immediate: true }
185
+ )
186
+
187
+ const localUnitsCount = ref<number>(0)
188
+ watch(
189
+ () => props.unitsCount,
190
+ (newValue) => {
191
+ localUnitsCount.value = newValue
192
+ },
193
+ { immediate: true }
194
+ )
195
+
196
+ const localPeriodType = ref<string>('')
197
+ watch(
198
+ () => props.periodType,
199
+ (newValue) => {
200
+ localPeriodType.value = newValue
201
+ },
202
+ { immediate: true }
203
+ )
204
+
205
+ const localCustomTime = ref<string>('')
206
+ watch(
207
+ () => props.selectedCustomTime,
208
+ (newValue) => {
209
+ localCustomTime.value = newValue
210
+ },
211
+ { immediate: true }
212
+ )
213
+
214
+ const isShowAlerts = ref<boolean>(false)
215
+ const alerts = ref<string[]>([])
216
+
217
+ const onRemoveAlerts = (): void => {
218
+ isShowAlerts.value = false
219
+ alerts.value = []
220
+ }
221
+
222
+ const onHide = (): void => {
223
+ emits('hide')
224
+ }
225
+
226
+ const selectedRows = ref<UI_I_AdvancedCounterItem[]>([])
227
+ const selectedMetricsKeys = computed<number[]>(() =>
228
+ selectedRows.value.map((item) => item.id)
229
+ )
230
+ const selectedChartTypeLocal = ref<string>('')
231
+
232
+ const checkValidations = (): boolean => {
233
+ const checkDateResult = checkDateFunc(
234
+ localization.value,
235
+ localCustomDateFrom.value,
236
+ localCustomDateTo.value,
237
+ localCustomTimeFrom.value,
238
+ localCustomTimeTo.value,
239
+ props.validDateEnd,
240
+ props.formatDate
241
+ )
242
+
243
+ if (isDisabledSubmit.value) {
244
+ alerts.value = [localization.value.inventoryMonitor.noCountersSelected]
245
+ isShowAlerts.value = true
246
+ return false
247
+ } else if (
248
+ timespanType.value === 'custom_interval' &&
249
+ localPeriodType.value === 'period' &&
250
+ checkDateResult !== '' &&
251
+ typeof checkDateResult === 'string'
252
+ ) {
253
+ alerts.value = [checkDateResult]
254
+ isShowAlerts.value = true
255
+ return false
256
+ }
257
+
258
+ return true
259
+ }
260
+
261
+ const localSelectedChartOptionName = ref<string>('')
262
+ watch(
263
+ () => props.selectedChartOptionName,
264
+ (newValue) => {
265
+ localSelectedChartOptionName.value = newValue
266
+ },
267
+ { immediate: true }
268
+ )
269
+
270
+ const selectedLocalOptionName = ref<string>('')
271
+
272
+ const localSelectedObjects = ref<string>('')
273
+
274
+ const currentFieldsByArray = (data: UI_I_AdvancedCounterItem[]): string => {
275
+ const result: string[] = []
276
+
277
+ data.forEach((item) => {
278
+ if (props.type === 'vm' && selectedMetric.value === 'network') {
279
+ const currentFields = []
280
+ const objectArray = localSelectedObjects.value.split(', ')
281
+ if (objectArray.length) {
282
+ objectArray.forEach((item2) => {
283
+ currentFields.push(`${item.nameEn} ${item2}`)
284
+ })
285
+ } else currentFields.push(item.nameEn)
286
+
287
+ result.push(currentFields.join(', '))
288
+ } else result.push(item.nameEn)
289
+ })
290
+
291
+ return result.join(',')
292
+ }
293
+
294
+ const onSubmit = (): void => {
295
+ if (!checkValidations()) return
296
+
297
+ if (['select_options', 'default'].includes(selectedLocalOptionName.value))
298
+ selectedLocalOptionName.value = 'custom'
299
+
300
+ onSaveOptions(selectedLocalOptionName.value)
301
+
302
+ // const currentFields =
303
+ // localSelectedObjects.value || currentFieldsByArray(selectedRows.value)
304
+
305
+ const currentFields = currentFieldsByArray(selectedRows.value)
306
+
307
+ const validPeriod = getValidDateByOptionFunc(
308
+ timespanType.value,
309
+ null,
310
+ unitCount.value,
311
+ localCustomTime.value
312
+ ).map((item) => Math.round(item / 1000))
313
+
314
+ if (
315
+ timespanType.value === 'custom_interval' &&
316
+ localPeriodType.value === 'period'
317
+ ) {
318
+ const checkDateResult = checkDateFunc(
319
+ localization.value,
320
+ localCustomDateFrom.value,
321
+ localCustomDateTo.value,
322
+ localCustomTimeFrom.value,
323
+ localCustomTimeTo.value,
324
+ props.validDateEnd,
325
+ props.formatDate
326
+ )
327
+ if (Array.isArray(checkDateResult)) {
328
+ validPeriod[0] = Math.round(checkDateResult[0] / 1000)
329
+ validPeriod[1] = Math.round(checkDateResult[1] / 1000)
330
+ }
331
+ }
332
+
333
+ const savedObject = {
334
+ fields: currentFields,
335
+ optionName: selectedLocalOptionName.value,
336
+ metric: selectedMetric.value,
337
+ counters: selectedRows.value,
338
+ timespanType: timespanType.value,
339
+ periodType: localPeriodType.value,
340
+ unitCount: unitCount.value,
341
+ localTimespanType: localCustomTime.value,
342
+ dateFrom: localCustomDateFrom.value,
343
+ timeFrom: localCustomTimeFrom.value,
344
+ dateTo: localCustomDateTo.value,
345
+ timeTo: localCustomTimeTo.value,
346
+ chartType: selectedChartTypeLocal.value,
347
+ objects: localSelectedObjects.value,
348
+ periodValue: validPeriod,
349
+ }
350
+
351
+ emits('submit-options', savedObject)
352
+ onHide()
353
+ }
354
+
355
+ const timespanType = ref<string>('')
356
+ const unitCount = ref<number>(1)
357
+
358
+ const optionsNames = ref<string[]>([])
359
+
360
+ const onSaveOptions = (name: string): void => {
361
+ const counters = selectedRows.value.map((item) => {
362
+ return {
363
+ id: item.id,
364
+ name: item.nameEn,
365
+ }
366
+ })
367
+ let chartType = 'line_graph'
368
+ if (selectedChartTypeLocal.value === 'spline') chartType = 'line_graph'
369
+ else if (selectedChartTypeLocal.value === 'area') chartType = 'stacked_graph'
370
+
371
+ const saveOptionsData = {
372
+ routeType,
373
+ chartType,
374
+ counters,
375
+ metric: selectedMetric.value,
376
+ timespan: {
377
+ periodType: localPeriodType.value,
378
+ units: localCustomTime.value,
379
+ unitsCount: unitCount.value,
380
+ type: timespanType.value,
381
+ },
382
+ }
383
+ const prefix = props.project === 'sphere'
384
+ useLocalStorage(`${name}ChartOptions`, saveOptionsData, prefix)
385
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
386
+ localSelectedChartOptionName.value = name
387
+ emits('save-option-name')
388
+ }
389
+
390
+ const setSelectOptions = (): void => {
391
+ selectedMetric.value = props.selectedMetric || metricsItems.value[0]?.value
392
+ localSelectedCountersKeys.value = props.selectedCountersKeys
393
+ localSelectedChartType.value = props.selectedChartType
394
+ localSelectedTimespanType.value = props.selectedTimespanType
395
+ localUnitsCount.value = props.unitsCount
396
+ localPeriodType.value = props.periodType
397
+ localCustomTime.value = props.selectedCustomTime
398
+ }
399
+
400
+ const setDefaultOptions = (): void => {
401
+ selectedMetric.value = metricsItems.value[0]?.value
402
+ localSelectedCountersKeys.value = []
403
+ localSelectedChartType.value = 'spline'
404
+ localSelectedTimespanType.value = ''
405
+ localUnitsCount.value = 0
406
+ localPeriodType.value = ''
407
+ localCustomTime.value = ''
408
+ }
409
+
410
+ const setCustomOptions = (name: string): void => {
411
+ const prefix = props.project === 'sphere'
412
+ const selectedValue = useLocalStorage(
413
+ name + 'ChartOptions',
414
+ undefined,
415
+ prefix
416
+ )
417
+
418
+ if (selectedValue.routeType !== routeType) return
419
+
420
+ let currentChartType = ''
421
+ if (selectedValue.chartType === 'line_graph') currentChartType = 'spline'
422
+ else if (selectedValue.chartType === 'stacked_graph')
423
+ currentChartType = 'area'
424
+
425
+ selectedMetric.value = selectedValue.metric
426
+ localSelectedCountersKeys.value = selectedValue.counters.map(
427
+ (item) => item.id
428
+ )
429
+ localSelectedChartType.value = currentChartType
430
+ localSelectedTimespanType.value = selectedValue.timespan.type
431
+ localUnitsCount.value = selectedValue.timespan.unitsCount
432
+ localPeriodType.value = selectedValue.timespan.periodType
433
+ localCustomTime.value = selectedValue.timespan.units
434
+ }
435
+
436
+ const onSelectLocalOptionName = (name: string): void => {
437
+ selectedLocalOptionName.value = name
438
+
439
+ if (optionsNames.value.includes(name)) setCustomOptions(name)
440
+ else if (name === 'default') setDefaultOptions()
441
+ else if (name === 'select_options') setSelectOptions()
442
+ }
443
+
444
+ watch(
445
+ localSelectedChartOptionName,
446
+ (newValue) => {
447
+ if (!newValue) return
448
+
449
+ setCustomOptions(newValue)
450
+ },
451
+ { immediate: true }
452
+ )
453
+
454
+ const onDeleteChartName = (name: string): void => {
455
+ window.localStorage.removeItem(name + 'ChartOptions')
456
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
457
+ setSelectOptions()
458
+ emits('delete-option')
459
+ }
460
+
461
+ const isDisabledSubmit = computed<boolean>(() =>
462
+ checkIsDisabledSubmit(
463
+ props.type,
464
+ selectedMetric.value,
465
+ selectedRows.value.length,
466
+ localSelectedObjects.value
467
+ )
468
+ )
469
+
470
+ watch(
471
+ selectedMetric,
472
+ (newValue) => {
473
+ emits('select-metric-local', newValue)
474
+ },
475
+ { immediate: true }
476
+ )
477
+
478
+ onMounted(() => {
479
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
480
+ })
481
+ </script>
482
+
483
+ <style scoped lang="scss">
484
+ .chart-options-modal {
485
+ .loader-on :deep(.modal-body) {
486
+ display: flex;
487
+ align-items: center;
488
+ justify-content: center;
489
+ }
490
+ :deep(.modal-title) {
491
+ text-transform: capitalize;
492
+ }
493
+
494
+ #loader {
495
+ min-height: 90px;
496
+ text-align: center;
497
+ }
498
+
499
+ .chart-options-content {
500
+ display: flex;
501
+ flex-direction: row;
502
+ flex-basis: 90%;
503
+ overflow-y: hidden;
504
+ }
505
+ }
506
+ @media (max-width: 1024px) {
507
+ .chart-options-content {
508
+ flex-direction: column !important;
509
+ }
510
+ }
511
+ </style>