bfg-common 1.4.166 → 1.4.167

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,453 +1,456 @@
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>
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
+ import { containerMediumSize } from '~/components/common/pages/hardwareHealth/historyTestimony/lib/config/containerSizes'
89
+
90
+ const props = defineProps<{
91
+ powerData: I_SeriesLine | null
92
+ temperatureData: I_SeriesLine | null
93
+ countersTableData: UI_I_HardwareHealthSensors[]
94
+ language: string
95
+ powerLoading: boolean
96
+ temperatureLoading: boolean
97
+ formattedDatetime: any
98
+ isDarkMode: boolean
99
+ getDateFormat: any
100
+ mainSelectedRow: number[]
101
+ }>()
102
+ const selectedView = defineModel<string>('selectedView')
103
+
104
+ const { $store }: any = useNuxtApp()
105
+
106
+ const historyTestimonyGraph = ref<any>(null)
107
+ const { width } = useElementSize(historyTestimonyGraph)
108
+ const isMediumSizeGraphsContainer = computed<boolean>(
109
+ () => width.value < containerMediumSize
110
+ )
111
+
112
+ // const historyTestimonyGraph = ref(null)
113
+ // const contentWidth = ref<number>(
114
+ // useElementSize(historyTestimonyGraph)?.width || 0
115
+ // )
116
+ // watch(contentWidth, (newValue) => {
117
+ // if (newValue) {
118
+ // updatePowerChart()
119
+ // updateTemperatureChart()
120
+ // }
121
+ // if (!powerChart.value || !temperatureChart.value) return
122
+ //
123
+ // powerChart.value.setSize(1, powerChart.chartHeight)
124
+ // temperatureChart.value.setSize(1, temperatureChart.chartHeight)
125
+ //
126
+ // setTimeout(() => {
127
+ // powerChart.value.setSize(newValue, powerChart.chartHeight)
128
+ // temperatureChart.value.setSize(newValue, temperatureChart.chartHeight)
129
+ // }, 1000)
130
+ // })
131
+ // const isContentMediumSize = computed<boolean>(() => contentWidth.value <= 1200)
132
+
133
+ const selectedChartOptionName = ref<string>('')
134
+ const isShowChartModal = ref<boolean>(false)
135
+ const selectedMetric = ref<UI_T_Chart>('power')
136
+ const selectedPowerCountersKeys = ref<number[]>([])
137
+ const selectedTemperatureCountersKeys = ref<number[]>([])
138
+ const selectedTimespanType = ref<string>('')
139
+ const customDateFrom = ref<string>('')
140
+ const customDateTo = ref<string>('')
141
+ const customTimeFrom = ref<string>('')
142
+ const customTimeTo = ref<string>('')
143
+
144
+ const selectedRowPower = ref<number[]>([])
145
+ const selectedRowTemperature = ref<number[]>([])
146
+ let powerCounters: UI_I_HardwareHealthSensors[] = []
147
+ let temperatureCounters: UI_I_HardwareHealthSensors[] = []
148
+ const updateAllSelectedSelectedRow = (): void => {
149
+ selectedRowPower.value = []
150
+ selectedRowTemperature.value = []
151
+
152
+ if (!props.mainSelectedRow.length) return
153
+
154
+ props.mainSelectedRow.forEach((key) => {
155
+ const selectedItem = props.countersTableData[key]
156
+ const category = selectedItem.category.toLowerCase()
157
+
158
+ if (category === 'power') {
159
+ const currentKey = powerCounters.findIndex(
160
+ (item) => item.id === selectedItem.id
161
+ )
162
+ selectedRowPower.value.push(currentKey)
163
+ } else if (category === 'temperature') {
164
+ const currentKey = temperatureCounters.findIndex(
165
+ (item) => item.id === selectedItem.id
166
+ )
167
+ selectedRowTemperature.value.push(currentKey)
168
+ }
169
+ })
170
+ }
171
+ watch(
172
+ () => props.countersTableData,
173
+ (newValue) => {
174
+ powerCounters = newValue.filter(
175
+ (item) => item.category.toLowerCase() === 'power'
176
+ )
177
+ temperatureCounters = newValue.filter(
178
+ (item) => item.category.toLowerCase() === 'temperature'
179
+ )
180
+ },
181
+ { deep: true, immediate: true }
182
+ )
183
+ watch(
184
+ () => props.mainSelectedRow,
185
+ () => {
186
+ updateAllSelectedSelectedRow()
187
+ },
188
+ { deep: true, immediate: true }
189
+ )
190
+ watch(
191
+ selectedView,
192
+ () => {
193
+ updateAllSelectedSelectedRow()
194
+ },
195
+ { deep: true }
196
+ )
197
+
198
+ const unitsCount = ref<number>(0)
199
+ const powerCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
200
+ const temperatureCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
201
+ const powerSelectedRowsLocal = ref<UI_I_HardwareHealthSensorsGraph[]>([])
202
+ const temperatureSelectedRowsLocal = ref<UI_I_HardwareHealthSensorsGraph[]>([])
203
+
204
+ watch(
205
+ () => props.countersTableData,
206
+ (newValue) => {
207
+ if (!newValue.length) return
208
+
209
+ powerCountersTableData.value = []
210
+ temperatureCountersTableData.value = []
211
+
212
+ newValue.forEach((item, key) => {
213
+ const newData: UI_I_HardwareHealthSensorsGraph = {
214
+ id: key,
215
+ name: item.name,
216
+ description: item.category,
217
+ measurement: '',
218
+ units: '',
219
+ nameEn: item.mainName || '',
220
+ testId: `counters-table-${item.name}-item`,
221
+ hidden: item.hidden,
222
+ }
223
+ if (item.category.toLowerCase() === 'power')
224
+ powerCountersTableData.value.push(newData)
225
+ else if (item.category.toLowerCase() === 'temperature')
226
+ temperatureCountersTableData.value.push(newData)
227
+ })
228
+ },
229
+ { immediate: true, deep: true }
230
+ )
231
+
232
+ const selectAllCounters = (): void => {
233
+ if (!powerCountersTableData.value)
234
+ setTimeout(() => {
235
+ selectAllCounters()
236
+ }, 2000)
237
+ else {
238
+ powerCountersTableData.value.forEach((item) => {
239
+ selectedPowerCountersKeys.value.push(item.id)
240
+ })
241
+ temperatureCountersTableData.value.forEach((item) => {
242
+ if (!item.hidden) selectedTemperatureCountersKeys.value.push(item.id)
243
+ })
244
+ }
245
+ }
246
+
247
+ onMounted(() => {
248
+ selectAllCounters()
249
+ })
250
+
251
+ const localization = computed<UI_I_Localization>(() => useLocal())
252
+
253
+ const powerDataLocal = ref<I_LineGraph | null>(null)
254
+ const temperatureDataLocal = ref<I_LineGraph | null>(null)
255
+ const updatePowerHelper = ref<number>(0)
256
+ const updateTemperatureHelper = ref<number>(0)
257
+ let dateFormat = ''
258
+ const powerChart = ref<any>(null)
259
+ const temperatureChart = ref<any>(null)
260
+ const timespanPeriodType = ref<string>('last')
261
+
262
+ const powerChartCallback = (newValue: any): void => {
263
+ newValue && (powerChart.value = newValue)
264
+ }
265
+
266
+ const temperatureChartCallback = (newValue: any): void => {
267
+ newValue && (temperatureChart.value = newValue)
268
+ }
269
+
270
+ const updatePowerChart = (): void => {
271
+ if (!props.powerData) return
272
+
273
+ powerDataLocal.value = graphDataFunc(
274
+ props.powerData,
275
+ props.isDarkMode,
276
+ localization.value,
277
+ () => {},
278
+ false,
279
+ false,
280
+ true,
281
+ 'spline',
282
+ '',
283
+ undefined,
284
+ powerChartCallback,
285
+ props.formattedDatetime,
286
+ format,
287
+ dateFormat
288
+ )
289
+
290
+ updatePowerHelper.value++
291
+ }
292
+
293
+ const updateTemperatureChart = (): void => {
294
+ if (!props.temperatureData) return
295
+
296
+ temperatureDataLocal.value = graphDataFunc(
297
+ props.temperatureData,
298
+ props.isDarkMode,
299
+ localization.value,
300
+ () => {},
301
+ false,
302
+ false,
303
+ true,
304
+ 'spline',
305
+ '',
306
+ undefined,
307
+ temperatureChartCallback,
308
+ props.formattedDatetime,
309
+ format,
310
+ dateFormat
311
+ )
312
+
313
+ updateTemperatureHelper.value++
314
+ }
315
+
316
+ watch(
317
+ () => [props.powerData, props.isDarkMode, props.language],
318
+ (newValue) => {
319
+ dateFormat = props.getDateFormat(newValue[2])
320
+ updatePowerChart()
321
+ },
322
+ { immediate: true, deep: true }
323
+ )
324
+
325
+ watch(
326
+ () => [props.temperatureData, props.isDarkMode, props.language],
327
+ (newValue) => {
328
+ dateFormat = props.getDateFormat(newValue[2])
329
+ updateTemperatureChart()
330
+ },
331
+ { immediate: true, deep: true }
332
+ )
333
+
334
+ const updateSelectedCountersKeys = (metricType: string): void => {
335
+ if (metricType === 'power') {
336
+ const newKeys: number[] = []
337
+
338
+ powerSelectedRowsLocal.value.forEach((item) => {
339
+ newKeys.push(item.id)
340
+ })
341
+ selectedPowerCountersKeys.value = newKeys
342
+ } else if (metricType === 'temperature') {
343
+ const newKeys: number[] = []
344
+
345
+ temperatureSelectedRowsLocal.value.forEach((item) => {
346
+ newKeys.push(item.id)
347
+ })
348
+ selectedTemperatureCountersKeys.value = newKeys
349
+ }
350
+ }
351
+
352
+ const tools = {
353
+ periodName: 'real_time',
354
+ view: 'power',
355
+ metricType: selectedMetric.value,
356
+ period: [],
357
+ }
358
+
359
+ const onSubmitOptions = (data: UI_I_OptionsForm): void => {
360
+ selectedTimespanType.value = data.periodName
361
+ updateSelectedCountersKeys(data.metric)
362
+ if (data.metric === 'power')
363
+ $store.dispatch(
364
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_POWER',
365
+ data
366
+ )
367
+ if (data.metric === 'temperature')
368
+ $store.dispatch(
369
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_TEMPERATURE',
370
+ data
371
+ )
372
+ }
373
+
374
+ const getAllMetrics = (): void => {
375
+ $store.dispatch(
376
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_POWER',
377
+ tools
378
+ )
379
+ $store.dispatch(
380
+ 'monitor/A_GET_HARDWARE_HEALTH_HISTORY_TESTIMONY_TEMPERATURE',
381
+ tools
382
+ )
383
+ }
384
+
385
+ const onUpdateTools = (data: UI_I_SensorsGraphPayload): void => {
386
+ const storageChartOptions = useLocalStorage(
387
+ data.view + 'ChartOptionsSensors',
388
+ undefined
389
+ )
390
+
391
+ selectedChartOptionName.value = ''
392
+
393
+ if (storageChartOptions) {
394
+ selectedChartOptionName.value = data.view
395
+ } else {
396
+ selectedMetric.value = 'power'
397
+ }
398
+
399
+ tools.periodName = data.periodName
400
+ tools.view = data.view
401
+ tools.period = data.period
402
+ tools.metricType = data.metricType || selectedMetric.value
403
+
404
+ getAllMetrics()
405
+ }
406
+
407
+ const onDeleteOption = (): void => {}
408
+ </script>
409
+
410
+ <style scoped lang="scss">
411
+ .history-testimony-graph {
412
+ display: flex;
413
+ align-items: center;
414
+ grid-gap: 20px;
415
+
416
+ &.medium {
417
+ flex-direction: column;
418
+
419
+ .graph-container {
420
+ width: 100%;
421
+ }
422
+ }
423
+ .graph-container {
424
+ width: calc(50% - 10px);
425
+ }
426
+ &.power {
427
+ & > div:nth-child(1) {
428
+ width: 100%;
429
+ }
430
+ & > div:nth-child(2) {
431
+ display: none;
432
+ width: 0;
433
+ }
434
+ }
435
+ &.temperature {
436
+ & > div:nth-child(1) {
437
+ display: none;
438
+ width: 0;
439
+ }
440
+ & > div:nth-child(2) {
441
+ width: 100%;
442
+ }
443
+ }
444
+
445
+ &__loader-block {
446
+ height: inherit;
447
+ display: flex;
448
+ justify-content: center;
449
+ align-items: center;
450
+ min-height: 300px;
451
+ }
452
+ &__empty-content {
453
+ height: inherit;
454
+ }
455
+ }
456
+ </style>
@@ -0,0 +1 @@
1
+ export const containerMediumSize: number = 1021
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.166",
4
+ "version": "1.4.167",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",