bfg-common 1.4.163 → 1.4.164

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,435 +1,453 @@
1
- <template>
2
- <common-pages-hardware-health-history-testimony-tools
3
- v-model:selected-view="selectedView"
4
- v-model:selected-timespan-type="selectedTimespanType"
5
- :selected-chart-option-name="selectedChartOptionName"
6
- :is-show-chart-modal="isShowChartModal"
7
- :chart-title="props.powerData?.groupName || ''"
8
- :selected-metric="selectedMetric"
9
- :selected-power-counters-keys="selectedPowerCountersKeys"
10
- :power-selected-rows-local="powerSelectedRowsLocal"
11
- :selected-temperature-counters-keys="selectedTemperatureCountersKeys"
12
- :temperature-selected-rows-local="temperatureSelectedRowsLocal"
13
- :units-count="unitsCount"
14
- :power-counters-table-data="powerCountersTableData"
15
- :temperature-counters-table-data="temperatureCountersTableData"
16
- :language="props.language"
17
- :custom-date-from="customDateFrom"
18
- :custom-date-to="customDateTo"
19
- :custom-time-from="customTimeFrom"
20
- :custom-time-to="customTimeTo"
21
- :start-date="props.powerData?.pointStart || 0"
22
- :timespan-period-type="timespanPeriodType"
23
- @power-selected-rows-local="powerSelectedRowsLocal = $event"
24
- @temperature-selected-rows-local="temperatureSelectedRowsLocal = $event"
25
- @show-chart-modal="isShowChartModal = true"
26
- @hide-chart-modal="isShowChartModal = false"
27
- @update-tools="onUpdateTools"
28
- @delete-option="onDeleteOption"
29
- @submit-options="onSubmitOptions"
30
- @update-timespan-period-type="timespanPeriodType = $event"
31
- />
32
- <div
33
- ref="historyTestimonyGraph"
34
- :class="`history-testimony-graph ${selectedView}`"
35
- >
36
- <div>
37
- <common-graph
38
- v-if="powerDataLocal && !props.powerLoading"
39
- :data="powerDataLocal"
40
- :update="updatePowerHelper"
41
- :chart="powerChart"
42
- :selected-row="selectedRowPower"
43
- />
44
- <div
45
- v-else-if="props.powerLoading"
46
- class="history-testimony-graph__loader-block"
47
- >
48
- <div class="spinner"></div>
49
- </div>
50
- <div v-else class="history-testimony-graph__empty-content"></div>
51
- </div>
52
- <div>
53
- <common-graph
54
- v-if="temperatureDataLocal && !props.temperatureLoading"
55
- :data="temperatureDataLocal"
56
- :update="updateTemperatureHelper"
57
- :chart="temperatureChart"
58
- :selected-row="selectedRowTemperature"
59
- />
60
- <div
61
- v-else-if="props.temperatureLoading"
62
- class="history-testimony-graph__loader-block"
63
- >
64
- <div class="spinner"></div>
65
- </div>
66
- <div v-else class="history-testimony-graph__empty-content"></div>
67
- </div>
68
- </div>
69
- </template>
70
-
71
- <script setup lang="ts">
72
- import { format } from 'date-fns'
73
- import type {
74
- I_SeriesLine,
75
- I_LineGraph,
76
- } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/models/interfaces'
77
- import { graphDataFunc } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/utils/renderGraph'
78
- import type { UI_I_OptionsForm } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/interfaces'
79
- import type { UI_I_Localization } from '~/lib/models/interfaces'
80
- import type { UI_T_Chart } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/types'
81
- import type { UI_I_HardwareHealthSensors } from '~/components/common/pages/hardwareHealth/tableView/lib/models/interfaces'
82
- import type { UI_I_HardwareHealthSensorsGraph } from '~/components/common/pages/hardwareHealth/historyTestimony/lib/models/interfaces'
83
- import type { UI_I_SensorsGraphPayload } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/lib/models/interfaces'
84
-
85
- const props = defineProps<{
86
- powerData: I_SeriesLine | null
87
- temperatureData: I_SeriesLine | null
88
- countersTableData: UI_I_HardwareHealthSensors[]
89
- language: string
90
- powerLoading: boolean
91
- temperatureLoading: boolean
92
- formattedDatetime: any
93
- isDarkMode: boolean
94
- getDateFormat: any
95
- mainSelectedRow: number[]
96
- }>()
97
- const selectedView = defineModel<string>('selectedView')
98
-
99
- const { $store }: any = useNuxtApp()
100
-
101
- // const historyTestimonyGraph = ref(null)
102
- // const contentWidth = ref<number>(
103
- // useElementSize(historyTestimonyGraph)?.width || 0
104
- // )
105
- // watch(contentWidth, (newValue) => {
106
- // if (newValue) {
107
- // updatePowerChart()
108
- // updateTemperatureChart()
109
- // }
110
- // if (!powerChart.value || !temperatureChart.value) return
111
- //
112
- // powerChart.value.setSize(1, powerChart.chartHeight)
113
- // temperatureChart.value.setSize(1, temperatureChart.chartHeight)
114
- //
115
- // setTimeout(() => {
116
- // powerChart.value.setSize(newValue, powerChart.chartHeight)
117
- // temperatureChart.value.setSize(newValue, temperatureChart.chartHeight)
118
- // }, 1000)
119
- // })
120
- // const isContentMediumSize = computed<boolean>(() => contentWidth.value <= 1200)
121
-
122
- const selectedChartOptionName = ref<string>('')
123
- const isShowChartModal = ref<boolean>(false)
124
- const selectedMetric = ref<UI_T_Chart>('power')
125
- const selectedPowerCountersKeys = ref<number[]>([])
126
- const selectedTemperatureCountersKeys = ref<number[]>([])
127
- const selectedTimespanType = ref<string>('')
128
- const customDateFrom = ref<string>('')
129
- const customDateTo = ref<string>('')
130
- const customTimeFrom = ref<string>('')
131
- const customTimeTo = ref<string>('')
132
-
133
- const selectedRowPower = ref<number[]>([])
134
- const selectedRowTemperature = ref<number[]>([])
135
- let powerCounters: UI_I_HardwareHealthSensors[] = []
136
- let temperatureCounters: UI_I_HardwareHealthSensors[] = []
137
- const updateAllSelectedSelectedRow = (): void => {
138
- selectedRowPower.value = []
139
- selectedRowTemperature.value = []
140
-
141
- if (!props.mainSelectedRow.length) return
142
-
143
- props.mainSelectedRow.forEach((key) => {
144
- const selectedItem = props.countersTableData[key]
145
- const category = selectedItem.category.toLowerCase()
146
-
147
- if (category === 'power') {
148
- const currentKey = powerCounters.findIndex(
149
- (item) => item.id === selectedItem.id
150
- )
151
- selectedRowPower.value.push(currentKey)
152
- } else if (category === 'temperature') {
153
- const currentKey = temperatureCounters.findIndex(
154
- (item) => item.id === selectedItem.id
155
- )
156
- selectedRowTemperature.value.push(currentKey)
157
- }
158
- })
159
- }
160
- watch(
161
- () => props.countersTableData,
162
- (newValue) => {
163
- powerCounters = newValue.filter(
164
- (item) => item.category.toLowerCase() === 'power'
165
- )
166
- temperatureCounters = newValue.filter(
167
- (item) => item.category.toLowerCase() === 'temperature'
168
- )
169
- },
170
- { deep: true, immediate: true }
171
- )
172
- watch(
173
- () => props.mainSelectedRow,
174
- () => {
175
- updateAllSelectedSelectedRow()
176
- },
177
- { deep: true, immediate: true }
178
- )
179
- watch(
180
- selectedView,
181
- () => {
182
- updateAllSelectedSelectedRow()
183
- },
184
- { deep: true }
185
- )
186
-
187
- const unitsCount = ref<number>(0)
188
- const powerCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
189
- const temperatureCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
190
- const powerSelectedRowsLocal = ref<UI_I_HardwareHealthSensorsGraph[]>([])
191
- const temperatureSelectedRowsLocal = ref<UI_I_HardwareHealthSensorsGraph[]>([])
192
-
193
- watch(
194
- () => props.countersTableData,
195
- (newValue) => {
196
- if (!newValue.length) return
197
-
198
- powerCountersTableData.value = []
199
- temperatureCountersTableData.value = []
200
-
201
- newValue.forEach((item, key) => {
202
- const newData: UI_I_HardwareHealthSensorsGraph = {
203
- id: key,
204
- name: item.name,
205
- description: item.category,
206
- measurement: '',
207
- units: '',
208
- nameEn: item.mainName || '',
209
- testId: `counters-table-${item.name}-item`,
210
- hidden: item.hidden,
211
- }
212
- if (item.category.toLowerCase() === 'power')
213
- powerCountersTableData.value.push(newData)
214
- else if (item.category.toLowerCase() === 'temperature')
215
- temperatureCountersTableData.value.push(newData)
216
- })
217
- },
218
- { immediate: true, deep: true }
219
- )
220
-
221
- const selectAllCounters = (): void => {
222
- if (!powerCountersTableData.value)
223
- setTimeout(() => {
224
- selectAllCounters()
225
- }, 2000)
226
- else {
227
- powerCountersTableData.value.forEach((item) => {
228
- selectedPowerCountersKeys.value.push(item.id)
229
- })
230
- temperatureCountersTableData.value.forEach((item) => {
231
- if (!item.hidden) selectedTemperatureCountersKeys.value.push(item.id)
232
- })
233
- }
234
- }
235
-
236
- onMounted(() => {
237
- selectAllCounters()
238
- })
239
-
240
- const localization = computed<UI_I_Localization>(() => useLocal())
241
-
242
- const powerDataLocal = ref<I_LineGraph | null>(null)
243
- const temperatureDataLocal = ref<I_LineGraph | null>(null)
244
- const updatePowerHelper = ref<number>(0)
245
- const updateTemperatureHelper = ref<number>(0)
246
- let dateFormat = ''
247
- const powerChart = ref<any>(null)
248
- const temperatureChart = ref<any>(null)
249
- const timespanPeriodType = ref<string>('last')
250
-
251
- const powerChartCallback = (newValue: any): void => {
252
- newValue && (powerChart.value = newValue)
253
- }
254
-
255
- const temperatureChartCallback = (newValue: any): void => {
256
- newValue && (temperatureChart.value = newValue)
257
- }
258
-
259
- const updatePowerChart = (): void => {
260
- if (!props.powerData) return
261
-
262
- powerDataLocal.value = graphDataFunc(
263
- props.powerData,
264
- props.isDarkMode,
265
- localization.value,
266
- () => {},
267
- false,
268
- false,
269
- true,
270
- 'spline',
271
- '',
272
- undefined,
273
- powerChartCallback,
274
- props.formattedDatetime,
275
- format,
276
- dateFormat
277
- )
278
-
279
- updatePowerHelper.value++
280
- }
281
-
282
- const updateTemperatureChart = (): void => {
283
- if (!props.temperatureData) return
284
-
285
- temperatureDataLocal.value = graphDataFunc(
286
- props.temperatureData,
287
- props.isDarkMode,
288
- localization.value,
289
- () => {},
290
- false,
291
- false,
292
- true,
293
- 'spline',
294
- '',
295
- undefined,
296
- temperatureChartCallback,
297
- props.formattedDatetime,
298
- format,
299
- dateFormat
300
- )
301
-
302
- updateTemperatureHelper.value++
303
- }
304
-
305
- watch(
306
- () => [props.powerData, props.isDarkMode, props.language],
307
- (newValue) => {
308
- dateFormat = props.getDateFormat(newValue[2])
309
- updatePowerChart()
310
- },
311
- { immediate: true, deep: true }
312
- )
313
-
314
- watch(
315
- () => [props.temperatureData, props.isDarkMode, props.language],
316
- (newValue) => {
317
- dateFormat = props.getDateFormat(newValue[2])
318
- updateTemperatureChart()
319
- },
320
- { immediate: true, deep: true }
321
- )
322
-
323
- const updateSelectedCountersKeys = (metricType: string): void => {
324
- if (metricType === 'power') {
325
- const newKeys: number[] = []
326
-
327
- powerSelectedRowsLocal.value.forEach((item) => {
328
- newKeys.push(item.id)
329
- })
330
- selectedPowerCountersKeys.value = newKeys
331
- } else if (metricType === 'temperature') {
332
- const newKeys: number[] = []
333
-
334
- temperatureSelectedRowsLocal.value.forEach((item) => {
335
- newKeys.push(item.id)
336
- })
337
- selectedTemperatureCountersKeys.value = newKeys
338
- }
339
- }
340
-
341
- const tools = {
342
- periodName: 'real_time',
343
- view: 'power',
344
- metricType: selectedMetric.value,
345
- period: [],
346
- }
347
-
348
- const onSubmitOptions = (data: UI_I_OptionsForm): void => {
349
- selectedTimespanType.value = data.periodName
350
- updateSelectedCountersKeys(data.metric)
351
- if (data.metric === 'power')
352
- $store.dispatch(
353
- 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_POWER',
354
- data
355
- )
356
- if (data.metric === 'temperature')
357
- $store.dispatch(
358
- 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_TEMPERATURE',
359
- data
360
- )
361
- }
362
-
363
- const getAllMetrics = (): void => {
364
- $store.dispatch(
365
- 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_POWER',
366
- tools
367
- )
368
- $store.dispatch(
369
- 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_TEMPERATURE',
370
- tools
371
- )
372
- }
373
-
374
- const onUpdateTools = (data: UI_I_SensorsGraphPayload): void => {
375
- const storageChartOptions = useLocalStorage(
376
- data.view + 'ChartOptionsSensors',
377
- undefined
378
- )
379
-
380
- selectedChartOptionName.value = ''
381
-
382
- if (storageChartOptions) {
383
- selectedChartOptionName.value = data.view
384
- } else {
385
- selectedMetric.value = 'power'
386
- }
387
-
388
- tools.periodName = data.periodName
389
- tools.view = data.view
390
- tools.period = data.period
391
- tools.metricType = data.metricType || selectedMetric.value
392
-
393
- getAllMetrics()
394
- }
395
-
396
- const onDeleteOption = (): void => {}
397
- </script>
398
-
399
- <style scoped lang="scss">
400
- .history-testimony-graph {
401
- display: grid;
402
- align-items: center;
403
- grid-gap: 20px;
404
- grid-template-columns: 1fr 1fr;
405
-
406
- //&.medium {
407
- // grid-template-columns: 1fr;
408
- //}
409
- &.power {
410
- grid-template-columns: 1fr 0;
411
-
412
- & > div:nth-child(2) {
413
- visibility: hidden;
414
- }
415
- }
416
- &.temperature {
417
- grid-template-columns: 0 1fr;
418
-
419
- & > div:nth-child(1) {
420
- visibility: hidden;
421
- }
422
- }
423
-
424
- &__loader-block {
425
- height: inherit;
426
- display: flex;
427
- justify-content: center;
428
- align-items: center;
429
- min-height: 300px;
430
- }
431
- &__empty-content {
432
- height: inherit;
433
- }
434
- }
435
- </style>
1
+ <template>
2
+ <common-pages-hardware-health-history-testimony-tools
3
+ v-model:selected-view="selectedView"
4
+ v-model:selected-timespan-type="selectedTimespanType"
5
+ :selected-chart-option-name="selectedChartOptionName"
6
+ :is-show-chart-modal="isShowChartModal"
7
+ :chart-title="props.powerData?.groupName || ''"
8
+ :selected-metric="selectedMetric"
9
+ :selected-power-counters-keys="selectedPowerCountersKeys"
10
+ :power-selected-rows-local="powerSelectedRowsLocal"
11
+ :selected-temperature-counters-keys="selectedTemperatureCountersKeys"
12
+ :temperature-selected-rows-local="temperatureSelectedRowsLocal"
13
+ :units-count="unitsCount"
14
+ :power-counters-table-data="powerCountersTableData"
15
+ :temperature-counters-table-data="temperatureCountersTableData"
16
+ :language="props.language"
17
+ :custom-date-from="customDateFrom"
18
+ :custom-date-to="customDateTo"
19
+ :custom-time-from="customTimeFrom"
20
+ :custom-time-to="customTimeTo"
21
+ :start-date="props.powerData?.pointStart || 0"
22
+ :timespan-period-type="timespanPeriodType"
23
+ @power-selected-rows-local="powerSelectedRowsLocal = $event"
24
+ @temperature-selected-rows-local="temperatureSelectedRowsLocal = $event"
25
+ @show-chart-modal="isShowChartModal = true"
26
+ @hide-chart-modal="isShowChartModal = false"
27
+ @update-tools="onUpdateTools"
28
+ @delete-option="onDeleteOption"
29
+ @submit-options="onSubmitOptions"
30
+ @update-timespan-period-type="timespanPeriodType = $event"
31
+ />
32
+ <div
33
+ ref="historyTestimonyGraph"
34
+ :class="[
35
+ `history-testimony-graph ${selectedView}`,
36
+ { medium: isMediumSizeGraphsContainer },
37
+ ]"
38
+ >
39
+ <div class="graph-container">
40
+ <common-graph
41
+ v-if="powerDataLocal && !props.powerLoading"
42
+ :data="powerDataLocal"
43
+ :update="updatePowerHelper"
44
+ :chart="powerChart"
45
+ :selected-row="selectedRowPower"
46
+ />
47
+ <div
48
+ v-else-if="props.powerLoading"
49
+ class="history-testimony-graph__loader-block"
50
+ >
51
+ <div class="spinner"></div>
52
+ </div>
53
+ <div v-else class="history-testimony-graph__empty-content"></div>
54
+ </div>
55
+ <div class="graph-container">
56
+ <common-graph
57
+ v-if="temperatureDataLocal && !props.temperatureLoading"
58
+ :data="temperatureDataLocal"
59
+ :update="updateTemperatureHelper"
60
+ :chart="temperatureChart"
61
+ :selected-row="selectedRowTemperature"
62
+ />
63
+ <div
64
+ v-else-if="props.temperatureLoading"
65
+ class="history-testimony-graph__loader-block"
66
+ >
67
+ <div class="spinner"></div>
68
+ </div>
69
+ <div v-else class="history-testimony-graph__empty-content"></div>
70
+ </div>
71
+ </div>
72
+ </template>
73
+
74
+ <script setup lang="ts">
75
+ import { useElementSize } from '@vueuse/core'
76
+ import { format } from 'date-fns'
77
+ import type {
78
+ I_SeriesLine,
79
+ I_LineGraph,
80
+ } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/models/interfaces'
81
+ import { graphDataFunc } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/utils/renderGraph'
82
+ import type { UI_I_OptionsForm } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/interfaces'
83
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
84
+ import type { UI_T_Chart } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/types'
85
+ import type { UI_I_HardwareHealthSensors } from '~/components/common/pages/hardwareHealth/tableView/lib/models/interfaces'
86
+ import type { UI_I_HardwareHealthSensorsGraph } from '~/components/common/pages/hardwareHealth/historyTestimony/lib/models/interfaces'
87
+ import type { UI_I_SensorsGraphPayload } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/lib/models/interfaces'
88
+
89
+ const props = defineProps<{
90
+ powerData: I_SeriesLine | null
91
+ temperatureData: I_SeriesLine | null
92
+ countersTableData: UI_I_HardwareHealthSensors[]
93
+ language: string
94
+ powerLoading: boolean
95
+ temperatureLoading: boolean
96
+ formattedDatetime: any
97
+ isDarkMode: boolean
98
+ getDateFormat: any
99
+ mainSelectedRow: number[]
100
+ }>()
101
+ const selectedView = defineModel<string>('selectedView')
102
+
103
+ const { $store }: any = useNuxtApp()
104
+
105
+ const historyTestimonyGraph = ref<any>(null)
106
+ const { width } = useElementSize(historyTestimonyGraph)
107
+ const isMediumSizeGraphsContainer = computed<boolean>(() => width.value < 1021)
108
+
109
+ // const historyTestimonyGraph = ref(null)
110
+ // const contentWidth = ref<number>(
111
+ // useElementSize(historyTestimonyGraph)?.width || 0
112
+ // )
113
+ // watch(contentWidth, (newValue) => {
114
+ // if (newValue) {
115
+ // updatePowerChart()
116
+ // updateTemperatureChart()
117
+ // }
118
+ // if (!powerChart.value || !temperatureChart.value) return
119
+ //
120
+ // powerChart.value.setSize(1, powerChart.chartHeight)
121
+ // temperatureChart.value.setSize(1, temperatureChart.chartHeight)
122
+ //
123
+ // setTimeout(() => {
124
+ // powerChart.value.setSize(newValue, powerChart.chartHeight)
125
+ // temperatureChart.value.setSize(newValue, temperatureChart.chartHeight)
126
+ // }, 1000)
127
+ // })
128
+ // const isContentMediumSize = computed<boolean>(() => contentWidth.value <= 1200)
129
+
130
+ const selectedChartOptionName = ref<string>('')
131
+ const isShowChartModal = ref<boolean>(false)
132
+ const selectedMetric = ref<UI_T_Chart>('power')
133
+ const selectedPowerCountersKeys = ref<number[]>([])
134
+ const selectedTemperatureCountersKeys = ref<number[]>([])
135
+ const selectedTimespanType = ref<string>('')
136
+ const customDateFrom = ref<string>('')
137
+ const customDateTo = ref<string>('')
138
+ const customTimeFrom = ref<string>('')
139
+ const customTimeTo = ref<string>('')
140
+
141
+ const selectedRowPower = ref<number[]>([])
142
+ const selectedRowTemperature = ref<number[]>([])
143
+ let powerCounters: UI_I_HardwareHealthSensors[] = []
144
+ let temperatureCounters: UI_I_HardwareHealthSensors[] = []
145
+ const updateAllSelectedSelectedRow = (): void => {
146
+ selectedRowPower.value = []
147
+ selectedRowTemperature.value = []
148
+
149
+ if (!props.mainSelectedRow.length) return
150
+
151
+ props.mainSelectedRow.forEach((key) => {
152
+ const selectedItem = props.countersTableData[key]
153
+ const category = selectedItem.category.toLowerCase()
154
+
155
+ if (category === 'power') {
156
+ const currentKey = powerCounters.findIndex(
157
+ (item) => item.id === selectedItem.id
158
+ )
159
+ selectedRowPower.value.push(currentKey)
160
+ } else if (category === 'temperature') {
161
+ const currentKey = temperatureCounters.findIndex(
162
+ (item) => item.id === selectedItem.id
163
+ )
164
+ selectedRowTemperature.value.push(currentKey)
165
+ }
166
+ })
167
+ }
168
+ watch(
169
+ () => props.countersTableData,
170
+ (newValue) => {
171
+ powerCounters = newValue.filter(
172
+ (item) => item.category.toLowerCase() === 'power'
173
+ )
174
+ temperatureCounters = newValue.filter(
175
+ (item) => item.category.toLowerCase() === 'temperature'
176
+ )
177
+ },
178
+ { deep: true, immediate: true }
179
+ )
180
+ watch(
181
+ () => props.mainSelectedRow,
182
+ () => {
183
+ updateAllSelectedSelectedRow()
184
+ },
185
+ { deep: true, immediate: true }
186
+ )
187
+ watch(
188
+ selectedView,
189
+ () => {
190
+ updateAllSelectedSelectedRow()
191
+ },
192
+ { deep: true }
193
+ )
194
+
195
+ const unitsCount = ref<number>(0)
196
+ const powerCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
197
+ const temperatureCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
198
+ const powerSelectedRowsLocal = ref<UI_I_HardwareHealthSensorsGraph[]>([])
199
+ const temperatureSelectedRowsLocal = ref<UI_I_HardwareHealthSensorsGraph[]>([])
200
+
201
+ watch(
202
+ () => props.countersTableData,
203
+ (newValue) => {
204
+ if (!newValue.length) return
205
+
206
+ powerCountersTableData.value = []
207
+ temperatureCountersTableData.value = []
208
+
209
+ newValue.forEach((item, key) => {
210
+ const newData: UI_I_HardwareHealthSensorsGraph = {
211
+ id: key,
212
+ name: item.name,
213
+ description: item.category,
214
+ measurement: '',
215
+ units: '',
216
+ nameEn: item.mainName || '',
217
+ testId: `counters-table-${item.name}-item`,
218
+ hidden: item.hidden,
219
+ }
220
+ if (item.category.toLowerCase() === 'power')
221
+ powerCountersTableData.value.push(newData)
222
+ else if (item.category.toLowerCase() === 'temperature')
223
+ temperatureCountersTableData.value.push(newData)
224
+ })
225
+ },
226
+ { immediate: true, deep: true }
227
+ )
228
+
229
+ const selectAllCounters = (): void => {
230
+ if (!powerCountersTableData.value)
231
+ setTimeout(() => {
232
+ selectAllCounters()
233
+ }, 2000)
234
+ else {
235
+ powerCountersTableData.value.forEach((item) => {
236
+ selectedPowerCountersKeys.value.push(item.id)
237
+ })
238
+ temperatureCountersTableData.value.forEach((item) => {
239
+ if (!item.hidden) selectedTemperatureCountersKeys.value.push(item.id)
240
+ })
241
+ }
242
+ }
243
+
244
+ onMounted(() => {
245
+ selectAllCounters()
246
+ })
247
+
248
+ const localization = computed<UI_I_Localization>(() => useLocal())
249
+
250
+ const powerDataLocal = ref<I_LineGraph | null>(null)
251
+ const temperatureDataLocal = ref<I_LineGraph | null>(null)
252
+ const updatePowerHelper = ref<number>(0)
253
+ const updateTemperatureHelper = ref<number>(0)
254
+ let dateFormat = ''
255
+ const powerChart = ref<any>(null)
256
+ const temperatureChart = ref<any>(null)
257
+ const timespanPeriodType = ref<string>('last')
258
+
259
+ const powerChartCallback = (newValue: any): void => {
260
+ newValue && (powerChart.value = newValue)
261
+ }
262
+
263
+ const temperatureChartCallback = (newValue: any): void => {
264
+ newValue && (temperatureChart.value = newValue)
265
+ }
266
+
267
+ const updatePowerChart = (): void => {
268
+ if (!props.powerData) return
269
+
270
+ powerDataLocal.value = graphDataFunc(
271
+ props.powerData,
272
+ props.isDarkMode,
273
+ localization.value,
274
+ () => {},
275
+ false,
276
+ false,
277
+ true,
278
+ 'spline',
279
+ '',
280
+ undefined,
281
+ powerChartCallback,
282
+ props.formattedDatetime,
283
+ format,
284
+ dateFormat
285
+ )
286
+
287
+ updatePowerHelper.value++
288
+ }
289
+
290
+ const updateTemperatureChart = (): void => {
291
+ if (!props.temperatureData) return
292
+
293
+ temperatureDataLocal.value = graphDataFunc(
294
+ props.temperatureData,
295
+ props.isDarkMode,
296
+ localization.value,
297
+ () => {},
298
+ false,
299
+ false,
300
+ true,
301
+ 'spline',
302
+ '',
303
+ undefined,
304
+ temperatureChartCallback,
305
+ props.formattedDatetime,
306
+ format,
307
+ dateFormat
308
+ )
309
+
310
+ updateTemperatureHelper.value++
311
+ }
312
+
313
+ watch(
314
+ () => [props.powerData, props.isDarkMode, props.language],
315
+ (newValue) => {
316
+ dateFormat = props.getDateFormat(newValue[2])
317
+ updatePowerChart()
318
+ },
319
+ { immediate: true, deep: true }
320
+ )
321
+
322
+ watch(
323
+ () => [props.temperatureData, props.isDarkMode, props.language],
324
+ (newValue) => {
325
+ dateFormat = props.getDateFormat(newValue[2])
326
+ updateTemperatureChart()
327
+ },
328
+ { immediate: true, deep: true }
329
+ )
330
+
331
+ const updateSelectedCountersKeys = (metricType: string): void => {
332
+ if (metricType === 'power') {
333
+ const newKeys: number[] = []
334
+
335
+ powerSelectedRowsLocal.value.forEach((item) => {
336
+ newKeys.push(item.id)
337
+ })
338
+ selectedPowerCountersKeys.value = newKeys
339
+ } else if (metricType === 'temperature') {
340
+ const newKeys: number[] = []
341
+
342
+ temperatureSelectedRowsLocal.value.forEach((item) => {
343
+ newKeys.push(item.id)
344
+ })
345
+ selectedTemperatureCountersKeys.value = newKeys
346
+ }
347
+ }
348
+
349
+ const tools = {
350
+ periodName: 'real_time',
351
+ view: 'power',
352
+ metricType: selectedMetric.value,
353
+ period: [],
354
+ }
355
+
356
+ const onSubmitOptions = (data: UI_I_OptionsForm): void => {
357
+ selectedTimespanType.value = data.periodName
358
+ updateSelectedCountersKeys(data.metric)
359
+ if (data.metric === 'power')
360
+ $store.dispatch(
361
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_POWER',
362
+ data
363
+ )
364
+ if (data.metric === 'temperature')
365
+ $store.dispatch(
366
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_TEMPERATURE',
367
+ data
368
+ )
369
+ }
370
+
371
+ const getAllMetrics = (): void => {
372
+ $store.dispatch(
373
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_POWER',
374
+ tools
375
+ )
376
+ $store.dispatch(
377
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_TEMPERATURE',
378
+ tools
379
+ )
380
+ }
381
+
382
+ const onUpdateTools = (data: UI_I_SensorsGraphPayload): void => {
383
+ const storageChartOptions = useLocalStorage(
384
+ data.view + 'ChartOptionsSensors',
385
+ undefined
386
+ )
387
+
388
+ selectedChartOptionName.value = ''
389
+
390
+ if (storageChartOptions) {
391
+ selectedChartOptionName.value = data.view
392
+ } else {
393
+ selectedMetric.value = 'power'
394
+ }
395
+
396
+ tools.periodName = data.periodName
397
+ tools.view = data.view
398
+ tools.period = data.period
399
+ tools.metricType = data.metricType || selectedMetric.value
400
+
401
+ getAllMetrics()
402
+ }
403
+
404
+ const onDeleteOption = (): void => {}
405
+ </script>
406
+
407
+ <style scoped lang="scss">
408
+ .history-testimony-graph {
409
+ display: flex;
410
+ align-items: center;
411
+ grid-gap: 20px;
412
+
413
+ &.medium {
414
+ flex-direction: column;
415
+
416
+ .graph-container {
417
+ width: 100%;
418
+ }
419
+ }
420
+ .graph-container {
421
+ width: calc(50% - 10px);
422
+ }
423
+ &.power {
424
+ & > div:nth-child(1) {
425
+ width: 100%;
426
+ }
427
+ & > div:nth-child(2) {
428
+ display: none;
429
+ width: 0;
430
+ }
431
+ }
432
+ &.temperature {
433
+ & > div:nth-child(1) {
434
+ display: none;
435
+ width: 0;
436
+ }
437
+ & > div:nth-child(2) {
438
+ width: 100%;
439
+ }
440
+ }
441
+
442
+ &__loader-block {
443
+ height: inherit;
444
+ display: flex;
445
+ justify-content: center;
446
+ align-items: center;
447
+ min-height: 300px;
448
+ }
449
+ &__empty-content {
450
+ height: inherit;
451
+ }
452
+ }
453
+ </style>