bfg-common 1.4.732 → 1.4.733

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.
@@ -6,6 +6,7 @@
6
6
  :is-show-chart-modal="isShowChartModal"
7
7
  :chart-title="props.powerData?.groupName || ''"
8
8
  :selected-metric="selectedMetric"
9
+ :selected-chart-type="selectedChartType"
9
10
  :selected-power-counters-keys="selectedPowerCountersKeys"
10
11
  :power-selected-rows-local="powerSelectedRowsLocal"
11
12
  :selected-temperature-counters-keys="selectedTemperatureCountersKeys"
@@ -151,6 +152,7 @@ const customDateFrom = ref<string>('')
151
152
  const customDateTo = ref<string>('')
152
153
  const customTimeFrom = ref<string>('')
153
154
  const customTimeTo = ref<string>('')
155
+ const selectedChartType = ref<string>('spline')
154
156
 
155
157
  const selectedRowPower = ref<number[]>([])
156
158
  const selectedRowTemperature = ref<number[]>([])
@@ -65,6 +65,7 @@
65
65
  v-if="props.isShowChartModal"
66
66
  :selected-chart-option-name="props.selectedChartOptionName"
67
67
  :selected-metric="props.selectedMetric"
68
+ :selected-chart-type="props.selectedChartType"
68
69
  :power-selected-rows-local="props.powerSelectedRowsLocal"
69
70
  :temperature-selected-rows-local="props.temperatureSelectedRowsLocal"
70
71
  :selected-power-counters-keys="props.selectedPowerCountersKeys"
@@ -113,6 +114,7 @@ const props = defineProps<{
113
114
  isShowChartModal: boolean
114
115
  chartTitle: string
115
116
  selectedMetric: UI_T_Chart
117
+ selectedChartType: string
116
118
  selectedPowerCountersKeys: number[]
117
119
  powerSelectedRowsLocal: UI_I_HardwareHealthSensorsGraph[]
118
120
  selectedTemperatureCountersKeys: number[]
@@ -1,494 +1,502 @@
1
- <template>
2
- <div class="chart-options-modal">
3
- <atoms-modal
4
- width="1150px"
5
- :show="true"
6
- :title="localization.inventoryMonitor.chartOptions"
7
- :disabled-submit="isDisabledSubmit"
8
- @hide="onHide"
9
- @submit="onSubmit"
10
- >
11
- <template #modalBody>
12
- <common-monitor-advanced-tools-chart-options-modal-notification
13
- v-show="isShowAlerts"
14
- :alerts="alerts"
15
- @remove="onRemoveAlerts"
16
- />
17
- <div>
18
- <common-pages-hardware-health-history-testimony-tools-chart-options-modal-actions
19
- :is-disabled-save="!currentSelectedRows.length"
20
- :options-names="optionsNames"
21
- :selected-chart-option-name="localSelectedChartOptionName"
22
- @save="onSaveOptions"
23
- @check-validation="checkValidations"
24
- @select-local-option-name="onSelectLocalOptionName"
25
- @delete-chart-name="onDeleteChartName"
26
- />
27
-
28
- <div class="horizontal-flex-container chart-options-content">
29
- <common-pages-hardware-health-history-testimony-tools-chart-options-modal-metrics
30
- v-model:selected-metric="selectedMetric"
31
- :metrics-items="metricsItems"
32
- />
33
- <common-pages-hardware-health-history-testimony-tools-chart-options-modal-counters
34
- :chart="selectedMetric"
35
- :selected-power-keys="localSelectedPowerCountersKeys"
36
- :selected-temperature-keys="localSelectedTemperatureCountersKeys"
37
- :power-counters-table-data="props.powerCountersTableData"
38
- :temperature-counters-table-data="
39
- props.temperatureCountersTableData
40
- "
41
- :language="props.language"
42
- :selected-chart-type="localSelectedChartType"
43
- :selected-timespan-type="localSelectedTimespanType"
44
- :units-count="localUnitsCount"
45
- :period-type="localTimespanPeriodType"
46
- :selected-custom-time="localCustomTime"
47
- :custom-date-from="props.customDateFrom"
48
- :custom-date-to="props.customDateTo"
49
- :custom-time-from="props.customTimeFrom"
50
- :custom-time-to="props.customTimeTo"
51
- :valid-date-end="props.validDateEnd"
52
- @select-power-row="onSelectPowerRow"
53
- @select-temperature-row="onSelectTemperatureRow"
54
- @update-chart-type="selectedChartTypeLocal = $event"
55
- @update-custom-time="localCustomTime = $event"
56
- @update-timespan-type="timespanType = $event"
57
- @update-unit-count="unitCount = $event"
58
- @update-period-type="localTimespanPeriodType = $event"
59
- @update-custom-date-from="onUpdateCustomDateFrom"
60
- @update-custom-date-to="onUpdateCustomDateTo"
61
- @update-custom-time-from="onUpdateCustomTimeFrom"
62
- @update-custom-time-to="onUpdateCustomTimeTo"
63
- />
64
- </div>
65
- </div>
66
- </template>
67
- </atoms-modal>
68
- </div>
69
- </template>
70
-
71
- <script setup lang="ts">
72
- import type { UI_I_Localization } from '~/lib/models/interfaces'
73
- import type { UI_I_VerticalTabs } from '~/components/atoms/tabs/lib/models/interfaces'
74
- import type { UI_T_Chart } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/types'
75
- import type { UI_I_OptionsForm } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/interfaces'
76
- import type { UI_I_HardwareHealthSensorsGraph } from '~/components/common/pages/hardwareHealth/historyTestimony/lib/models/interfaces'
77
- import { metricsFunc } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/config/optionsMetrics'
78
- import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
79
- import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
80
- import { getCurrentOptionsStorageFunc } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/lib/config/toolbar'
81
-
82
- const props = defineProps<{
83
- selectedChartOptionName: string
84
- selectedMetric: UI_T_Chart
85
- selectedPowerCountersKeys: number[]
86
- powerSelectedRowsLocal: UI_I_HardwareHealthSensorsGraph[]
87
- selectedTemperatureCountersKeys: number[]
88
- temperatureSelectedRowsLocal: UI_I_HardwareHealthSensorsGraph[]
89
- unitsCount: number
90
- powerCountersTableData: UI_I_HardwareHealthSensorsGraph[]
91
- temperatureCountersTableData: UI_I_HardwareHealthSensorsGraph[]
92
- language: string
93
- selectedTimespanType: string
94
- customDateFrom: string
95
- customDateTo: string
96
- customTimeFrom: string
97
- customTimeTo: string
98
- timespanPeriodType: string
99
- validDateEnd: number
100
- formatDate: string
101
- }>()
102
-
103
- const emits = defineEmits<{
104
- (event: 'hide'): void
105
- (event: 'select-metric-local', value: string): void
106
- (
107
- event: 'power-selected-rows-local',
108
- value: UI_I_HardwareHealthSensorsGraph[]
109
- ): void
110
- (
111
- event: 'temperature-selected-rows-local',
112
- value: UI_I_HardwareHealthSensorsGraph[]
113
- ): void
114
- (event: 'update-chart-type', value: string): void
115
- (event: 'update-timespan-type', value: string): void
116
- (event: 'update-unit-count', value: number): void
117
- (event: 'update-period-type', value: string): void
118
- (event: 'update-custom-time', value: string): void
119
- (event: 'delete-option'): void
120
- (event: 'save-option-name'): void
121
- (event: 'update-custom-date-from', value: string): void
122
- (event: 'update-custom-date-to', value: string): void
123
- (event: 'update-custom-time-from', value: string): void
124
- (event: 'update-custom-time-to', value: string): void
125
- (event: 'submit-options', value: UI_I_OptionsForm): void
126
- }>()
127
-
128
- const routeType = '' + useRoute().params.type
129
-
130
- const localization = computed<UI_I_Localization>(() => useLocal())
131
-
132
- const localCustomDateFrom = ref<string>('')
133
- const onUpdateCustomDateFrom = (value: string): void => {
134
- localCustomDateFrom.value = value
135
- }
136
- const localCustomDateTo = ref<string>('')
137
- const onUpdateCustomDateTo = (value: string): void => {
138
- localCustomDateTo.value = value
139
- }
140
- const localCustomTimeFrom = ref<string>('')
141
- const onUpdateCustomTimeFrom = (value: string): void => {
142
- localCustomTimeFrom.value = value
143
- }
144
- const localCustomTimeTo = ref<string>('')
145
- const onUpdateCustomTimeTo = (value: string): void => {
146
- localCustomTimeTo.value = value
147
- }
148
-
149
- const metricsItems = computed<UI_I_VerticalTabs[]>(() =>
150
- metricsFunc(localization.value)
151
- )
152
- const selectedMetric = ref<UI_T_Chart>(
153
- props.selectedMetric || '' + metricsItems.value[0]?.value
154
- )
155
-
156
- const localSelectedPowerCountersKeys = ref<number[]>([])
157
- watch(
158
- () => props.selectedPowerCountersKeys,
159
- (newValue) => {
160
- localSelectedPowerCountersKeys.value = newValue
161
- },
162
- { immediate: true, deep: true }
163
- )
164
-
165
- const localSelectedTemperatureCountersKeys = ref<number[]>([])
166
- watch(
167
- () => props.selectedTemperatureCountersKeys,
168
- (newValue) => {
169
- localSelectedTemperatureCountersKeys.value = newValue
170
- },
171
- { immediate: true, deep: true }
172
- )
173
-
174
- const localSelectedChartType = ref<string>('')
175
-
176
- const localSelectedTimespanType = ref<string>('')
177
- watch(
178
- () => props.selectedTimespanType,
179
- (newValue) => {
180
- localSelectedTimespanType.value = newValue
181
- },
182
- { immediate: true }
183
- )
184
-
185
- const localUnitsCount = ref<number>(0)
186
- watch(
187
- () => props.unitsCount,
188
- (newValue) => {
189
- localUnitsCount.value = newValue
190
- },
191
- { immediate: true }
192
- )
193
-
194
- const localTimespanPeriodType = ref<string>('')
195
- watch(
196
- () => props.timespanPeriodType,
197
- (newValue) => {
198
- localTimespanPeriodType.value = newValue
199
- },
200
- { immediate: true }
201
- )
202
-
203
- const localCustomTime = ref<string>('')
204
-
205
- const isShowAlerts = ref<boolean>(false)
206
- const alerts = ref<string[]>([])
207
-
208
- const onRemoveAlerts = (): void => {
209
- isShowAlerts.value = false
210
- alerts.value = []
211
- }
212
-
213
- const onHide = (): void => {
214
- emits('hide')
215
- }
216
-
217
- const onSelectPowerRow = (data: UI_I_HardwareHealthSensorsGraph[]): void => {
218
- emits('power-selected-rows-local', data)
219
- }
220
- const onSelectTemperatureRow = (
221
- data: UI_I_HardwareHealthSensorsGraph[]
222
- ): void => {
223
- emits('temperature-selected-rows-local', data)
224
- }
225
-
226
- const currentSelectedRows = computed<UI_I_HardwareHealthSensorsGraph[]>(() => {
227
- let result: UI_I_HardwareHealthSensorsGraph[] = []
228
-
229
- switch (selectedMetric.value) {
230
- case 'power':
231
- result = props.powerSelectedRowsLocal
232
- break
233
- case 'temperature':
234
- result = props.temperatureSelectedRowsLocal
235
- break
236
- }
237
-
238
- return result
239
- })
240
-
241
- const selectedChartTypeLocal = ref<string>('')
242
-
243
- const checkValidations = (): boolean => {
244
- const checkDateResult = checkDateFunc(
245
- localization.value,
246
- localCustomDateFrom.value,
247
- localCustomDateTo.value,
248
- localCustomTimeFrom.value,
249
- localCustomTimeTo.value,
250
- props.validDateEnd,
251
- props.formatDate
252
- )
253
-
254
- if (isDisabledSubmit.value) {
255
- alerts.value = [localization.value.inventoryMonitor.noCountersSelected]
256
- isShowAlerts.value = true
257
- return false
258
- } else if (
259
- timespanType.value === 'custom_interval' &&
260
- localTimespanPeriodType.value === 'period' &&
261
- checkDateResult !== '' &&
262
- typeof checkDateResult === 'string'
263
- ) {
264
- alerts.value = [checkDateResult]
265
- isShowAlerts.value = true
266
- return false
267
- }
268
-
269
- return true
270
- }
271
-
272
- const localSelectedChartOptionName = ref<string>('')
273
- watch(
274
- () => props.selectedChartOptionName,
275
- (newValue) => {
276
- localSelectedChartOptionName.value = newValue
277
- },
278
- { immediate: true }
279
- )
280
-
281
- const selectedLocalOptionName = ref<string>('')
282
-
283
- const currentFieldsByArray = (
284
- data: UI_I_HardwareHealthSensorsGraph[]
285
- ): string => {
286
- const result: string[] = []
287
- data.forEach((item) => {
288
- result.push(item.nameEn)
289
- })
290
- return result.join('>>')
291
- }
292
-
293
- const onSubmit = (): void => {
294
- if (!checkValidations()) return
295
-
296
- if (['select_options', 'default'].includes(selectedLocalOptionName.value))
297
- selectedLocalOptionName.value = 'custom'
298
-
299
- onSaveOptions(selectedLocalOptionName.value)
300
-
301
- const currentFields = currentFieldsByArray(currentSelectedRows.value)
302
-
303
- const validPeriod = getValidDateByOptionFunc(
304
- timespanType.value,
305
- null,
306
- unitCount.value,
307
- localCustomTime.value
308
- )
309
- if (
310
- timespanType.value === 'custom_interval' &&
311
- localTimespanPeriodType.value === 'period'
312
- ) {
313
- const checkDateResult = checkDateFunc(
314
- localization.value,
315
- localCustomDateFrom.value,
316
- localCustomDateTo.value,
317
- localCustomTimeFrom.value,
318
- localCustomTimeTo.value,
319
- props.validDateEnd,
320
- props.formatDate
321
- )
322
- if (Array.isArray(checkDateResult)) {
323
- validPeriod[0] = checkDateResult[0]
324
- validPeriod[1] = checkDateResult[1]
325
- }
326
- }
327
-
328
- const savedObject = {
329
- fields: currentFields,
330
- optionName: selectedLocalOptionName.value,
331
- metric: selectedMetric.value,
332
- periodName: timespanType.value,
333
- periodType: localTimespanPeriodType.value,
334
- unitCount: unitCount.value,
335
- localTimespanType: localCustomTime.value,
336
- dateFrom: localCustomDateFrom.value,
337
- timeFrom: localCustomTimeFrom.value,
338
- dateTo: localCustomDateTo.value,
339
- timeTo: localCustomTimeTo.value,
340
- chartType: selectedChartTypeLocal.value,
341
- period: validPeriod,
342
- }
343
-
344
- emits('update-period-type', savedObject.periodType)
345
- emits('submit-options', savedObject)
346
- onHide()
347
- }
348
-
349
- const timespanType = ref<string>('')
350
- const unitCount = ref<number>(1)
351
-
352
- const optionsNames = ref<string[]>([])
353
-
354
- const onSaveOptions = (name: string): void => {
355
- const counters = currentSelectedRows.value.map((item) => {
356
- return {
357
- id: item.id,
358
- name: item.nameEn,
359
- }
360
- })
361
- let chartType = 'line_graph'
362
- if (selectedChartTypeLocal.value === 'spline') chartType = 'line_graph'
363
- else if (selectedChartTypeLocal.value === 'area') chartType = 'stacked_graph'
364
-
365
- const saveOptionsData = {
366
- routeType,
367
- chartType,
368
- counters,
369
- metric: selectedMetric.value,
370
- timespan: {
371
- periodType: localTimespanPeriodType.value,
372
- units: localCustomTime.value,
373
- unitsCount: unitCount.value,
374
- type: timespanType.value,
375
- },
376
- }
377
- useLocalStorage(`${name}ChartOptionsSensors`, saveOptionsData)
378
- optionsNames.value = getCurrentOptionsStorageFunc()
379
- localSelectedChartOptionName.value = name
380
- emits('save-option-name')
381
- }
382
-
383
- const setSelectOptions = (): void => {
384
- selectedMetric.value = props.selectedMetric || metricsItems.value[0]?.value
385
- }
386
-
387
- const setDefaultOptions = (): void => {
388
- selectedMetric.value = metricsItems.value[0]?.value
389
- localSelectedPowerCountersKeys.value = []
390
- localSelectedTemperatureCountersKeys.value = []
391
- localSelectedChartType.value = 'spline'
392
- localSelectedTimespanType.value = ''
393
- localUnitsCount.value = 0
394
- localTimespanPeriodType.value = ''
395
- localCustomTime.value = ''
396
- }
397
-
398
- const setCustomOptions = (name: string): void => {
399
- const selectedValue = useLocalStorage(name + 'ChartOptionsSensors', undefined)
400
-
401
- if (selectedValue.routeType !== routeType) return
402
-
403
- let currentChartType = ''
404
- if (selectedValue.chartType === 'line_graph') currentChartType = 'spline'
405
- else if (selectedValue.chartType === 'stacked_graph')
406
- currentChartType = 'area'
407
-
408
- selectedMetric.value = selectedValue.metric
409
- if (selectedMetric.value === 'power')
410
- localSelectedPowerCountersKeys.value = selectedValue.counters.map(
411
- (item) => item.id
412
- )
413
- if (selectedMetric.value === 'temperature')
414
- localSelectedTemperatureCountersKeys.value = selectedValue.counters.map(
415
- (item) => item.id
416
- )
417
- localSelectedChartType.value = currentChartType
418
- localSelectedTimespanType.value = selectedValue.timespan.type
419
- localUnitsCount.value = selectedValue.timespan.unitsCount
420
- localTimespanPeriodType.value = selectedValue.timespan.periodType
421
- localCustomTime.value = selectedValue.timespan.units
422
- }
423
-
424
- const onSelectLocalOptionName = (name: string): void => {
425
- selectedLocalOptionName.value = name
426
-
427
- if (optionsNames.value.includes(name)) setCustomOptions(name)
428
- else if (name === 'default') setDefaultOptions()
429
- else if (name === 'select_options') setSelectOptions()
430
- }
431
-
432
- watch(
433
- localSelectedChartOptionName,
434
- (newValue) => {
435
- if (!newValue) return
436
-
437
- setCustomOptions(newValue)
438
- },
439
- { immediate: true }
440
- )
441
-
442
- const onDeleteChartName = (name: string): void => {
443
- window.localStorage.removeItem(name + 'ChartOptionsSensors')
444
- optionsNames.value = getCurrentOptionsStorageFunc()
445
- setSelectOptions()
446
- emits('delete-option')
447
- }
448
-
449
- const isDisabledSubmit = computed<boolean>(
450
- () => !currentSelectedRows.value.length
451
- )
452
-
453
- watch(
454
- selectedMetric,
455
- (newValue) => {
456
- emits('select-metric-local', newValue)
457
- },
458
- { immediate: true }
459
- )
460
-
461
- onMounted(() => {
462
- optionsNames.value = getCurrentOptionsStorageFunc(routeType)
463
- })
464
- </script>
465
-
466
- <style scoped lang="scss">
467
- .chart-options-modal {
468
- .loader-on :deep(.modal-body) {
469
- display: flex;
470
- align-items: center;
471
- justify-content: center;
472
- }
473
- :deep(.modal-title) {
474
- text-transform: capitalize;
475
- }
476
-
477
- #loader {
478
- min-height: 90px;
479
- text-align: center;
480
- }
481
-
482
- .chart-options-content {
483
- display: flex;
484
- flex-direction: row;
485
- flex-basis: 90%;
486
- overflow-y: hidden;
487
- }
488
- }
489
- @media (max-width: 1024px) {
490
- .chart-options-content {
491
- flex-direction: column !important;
492
- }
493
- }
494
- </style>
1
+ <template>
2
+ <div class="chart-options-modal">
3
+ <atoms-modal
4
+ width="1150px"
5
+ :show="true"
6
+ :title="localization.inventoryMonitor.chartOptions"
7
+ :disabled-submit="isDisabledSubmit"
8
+ @hide="onHide"
9
+ @submit="onSubmit"
10
+ >
11
+ <template #modalBody>
12
+ <common-monitor-advanced-tools-chart-options-modal-notification
13
+ v-show="isShowAlerts"
14
+ :alerts="alerts"
15
+ @remove="onRemoveAlerts"
16
+ />
17
+ <div>
18
+ <common-pages-hardware-health-history-testimony-tools-chart-options-modal-actions
19
+ :is-disabled-save="!currentSelectedRows.length"
20
+ :options-names="optionsNames"
21
+ :selected-chart-option-name="localSelectedChartOptionName"
22
+ @save="onSaveOptions"
23
+ @check-validation="checkValidations"
24
+ @select-local-option-name="onSelectLocalOptionName"
25
+ @delete-chart-name="onDeleteChartName"
26
+ />
27
+
28
+ <div class="horizontal-flex-container chart-options-content">
29
+ <common-pages-hardware-health-history-testimony-tools-chart-options-modal-metrics
30
+ v-model:selected-metric="selectedMetric"
31
+ :metrics-items="metricsItems"
32
+ />
33
+ <common-pages-hardware-health-history-testimony-tools-chart-options-modal-counters
34
+ :chart="selectedMetric"
35
+ :selected-power-keys="localSelectedPowerCountersKeys"
36
+ :selected-temperature-keys="localSelectedTemperatureCountersKeys"
37
+ :power-counters-table-data="props.powerCountersTableData"
38
+ :temperature-counters-table-data="
39
+ props.temperatureCountersTableData
40
+ "
41
+ :language="props.language"
42
+ :selected-chart-type="localSelectedChartType"
43
+ :selected-timespan-type="localSelectedTimespanType"
44
+ :units-count="localUnitsCount"
45
+ :period-type="localTimespanPeriodType"
46
+ :selected-custom-time="localCustomTime"
47
+ :custom-date-from="props.customDateFrom"
48
+ :custom-date-to="props.customDateTo"
49
+ :custom-time-from="props.customTimeFrom"
50
+ :custom-time-to="props.customTimeTo"
51
+ :valid-date-end="props.validDateEnd"
52
+ @select-power-row="onSelectPowerRow"
53
+ @select-temperature-row="onSelectTemperatureRow"
54
+ @update-chart-type="selectedChartTypeLocal = $event"
55
+ @update-custom-time="localCustomTime = $event"
56
+ @update-timespan-type="timespanType = $event"
57
+ @update-unit-count="unitCount = $event"
58
+ @update-period-type="localTimespanPeriodType = $event"
59
+ @update-custom-date-from="onUpdateCustomDateFrom"
60
+ @update-custom-date-to="onUpdateCustomDateTo"
61
+ @update-custom-time-from="onUpdateCustomTimeFrom"
62
+ @update-custom-time-to="onUpdateCustomTimeTo"
63
+ />
64
+ </div>
65
+ </div>
66
+ </template>
67
+ </atoms-modal>
68
+ </div>
69
+ </template>
70
+
71
+ <script setup lang="ts">
72
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
73
+ import type { UI_I_VerticalTabs } from '~/components/atoms/tabs/lib/models/interfaces'
74
+ import type { UI_T_Chart } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/types'
75
+ import type { UI_I_OptionsForm } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/models/interfaces'
76
+ import type { UI_I_HardwareHealthSensorsGraph } from '~/components/common/pages/hardwareHealth/historyTestimony/lib/models/interfaces'
77
+ import { metricsFunc } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/chartOptionsModal/lib/config/optionsMetrics'
78
+ import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
79
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
80
+ import { getCurrentOptionsStorageFunc } from '~/components/common/pages/hardwareHealth/historyTestimony/tools/lib/config/toolbar'
81
+
82
+ const props = defineProps<{
83
+ selectedChartOptionName: string
84
+ selectedMetric: UI_T_Chart
85
+ selectedChartType: string
86
+ selectedPowerCountersKeys: number[]
87
+ powerSelectedRowsLocal: UI_I_HardwareHealthSensorsGraph[]
88
+ selectedTemperatureCountersKeys: number[]
89
+ temperatureSelectedRowsLocal: UI_I_HardwareHealthSensorsGraph[]
90
+ unitsCount: number
91
+ powerCountersTableData: UI_I_HardwareHealthSensorsGraph[]
92
+ temperatureCountersTableData: UI_I_HardwareHealthSensorsGraph[]
93
+ language: string
94
+ selectedTimespanType: string
95
+ customDateFrom: string
96
+ customDateTo: string
97
+ customTimeFrom: string
98
+ customTimeTo: string
99
+ timespanPeriodType: string
100
+ validDateEnd: number
101
+ formatDate: string
102
+ }>()
103
+
104
+ const emits = defineEmits<{
105
+ (event: 'hide'): void
106
+ (event: 'select-metric-local', value: string): void
107
+ (
108
+ event: 'power-selected-rows-local',
109
+ value: UI_I_HardwareHealthSensorsGraph[]
110
+ ): void
111
+ (
112
+ event: 'temperature-selected-rows-local',
113
+ value: UI_I_HardwareHealthSensorsGraph[]
114
+ ): void
115
+ (event: 'update-chart-type', value: string): void
116
+ (event: 'update-timespan-type', value: string): void
117
+ (event: 'update-unit-count', value: number): void
118
+ (event: 'update-period-type', value: string): void
119
+ (event: 'update-custom-time', value: string): void
120
+ (event: 'delete-option'): void
121
+ (event: 'save-option-name'): void
122
+ (event: 'update-custom-date-from', value: string): void
123
+ (event: 'update-custom-date-to', value: string): void
124
+ (event: 'update-custom-time-from', value: string): void
125
+ (event: 'update-custom-time-to', value: string): void
126
+ (event: 'submit-options', value: UI_I_OptionsForm): void
127
+ }>()
128
+
129
+ const routeType = '' + useRoute().params.type
130
+
131
+ const localization = computed<UI_I_Localization>(() => useLocal())
132
+
133
+ const localCustomDateFrom = ref<string>('')
134
+ const onUpdateCustomDateFrom = (value: string): void => {
135
+ localCustomDateFrom.value = value
136
+ }
137
+ const localCustomDateTo = ref<string>('')
138
+ const onUpdateCustomDateTo = (value: string): void => {
139
+ localCustomDateTo.value = value
140
+ }
141
+ const localCustomTimeFrom = ref<string>('')
142
+ const onUpdateCustomTimeFrom = (value: string): void => {
143
+ localCustomTimeFrom.value = value
144
+ }
145
+ const localCustomTimeTo = ref<string>('')
146
+ const onUpdateCustomTimeTo = (value: string): void => {
147
+ localCustomTimeTo.value = value
148
+ }
149
+
150
+ const metricsItems = computed<UI_I_VerticalTabs[]>(() =>
151
+ metricsFunc(localization.value)
152
+ )
153
+ const selectedMetric = ref<UI_T_Chart>(
154
+ props.selectedMetric || '' + metricsItems.value[0]?.value
155
+ )
156
+
157
+ const localSelectedPowerCountersKeys = ref<number[]>([])
158
+ watch(
159
+ () => props.selectedPowerCountersKeys,
160
+ (newValue) => {
161
+ localSelectedPowerCountersKeys.value = newValue
162
+ },
163
+ { immediate: true, deep: true }
164
+ )
165
+
166
+ const localSelectedTemperatureCountersKeys = ref<number[]>([])
167
+ watch(
168
+ () => props.selectedTemperatureCountersKeys,
169
+ (newValue) => {
170
+ localSelectedTemperatureCountersKeys.value = newValue
171
+ },
172
+ { immediate: true, deep: true }
173
+ )
174
+
175
+ const localSelectedChartType = ref<string>('')
176
+ watch(
177
+ () => props.selectedChartType,
178
+ (newValue) => {
179
+ localSelectedChartType.value = newValue
180
+ },
181
+ { immediate: true }
182
+ )
183
+
184
+ const localSelectedTimespanType = ref<string>('')
185
+ watch(
186
+ () => props.selectedTimespanType,
187
+ (newValue) => {
188
+ localSelectedTimespanType.value = newValue
189
+ },
190
+ { immediate: true }
191
+ )
192
+
193
+ const localUnitsCount = ref<number>(0)
194
+ watch(
195
+ () => props.unitsCount,
196
+ (newValue) => {
197
+ localUnitsCount.value = newValue
198
+ },
199
+ { immediate: true }
200
+ )
201
+
202
+ const localTimespanPeriodType = ref<string>('')
203
+ watch(
204
+ () => props.timespanPeriodType,
205
+ (newValue) => {
206
+ localTimespanPeriodType.value = newValue
207
+ },
208
+ { immediate: true }
209
+ )
210
+
211
+ const localCustomTime = ref<string>('')
212
+
213
+ const isShowAlerts = ref<boolean>(false)
214
+ const alerts = ref<string[]>([])
215
+
216
+ const onRemoveAlerts = (): void => {
217
+ isShowAlerts.value = false
218
+ alerts.value = []
219
+ }
220
+
221
+ const onHide = (): void => {
222
+ emits('hide')
223
+ }
224
+
225
+ const onSelectPowerRow = (data: UI_I_HardwareHealthSensorsGraph[]): void => {
226
+ emits('power-selected-rows-local', data)
227
+ }
228
+ const onSelectTemperatureRow = (
229
+ data: UI_I_HardwareHealthSensorsGraph[]
230
+ ): void => {
231
+ emits('temperature-selected-rows-local', data)
232
+ }
233
+
234
+ const currentSelectedRows = computed<UI_I_HardwareHealthSensorsGraph[]>(() => {
235
+ let result: UI_I_HardwareHealthSensorsGraph[] = []
236
+
237
+ switch (selectedMetric.value) {
238
+ case 'power':
239
+ result = props.powerSelectedRowsLocal
240
+ break
241
+ case 'temperature':
242
+ result = props.temperatureSelectedRowsLocal
243
+ break
244
+ }
245
+
246
+ return result
247
+ })
248
+
249
+ const selectedChartTypeLocal = ref<string>('')
250
+
251
+ const checkValidations = (): boolean => {
252
+ const checkDateResult = checkDateFunc(
253
+ localization.value,
254
+ localCustomDateFrom.value,
255
+ localCustomDateTo.value,
256
+ localCustomTimeFrom.value,
257
+ localCustomTimeTo.value,
258
+ props.validDateEnd,
259
+ props.formatDate
260
+ )
261
+
262
+ if (isDisabledSubmit.value) {
263
+ alerts.value = [localization.value.inventoryMonitor.noCountersSelected]
264
+ isShowAlerts.value = true
265
+ return false
266
+ } else if (
267
+ timespanType.value === 'custom_interval' &&
268
+ localTimespanPeriodType.value === 'period' &&
269
+ checkDateResult !== '' &&
270
+ typeof checkDateResult === 'string'
271
+ ) {
272
+ alerts.value = [checkDateResult]
273
+ isShowAlerts.value = true
274
+ return false
275
+ }
276
+
277
+ return true
278
+ }
279
+
280
+ const localSelectedChartOptionName = ref<string>('')
281
+ watch(
282
+ () => props.selectedChartOptionName,
283
+ (newValue) => {
284
+ localSelectedChartOptionName.value = newValue
285
+ },
286
+ { immediate: true }
287
+ )
288
+
289
+ const selectedLocalOptionName = ref<string>('')
290
+
291
+ const currentFieldsByArray = (
292
+ data: UI_I_HardwareHealthSensorsGraph[]
293
+ ): string => {
294
+ const result: string[] = []
295
+ data.forEach((item) => {
296
+ result.push(item.nameEn)
297
+ })
298
+ return result.join('>>')
299
+ }
300
+
301
+ const onSubmit = (): void => {
302
+ if (!checkValidations()) return
303
+
304
+ if (['select_options', 'default'].includes(selectedLocalOptionName.value))
305
+ selectedLocalOptionName.value = 'custom'
306
+
307
+ onSaveOptions(selectedLocalOptionName.value)
308
+
309
+ const currentFields = currentFieldsByArray(currentSelectedRows.value)
310
+
311
+ const validPeriod = getValidDateByOptionFunc(
312
+ timespanType.value,
313
+ null,
314
+ unitCount.value,
315
+ localCustomTime.value
316
+ )
317
+ if (
318
+ timespanType.value === 'custom_interval' &&
319
+ localTimespanPeriodType.value === 'period'
320
+ ) {
321
+ const checkDateResult = checkDateFunc(
322
+ localization.value,
323
+ localCustomDateFrom.value,
324
+ localCustomDateTo.value,
325
+ localCustomTimeFrom.value,
326
+ localCustomTimeTo.value,
327
+ props.validDateEnd,
328
+ props.formatDate
329
+ )
330
+ if (Array.isArray(checkDateResult)) {
331
+ validPeriod[0] = checkDateResult[0]
332
+ validPeriod[1] = checkDateResult[1]
333
+ }
334
+ }
335
+
336
+ const savedObject = {
337
+ fields: currentFields,
338
+ optionName: selectedLocalOptionName.value,
339
+ metric: selectedMetric.value,
340
+ periodName: timespanType.value,
341
+ periodType: localTimespanPeriodType.value,
342
+ unitCount: unitCount.value,
343
+ localTimespanType: localCustomTime.value,
344
+ dateFrom: localCustomDateFrom.value,
345
+ timeFrom: localCustomTimeFrom.value,
346
+ dateTo: localCustomDateTo.value,
347
+ timeTo: localCustomTimeTo.value,
348
+ chartType: selectedChartTypeLocal.value,
349
+ period: validPeriod,
350
+ }
351
+
352
+ emits('update-period-type', savedObject.periodType)
353
+ emits('submit-options', savedObject)
354
+ onHide()
355
+ }
356
+
357
+ const timespanType = ref<string>('')
358
+ const unitCount = ref<number>(1)
359
+
360
+ const optionsNames = ref<string[]>([])
361
+
362
+ const onSaveOptions = (name: string): void => {
363
+ const counters = currentSelectedRows.value.map((item) => {
364
+ return {
365
+ id: item.id,
366
+ name: item.nameEn,
367
+ }
368
+ })
369
+ let chartType = 'line_graph'
370
+ if (selectedChartTypeLocal.value === 'spline') chartType = 'line_graph'
371
+ else if (selectedChartTypeLocal.value === 'area') chartType = 'stacked_graph'
372
+
373
+ const saveOptionsData = {
374
+ routeType,
375
+ chartType,
376
+ counters,
377
+ metric: selectedMetric.value,
378
+ timespan: {
379
+ periodType: localTimespanPeriodType.value,
380
+ units: localCustomTime.value,
381
+ unitsCount: unitCount.value,
382
+ type: timespanType.value,
383
+ },
384
+ }
385
+ useLocalStorage(`${name}ChartOptionsSensors`, saveOptionsData)
386
+ optionsNames.value = getCurrentOptionsStorageFunc()
387
+ localSelectedChartOptionName.value = name
388
+ emits('save-option-name')
389
+ }
390
+
391
+ const setSelectOptions = (): void => {
392
+ selectedMetric.value = props.selectedMetric || metricsItems.value[0]?.value
393
+ }
394
+
395
+ const setDefaultOptions = (): void => {
396
+ selectedMetric.value = metricsItems.value[0]?.value
397
+ localSelectedPowerCountersKeys.value = []
398
+ localSelectedTemperatureCountersKeys.value = []
399
+ localSelectedChartType.value = 'spline'
400
+ localSelectedTimespanType.value = ''
401
+ localUnitsCount.value = 0
402
+ localTimespanPeriodType.value = ''
403
+ localCustomTime.value = ''
404
+ }
405
+
406
+ const setCustomOptions = (name: string): void => {
407
+ const selectedValue = useLocalStorage(name + 'ChartOptionsSensors', undefined)
408
+
409
+ if (selectedValue.routeType !== routeType) return
410
+
411
+ let currentChartType = ''
412
+ if (selectedValue.chartType === 'line_graph') currentChartType = 'spline'
413
+ else if (selectedValue.chartType === 'stacked_graph')
414
+ currentChartType = 'area'
415
+
416
+ selectedMetric.value = selectedValue.metric
417
+ if (selectedMetric.value === 'power')
418
+ localSelectedPowerCountersKeys.value = selectedValue.counters.map(
419
+ (item) => item.id
420
+ )
421
+ if (selectedMetric.value === 'temperature')
422
+ localSelectedTemperatureCountersKeys.value = selectedValue.counters.map(
423
+ (item) => item.id
424
+ )
425
+ localSelectedChartType.value = currentChartType
426
+ localSelectedTimespanType.value = selectedValue.timespan.type
427
+ localUnitsCount.value = selectedValue.timespan.unitsCount
428
+ localTimespanPeriodType.value = selectedValue.timespan.periodType
429
+ localCustomTime.value = selectedValue.timespan.units
430
+ }
431
+
432
+ const onSelectLocalOptionName = (name: string): void => {
433
+ selectedLocalOptionName.value = name
434
+
435
+ if (optionsNames.value.includes(name)) setCustomOptions(name)
436
+ else if (name === 'default') setDefaultOptions()
437
+ else if (name === 'select_options') setSelectOptions()
438
+ }
439
+
440
+ watch(
441
+ localSelectedChartOptionName,
442
+ (newValue) => {
443
+ if (!newValue) return
444
+
445
+ setCustomOptions(newValue)
446
+ },
447
+ { immediate: true }
448
+ )
449
+
450
+ const onDeleteChartName = (name: string): void => {
451
+ window.localStorage.removeItem(name + 'ChartOptionsSensors')
452
+ optionsNames.value = getCurrentOptionsStorageFunc()
453
+ setSelectOptions()
454
+ emits('delete-option')
455
+ }
456
+
457
+ const isDisabledSubmit = computed<boolean>(
458
+ () => !currentSelectedRows.value.length
459
+ )
460
+
461
+ watch(
462
+ selectedMetric,
463
+ (newValue) => {
464
+ emits('select-metric-local', newValue)
465
+ },
466
+ { immediate: true }
467
+ )
468
+
469
+ onMounted(() => {
470
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType)
471
+ })
472
+ </script>
473
+
474
+ <style scoped lang="scss">
475
+ .chart-options-modal {
476
+ .loader-on :deep(.modal-body) {
477
+ display: flex;
478
+ align-items: center;
479
+ justify-content: center;
480
+ }
481
+ :deep(.modal-title) {
482
+ text-transform: capitalize;
483
+ }
484
+
485
+ #loader {
486
+ min-height: 90px;
487
+ text-align: center;
488
+ }
489
+
490
+ .chart-options-content {
491
+ display: flex;
492
+ flex-direction: row;
493
+ flex-basis: 90%;
494
+ overflow-y: hidden;
495
+ }
496
+ }
497
+ @media (max-width: 1024px) {
498
+ .chart-options-content {
499
+ flex-direction: column !important;
500
+ }
501
+ }
502
+ </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.732",
4
+ "version": "1.4.733",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",