bfg-common 1.4.36 → 1.4.38

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,109 +1,110 @@
1
- <template>
2
- <div class="graph-content">
3
- <template v-if="chartOptions">
4
- <client-only>
5
- <highchart
6
- :options="chartOptions"
7
- :modules="['exporting', 'export-data']"
8
- class="graph-block"
9
- />
10
- </client-only>
11
- </template>
12
- </div>
13
- </template>
14
-
15
- <script setup lang="ts">
16
- import type {
17
- I_LineGraph,
18
- I_DiskGraph,
19
- } from 'bfg-nuxt-3-graph/graph/lib/models/interfaces'
20
-
21
- const props = defineProps<{
22
- chart?: any
23
- data: I_LineGraph | I_DiskGraph
24
- update: number
25
- exportType?: string
26
- selectedRow?: number[]
27
- }>()
28
-
29
- let localChart: any = null
30
- const exportChart = (type: string): void => {
31
- if (type === 'png') {
32
- localChart.exportChart({
33
- type: 'image/png',
34
- })
35
- } else if (type === 'jpeg') {
36
- localChart.exportChart({
37
- type: 'image/jpeg',
38
- })
39
- } else if (type === 'svg') {
40
- localChart.exportChart({
41
- type: 'image/svg+xml',
42
- })
43
- } else if (type === 'csv') {
44
- localChart.downloadCSV()
45
- }
46
- }
47
-
48
- const chartOptions = ref<I_LineGraph | I_DiskGraph | null>(null)
49
- const initGraph = (): void => {
50
- if (!props.data) return
51
- setTimeout(() => {
52
- chartOptions.value = props.data
53
- }, 500)
54
- }
55
-
56
- watch(
57
- () => props.update,
58
- (newValue) => {
59
- newValue && initGraph()
60
- },
61
- { immediate: true }
62
- )
63
-
64
- watch(
65
- () => props.exportType,
66
- (newValue) => {
67
- if (!newValue) return
68
-
69
- exportChart(newValue)
70
- }
71
- )
72
-
73
- watch(
74
- () => props.chart,
75
- (newValue) => {
76
- if (newValue.series) localChart = newValue
77
- },
78
- { deep: true }
79
- )
80
-
81
- const updateSeriesStrokeWidth = (data: number[]): void => {
82
- if (!localChart) return
83
-
84
- localChart.series.forEach((_: any, key: number) => {
85
- localChart.options.series[key].lineWidth = 1.5
86
-
87
- if (data.includes(key)) localChart.options.series[key].lineWidth = 3
88
- })
89
-
90
- localChart.update(localChart.options)
91
- }
92
-
93
- watch(
94
- () => props.selectedRow,
95
- (newValue) => newValue && updateSeriesStrokeWidth(newValue)
96
- )
97
- </script>
98
-
99
- <style scoped lang="scss">
100
- .graph-content {
101
- width: 100%;
102
- //height: inherit;
103
- height: 100%;
104
-
105
- .graph-block {
106
- height: 100%;
107
- }
108
- }
109
- </style>
1
+ <template>
2
+ <div class="graph-content">
3
+ <template v-if="chartOptions">
4
+ <client-only>
5
+ <highchart
6
+ :options="chartOptions"
7
+ :modules="['exporting', 'export-data']"
8
+ class="graph-block"
9
+ />
10
+ </client-only>
11
+ </template>
12
+ </div>
13
+ </template>
14
+
15
+ <script setup lang="ts">
16
+ import type {
17
+ I_LineGraph,
18
+ I_DiskGraph,
19
+ } from 'bfg-nuxt-3-graph/graph/lib/models/interfaces'
20
+
21
+ const props = defineProps<{
22
+ chart?: any
23
+ data: I_LineGraph | I_DiskGraph
24
+ update: number
25
+ exportType?: string
26
+ selectedRow?: number[]
27
+ }>()
28
+
29
+ let localChart: any = null
30
+ const exportChart = (type: string): void => {
31
+ if (type === 'png') {
32
+ localChart.exportChart({
33
+ type: 'image/png',
34
+ })
35
+ } else if (type === 'jpeg') {
36
+ localChart.exportChart({
37
+ type: 'image/jpeg',
38
+ })
39
+ } else if (type === 'svg') {
40
+ localChart.exportChart({
41
+ type: 'image/svg+xml',
42
+ })
43
+ } else if (type === 'csv') {
44
+ localChart.downloadCSV()
45
+ }
46
+ }
47
+
48
+ const chartOptions = ref<I_LineGraph | I_DiskGraph | null>(null)
49
+ const initGraph = (): void => {
50
+ if (!props.data) return
51
+ setTimeout(() => {
52
+ chartOptions.value = props.data
53
+ }, 500)
54
+ }
55
+
56
+ watch(
57
+ () => props.update,
58
+ (newValue) => {
59
+ newValue && initGraph()
60
+ },
61
+ { immediate: true }
62
+ )
63
+
64
+ watch(
65
+ () => props.exportType,
66
+ (newValue) => {
67
+ if (!newValue) return
68
+
69
+ exportChart(newValue)
70
+ }
71
+ )
72
+
73
+ watch(
74
+ () => props.chart,
75
+ (newValue) => {
76
+ if (newValue.series) localChart = newValue
77
+ },
78
+ { deep: true }
79
+ )
80
+
81
+ const updateSeriesStrokeWidth = (data: number[]): void => {
82
+ if (!localChart) return
83
+
84
+ const newChartOptions = chartOptions.value
85
+ newChartOptions.series.forEach((_: any, key: number) => {
86
+ newChartOptions.series[key].lineWidth = 1.5
87
+
88
+ if (data.includes(key)) newChartOptions.series[key].lineWidth = 3
89
+ })
90
+
91
+ chartOptions.value = newChartOptions
92
+ }
93
+
94
+ watch(
95
+ () => props.selectedRow,
96
+ (newValue) => newValue && updateSeriesStrokeWidth(newValue)
97
+ )
98
+ </script>
99
+
100
+ <style scoped lang="scss">
101
+ .graph-content {
102
+ width: 100%;
103
+ //height: inherit;
104
+ height: 100%;
105
+
106
+ .graph-block {
107
+ height: 100%;
108
+ }
109
+ }
110
+ </style>
@@ -72,7 +72,6 @@ const emits = defineEmits<{
72
72
  (event: 'update-timespan-type', value: string): void
73
73
  (event: 'update-unit-count', value: number): void
74
74
  (event: 'update-period-type', value: string): void
75
- (event: 'update-period-type', value: string): void
76
75
  (event: 'update-custom-date-from', value: string): void
77
76
  (event: 'update-custom-date-to', value: string): void
78
77
  (event: 'update-custom-time-from', value: string): void
@@ -45,6 +45,7 @@
45
45
  >
46
46
  <common-pages-hardware-health-history-testimony-graph
47
47
  v-if="activeTab === 'history-testimony'"
48
+ v-model:selected-view="selectedGraphView"
48
49
  :power-data="props.historyTestimonyPower"
49
50
  :temperature-data="props.historyTestimonyTemperature"
50
51
  :counters-table-data="hardwareHealth"
@@ -59,7 +60,8 @@
59
60
 
60
61
  <common-pages-hardware-health-table-view
61
62
  :key="uniqueKey"
62
- v-model:selected="selectedRow"
63
+ v-model:selected-row="selectedRow"
64
+ :selected-graph-view="selectedGraphView"
63
65
  :data-table="hardwareHealth"
64
66
  :total-items="hardwareHealth.length"
65
67
  :total-pages="1"
@@ -96,6 +98,7 @@ const localization = computed<UI_I_Localization>(() => useLocal())
96
98
  const { $store }: any = useNuxtApp()
97
99
 
98
100
  const activeTab = ref<UI_T_HardwareHealthTabMode>('sensor')
101
+ const selectedGraphView = ref<string>('all')
99
102
  const uniqueKey = ref<number>(0)
100
103
 
101
104
  const selectedRow = ref<number[]>([])
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <common-pages-hardware-health-history-testimony-tools
3
+ v-model:selected-view="selectedView"
3
4
  v-model:selected-timespan-type="selectedTimespanType"
4
5
  :selected-chart-option-name="selectedChartOptionName"
5
6
  :is-show-chart-modal="isShowChartModal"
@@ -27,7 +28,7 @@
27
28
  @delete-option="onDeleteOption"
28
29
  @submit-options="onSubmitOptions"
29
30
  />
30
- <div class="hardware-health-graph">
31
+ <div :class="`hardware-health-graph ${selectedView}`">
31
32
  <div class="power-container">
32
33
  <common-graph
33
34
  v-if="powerDataLocal && !props.powerLoading"
@@ -83,6 +84,7 @@ const props = defineProps<{
83
84
  getDateFormat: any
84
85
  mainSelectedRow: number[]
85
86
  }>()
87
+ const selectedView = defineModel<string>('selectedView')
86
88
 
87
89
  const { $store }: any = useNuxtApp()
88
90
 
@@ -99,22 +101,43 @@ const customTimeTo = ref<string>('')
99
101
 
100
102
  const selectedRowPower = ref<number[]>([])
101
103
  const selectedRowTemperature = ref<number[]>([])
104
+ let powerCounters: UI_I_HardwareHealthSensors[] = []
105
+ let temperatureCounters: UI_I_HardwareHealthSensors[] = []
102
106
  const updateAllSelectedSelectedRow = (): void => {
103
107
  selectedRowPower.value = []
104
108
  selectedRowTemperature.value = []
109
+
110
+ if (!props.mainSelectedRow.length) return
111
+
105
112
  props.mainSelectedRow.forEach((key) => {
106
- const category = props.countersTableData[key].category.toLowerCase()
107
-
108
- switch (category) {
109
- case 'power':
110
- selectedRowPower.value.push(key)
111
- break
112
- case 'temperature':
113
- selectedRowTemperature.value.push(key)
114
- break
113
+ const selectedItem = props.countersTableData[key]
114
+ const category = selectedItem.category.toLowerCase()
115
+
116
+ if (category === 'power') {
117
+ const currentKey = powerCounters.findIndex(
118
+ (item) => item.id === selectedItem.id
119
+ )
120
+ selectedRowPower.value.push(currentKey)
121
+ } else if (category === 'temperature') {
122
+ const currentKey = temperatureCounters.findIndex(
123
+ (item) => item.id === selectedItem.id
124
+ )
125
+ selectedRowTemperature.value.push(currentKey)
115
126
  }
116
127
  })
117
128
  }
129
+ watch(
130
+ () => props.countersTableData,
131
+ (newValue) => {
132
+ powerCounters = newValue.filter(
133
+ (item) => item.category.toLowerCase() === 'power'
134
+ )
135
+ temperatureCounters = newValue.filter(
136
+ (item) => item.category.toLowerCase() === 'temperature'
137
+ )
138
+ },
139
+ { deep: true, immediate: true }
140
+ )
118
141
  watch(
119
142
  () => props.mainSelectedRow,
120
143
  () => {
@@ -122,6 +145,13 @@ watch(
122
145
  },
123
146
  { deep: true, immediate: true }
124
147
  )
148
+ watch(
149
+ selectedView,
150
+ () => {
151
+ updateAllSelectedSelectedRow()
152
+ },
153
+ { deep: true }
154
+ )
125
155
 
126
156
  const unitsCount = ref<number>(0)
127
157
  const powerCountersTableData = ref<UI_I_HardwareHealthSensorsGraph[]>([])
@@ -337,9 +367,26 @@ const onDeleteOption = (): void => {}
337
367
  .hardware-health-graph {
338
368
  display: grid;
339
369
  align-items: center;
340
- grid-template-columns: 1fr 1fr;
341
370
  grid-gap: 20px;
342
371
 
372
+ &.all {
373
+ grid-template-columns: 1fr 1fr;
374
+ }
375
+ &.power {
376
+ grid-template-columns: 1fr 0;
377
+
378
+ & > div:nth-child(2) {
379
+ visibility: hidden;
380
+ }
381
+ }
382
+ &.temperature {
383
+ grid-template-columns: 0 1fr;
384
+
385
+ & > div:nth-child(1) {
386
+ visibility: hidden;
387
+ }
388
+ }
389
+
343
390
  .graphic-loader-block {
344
391
  height: inherit;
345
392
  display: flex;
@@ -125,6 +125,7 @@ const props = defineProps<{
125
125
  startDate: number
126
126
  periodType: string
127
127
  }>()
128
+ const selectedView = defineModel<string>('selectedView')
128
129
 
129
130
  const emits = defineEmits<{
130
131
  (event: 'show-chart-modal'): void
@@ -172,7 +173,6 @@ const selectedPeriod = computed<string>({
172
173
 
173
174
  const optionsNames = ref<string[]>([])
174
175
 
175
- const selectedView = ref<string>('power')
176
176
  const viewOptions = computed<UI_I_OptionItem[]>(() =>
177
177
  viewFunc(localization.value, optionsNames.value)
178
178
  )
@@ -300,6 +300,22 @@ const onSubmit = (): void => {
300
300
  unitCount.value,
301
301
  localCustomTime.value
302
302
  )
303
+ if (
304
+ timespanType.value === 'custom_interval' &&
305
+ localPeriodType.value === 'period'
306
+ ) {
307
+ const checkDateResult = checkDateFunc(
308
+ localization.value,
309
+ localCustomDateFrom.value,
310
+ localCustomDateTo.value,
311
+ localCustomTimeFrom.value,
312
+ localCustomTimeTo.value
313
+ )
314
+ if (Array.isArray(checkDateResult)) {
315
+ validPeriod[0] = checkDateResult[0]
316
+ validPeriod[1] = checkDateResult[1]
317
+ }
318
+ }
303
319
 
304
320
  const savedObject = {
305
321
  fields: currentFields,
@@ -43,6 +43,10 @@ export const viewFunc = (
43
43
  optionsNames: string[]
44
44
  ): UI_I_OptionItem[] => {
45
45
  const result = [
46
+ {
47
+ text: localization.common.all,
48
+ value: 'all',
49
+ },
46
50
  {
47
51
  text: localization.common.power,
48
52
  value: 'power',
@@ -81,13 +81,14 @@ import * as systemLogTable from '~/components/common/pages/hardwareHealth/tableV
81
81
  import * as historyTestimonyTable from '~/components/common/pages/hardwareHealth/tableView/lib/config/historyTestimonyTable'
82
82
 
83
83
  const props = defineProps<{
84
+ selectedGraphView: string
84
85
  dataTable: UI_I_HardwareHealthSensors[]
85
86
  loading: boolean
86
87
  totalItems: number
87
88
  totalPages: number
88
89
  tableMode: UI_T_HardwareHealthTabMode
89
90
  }>()
90
- const selectedRow = defineModel<string[]>('selected')
91
+ const selectedRow = defineModel<number[]>('selectedRow')
91
92
  const localization = computed<UI_I_Localization>(() => useLocal())
92
93
 
93
94
  const table: any = {
@@ -135,7 +136,11 @@ const bodyItems = computed<UI_I_BodyItem[][]>(() => {
135
136
  break
136
137
  }
137
138
 
138
- return table[props.tableMode].bodyItems(tableData, localization.value)
139
+ return table[props.tableMode].bodyItems(
140
+ tableData,
141
+ localization.value,
142
+ props.selectedGraphView
143
+ )
139
144
  })
140
145
 
141
146
  const isShowSensorWarningDetails = ref<boolean>(false)
@@ -79,7 +79,8 @@ export const headItems = (localization: UI_I_Localization): UI_I_HeadItem[] => {
79
79
 
80
80
  export const bodyItems = (
81
81
  data: UI_I_HardwareHealthSensors[],
82
- localization: UI_I_Localization
82
+ localization: UI_I_Localization,
83
+ selectedGraphView: string
83
84
  ): UI_I_BodyItem[][] => {
84
85
  const bodyItems: UI_I_BodyItem[][] = []
85
86
  data.forEach((sensor: UI_I_HardwareHealthSensors, key) => {
@@ -89,7 +90,15 @@ export const bodyItems = (
89
90
  warning: sensor.warning,
90
91
  }
91
92
 
92
- if (!['disk health'].includes(sensor.category.toLowerCase()))
93
+ const isCurrentItem =
94
+ selectedGraphView !== 'all'
95
+ ? selectedGraphView === sensor.category.toLowerCase()
96
+ : true
97
+
98
+ if (
99
+ !['disk health'].includes(sensor.category.toLowerCase()) &&
100
+ isCurrentItem
101
+ )
93
102
  bodyItems.push([
94
103
  {
95
104
  key: 'col0',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.36",
4
+ "version": "1.4.38",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",