bfg-common 1.4.16 → 1.4.18

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 (40) hide show
  1. package/assets/localization/local_be.json +7 -1
  2. package/assets/localization/local_en.json +7 -1
  3. package/assets/localization/local_hy.json +7 -1
  4. package/assets/localization/local_kk.json +7 -1
  5. package/assets/localization/local_ru.json +7 -1
  6. package/assets/localization/local_zh.json +7 -1
  7. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/form/Form.vue +4 -4
  8. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/form/lib/config/dateForm.ts +1 -1
  9. package/components/common/pages/hardwareHealth/HardwareHealth.vue +43 -61
  10. package/components/common/pages/hardwareHealth/historyTestimony/Graph.vue +331 -0
  11. package/components/common/pages/hardwareHealth/historyTestimony/lib/models/interfaces.ts +9 -0
  12. package/components/common/pages/hardwareHealth/historyTestimony/tools/Tools.vue +375 -0
  13. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/ChartOptionsModal.vue +469 -0
  14. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/Notification.vue +30 -0
  15. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/actions/Actions.vue +157 -0
  16. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/actions/SaveOptionsModal.vue +81 -0
  17. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/actions/lib/utils/optionsActions.ts +25 -0
  18. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/Counters.vue +89 -0
  19. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/table/Table.vue +174 -0
  20. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/table/lib/config/tableConfig.ts +89 -0
  21. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/table/lib/models/types.ts +5 -0
  22. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/timespan/Timespan.vue +64 -0
  23. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/timespan/form/Form.vue +539 -0
  24. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/counters/timespan/form/lib/config/dateForm.ts +115 -0
  25. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/config/optionsMetrics.ts +17 -0
  26. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/interfaces.ts +15 -0
  27. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/types.ts +1 -0
  28. package/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/metrics/Metrics.vue +31 -0
  29. package/components/common/pages/hardwareHealth/historyTestimony/tools/lib/config/toolbar.ts +78 -0
  30. package/components/common/pages/hardwareHealth/historyTestimony/tools/lib/models/interfaces.ts +9 -0
  31. package/components/common/pages/hardwareHealth/tableView/TableView.vue +4 -10
  32. package/components/common/pages/hardwareHealth/tableView/lib/config/historyTestimonyTable.ts +128 -0
  33. package/components/common/pages/hardwareHealth/tableView/lib/config/sensorTable.ts +7 -11
  34. package/components/common/pages/hardwareHealth/tableView/lib/config/tableKeys.ts +6 -7
  35. package/components/common/pages/hardwareHealth/tableView/lib/models/interfaces.ts +2 -0
  36. package/components/common/pages/hardwareHealth/tableView/lib/models/types.ts +9 -4
  37. package/lib/models/interfaces.ts +2 -0
  38. package/lib/models/types.ts +1 -0
  39. package/package.json +1 -1
  40. package/components/common/pages/hardwareHealth/Graph.vue +0 -84
@@ -0,0 +1,331 @@
1
+ <template>
2
+ <common-pages-hardware-health-history-testimony-tools
3
+ v-model:selected-timespan-type="selectedTimespanType"
4
+ :selected-chart-option-name="selectedChartOptionName"
5
+ :is-show-chart-modal="isShowChartModal"
6
+ :chart-title="props.powerData?.groupName || ''"
7
+ :selected-metric="selectedMetric"
8
+ :selected-power-counters-keys="selectedPowerCountersKeys"
9
+ :power-selected-rows-local="powerSelectedRowsLocal"
10
+ :selected-temperature-counters-keys="selectedTemperatureCountersKeys"
11
+ :temperature-selected-rows-local="temperatureSelectedRowsLocal"
12
+ :units-count="unitsCount"
13
+ :power-counters-table-data="powerCountersTableData"
14
+ :temperature-counters-table-data="temperatureCountersTableData"
15
+ :language="props.language"
16
+ :custom-date-from="customDateFrom"
17
+ :custom-date-to="customDateTo"
18
+ :custom-time-from="customTimeFrom"
19
+ :custom-time-to="customTimeTo"
20
+ :start-date="props.powerData?.pointStart || 0"
21
+ :period-type="tools.periodName"
22
+ @power-selected-rows-local="powerSelectedRowsLocal = $event"
23
+ @temperature-selected-rows-local="temperatureSelectedRowsLocal = $event"
24
+ @show-chart-modal="isShowChartModal = true"
25
+ @hide-chart-modal="isShowChartModal = false"
26
+ @update-tools="onUpdateTools"
27
+ @delete-option="onDeleteOption"
28
+ @submit-options="onSubmitOptions"
29
+ />
30
+ <div class="hardware-health-graph">
31
+ <div class="power-container">
32
+ <common-graph
33
+ v-if="powerDataLocal && !props.powerLoading"
34
+ :data="powerDataLocal"
35
+ :update="updatePowerHelper"
36
+ :chart="powerChart"
37
+ :selected-row="props.mainSelectedRow"
38
+ />
39
+ <div v-else-if="props.powerLoading" class="graphic-loader-block">
40
+ <div class="spinner"></div>
41
+ </div>
42
+ <div v-else class="empty-content"></div>
43
+ </div>
44
+ <div class="temperature-container">
45
+ <common-graph
46
+ v-if="temperatureDataLocal && !props.temperatureLoading"
47
+ :data="temperatureDataLocal"
48
+ :update="updateTemperatureHelper"
49
+ :chart="temperatureChart"
50
+ :selected-row="props.mainSelectedRow"
51
+ />
52
+ <div v-else-if="props.temperatureLoading" class="graphic-loader-block">
53
+ <div class="spinner"></div>
54
+ </div>
55
+ <div v-else class="empty-content"></div>
56
+ </div>
57
+ </div>
58
+ </template>
59
+
60
+ <script setup lang="ts">
61
+ import { format } from 'date-fns'
62
+ import type {
63
+ I_SeriesLine,
64
+ I_LineGraph,
65
+ } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/models/interfaces'
66
+ import { graphDataFunc } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/utils/renderGraph'
67
+ import type { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/interfaces'
68
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
69
+ import type { UI_T_Chart } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/types'
70
+ import type { UI_I_HardwareHealthSensors } from '~/components/common/pages/hardwareHealth/tableView/lib/models/interfaces'
71
+ import type { UI_I_HardwareHealthSensorsGraph } from '~/components/common/pages/hardwareHealth/historyTestimony/lib/models/interfaces'
72
+ import type { UI_I_SensorsGraphPayload } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/lib/models/interfaces'
73
+
74
+ const props = defineProps<{
75
+ powerData: I_SeriesLine | null
76
+ temperatureData: I_SeriesLine | null
77
+ countersTableData: UI_I_HardwareHealthSensors[]
78
+ language: string
79
+ powerLoading: boolean
80
+ temperatureLoading: boolean
81
+ formattedDatetime: any
82
+ isDarkMode: boolean
83
+ getDateFormat: any
84
+ mainSelectedRow: number[]
85
+ }>()
86
+
87
+ const emits = defineEmits<{
88
+ (event: 'update:selected-timespan-type', value: string): void
89
+ }>()
90
+
91
+ const { $store }: any = useNuxtApp()
92
+
93
+ const selectedChartOptionName = ref<string>('')
94
+ const isShowChartModal = ref<boolean>(false)
95
+ const selectedMetric = ref<UI_T_Chart>('power')
96
+ const selectedPowerCountersKeys = ref<number[]>([])
97
+ const selectedTemperatureCountersKeys = ref<number[]>([])
98
+ const selectedTimespanType = ref<string>('')
99
+ const customDateFrom = ref<string>('')
100
+ const customDateTo = ref<string>('')
101
+ const customTimeFrom = ref<string>('')
102
+ const customTimeTo = ref<string>('')
103
+
104
+ const unitsCount = ref<number>(0)
105
+ const powerCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
106
+ const temperatureCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
107
+ const powerSelectedRowsLocal = ref<UI_I_HardwareHealthSensorsGraph[]>([])
108
+ const temperatureSelectedRowsLocal = ref<UI_I_HardwareHealthSensorsGraph[]>([])
109
+
110
+ watch(
111
+ () => props.countersTableData,
112
+ (newValue) => {
113
+ if (!newValue.length) return
114
+
115
+ powerCountersTableData.value = []
116
+ temperatureCountersTableData.value = []
117
+
118
+ newValue.forEach((item, key) => {
119
+ const newData: UI_I_HardwareHealthSensorsGraph = {
120
+ id: key,
121
+ name: item.name,
122
+ description: item.category,
123
+ measurement: '',
124
+ units: '',
125
+ nameEn: item.mainName || '',
126
+ testId: `counters-table-${item.name}-item`,
127
+ }
128
+ if (item.category.toLowerCase() === 'power')
129
+ powerCountersTableData.value.push(newData)
130
+ else if (item.category.toLowerCase() === 'temperature')
131
+ temperatureCountersTableData.value.push(newData)
132
+ })
133
+ },
134
+ { immediate: true, deep: true }
135
+ )
136
+
137
+ const selectAllCounters = (): void => {
138
+ if (!powerCountersTableData.value)
139
+ setTimeout(() => {
140
+ selectAllCounters()
141
+ }, 2000)
142
+ else {
143
+ powerCountersTableData.value.forEach((item) => {
144
+ selectedPowerCountersKeys.value.push(item.id)
145
+ })
146
+ temperatureCountersTableData.value.forEach((item) => {
147
+ selectedTemperatureCountersKeys.value.push(item.id)
148
+ })
149
+ }
150
+ }
151
+
152
+ onMounted(() => {
153
+ selectAllCounters()
154
+ })
155
+
156
+ const localization = computed<UI_I_Localization>(() => useLocal())
157
+
158
+ const powerDataLocal = ref<I_LineGraph | null>(null)
159
+ const temperatureDataLocal = ref<I_LineGraph | null>(null)
160
+ const updatePowerHelper = ref<number>(0)
161
+ const updateTemperatureHelper = ref<number>(0)
162
+ let dateFormat = ''
163
+ const powerChart = ref<any>(null)
164
+ const temperatureChart = ref<any>(null)
165
+
166
+ const powerChartCallback = (newValue: any): void => {
167
+ newValue && (powerChart.value = newValue)
168
+ }
169
+
170
+ const temperatureChartCallback = (newValue: any): void => {
171
+ newValue && (temperatureChart.value = newValue)
172
+ }
173
+
174
+ const updatePowerChart = (): void => {
175
+ if (!props.powerData) return
176
+
177
+ powerDataLocal.value = graphDataFunc(
178
+ props.powerData,
179
+ props.isDarkMode,
180
+ localization.value,
181
+ () => {},
182
+ false,
183
+ false,
184
+ true,
185
+ 'spline',
186
+ '',
187
+ undefined,
188
+ powerChartCallback,
189
+ props.formattedDatetime,
190
+ format,
191
+ dateFormat
192
+ )
193
+
194
+ updatePowerHelper.value++
195
+ }
196
+
197
+ const updateTemperatureChart = (): void => {
198
+ if (!props.temperatureData) return
199
+
200
+ temperatureDataLocal.value = graphDataFunc(
201
+ props.temperatureData,
202
+ props.isDarkMode,
203
+ localization.value,
204
+ () => {},
205
+ false,
206
+ false,
207
+ true,
208
+ 'spline',
209
+ '',
210
+ undefined,
211
+ temperatureChartCallback,
212
+ props.formattedDatetime,
213
+ format,
214
+ dateFormat
215
+ )
216
+
217
+ updateTemperatureHelper.value++
218
+ }
219
+
220
+ watch(
221
+ () => [props.powerData, props.isDarkMode, props.language],
222
+ (newValue) => {
223
+ dateFormat = props.getDateFormat(newValue[2])
224
+ updatePowerChart()
225
+ },
226
+ { immediate: true, deep: true }
227
+ )
228
+
229
+ watch(
230
+ () => [props.temperatureData, props.isDarkMode, props.language],
231
+ (newValue) => {
232
+ dateFormat = props.getDateFormat(newValue[2])
233
+ updateTemperatureChart()
234
+ },
235
+ { immediate: true, deep: true }
236
+ )
237
+
238
+ const updateSelectedCountersKeys = (metricType: string): void => {
239
+ if (metricType === 'power') {
240
+ const newKeys: number[] = []
241
+
242
+ powerSelectedRowsLocal.value.forEach((item) => {
243
+ newKeys.push(item.id)
244
+ })
245
+ selectedPowerCountersKeys.value = newKeys
246
+ } else if (metricType === 'temperature') {
247
+ const newKeys: number[] = []
248
+
249
+ temperatureSelectedRowsLocal.value.forEach((item) => {
250
+ newKeys.push(item.id)
251
+ })
252
+ selectedTemperatureCountersKeys.value = newKeys
253
+ }
254
+ }
255
+
256
+ const tools = {
257
+ periodName: 'real_time',
258
+ view: 'power',
259
+ metricType: selectedMetric.value,
260
+ period: [],
261
+ }
262
+
263
+ const onSubmitOptions = (data: UI_I_OptionsForm): void => {
264
+ updateSelectedCountersKeys(data.metric)
265
+ if (data.metric === 'power')
266
+ $store.dispatch(
267
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_POWER',
268
+ data
269
+ )
270
+ if (data.metric === 'temperature')
271
+ $store.dispatch(
272
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_TEMPERATURE',
273
+ data
274
+ )
275
+ }
276
+
277
+ const getAllMetrics = (): void => {
278
+ $store.dispatch(
279
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_POWER',
280
+ tools
281
+ )
282
+ $store.dispatch(
283
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_TEMPERATURE',
284
+ tools
285
+ )
286
+ }
287
+
288
+ const onUpdateTools = (data: UI_I_SensorsGraphPayload): void => {
289
+ const storageChartOptions = useLocalStorage(
290
+ data.view + 'ChartOptionsSensors',
291
+ undefined
292
+ )
293
+
294
+ selectedChartOptionName.value = ''
295
+
296
+ if (storageChartOptions) {
297
+ selectedChartOptionName.value = data.view
298
+ } else {
299
+ selectedMetric.value = 'power'
300
+ }
301
+
302
+ tools.periodName = data.periodName
303
+ tools.view = data.view
304
+ tools.period = data.period
305
+ tools.metricType = data.metricType || selectedMetric.value
306
+
307
+ getAllMetrics()
308
+ }
309
+
310
+ const onDeleteOption = (): void => {}
311
+ </script>
312
+
313
+ <style scoped lang="scss">
314
+ .hardware-health-graph {
315
+ display: grid;
316
+ align-items: center;
317
+ grid-template-columns: 1fr 1fr;
318
+ grid-gap: 20px;
319
+
320
+ .graphic-loader-block {
321
+ height: inherit;
322
+ display: flex;
323
+ justify-content: center;
324
+ align-items: center;
325
+ min-height: 300px;
326
+ }
327
+ .empty-content {
328
+ height: inherit;
329
+ }
330
+ }
331
+ </style>
@@ -0,0 +1,9 @@
1
+ export interface UI_I_HardwareHealthSensorsGraph {
2
+ id: number
3
+ name: string
4
+ description: string
5
+ measurement: string
6
+ units: string
7
+ nameEn: string
8
+ testId: string
9
+ }
@@ -0,0 +1,375 @@
1
+ <template>
2
+ <div class="horizontal-flex-container">
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.common.period }}:</label
16
+ >
17
+ <div class="select">
18
+ <select
19
+ id="periodSelect"
20
+ v-model="selectedPeriod"
21
+ data-id="period-select"
22
+ @change="onUpdateTools"
23
+ >
24
+ <option
25
+ v-for="(item, index) in periodOptions"
26
+ :key="index"
27
+ :value="item.value"
28
+ >
29
+ {{ item.text }}
30
+ </option>
31
+ </select>
32
+ </div>
33
+ <a
34
+ id="chart-options-button"
35
+ class="chart-options-button"
36
+ data-id="show-chart-options-button"
37
+ @click="onShowChartOptions"
38
+ >{{ localization.common.chartOptions }}</a
39
+ >
40
+ </div>
41
+ <div class="view-select-label horizontal-flex-container">
42
+ <label for="viewSelect" class="label-select"
43
+ >{{ localization.common.view }}:</label
44
+ >
45
+ <div class="select">
46
+ <select
47
+ id="viewSelect"
48
+ v-model="selectedView"
49
+ data-id="view-select"
50
+ @change="onUpdateTools"
51
+ >
52
+ <option
53
+ v-for="(item, index) in viewOptions"
54
+ :key="index"
55
+ :value="item.value"
56
+ >
57
+ {{ item.text }}
58
+ </option>
59
+ </select>
60
+ </div>
61
+ </div>
62
+ </div>
63
+
64
+ <common-pages-hardware-health-history-testimony-tools-chart-options-modal
65
+ v-if="props.isShowChartModal"
66
+ :selected-chart-option-name="props.selectedChartOptionName"
67
+ :selected-metric="props.selectedMetric"
68
+ :power-selected-rows-local="props.powerSelectedRowsLocal"
69
+ :temperature-selected-rows-local="props.temperatureSelectedRowsLocal"
70
+ :selected-power-counters-keys="props.selectedPowerCountersKeys"
71
+ :selected-temperature-counters-keys="props.selectedTemperatureCountersKeys"
72
+ :units-count="props.unitsCount"
73
+ :power-counters-table-data="props.powerCountersTableData"
74
+ :temperature-counters-table-data="props.temperatureCountersTableData"
75
+ :language="props.language"
76
+ :selected-timespan-type="props.selectedTimespanType"
77
+ :custom-date-from="props.customDateFrom"
78
+ :custom-date-to="props.customDateTo"
79
+ :custom-time-from="props.customTimeFrom"
80
+ :custom-time-to="props.customTimeTo"
81
+ @save-option-name="onSaveOptionName"
82
+ @delete-option="emits('delete-option')"
83
+ @power-selected-rows-local="emits('power-selected-rows-local', $event)"
84
+ @temperature-selected-rows-local="
85
+ emits('temperature-selected-rows-local', $event)
86
+ "
87
+ @submit-options="emits('submit-options', $event)"
88
+ @hide="onHideChartModal"
89
+ />
90
+ </template>
91
+
92
+ <script setup lang="ts">
93
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
94
+ import type { UI_I_HardwareHealthSensorsGraph } from '~/components/common/pages/hardwareHealth/historyTestimony/lib/models/interfaces'
95
+ import type { UI_I_SensorsGraphPayload } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/lib/models/interfaces'
96
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
97
+ import type { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/lib/models/interfaces'
98
+ import type { UI_T_Chart } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/types'
99
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
100
+ import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
101
+ import {
102
+ getCurrentOptionsStorageFunc,
103
+ periodFunc,
104
+ viewFunc,
105
+ } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/lib/config/toolbar'
106
+
107
+ const props = defineProps<{
108
+ selectedChartOptionName: string
109
+ isShowChartModal: boolean
110
+ chartTitle: string
111
+ selectedMetric: UI_T_Chart
112
+ selectedPowerCountersKeys: number[]
113
+ powerSelectedRowsLocal: UI_I_HardwareHealthSensorsGraph[]
114
+ selectedTemperatureCountersKeys: number[]
115
+ temperatureSelectedRowsLocal: UI_I_HardwareHealthSensorsGraph[]
116
+ unitsCount: number
117
+ powerCountersTableData: UI_I_HardwareHealthSensorsGraph[]
118
+ temperatureCountersTableData: UI_I_HardwareHealthSensorsGraph[]
119
+ language: string
120
+ customDateFrom: string
121
+ customDateTo: string
122
+ customTimeFrom: string
123
+ customTimeTo: string
124
+ selectedTimespanType: string
125
+ startDate: number
126
+ periodType: string
127
+ }>()
128
+
129
+ const emits = defineEmits<{
130
+ (event: 'show-chart-modal'): void
131
+ (event: 'hide-chart-modal'): void
132
+ (event: 'update-tools', value: UI_I_SensorsGraphPayload): void
133
+ (event: 'exporting', value: string): void
134
+ (event: 'open-advanced-page'): void
135
+ (event: 'select-metric-local', value: string): void
136
+ (
137
+ event: 'power-selected-rows-local',
138
+ value: UI_I_HardwareHealthSensorsGraph[]
139
+ ): void
140
+ (
141
+ event: 'temperature-selected-rows-local',
142
+ value: UI_I_HardwareHealthSensorsGraph[]
143
+ ): void
144
+ (event: 'update-chart-type', value: string): void
145
+ (event: 'update-timespan-type', value: string): void
146
+ (event: 'update-unit-count', value: number): void
147
+ (event: 'update-period-type', value: string): void
148
+ (event: 'update-custom-time', value: string): void
149
+ (event: 'delete-option'): void
150
+ (event: 'update-custom-date-from', value: string): void
151
+ (event: 'update-custom-date-to', value: string): void
152
+ (event: 'update-custom-time-from', value: string): void
153
+ (event: 'update-custom-time-to', value: string): void
154
+ (event: 'submit-options', value: UI_I_OptionsForm): void
155
+ (event: 'update:selected-timespan-type', value: string): void
156
+ }>()
157
+
158
+ const localization = computed<UI_I_Localization>(() => useLocal())
159
+ const { $formattedDatetime } = useNuxtApp()
160
+
161
+ const periodOptions = computed<UI_I_OptionItem[]>(() =>
162
+ periodFunc(localization.value, props.selectedTimespanType)
163
+ )
164
+ const selectedPeriod = computed<string>({
165
+ get() {
166
+ return props.selectedTimespanType || periodOptions.value[0].value
167
+ },
168
+ set(newValue) {
169
+ emits('update:selected-timespan-type', newValue)
170
+ },
171
+ })
172
+
173
+ const optionsNames = ref<string[]>([])
174
+
175
+ const selectedView = ref<string>('power')
176
+ const viewOptions = computed<UI_I_OptionItem[]>(() =>
177
+ viewFunc(localization.value, optionsNames.value)
178
+ )
179
+
180
+ watch(
181
+ () => props.selectedChartOptionName,
182
+ (newValue) => {
183
+ let currentValue = ''
184
+
185
+ if (newValue) currentValue = newValue
186
+ else if (
187
+ selectedView.value &&
188
+ optionsNames.value.includes(selectedView.value)
189
+ )
190
+ currentValue = selectedView.value
191
+ else currentValue = selectedView.value || viewOptions.value[0]?.value
192
+
193
+ selectedView.value = currentValue
194
+ },
195
+ { immediate: true }
196
+ )
197
+
198
+ const onHideChartModal = (): void => {
199
+ emits('hide-chart-modal')
200
+ }
201
+
202
+ const onUpdateTools = (): void => {
203
+ const periodValue = selectedPeriod.value
204
+ const viewValue = selectedView.value
205
+ const selectedValue = useLocalStorage(
206
+ viewValue + 'ChartOptionsSensors',
207
+ undefined
208
+ )
209
+
210
+ const fields = selectedValue
211
+ ? selectedValue.counters.map((item) => item.name).join(', ')
212
+ : ''
213
+ const validPeriodData = getValidDateByOptionFunc(
214
+ periodValue,
215
+ null,
216
+ null,
217
+ null
218
+ )
219
+
220
+ const period = [
221
+ Math.round(validPeriodData[0] / 1000),
222
+ Math.round(validPeriodData[1] / 1000),
223
+ ]
224
+
225
+ if (periodValue === 'custom_interval' && props.periodType === 'period') {
226
+ const checkDateResult = checkDateFunc(
227
+ localization.value,
228
+ props.customDateFrom,
229
+ props.customDateTo,
230
+ props.customTimeFrom,
231
+ props.customTimeTo
232
+ )
233
+ if (Array.isArray(checkDateResult)) {
234
+ period[0] = Math.round(checkDateResult[0] / 1000)
235
+ period[1] = Math.round(checkDateResult[1] / 1000)
236
+ }
237
+ }
238
+
239
+ const tools: UI_I_SensorsGraphPayload = {
240
+ fields,
241
+ period,
242
+ periodName: periodValue,
243
+ view: viewValue,
244
+ }
245
+ if (selectedValue.metric) tools.metricType = selectedValue.metric
246
+
247
+ emits('update-timespan-type', selectedPeriod.value)
248
+ emits('update-tools', tools)
249
+ }
250
+
251
+ const chartTitleDate = computed<string>(() => {
252
+ if (!props.startDate) return ''
253
+
254
+ const start = $formattedDatetime(props.startDate, '', true)
255
+ const end = $formattedDatetime(new Date(), '', true)
256
+ return `${start} - ${end}`
257
+ })
258
+
259
+ const onShowChartOptions = (): void => {
260
+ emits('show-chart-modal')
261
+ }
262
+
263
+ const onSaveOptionName = (): void => {
264
+ optionsNames.value = getCurrentOptionsStorageFunc()
265
+ }
266
+
267
+ onMounted(() => {
268
+ optionsNames.value = getCurrentOptionsStorageFunc()
269
+ onUpdateTools()
270
+ })
271
+ </script>
272
+
273
+ <style scoped lang="scss">
274
+ .horizontal-flex-container {
275
+ display: flex;
276
+ flex-direction: row;
277
+ align-items: center;
278
+ line-height: 20px;
279
+ flex-shrink: 0;
280
+
281
+ .chart-title-content {
282
+ overflow: hidden;
283
+ text-overflow: ellipsis;
284
+ }
285
+
286
+ .select select {
287
+ height: 20px;
288
+ margin: 5px;
289
+ color: var(--global-font-color);
290
+ }
291
+ .single-option {
292
+ margin-left: 5px;
293
+ }
294
+
295
+ .chart-title {
296
+ color: var(--global-font-color);
297
+ text-overflow: ellipsis;
298
+ white-space: nowrap;
299
+ overflow: hidden;
300
+ margin: 6px;
301
+ font-weight: 700;
302
+ text-transform: capitalize;
303
+
304
+ &.uppercase {
305
+ text-transform: uppercase;
306
+ }
307
+ }
308
+
309
+ .view-select-label {
310
+ margin-left: auto;
311
+ padding-right: 7px;
312
+ padding-left: 7px;
313
+ text-overflow: ellipsis;
314
+ white-space: nowrap;
315
+ align-items: center;
316
+ }
317
+
318
+ .chart-options-button {
319
+ margin-left: 5px;
320
+ text-overflow: ellipsis;
321
+ white-space: nowrap;
322
+ text-transform: capitalize;
323
+ color: var(--dropdown-item-color);
324
+ cursor: pointer;
325
+ }
326
+
327
+ .chart-action-bar {
328
+ white-space: nowrap;
329
+
330
+ .menu-item {
331
+ padding-right: 4px;
332
+ display: inline-block;
333
+ list-style: none;
334
+ vertical-align: middle;
335
+
336
+ &:last-child {
337
+ padding-right: 0;
338
+ }
339
+
340
+ .item-link {
341
+ padding: 4px;
342
+ line-height: 22px;
343
+ border: 1px solid transparent;
344
+ display: inline-block;
345
+
346
+ &:hover {
347
+ text-decoration: none;
348
+ background-color: #e9f6fd;
349
+ border: 1px solid #c7e9ff;
350
+ }
351
+
352
+ .icon {
353
+ width: 16px;
354
+ height: 16px;
355
+ display: block;
356
+ min-width: 16px;
357
+ min-height: 16px;
358
+ background-size: 100% auto;
359
+ }
360
+ }
361
+
362
+ :deep(.dropdown-menu) {
363
+ min-width: auto;
364
+ padding: 0;
365
+ }
366
+ :deep(.user-menu-large) {
367
+ padding: 0;
368
+ }
369
+ :deep(.angle-icon) {
370
+ display: none;
371
+ }
372
+ }
373
+ }
374
+ }
375
+ </style>