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,447 +1,447 @@
1
- <template>
2
- <div class="horizontal-flex-container overview-chart-title-bar">
3
- <div class="chart-title-content">
4
- <client-only>
5
- <span v-if="props.chartTitle" class="chart-title"
6
- >{{ props.chartTitle }},</span
7
- >
8
- <span v-if="chartTitleDate" class="chart-title uppercase">{{
9
- chartTitleDate
10
- }}</span>
11
- </client-only>
12
- </div>
13
- <div class="horizontal-flex-container">
14
- <label for="periodSelect" class="label-select"
15
- >{{ localization.inventoryMonitor.period }}:</label
16
- >
17
- <div class="select">
18
- <select
19
- id="periodSelect"
20
- v-model="selectedPeriod"
21
- data-id="period-select"
22
- :disabled="props.disabledPeriod"
23
- @change="onChangePeriod"
24
- >
25
- <option
26
- v-for="(item, index) in periodOptions"
27
- :key="index"
28
- :value="item.value"
29
- >
30
- {{ item.text }}
31
- </option>
32
- </select>
33
- </div>
34
- <a
35
- id="chart-options-button"
36
- class="chart-options-button"
37
- data-id="show-chart-options-button"
38
- @click="onShowChartOptions"
39
- >{{ localization.inventoryMonitor.chartOptions }}</a
40
- >
41
- </div>
42
- <div class="view-select-label horizontal-flex-container">
43
- <label for="viewSelect" class="label-select"
44
- >{{ localization.common.view }}:</label
45
- >
46
- <div class="select">
47
- <select
48
- id="viewSelect"
49
- v-model="selectedView"
50
- data-id="view-select"
51
- :disabled="props.disabledView"
52
- @change="onChangeView"
53
- >
54
- <option
55
- v-for="(item, index) in viewOptions"
56
- :key="index"
57
- :value="item.value"
58
- >
59
- {{ item.text }}
60
- </option>
61
- </select>
62
- </div>
63
- </div>
64
- <div class="chart-action-bar vui-action-bar">
65
- <ul>
66
- <li class="menu-item">
67
- <a
68
- id="advanced-page-link"
69
- data-id="advanced-page-button"
70
- class="item-link"
71
- @click="onOpenAdvancedPage"
72
- >
73
- <span class="vx-icon-window-popout icon"></span>
74
- </a>
75
- </li>
76
- <li class="menu-item">
77
- <atoms-dropdown :drop-menu="exportMenu" @select="onExportMenuItem">
78
- <template #icon>
79
- <a
80
- id="export-link"
81
- data-id="export-link"
82
- href="#"
83
- class="item-link"
84
- >
85
- <span class="vx-icon-export icon"></span>
86
- </a>
87
- </template>
88
- </atoms-dropdown>
89
- </li>
90
- </ul>
91
- </div>
92
- </div>
93
-
94
- <common-monitor-advanced-tools-chart-options-modal
95
- v-if="isShowModal"
96
- :type="props.type"
97
- :language="props.language"
98
- :selected-counters-keys="props.selectedCountersKeys"
99
- :selected-metric="props.selectedMetric"
100
- :selected-metric-local="props.selectedMetricLocal"
101
- :selected-chart-type="props.selectedChartType"
102
- :selected-timespan-type="props.selectedTimespanType"
103
- :units-count="props.unitsCount"
104
- :period-type="props.periodType"
105
- :selected-custom-time="props.selectedCustomTime"
106
- :selected-chart-option-name="props.selectedChartOptionName"
107
- :custom-date-from="props.customDateFrom"
108
- :custom-date-to="props.customDateTo"
109
- :custom-time-from="props.customTimeFrom"
110
- :custom-time-to="props.customTimeTo"
111
- :total-cores="props.totalCores"
112
- :host-id="props.hostId"
113
- :selected-objects="props.selectedObjects"
114
- :project="props.project"
115
- :objects-loading="props.objectsLoading"
116
- :objects-data="props.objectsData"
117
- :valid-date-end="props.validDateEnd"
118
- :format-date="props.formatDate"
119
- @hide="isShowModal = false"
120
- @select-row="emits('select-row', $event)"
121
- @select-metric-local="emits('select-metric-local', $event)"
122
- @update-chart-type="emits('update-chart-type', $event)"
123
- @update-timespan-type="emits('update-timespan-type', $event)"
124
- @update-unit-count="emits('update-unit-count', $event)"
125
- @update-period-type="emits('update-period-type', $event)"
126
- @update-custom-time="emits('update-custom-time', $event)"
127
- @delete-option="onDeleteOption"
128
- @save-option-name="onSaveOptionName"
129
- @submit-options="emits('submit-options', $event)"
130
- />
131
- </template>
132
-
133
- <script setup lang="ts">
134
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
135
- import type { UI_I_Localization } from '~/lib/models/interfaces'
136
- import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
137
- import type { UI_I_DropMenu } from '~/components/common/monitor/advanced/tools/lib/models/interfaces'
138
- import type { UI_T_AdvancedType } from '~/components/common/monitor/advanced/lib/models/types'
139
- import type {
140
- UI_T_ChartHost,
141
- UI_T_ChartVm,
142
- } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/types'
143
- import type { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/interfaces'
144
- import type { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/models/interfaces'
145
- import type { UI_I_ObjectItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/models/interfaces'
146
- import type { UI_T_Project } from '~/lib/models/types'
147
- import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
148
- import {
149
- periodFunc,
150
- viewFunc,
151
- exportFunc,
152
- getCurrentOptionsStorageFunc,
153
- } from '~/components/common/monitor/advanced/tools/lib/config/advancedToolbar'
154
- import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
155
-
156
- const props = defineProps<{
157
- type: UI_T_AdvancedType
158
- startDate: number
159
- endDate: number
160
- chartTitle: string
161
- language: string
162
- selectedCountersKeys: number[]
163
- selectedMetric: UI_T_ChartHost | UI_T_ChartVm
164
- selectedMetricLocal: UI_T_ChartHost | UI_T_ChartVm
165
- selectedChartType: string
166
- selectedTimespanType: string
167
- unitsCount: number
168
- periodType: string
169
- selectedCustomTime: string
170
- selectedChartOptionName: string
171
- customDateFrom: string
172
- customDateTo: string
173
- customTimeFrom: string
174
- customTimeTo: string
175
- totalCores: number
176
- hostId: string
177
- selectedObjects: string
178
- project: UI_T_Project
179
- objectsLoading: boolean
180
- objectsData: UI_I_ObjectItem[]
181
- validDateEnd: number
182
- formatDate: string
183
- disabledPeriod?: boolean
184
- disabledView?: boolean
185
- }>()
186
-
187
- const emits = defineEmits<{
188
- (event: 'update-tools', value: UI_I_MonitorGraphPayload): void
189
- (event: 'exporting', value: string): void
190
- (event: 'open-advanced-page'): void
191
- (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
192
- (event: 'select-metric-local', value: string): void
193
- (event: 'update-chart-type', value: string): void
194
- (event: 'update-timespan-type', value: string): void
195
- (event: 'update-unit-count', value: number): void
196
- (event: 'update-period-type', value: string): void
197
- (event: 'update-custom-time', value: string): void
198
- (event: 'delete-option'): void
199
- (event: 'submit-options', value: UI_I_OptionsForm): void
200
- (event: 'update:selected-timespan-type', value: string): void
201
- }>()
202
-
203
- const routeType = '' + useRoute().params.type
204
-
205
- const localization = computed<UI_I_Localization>(() => useLocal())
206
- const { $formattedDatetime } = useNuxtApp()
207
-
208
- const selectedView = ref<string>('')
209
- const optionsNames = ref<string[]>([])
210
- const viewOptions = computed<UI_I_OptionItem[]>(() =>
211
- viewFunc(localization.value, props.type, optionsNames.value)
212
- )
213
-
214
- watch(
215
- () => props.selectedChartOptionName,
216
- (newValue) => {
217
- let currentValue = ''
218
-
219
- if (newValue) currentValue = newValue
220
- else if (
221
- selectedView.value &&
222
- optionsNames.value.includes(selectedView.value)
223
- )
224
- currentValue = selectedView.value
225
- else currentValue = selectedView.value || viewOptions.value[0]?.value
226
-
227
- selectedView.value = currentValue
228
- },
229
- { immediate: true }
230
- )
231
-
232
- const onDeleteOption = (): void => {
233
- emits('delete-option')
234
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
235
- }
236
-
237
- const periodOptions = computed<UI_I_OptionItem[]>(() =>
238
- periodFunc(localization.value, props.selectedTimespanType)
239
- )
240
- const selectedPeriod = computed<string>({
241
- get() {
242
- return props.selectedTimespanType || periodOptions.value[0].value
243
- },
244
- set(newValue) {
245
- emits('update:selected-timespan-type', newValue)
246
- },
247
- })
248
-
249
- const isShowModal = ref<boolean>(false)
250
- watch(isShowModal, (newValue) => {
251
- if (!newValue && !selectedView.value)
252
- selectedView.value = viewOptions.value[0].value
253
- })
254
-
255
- const updateTools = (): void => {
256
- const periodValue = selectedPeriod.value
257
- const viewValue = selectedView.value
258
- const prefix = props.project === 'sphere'
259
- const selectedValue = useLocalStorage(
260
- viewValue + 'ChartOptions',
261
- undefined,
262
- prefix
263
- )
264
-
265
- const fields = selectedValue
266
- ? selectedValue.counters.map((item) => item.name).join(', ')
267
- : ''
268
- const validPeriodData = getValidDateByOptionFunc(
269
- periodValue,
270
- selectedValue,
271
- props.unitsCount,
272
- props.selectedCustomTime
273
- )
274
-
275
- const period = [
276
- Math.round(validPeriodData[0] / 1000),
277
- Math.round(validPeriodData[1] / 1000),
278
- ]
279
-
280
- if (periodValue === 'custom_interval' && props.periodType === 'period') {
281
- const checkDateResult = checkDateFunc(
282
- localization.value,
283
- props.customDateFrom,
284
- props.customDateTo,
285
- props.customTimeFrom,
286
- props.customTimeTo,
287
- props.validDateEnd,
288
- props.formatDate
289
- )
290
- if (Array.isArray(checkDateResult)) {
291
- period[0] = Math.round(checkDateResult[0] / 1000)
292
- period[1] = Math.round(checkDateResult[1] / 1000)
293
- }
294
- }
295
-
296
- const tools: UI_I_MonitorGraphPayload = {
297
- fields,
298
- period,
299
- periodType: periodValue,
300
- view: viewValue,
301
- }
302
- if (selectedValue.metric) tools.metricType = selectedValue.metric
303
-
304
- emits('update-timespan-type', selectedPeriod.value)
305
- emits('update-tools', tools)
306
- }
307
-
308
- const onChangePeriod = (): void => {
309
- updateTools()
310
- }
311
-
312
- const onChangeView = (): void => {
313
- updateTools()
314
- }
315
-
316
- const chartTitleDate = computed<string>(() => {
317
- if (!props.startDate) return ''
318
-
319
- const start = $formattedDatetime(props.startDate, '', true)
320
- const end = $formattedDatetime(props.endDate, '', true)
321
- return `${start} - ${end}`
322
- })
323
-
324
- const onOpenAdvancedPage = (): void => emits('open-advanced-page')
325
-
326
- const exportMenu = ref<UI_I_DropMenu<string>[]>(exportFunc(localization.value))
327
-
328
- const onExportMenuItem = (item: UI_I_DropMenu<any>): void =>
329
- emits('exporting', item.action)
330
-
331
- const onShowChartOptions = (): void => {
332
- isShowModal.value = true
333
- }
334
-
335
- const onSaveOptionName = (): void => {
336
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
337
- }
338
-
339
- onMounted(() => {
340
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
341
- updateTools()
342
- })
343
- </script>
344
-
345
- <style scoped lang="scss">
346
- .horizontal-flex-container {
347
- display: flex;
348
- flex-direction: row;
349
- align-items: center;
350
- line-height: 20px;
351
- flex-shrink: 0;
352
-
353
- .chart-title-content {
354
- overflow: hidden;
355
- text-overflow: ellipsis;
356
- }
357
-
358
- .select select {
359
- height: 20px;
360
- margin: 5px;
361
- color: var(--global-font-color);
362
- }
363
- .single-option {
364
- margin-left: 5px;
365
- }
366
-
367
- .chart-title {
368
- color: var(--global-font-color);
369
- text-overflow: ellipsis;
370
- white-space: nowrap;
371
- overflow: hidden;
372
- margin: 6px;
373
- font-weight: 700;
374
- text-transform: capitalize;
375
-
376
- &.uppercase {
377
- text-transform: uppercase;
378
- }
379
- }
380
-
381
- .view-select-label {
382
- margin-left: auto;
383
- padding-right: 7px;
384
- padding-left: 7px;
385
- text-overflow: ellipsis;
386
- white-space: nowrap;
387
- align-items: center;
388
- }
389
-
390
- .chart-options-button {
391
- margin-left: 5px;
392
- text-overflow: ellipsis;
393
- white-space: nowrap;
394
- text-transform: capitalize;
395
- color: var(--dropdown-item-color);
396
- cursor: pointer;
397
- }
398
-
399
- .chart-action-bar {
400
- white-space: nowrap;
401
-
402
- .menu-item {
403
- padding-right: 4px;
404
- display: inline-block;
405
- list-style: none;
406
- vertical-align: middle;
407
-
408
- &:last-child {
409
- padding-right: 0;
410
- }
411
-
412
- .item-link {
413
- padding: 4px;
414
- line-height: 22px;
415
- border: 1px solid transparent;
416
- display: inline-block;
417
-
418
- &:hover {
419
- text-decoration: none;
420
- background-color: #e9f6fd;
421
- border: 1px solid #c7e9ff;
422
- }
423
-
424
- .icon {
425
- width: 16px;
426
- height: 16px;
427
- display: block;
428
- min-width: 16px;
429
- min-height: 16px;
430
- background-size: 100% auto;
431
- }
432
- }
433
-
434
- :deep(.dropdown-menu) {
435
- min-width: auto;
436
- padding: 0;
437
- }
438
- :deep(.user-menu-large) {
439
- padding: 0;
440
- }
441
- :deep(.angle-icon) {
442
- display: none;
443
- }
444
- }
445
- }
446
- }
447
- </style>
1
+ <template>
2
+ <div class="horizontal-flex-container overview-chart-title-bar">
3
+ <div class="chart-title-content">
4
+ <client-only>
5
+ <span v-if="props.chartTitle" class="chart-title"
6
+ >{{ props.chartTitle }},</span
7
+ >
8
+ <span v-if="chartTitleDate" class="chart-title uppercase">{{
9
+ chartTitleDate
10
+ }}</span>
11
+ </client-only>
12
+ </div>
13
+ <div class="horizontal-flex-container">
14
+ <label for="periodSelect" class="label-select"
15
+ >{{ localization.inventoryMonitor.period }}:</label
16
+ >
17
+ <div class="select">
18
+ <select
19
+ id="periodSelect"
20
+ v-model="selectedPeriod"
21
+ data-id="period-select"
22
+ :disabled="props.disabledPeriod"
23
+ @change="onChangePeriod"
24
+ >
25
+ <option
26
+ v-for="(item, index) in periodOptions"
27
+ :key="index"
28
+ :value="item.value"
29
+ >
30
+ {{ item.text }}
31
+ </option>
32
+ </select>
33
+ </div>
34
+ <a
35
+ id="chart-options-button"
36
+ class="chart-options-button"
37
+ data-id="show-chart-options-button"
38
+ @click="onShowChartOptions"
39
+ >{{ localization.inventoryMonitor.chartOptions }}</a
40
+ >
41
+ </div>
42
+ <div class="view-select-label horizontal-flex-container">
43
+ <label for="viewSelect" class="label-select"
44
+ >{{ localization.common.view }}:</label
45
+ >
46
+ <div class="select">
47
+ <select
48
+ id="viewSelect"
49
+ v-model="selectedView"
50
+ data-id="view-select"
51
+ :disabled="props.disabledView"
52
+ @change="onChangeView"
53
+ >
54
+ <option
55
+ v-for="(item, index) in viewOptions"
56
+ :key="index"
57
+ :value="item.value"
58
+ >
59
+ {{ item.text }}
60
+ </option>
61
+ </select>
62
+ </div>
63
+ </div>
64
+ <div class="chart-action-bar vui-action-bar">
65
+ <ul>
66
+ <li class="menu-item">
67
+ <a
68
+ id="advanced-page-link"
69
+ data-id="advanced-page-button"
70
+ class="item-link"
71
+ @click="onOpenAdvancedPage"
72
+ >
73
+ <span class="vx-icon-window-popout icon"></span>
74
+ </a>
75
+ </li>
76
+ <li class="menu-item">
77
+ <atoms-dropdown :drop-menu="exportMenu" @select="onExportMenuItem">
78
+ <template #icon>
79
+ <a
80
+ id="export-link"
81
+ data-id="export-link"
82
+ href="#"
83
+ class="item-link"
84
+ >
85
+ <span class="vx-icon-export icon"></span>
86
+ </a>
87
+ </template>
88
+ </atoms-dropdown>
89
+ </li>
90
+ </ul>
91
+ </div>
92
+ </div>
93
+
94
+ <common-monitor-advanced-tools-chart-options-modal
95
+ v-if="isShowModal"
96
+ :type="props.type"
97
+ :language="props.language"
98
+ :selected-counters-keys="props.selectedCountersKeys"
99
+ :selected-metric="props.selectedMetric"
100
+ :selected-metric-local="props.selectedMetricLocal"
101
+ :selected-chart-type="props.selectedChartType"
102
+ :selected-timespan-type="props.selectedTimespanType"
103
+ :units-count="props.unitsCount"
104
+ :period-type="props.periodType"
105
+ :selected-custom-time="props.selectedCustomTime"
106
+ :selected-chart-option-name="props.selectedChartOptionName"
107
+ :custom-date-from="props.customDateFrom"
108
+ :custom-date-to="props.customDateTo"
109
+ :custom-time-from="props.customTimeFrom"
110
+ :custom-time-to="props.customTimeTo"
111
+ :total-cores="props.totalCores"
112
+ :host-id="props.hostId"
113
+ :selected-objects="props.selectedObjects"
114
+ :project="props.project"
115
+ :objects-loading="props.objectsLoading"
116
+ :objects-data="props.objectsData"
117
+ :valid-date-end="props.validDateEnd"
118
+ :format-date="props.formatDate"
119
+ @hide="isShowModal = false"
120
+ @select-row="emits('select-row', $event)"
121
+ @select-metric-local="emits('select-metric-local', $event)"
122
+ @update-chart-type="emits('update-chart-type', $event)"
123
+ @update-timespan-type="emits('update-timespan-type', $event)"
124
+ @update-unit-count="emits('update-unit-count', $event)"
125
+ @update-period-type="emits('update-period-type', $event)"
126
+ @update-custom-time="emits('update-custom-time', $event)"
127
+ @delete-option="onDeleteOption"
128
+ @save-option-name="onSaveOptionName"
129
+ @submit-options="emits('submit-options', $event)"
130
+ />
131
+ </template>
132
+
133
+ <script setup lang="ts">
134
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
135
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
136
+ import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
137
+ import type { UI_I_DropMenu } from '~/components/common/monitor/advanced/tools/lib/models/interfaces'
138
+ import type { UI_T_AdvancedType } from '~/components/common/monitor/advanced/lib/models/types'
139
+ import type {
140
+ UI_T_ChartHost,
141
+ UI_T_ChartVm,
142
+ } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/types'
143
+ import type { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/interfaces'
144
+ import type { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/models/interfaces'
145
+ import type { UI_I_ObjectItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/models/interfaces'
146
+ import type { UI_T_Project } from '~/lib/models/types'
147
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
148
+ import {
149
+ periodFunc,
150
+ viewFunc,
151
+ exportFunc,
152
+ getCurrentOptionsStorageFunc,
153
+ } from '~/components/common/monitor/advanced/tools/lib/config/advancedToolbar'
154
+ import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
155
+
156
+ const props = defineProps<{
157
+ type: UI_T_AdvancedType
158
+ startDate: number
159
+ endDate: number
160
+ chartTitle: string
161
+ language: string
162
+ selectedCountersKeys: number[]
163
+ selectedMetric: UI_T_ChartHost | UI_T_ChartVm
164
+ selectedMetricLocal: UI_T_ChartHost | UI_T_ChartVm
165
+ selectedChartType: string
166
+ selectedTimespanType: string
167
+ unitsCount: number
168
+ periodType: string
169
+ selectedCustomTime: string
170
+ selectedChartOptionName: string
171
+ customDateFrom: string
172
+ customDateTo: string
173
+ customTimeFrom: string
174
+ customTimeTo: string
175
+ totalCores: number
176
+ hostId: string
177
+ selectedObjects: string
178
+ project: UI_T_Project
179
+ objectsLoading: boolean
180
+ objectsData: UI_I_ObjectItem[]
181
+ validDateEnd: number
182
+ formatDate: string
183
+ disabledPeriod?: boolean
184
+ disabledView?: boolean
185
+ }>()
186
+
187
+ const emits = defineEmits<{
188
+ (event: 'update-tools', value: UI_I_MonitorGraphPayload): void
189
+ (event: 'exporting', value: string): void
190
+ (event: 'open-advanced-page'): void
191
+ (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
192
+ (event: 'select-metric-local', value: string): void
193
+ (event: 'update-chart-type', value: string): void
194
+ (event: 'update-timespan-type', value: string): void
195
+ (event: 'update-unit-count', value: number): void
196
+ (event: 'update-period-type', value: string): void
197
+ (event: 'update-custom-time', value: string): void
198
+ (event: 'delete-option'): void
199
+ (event: 'submit-options', value: UI_I_OptionsForm): void
200
+ (event: 'update:selected-timespan-type', value: string): void
201
+ }>()
202
+
203
+ const routeType = '' + useRoute().params.type
204
+
205
+ const localization = computed<UI_I_Localization>(() => useLocal())
206
+ const { $formattedDatetime } = useNuxtApp()
207
+
208
+ const selectedView = ref<string>('')
209
+ const optionsNames = ref<string[]>([])
210
+ const viewOptions = computed<UI_I_OptionItem[]>(() =>
211
+ viewFunc(localization.value, props.type, optionsNames.value)
212
+ )
213
+
214
+ watch(
215
+ () => props.selectedChartOptionName,
216
+ (newValue) => {
217
+ let currentValue = ''
218
+
219
+ if (newValue) currentValue = newValue
220
+ else if (
221
+ selectedView.value &&
222
+ optionsNames.value.includes(selectedView.value)
223
+ )
224
+ currentValue = selectedView.value
225
+ else currentValue = selectedView.value || viewOptions.value[0]?.value
226
+
227
+ selectedView.value = currentValue
228
+ },
229
+ { immediate: true }
230
+ )
231
+
232
+ const onDeleteOption = (): void => {
233
+ emits('delete-option')
234
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
235
+ }
236
+
237
+ const periodOptions = computed<UI_I_OptionItem[]>(() =>
238
+ periodFunc(localization.value, props.selectedTimespanType)
239
+ )
240
+ const selectedPeriod = computed<string>({
241
+ get() {
242
+ return props.selectedTimespanType || periodOptions.value[0].value
243
+ },
244
+ set(newValue) {
245
+ emits('update:selected-timespan-type', newValue)
246
+ },
247
+ })
248
+
249
+ const isShowModal = ref<boolean>(false)
250
+ watch(isShowModal, (newValue) => {
251
+ if (!newValue && !selectedView.value)
252
+ selectedView.value = viewOptions.value[0].value
253
+ })
254
+
255
+ const updateTools = (): void => {
256
+ const periodValue = selectedPeriod.value
257
+ const viewValue = selectedView.value
258
+ const prefix = props.project === 'sphere'
259
+ const selectedValue = useLocalStorage(
260
+ viewValue + 'ChartOptions',
261
+ undefined,
262
+ prefix
263
+ )
264
+
265
+ const fields = selectedValue
266
+ ? selectedValue.counters.map((item) => item.name).join(', ')
267
+ : ''
268
+ const validPeriodData = getValidDateByOptionFunc(
269
+ periodValue,
270
+ selectedValue,
271
+ props.unitsCount,
272
+ props.selectedCustomTime
273
+ )
274
+
275
+ const period = [
276
+ Math.round(validPeriodData[0] / 1000),
277
+ Math.round(validPeriodData[1] / 1000),
278
+ ]
279
+
280
+ if (periodValue === 'custom_interval' && props.periodType === 'period') {
281
+ const checkDateResult = checkDateFunc(
282
+ localization.value,
283
+ props.customDateFrom,
284
+ props.customDateTo,
285
+ props.customTimeFrom,
286
+ props.customTimeTo,
287
+ props.validDateEnd,
288
+ props.formatDate
289
+ )
290
+ if (Array.isArray(checkDateResult)) {
291
+ period[0] = Math.round(checkDateResult[0] / 1000)
292
+ period[1] = Math.round(checkDateResult[1] / 1000)
293
+ }
294
+ }
295
+
296
+ const tools: UI_I_MonitorGraphPayload = {
297
+ fields,
298
+ period,
299
+ periodType: periodValue,
300
+ view: viewValue,
301
+ }
302
+ if (selectedValue.metric) tools.metricType = selectedValue.metric
303
+
304
+ emits('update-timespan-type', selectedPeriod.value)
305
+ emits('update-tools', tools)
306
+ }
307
+
308
+ const onChangePeriod = (): void => {
309
+ updateTools()
310
+ }
311
+
312
+ const onChangeView = (): void => {
313
+ updateTools()
314
+ }
315
+
316
+ const chartTitleDate = computed<string>(() => {
317
+ if (!props.startDate) return ''
318
+
319
+ const start = $formattedDatetime(props.startDate, '', true)
320
+ const end = $formattedDatetime(props.endDate, '', true)
321
+ return `${start} - ${end}`
322
+ })
323
+
324
+ const onOpenAdvancedPage = (): void => emits('open-advanced-page')
325
+
326
+ const exportMenu = ref<UI_I_DropMenu<string>[]>(exportFunc(localization.value))
327
+
328
+ const onExportMenuItem = (item: UI_I_DropMenu<any>): void =>
329
+ emits('exporting', item.action)
330
+
331
+ const onShowChartOptions = (): void => {
332
+ isShowModal.value = true
333
+ }
334
+
335
+ const onSaveOptionName = (): void => {
336
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
337
+ }
338
+
339
+ onMounted(() => {
340
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
341
+ updateTools()
342
+ })
343
+ </script>
344
+
345
+ <style scoped lang="scss">
346
+ .horizontal-flex-container {
347
+ display: flex;
348
+ flex-direction: row;
349
+ align-items: center;
350
+ line-height: 20px;
351
+ flex-shrink: 0;
352
+
353
+ .chart-title-content {
354
+ overflow: hidden;
355
+ text-overflow: ellipsis;
356
+ }
357
+
358
+ .select select {
359
+ height: 20px;
360
+ margin: 5px;
361
+ color: var(--global-font-color);
362
+ }
363
+ .single-option {
364
+ margin-left: 5px;
365
+ }
366
+
367
+ .chart-title {
368
+ color: var(--global-font-color);
369
+ text-overflow: ellipsis;
370
+ white-space: nowrap;
371
+ overflow: hidden;
372
+ margin: 6px;
373
+ font-weight: 700;
374
+ text-transform: capitalize;
375
+
376
+ &.uppercase {
377
+ text-transform: uppercase;
378
+ }
379
+ }
380
+
381
+ .view-select-label {
382
+ margin-left: auto;
383
+ padding-right: 7px;
384
+ padding-left: 7px;
385
+ text-overflow: ellipsis;
386
+ white-space: nowrap;
387
+ align-items: center;
388
+ }
389
+
390
+ .chart-options-button {
391
+ margin-left: 5px;
392
+ text-overflow: ellipsis;
393
+ white-space: nowrap;
394
+ text-transform: capitalize;
395
+ color: var(--dropdown-item-color);
396
+ cursor: pointer;
397
+ }
398
+
399
+ .chart-action-bar {
400
+ white-space: nowrap;
401
+
402
+ .menu-item {
403
+ padding-right: 4px;
404
+ display: inline-block;
405
+ list-style: none;
406
+ vertical-align: middle;
407
+
408
+ &:last-child {
409
+ padding-right: 0;
410
+ }
411
+
412
+ .item-link {
413
+ padding: 4px;
414
+ line-height: 22px;
415
+ border: 1px solid transparent;
416
+ display: inline-block;
417
+
418
+ &:hover {
419
+ text-decoration: none;
420
+ background-color: #e9f6fd;
421
+ border: 1px solid #c7e9ff;
422
+ }
423
+
424
+ .icon {
425
+ width: 16px;
426
+ height: 16px;
427
+ display: block;
428
+ min-width: 16px;
429
+ min-height: 16px;
430
+ background-size: 100% auto;
431
+ }
432
+ }
433
+
434
+ :deep(.dropdown-menu) {
435
+ min-width: auto;
436
+ padding: 0;
437
+ }
438
+ :deep(.user-menu-large) {
439
+ padding: 0;
440
+ }
441
+ :deep(.angle-icon) {
442
+ display: none;
443
+ }
444
+ }
445
+ }
446
+ }
447
+ </style>