bfg-common 1.4.721 → 1.4.722

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,440 +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
- @hide="isShowModal = false"
118
- @select-row="emits('select-row', $event)"
119
- @select-metric-local="emits('select-metric-local', $event)"
120
- @update-chart-type="emits('update-chart-type', $event)"
121
- @update-timespan-type="emits('update-timespan-type', $event)"
122
- @update-unit-count="emits('update-unit-count', $event)"
123
- @update-period-type="emits('update-period-type', $event)"
124
- @update-custom-time="emits('update-custom-time', $event)"
125
- @delete-option="onDeleteOption"
126
- @save-option-name="onSaveOptionName"
127
- @submit-options="emits('submit-options', $event)"
128
- />
129
- </template>
130
-
131
- <script setup lang="ts">
132
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
133
- import type { UI_I_Localization } from '~/lib/models/interfaces'
134
- import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
135
- import type { UI_I_DropMenu } from '~/components/common/monitor/advanced/tools/lib/models/interfaces'
136
- import type { UI_T_AdvancedType } from '~/components/common/monitor/advanced/lib/models/types'
137
- import type {
138
- UI_T_ChartHost,
139
- UI_T_ChartVm,
140
- } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/types'
141
- import type { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/interfaces'
142
- import type { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/lib/models/interfaces'
143
- import type { UI_I_ObjectItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/lib/models/interfaces'
144
- import type { UI_T_Project } from '~/lib/models/types'
145
- import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
146
- import {
147
- periodFunc,
148
- viewFunc,
149
- exportFunc,
150
- getCurrentOptionsStorageFunc,
151
- } from '~/components/common/monitor/advanced/tools/lib/config/advancedToolbar'
152
- import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
153
-
154
- const props = defineProps<{
155
- type: UI_T_AdvancedType
156
- startDate: number
157
- chartTitle: string
158
- language: string
159
- selectedCountersKeys: number[]
160
- selectedMetric: UI_T_ChartHost | UI_T_ChartVm
161
- selectedMetricLocal: UI_T_ChartHost | UI_T_ChartVm
162
- selectedChartType: string
163
- selectedTimespanType: string
164
- unitsCount: number
165
- periodType: string
166
- selectedCustomTime: string
167
- selectedChartOptionName: string
168
- customDateFrom: string
169
- customDateTo: string
170
- customTimeFrom: string
171
- customTimeTo: string
172
- totalCores: number
173
- hostId: string
174
- selectedObjects: string
175
- project: UI_T_Project
176
- objectsLoading: boolean
177
- objectsData: UI_I_ObjectItem[]
178
- disabledPeriod?: boolean
179
- disabledView?: boolean
180
- }>()
181
-
182
- const emits = defineEmits<{
183
- (event: 'update-tools', value: UI_I_MonitorGraphPayload): void
184
- (event: 'exporting', value: string): void
185
- (event: 'open-advanced-page'): void
186
- (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
187
- (event: 'select-metric-local', value: string): void
188
- (event: 'update-chart-type', value: string): void
189
- (event: 'update-timespan-type', value: string): void
190
- (event: 'update-unit-count', value: number): void
191
- (event: 'update-period-type', value: string): void
192
- (event: 'update-custom-time', value: string): void
193
- (event: 'delete-option'): void
194
- (event: 'submit-options', value: UI_I_OptionsForm): void
195
- (event: 'update:selected-timespan-type', value: string): void
196
- }>()
197
-
198
- const routeType = '' + useRoute().params.type
199
-
200
- const localization = computed<UI_I_Localization>(() => useLocal())
201
- const { $formattedDatetime } = useNuxtApp()
202
-
203
- const selectedView = ref<string>('')
204
- const optionsNames = ref<string[]>([])
205
- const viewOptions = computed<UI_I_OptionItem[]>(() =>
206
- viewFunc(localization.value, props.type, optionsNames.value)
207
- )
208
-
209
- watch(
210
- () => props.selectedChartOptionName,
211
- (newValue) => {
212
- let currentValue = ''
213
-
214
- if (newValue) currentValue = newValue
215
- else if (
216
- selectedView.value &&
217
- optionsNames.value.includes(selectedView.value)
218
- )
219
- currentValue = selectedView.value
220
- else currentValue = selectedView.value || viewOptions.value[0]?.value
221
-
222
- selectedView.value = currentValue
223
- },
224
- { immediate: true }
225
- )
226
-
227
- const onDeleteOption = (): void => {
228
- emits('delete-option')
229
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
230
- }
231
-
232
- const periodOptions = computed<UI_I_OptionItem[]>(() =>
233
- periodFunc(localization.value, props.selectedTimespanType)
234
- )
235
- const selectedPeriod = computed<string>({
236
- get() {
237
- return props.selectedTimespanType || periodOptions.value[0].value
238
- },
239
- set(newValue) {
240
- emits('update:selected-timespan-type', newValue)
241
- },
242
- })
243
-
244
- const isShowModal = ref<boolean>(false)
245
- watch(isShowModal, (newValue) => {
246
- if (!newValue && !selectedView.value)
247
- selectedView.value = viewOptions.value[0].value
248
- })
249
-
250
- const updateTools = (): void => {
251
- const periodValue = selectedPeriod.value
252
- const viewValue = selectedView.value
253
- const prefix = props.project === 'sphere'
254
- const selectedValue = useLocalStorage(
255
- viewValue + 'ChartOptions',
256
- undefined,
257
- prefix
258
- )
259
-
260
- const fields = selectedValue
261
- ? selectedValue.counters.map((item) => item.name).join(', ')
262
- : ''
263
- const validPeriodData = getValidDateByOptionFunc(
264
- periodValue,
265
- selectedValue,
266
- props.unitsCount,
267
- props.selectedCustomTime
268
- )
269
-
270
- const period = [
271
- Math.round(validPeriodData[0] / 1000),
272
- Math.round(validPeriodData[1] / 1000),
273
- ]
274
-
275
- if (periodValue === 'custom_interval' && props.periodType === 'period') {
276
- const checkDateResult = checkDateFunc(
277
- localization.value,
278
- props.customDateFrom,
279
- props.customDateTo,
280
- props.customTimeFrom,
281
- props.customTimeTo
282
- )
283
- if (Array.isArray(checkDateResult)) {
284
- period[0] = Math.round(checkDateResult[0] / 1000)
285
- period[1] = Math.round(checkDateResult[1] / 1000)
286
- }
287
- }
288
-
289
- const tools: UI_I_MonitorGraphPayload = {
290
- fields,
291
- period,
292
- periodType: periodValue,
293
- view: viewValue,
294
- }
295
- if (selectedValue.metric) tools.metricType = selectedValue.metric
296
-
297
- emits('update-timespan-type', selectedPeriod.value)
298
- emits('update-tools', tools)
299
- }
300
-
301
- const onChangePeriod = (): void => {
302
- updateTools()
303
- }
304
-
305
- const onChangeView = (): void => {
306
- updateTools()
307
- }
308
-
309
- const chartTitleDate = computed<string>(() => {
310
- if (!props.startDate) return ''
311
-
312
- const start = $formattedDatetime(props.startDate, '', true)
313
- const end = $formattedDatetime(new Date(), '', true)
314
- return `${start} - ${end}`
315
- })
316
-
317
- const onOpenAdvancedPage = (): void => emits('open-advanced-page')
318
-
319
- const exportMenu = ref<UI_I_DropMenu<string>[]>(exportFunc(localization.value))
320
-
321
- const onExportMenuItem = (item: UI_I_DropMenu<any>): void =>
322
- emits('exporting', item.action)
323
-
324
- const onShowChartOptions = (): void => {
325
- isShowModal.value = true
326
- }
327
-
328
- const onSaveOptionName = (): void => {
329
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
330
- }
331
-
332
- onMounted(() => {
333
- optionsNames.value = getCurrentOptionsStorageFunc(routeType, props.project)
334
- updateTools()
335
- })
336
- </script>
337
-
338
- <style scoped lang="scss">
339
- .horizontal-flex-container {
340
- display: flex;
341
- flex-direction: row;
342
- align-items: center;
343
- line-height: 20px;
344
- flex-shrink: 0;
345
-
346
- .chart-title-content {
347
- overflow: hidden;
348
- text-overflow: ellipsis;
349
- }
350
-
351
- .select select {
352
- height: 20px;
353
- margin: 5px;
354
- color: var(--global-font-color);
355
- }
356
- .single-option {
357
- margin-left: 5px;
358
- }
359
-
360
- .chart-title {
361
- color: var(--global-font-color);
362
- text-overflow: ellipsis;
363
- white-space: nowrap;
364
- overflow: hidden;
365
- margin: 6px;
366
- font-weight: 700;
367
- text-transform: capitalize;
368
-
369
- &.uppercase {
370
- text-transform: uppercase;
371
- }
372
- }
373
-
374
- .view-select-label {
375
- margin-left: auto;
376
- padding-right: 7px;
377
- padding-left: 7px;
378
- text-overflow: ellipsis;
379
- white-space: nowrap;
380
- align-items: center;
381
- }
382
-
383
- .chart-options-button {
384
- margin-left: 5px;
385
- text-overflow: ellipsis;
386
- white-space: nowrap;
387
- text-transform: capitalize;
388
- color: var(--dropdown-item-color);
389
- cursor: pointer;
390
- }
391
-
392
- .chart-action-bar {
393
- white-space: nowrap;
394
-
395
- .menu-item {
396
- padding-right: 4px;
397
- display: inline-block;
398
- list-style: none;
399
- vertical-align: middle;
400
-
401
- &:last-child {
402
- padding-right: 0;
403
- }
404
-
405
- .item-link {
406
- padding: 4px;
407
- line-height: 22px;
408
- border: 1px solid transparent;
409
- display: inline-block;
410
-
411
- &:hover {
412
- text-decoration: none;
413
- background-color: #e9f6fd;
414
- border: 1px solid #c7e9ff;
415
- }
416
-
417
- .icon {
418
- width: 16px;
419
- height: 16px;
420
- display: block;
421
- min-width: 16px;
422
- min-height: 16px;
423
- background-size: 100% auto;
424
- }
425
- }
426
-
427
- :deep(.dropdown-menu) {
428
- min-width: auto;
429
- padding: 0;
430
- }
431
- :deep(.user-menu-large) {
432
- padding: 0;
433
- }
434
- :deep(.angle-icon) {
435
- display: none;
436
- }
437
- }
438
- }
439
- }
440
- </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>