bfg-common 1.3.615 → 1.3.616

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.
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <div class="hardware-health-graph">
3
+ <common-graph
4
+ v-if="dataLocal && !props.loading"
5
+ :data="dataLocal"
6
+ :update="updateHelper"
7
+ />
8
+ <div v-else-if="props.loading" class="graphic-loader-block">
9
+ <div class="spinner"></div>
10
+ </div>
11
+ <div v-else class="empty-content"></div>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import { format } from 'date-fns'
17
+ import type { I_SeriesLine } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/models/interfaces'
18
+ import type { I_LineGraph } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/models/interfaces'
19
+ import { graphDataFunc } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/utils/renderGraph'
20
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
21
+
22
+ const props = defineProps<{
23
+ data: I_SeriesLine | null
24
+ loading: boolean
25
+ formattedDatetime: any
26
+ isDarkMode: boolean
27
+ getDateFormat: any
28
+ language: string
29
+ }>()
30
+
31
+ const localization = computed<UI_I_Localization>(() => useLocal())
32
+
33
+ const dataLocal = ref<I_LineGraph | null>(null)
34
+ const updateHelper = ref<number>(0)
35
+ let dateFormat = ''
36
+
37
+ const updateChart = (): void => {
38
+ if (!props.data) return
39
+
40
+ dataLocal.value = graphDataFunc(
41
+ props.data,
42
+ props.isDarkMode,
43
+ localization.value,
44
+ () => {},
45
+ false,
46
+ false,
47
+ true,
48
+ 'spline',
49
+ '',
50
+ undefined,
51
+ () => {},
52
+ props.formattedDatetime,
53
+ format,
54
+ dateFormat
55
+ )
56
+
57
+ updateHelper.value++
58
+ }
59
+
60
+ watch(
61
+ () => [props.data, props.isDarkMode, props.language],
62
+ (newValue) => {
63
+ dateFormat = props.getDateFormat(newValue[2])
64
+ updateChart()
65
+ },
66
+ { immediate: true, deep: true }
67
+ )
68
+ </script>
69
+
70
+ <style scoped lang="scss">
71
+ .hardware-health-graph {
72
+ height: 300px;
73
+
74
+ .graphic-loader-block {
75
+ height: inherit;
76
+ display: flex;
77
+ justify-content: center;
78
+ align-items: center;
79
+ }
80
+ .empty-content {
81
+ height: inherit;
82
+ }
83
+ }
84
+ </style>
@@ -37,8 +37,19 @@
37
37
 
38
38
  <common-pages-hardware-health-tools-panel :selected-tab="activeTab" />
39
39
 
40
+ <common-pages-hardware-health-graph
41
+ v-if="activeTab === 'history-testimony'"
42
+ :data="props.historyTestimony"
43
+ :loading="props.loadingHistoryTestimony"
44
+ :is-dark-mode="props.isDarkMode"
45
+ :formatted-datetime="props.formattedDatetime"
46
+ :get-date-format="props.getDateFormat"
47
+ :language="props.language"
48
+ />
49
+
40
50
  <common-pages-hardware-health-table-view
41
51
  :key="uniqueKey"
52
+ v-model:selected="selectedRow"
42
53
  :data-table="hardwareHealth"
43
54
  :total-items="hardwareHealth.length"
44
55
  :total-pages="1"
@@ -49,16 +60,28 @@
49
60
  </template>
50
61
 
51
62
  <script lang="ts" setup>
52
- import { UI_I_Localization } from '~/lib/models/interfaces'
53
- import { UI_I_CollapseNavItem } from '~/components/atoms/collapse/lib/models/interfaces'
63
+ import type { I_SeriesLine } from '~/node_modules/bfg-nuxt-3-graph/graph/lib/models/interfaces'
64
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
65
+ import type { UI_I_CollapseNavItem } from '~/components/atoms/collapse/lib/models/interfaces'
54
66
  import type { UI_T_HardwareHealthTabMode } from '~/components/common/pages/hardwareHealth/lib/models/types'
55
67
  import type { UI_I_StorageSensorsAlert } from '~/components/common/pages/hardwareHealth/lib/models/interfaces'
56
68
  import type { UI_I_HardwareHealthSensors } from '~/components/common/pages/hardwareHealth/tableView/lib/models/interfaces'
69
+ import type { UI_T_SelectedRow } from '~/components/atoms/table/dataGrid/lib/models/types'
57
70
  import { hardwareHealthTabsFunc } from '~/components/common/pages/hardwareHealth/lib/config/tabsPannel'
58
71
 
59
72
  const props = defineProps<{
60
73
  data: UI_I_HardwareHealthSensors[]
61
74
  loading: boolean
75
+ historyTestimony: I_SeriesLine | null
76
+ loadingHistoryTestimony: boolean
77
+ isDarkMode: boolean
78
+ formattedDatetime: any
79
+ getDateFormat: any
80
+ language: string
81
+ }>()
82
+
83
+ const emits = defineEmits<{
84
+ (event: 'update-chart-data', value: string): void
62
85
  }>()
63
86
 
64
87
  const localization = computed<UI_I_Localization>(() => useLocal())
@@ -67,6 +90,8 @@ const { $store }: any = useNuxtApp()
67
90
  const activeTab = ref<UI_T_HardwareHealthTabMode>('sensor')
68
91
  const uniqueKey = ref<number>(0)
69
92
 
93
+ const selectedRow = ref<UI_T_SelectedRow>([])
94
+
70
95
  const hardwareHealthTabs = computed<UI_I_CollapseNavItem[]>(() =>
71
96
  hardwareHealthTabsFunc(localization.value)
72
97
  )
@@ -126,10 +151,38 @@ const generateAlertTextWithLink = computed<UI_I_StorageSensorsAlert>(() => {
126
151
  }
127
152
  })
128
153
 
154
+ const updateChartData = (isSendAll: boolean = false): void => {
155
+ const selectedNames: string[] = []
156
+ hardwareHealth.value.forEach((item, key) => {
157
+ if (isSendAll) {
158
+ if (['power', 'temperature'].includes(item.category.toLowerCase()))
159
+ selectedNames.push(item.name)
160
+ } else if (
161
+ ['power', 'temperature'].includes(item.category.toLowerCase()) &&
162
+ selectedRow.value.includes(key)
163
+ ) {
164
+ selectedNames.push(item.name)
165
+ }
166
+ })
167
+ emits('update-chart-data', selectedNames.join(','))
168
+ }
169
+
170
+ watch(selectedRow, (newValue) => {
171
+ newValue.length && updateChartData()
172
+ })
173
+
129
174
  watch(activeTab, () => {
130
175
  uniqueKey.value++
131
176
  })
132
177
 
178
+ watch(
179
+ hardwareHealth,
180
+ (newValue) => {
181
+ newValue.length && updateChartData(true)
182
+ },
183
+ { immediate: true }
184
+ )
185
+
133
186
  onMounted(() => {
134
187
  $store.dispatch('main/A_CONTINUE_GLOBAL_REFRESH', 'hardwareHealth')
135
188
  })
@@ -1,8 +1,14 @@
1
- import { UI_I_Localization } from '~/lib/models/interfaces'
2
- import { UI_I_CollapseNavItem } from '~/components/atoms/collapse/lib/models/interfaces'
1
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
2
+ import type { UI_I_CollapseNavItem } from '~/components/atoms/collapse/lib/models/interfaces'
3
+
3
4
  export const hardwareHealthTabsFunc = (
4
5
  localization: UI_I_Localization
5
6
  ): UI_I_CollapseNavItem[] => {
7
+ const config = useRuntimeConfig()
8
+
9
+ const isDisabledHistoryTestimony =
10
+ String(config.public.PRODUCT_NAME_EN).toLowerCase() === 'sphere'
11
+
6
12
  return [
7
13
  {
8
14
  text: localization.sensors,
@@ -28,5 +34,11 @@ export const hardwareHealthTabsFunc = (
28
34
  disabled: false,
29
35
  testId: 'hardware-health-system-log',
30
36
  },
37
+ {
38
+ text: localization.historyTestimony,
39
+ value: 'history-testimony',
40
+ disabled: isDisabledHistoryTestimony,
41
+ testId: 'hardware-health-history-testimony',
42
+ },
31
43
  ]
32
44
  }
@@ -3,12 +3,14 @@
3
3
  <div class="data-table-view__inner">
4
4
  <atoms-table-data-grid
5
5
  v-model:column-keys="columnKeys"
6
+ v-model:selected-row="selectedRow"
6
7
  :head-items="headItems"
7
8
  :body-items="bodyItems"
8
9
  :total-items="props.totalItems"
9
10
  :total-pages="props.totalPages"
10
11
  :page-size="100"
11
12
  :page="1"
13
+ :type="tableType"
12
14
  class="data-table"
13
15
  test-id="hardware-health-table"
14
16
  :loading="props.loading"
@@ -71,6 +73,10 @@ import type {
71
73
  import type { UI_I_Localization } from '~/lib/models/interfaces'
72
74
  import type { UI_I_HardwareHealthSensors } from '~/components/common/pages/hardwareHealth/tableView/lib/models/interfaces'
73
75
  import type { UI_T_HardwareHealthTabMode } from '~/components/common/pages/hardwareHealth/lib/models/types'
76
+ import type {
77
+ UI_T_DataGridType,
78
+ UI_T_SelectedRow,
79
+ } from '~/components/atoms/table/dataGrid/lib/models/types'
74
80
  import * as sensorTable from '~/components/common/pages/hardwareHealth/tableView/lib/config/sensorTable'
75
81
  import * as storageSensorTable from '~/components/common/pages/hardwareHealth/tableView/lib/config/storageSensorTable'
76
82
  import * as alertWarningTable from '~/components/common/pages/hardwareHealth/tableView/lib/config/alertWarningTable'
@@ -83,6 +89,7 @@ const props = defineProps<{
83
89
  totalPages: number
84
90
  tableMode: UI_T_HardwareHealthTabMode
85
91
  }>()
92
+ const selectedRow = defineModel<string[]>('selected')
86
93
  const localization = computed<UI_I_Localization>(() => useLocal())
87
94
 
88
95
  const table: any = {
@@ -90,8 +97,13 @@ const table: any = {
90
97
  'storage-sensor': storageSensorTable,
91
98
  'alert-warning': alertWarningTable,
92
99
  'system-log': systemLogTable,
100
+ 'history-testimony': sensorTable,
93
101
  }
94
102
 
103
+ const tableType = computed<UI_T_DataGridType | undefined>(() =>
104
+ props.tableMode === 'history-testimony' ? 'checkbox' : undefined
105
+ )
106
+
95
107
  const hasNonEmptySelEntries = computed<boolean>(() => {
96
108
  return (
97
109
  props.dataTable.some(
@@ -125,7 +137,11 @@ const bodyItems = computed<UI_I_BodyItem[][]>(() => {
125
137
  break
126
138
  }
127
139
 
128
- return table[props.tableMode].bodyItems(tableData, localization.value)
140
+ return table[props.tableMode].bodyItems(
141
+ tableData,
142
+ localization.value,
143
+ props.tableMode
144
+ )
129
145
  })
130
146
 
131
147
  const isShowSensorWarningDetails = ref<boolean>(false)
@@ -9,6 +9,7 @@ import {
9
9
  constructColumnKey,
10
10
  } from '~/components/atoms/table/dataGrid/lib/utils/constructDataTable'
11
11
  import type { UI_I_HardwareHealthSensors } from '~/components/common/pages/hardwareHealth/tableView/lib/models/interfaces'
12
+ import type { UI_T_HardwareHealthTabMode } from '~/components/common/pages/hardwareHealth/lib/models/types'
12
13
  import { UI_E_SensorsCategoryIcon } from '~/components/common/pages/hardwareHealth/lib/models/enums'
13
14
  import { hardwareHealthSensorTableKeys } from '~/components/common/pages/hardwareHealth/tableView/lib/config/tableKeys'
14
15
  import {
@@ -21,7 +22,12 @@ const getItems = (
21
22
  ): [string, boolean, string, string][] => {
22
23
  return [
23
24
  [localization.sensors, true, '330px', hardwareHealthSensorTableKeys[0]],
24
- [localization.common.status, true, '140px', hardwareHealthSensorTableKeys[1]],
25
+ [
26
+ localization.common.status,
27
+ true,
28
+ '140px',
29
+ hardwareHealthSensorTableKeys[1],
30
+ ],
25
31
  [localization.reading, true, '115px', hardwareHealthSensorTableKeys[2]],
26
32
  [localization.categories, true, '130px', hardwareHealthSensorTableKeys[3]],
27
33
  [localization.lastUpdated, true, '195px', hardwareHealthSensorTableKeys[4]],
@@ -60,7 +66,8 @@ export const headItems = (localization: UI_I_Localization): UI_I_HeadItem[] => {
60
66
 
61
67
  export const bodyItems = (
62
68
  data: UI_I_HardwareHealthSensors[],
63
- localization: UI_I_Localization
69
+ localization: UI_I_Localization,
70
+ tableMode: UI_T_HardwareHealthTabMode
64
71
  ): UI_I_BodyItem[][] => {
65
72
  const bodyItems: UI_I_BodyItem[][] = []
66
73
  data.forEach((sensor: UI_I_HardwareHealthSensors, key) => {
@@ -70,6 +77,13 @@ export const bodyItems = (
70
77
  warning: sensor.warning,
71
78
  }
72
79
 
80
+ let isDisabledRow = false
81
+ if (
82
+ tableMode === 'history-testimony' &&
83
+ !['power', 'temperature'].includes(sensor.category.toLowerCase())
84
+ )
85
+ isDisabledRow = true
86
+
73
87
  bodyItems.push([
74
88
  // {
75
89
  // data,
@@ -82,6 +96,7 @@ export const bodyItems = (
82
96
  key: 'col0',
83
97
  text: sensor[hardwareHealthSensorTableKeys[0]],
84
98
  id: key,
99
+ disabled: isDisabledRow,
85
100
  },
86
101
  {
87
102
  key: 'icon',