bfg-common 1.4.884 → 1.4.886

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,142 +1,120 @@
1
- <template>
2
- <div class="charts-view">
3
- <!-- <div v-if="!props.allData.length" class="content-global-loading">-->
4
- <!-- {{ localization.common.loading }}...-->
5
- <!-- </div>-->
6
- <!-- <template v-else>-->
7
- <template v-for="(chartData, key) in props.allData" :key="chartData.title">
8
- <div :class="['chart-container', `graph-${chartData.title}`]">
9
- <div v-if="chartData.loader" class="graphic-loader-block">
10
- <ui-skeleton-metric />
11
- </div>
12
- <common-graph
13
- v-else-if="chartData.data"
14
- :data="chartData.data"
15
- :chart="props.charts[key]"
16
- :update="props.updateHelper"
17
- />
18
- <div v-else class="graph-empty-block">
19
- <div class="title">{{ chartData.title }}</div>
20
- <div class="body-block">
21
- {{ localization.common.emptyGraphText }}
22
- </div>
23
- </div>
24
- </div>
25
- </template>
26
- <!-- </template>-->
27
- </div>
28
- </template>
29
-
30
- <script setup lang="ts">
31
- import type { UI_I_Localization } from '~/lib/models/interfaces'
32
- import type { UI_I_GraphDataSettingItem } from '~/components/common/monitor/lib/models/interfaces'
33
-
34
- const props = defineProps<{
35
- charts: (UI_I_GraphDataSettingItem | null)[]
36
- allData: UI_I_GraphDataSettingItem[]
37
- updateHelper: number
38
- }>()
39
-
40
- const localization = computed<UI_I_Localization>(() => useLocal())
41
- </script>
42
-
43
- <style>
44
- :root {
45
- --overview-chart-loader-bg-color: #ffffff;
46
- }
47
- :root.dark-theme {
48
- --overview-chart-loader-bg-color: #334453;
49
- }
50
- </style>
51
-
52
- <style scoped lang="scss">
53
- .charts-view {
54
- position: relative;
55
- display: flex;
56
- flex-direction: row;
57
- flex-wrap: wrap;
58
- justify-content: space-between;
59
- overflow: auto;
60
- height: 100%;
61
- gap: 16px;
62
- padding: 0 16px;
63
-
64
- .graphic-loader-block {
65
- background-color: var(--overview-chart-loader-bg-color);
66
- height: 100%;
67
- display: flex;
68
- flex-direction: column;
69
- align-items: center;
70
- justify-content: center;
71
- border-radius: 8px;
72
- }
73
-
74
- .graph-empty-block {
75
- display: flex;
76
- flex-direction: column;
77
- height: 100%;
78
- background-color: var(--overview-chart-loader-bg-color);
79
- border-radius: 8px;
80
-
81
- .title {
82
- text-align: center;
83
- font-size: 18px;
84
- margin-top: 10px;
85
- color: var(--global-font-color);
86
- }
87
-
88
- .body-block {
89
- height: 100%;
90
- display: flex;
91
- justify-content: center;
92
- text-align: center;
93
- align-items: center;
94
- color: var(--global-font-color);
95
- }
96
- }
97
-
98
- .chart-container {
99
- position: relative;
100
- width: 100%;
101
- min-width: 300px;
102
- height: 100%;
103
- min-height: 300px;
104
- flex-grow: 1;
105
- box-sizing: border-box;
106
-
107
- &:first-child:last-child {
108
- height: 100%;
109
- width: 100%;
110
- }
111
-
112
- &:first-child:nth-last-child(2),
113
- &:nth-child(2):last-child {
114
- width: 50%;
115
- height: 100%;
116
- }
117
-
118
- :deep(svg > .skeleton-metric__line) {
119
- display: none;
120
- }
121
- }
122
-
123
- //.content-global-loading {
124
- // width: 100%;
125
- // height: 100%;
126
- // display: flex;
127
- // align-items: center;
128
- // justify-content: center;
129
- // color: var(--global-font-color);
130
- //}
131
- }
132
- @media (min-width: 1280px) {
133
- .charts-view .chart-container {
134
- width: 50%;
135
- }
136
- }
137
- @media (min-height: 800px) {
138
- .charts-view .chart-container {
139
- height: 50%;
140
- }
141
- }
142
- </style>
1
+ <template>
2
+ <div ref="chartsView" :class="['charts-view', { 'has-scroll': isHasScroll }]">
3
+ <template v-for="(chartData, key) in props.allData" :key="chartData.title">
4
+ <div :class="['chart-container', `graph-${chartData.title}`]">
5
+ <ui-skeleton-long-metric v-if="chartData.loader" height="336px" />
6
+ <common-graph
7
+ v-else-if="chartData.data"
8
+ :data="chartData.data"
9
+ :chart="props.charts[key]"
10
+ :update="props.updateHelper"
11
+ />
12
+ <div v-else class="graph-empty-block">
13
+ <div class="title">{{ chartData.title }}</div>
14
+ <div class="body-block">
15
+ {{ localization.common.emptyGraphText }}
16
+ </div>
17
+ </div>
18
+ </div>
19
+ </template>
20
+ </div>
21
+ </template>
22
+
23
+ <script setup lang="ts">
24
+ import { useElementSize } from '@vueuse/core'
25
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
26
+ import type { UI_I_GraphDataSettingItem } from '~/components/common/monitor/lib/models/interfaces'
27
+
28
+ const props = defineProps<{
29
+ charts: (UI_I_GraphDataSettingItem | null)[]
30
+ allData: UI_I_GraphDataSettingItem[]
31
+ updateHelper: number
32
+ }>()
33
+
34
+ const localization = computed<UI_I_Localization>(() => useLocal())
35
+
36
+ const chartsView = ref<HTMLElement | null>(null)
37
+ const { width, height } = useElementSize(chartsView)
38
+ const isHasScroll = ref<boolean>(false)
39
+ const isScrollVisible = (element: HTMLElement): boolean =>
40
+ element.scrollHeight > element.clientHeight &&
41
+ getComputedStyle(element).overflowY !== 'hidden'
42
+
43
+ watch([width, height], () => {
44
+ if (!chartsView.value) return
45
+
46
+ isHasScroll.value = isScrollVisible(chartsView.value)
47
+ })
48
+ </script>
49
+
50
+ <style scoped lang="scss">
51
+ .charts-view {
52
+ position: relative;
53
+ display: grid;
54
+ overflow: auto;
55
+ height: 100%;
56
+ gap: 12px;
57
+ padding: 4px 16px 16px 16px;
58
+ grid-template-rows: 400px;
59
+
60
+ &.has-scroll {
61
+ padding-right: 3px;
62
+ }
63
+
64
+ &:has(.chart-container:nth-child(4)),
65
+ &:has(.chart-container:nth-child(3)):not(:has(.chart-container:nth-child(4))),
66
+ &:has(.chart-container:nth-child(2)):not(:has(.chart-container:nth-child(3))) {
67
+ grid-template-columns: 1fr 1fr;
68
+ }
69
+ &:has(.chart-container:nth-child(1)):not(:has(.chart-container:nth-child(2))) {
70
+ grid-template-columns: 1fr;
71
+ }
72
+ &:has(.chart-container:nth-child(3)):not(:has(.chart-container:nth-child(4)))
73
+ .chart-container:nth-child(3) {
74
+ grid-column: 1 / -1;
75
+ }
76
+
77
+ .graph-empty-block {
78
+ display: flex;
79
+ flex-direction: column;
80
+ height: 100%;
81
+ background-color: var(--overview-chart-loader-bg-color);
82
+ border-radius: 8px;
83
+
84
+ .title {
85
+ text-align: center;
86
+ font-size: 18px;
87
+ margin-top: 10px;
88
+ color: var(--global-font-color);
89
+ }
90
+
91
+ .body-block {
92
+ height: 100%;
93
+ display: flex;
94
+ justify-content: center;
95
+ text-align: center;
96
+ align-items: center;
97
+ color: var(--global-font-color);
98
+ }
99
+ }
100
+
101
+ .chart-container {
102
+ position: relative;
103
+ width: 100%;
104
+ min-width: 300px;
105
+ height: 100%;
106
+ min-height: 300px;
107
+ flex-grow: 1;
108
+ box-sizing: border-box;
109
+
110
+ :deep(svg > .skeleton-metric__line) {
111
+ display: none;
112
+ }
113
+ }
114
+ }
115
+ @container (max-width: 920px) {
116
+ .charts-view {
117
+ grid-template-columns: 1fr !important;
118
+ }
119
+ }
120
+ </style>
@@ -1,166 +1,169 @@
1
- <template>
2
- <common-monitor-overview-filters-new
3
- v-if="isNewView"
4
- v-model:selected-period="selectedPeriod"
5
- v-model:selected-view="selectedView"
6
- :disabled-period-options="disabledPeriodOptions"
7
- :period-options="periodOptions"
8
- :is-show-custom-interval-button="isShowCustomIntervalButton"
9
- :chart-title-date="chartTitleDate"
10
- :view-options="viewOptions"
11
- :valid-date-end="props.validDateEnd"
12
- :is-show-interval-modal="isShowIntervalModal"
13
- :selected-periods="props.selectedPeriods"
14
- :format-date="props.formatDate"
15
- :current-lang="props.currentLang"
16
- @submit-interval-modal="onSubmitIntervalModal"
17
- @show-interval-modal="onShowIntervalModal"
18
- @hide-interval-modal="onHideIntervalModal"
19
- />
20
- <common-monitor-overview-filters-old
21
- v-else
22
- v-model:selected-period="selectedPeriod"
23
- v-model:selected-view="selectedView"
24
- :disabled-period-options="disabledPeriodOptions"
25
- :period-options="periodOptions"
26
- :is-show-custom-interval-button="isShowCustomIntervalButton"
27
- :chart-title-date="chartTitleDate"
28
- :view-options="viewOptions"
29
- :valid-date-end="props.validDateEnd"
30
- :is-show-interval-modal="isShowIntervalModal"
31
- :selected-periods="props.selectedPeriods"
32
- :format-date="props.formatDate"
33
- :current-lang="props.currentLang"
34
- @submit-interval-modal="onSubmitIntervalModal"
35
- @show-interval-modal="onShowIntervalModal"
36
- @hide-interval-modal="onHideIntervalModal"
37
- />
38
- </template>
39
-
40
- <script setup lang="ts">
41
- import type { UI_I_Localization } from '~/lib/models/interfaces'
42
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
43
- import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
44
- import type { UI_T_OverviewViewType } from '~/components/common/monitor/overview/filters/lib/models/types'
45
- import {
46
- periodFunc,
47
- viewFunc,
48
- } from '~/components/common/monitor/overview/filters/lib/config/filterOptions'
49
- import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
50
-
51
- const { $formattedDatetime, $store }: any = useNuxtApp()
52
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
53
-
54
- const props = defineProps<{
55
- startDate: number
56
- endDate: number
57
- chartType: 'spline' | 'pie'
58
- view: UI_T_OverviewViewType
59
- selectedPeriods: number[]
60
- formatDate: string
61
- currentLang: string
62
- validDateEnd: number
63
- formatTime?: string
64
- }>()
65
-
66
- const emits = defineEmits<{
67
- (event: 'update-filters', value: UI_I_MonitorGraphPayload): void
68
- (event: 'update-custom-date', value: number[]): void
69
- }>()
70
-
71
- const localization = computed<UI_I_Localization>(() => useLocal())
72
-
73
- const selectedPeriod = ref<string>('')
74
- const periodOptions = computed<UI_I_OptionItem[]>(() =>
75
- periodFunc(localization.value)
76
- )
77
- watch(
78
- () => periodOptions.value,
79
- (newValue: UI_I_OptionItem[]) => {
80
- if (newValue) selectedPeriod.value = newValue[0].value
81
- },
82
- { immediate: true }
83
- )
84
-
85
- const isShowCustomIntervalButton = computed<boolean>(
86
- () => selectedPeriod.value === 'custom_interval'
87
- )
88
-
89
- const isShowIntervalModal = ref<boolean>(false)
90
- const onShowIntervalModal = (): void => {
91
- isShowIntervalModal.value = true
92
- }
93
- const onHideIntervalModal = (): void => {
94
- isShowIntervalModal.value = false
95
- }
96
- const onSubmitIntervalModal = (customDates: number[]): void => {
97
- customDatesData.value = customDates
98
- sendUpdatedFilters()
99
- onHideIntervalModal()
100
- emits('update-custom-date', customDates)
101
- }
102
-
103
- const chartTitleDate = computed<string>(() => {
104
- const startValue = props.startDate
105
- const endValue = props.endDate
106
- if (!startValue && !endValue) return ''
107
-
108
- const start = $formattedDatetime(
109
- startValue,
110
- props.formatDate,
111
- true,
112
- '',
113
- props.formatTime
114
- )
115
- const end = $formattedDatetime(
116
- endValue,
117
- props.formatDate,
118
- true,
119
- '',
120
- props.formatTime
121
- )
122
- return `${start} - ${end}`
123
- })
124
-
125
- // const disabledPeriodOptions = computed<boolean>(
126
- // () => props.chartType === 'pie' || !chartTitleDate.value
127
- // )
128
-
129
- const disabledPeriodOptions = computed<boolean>(() => props.chartType === 'pie')
130
-
131
- const selectedView = ref<string>('')
132
- const viewOptions = computed<UI_I_OptionItem[]>(() =>
133
- viewFunc(localization.value, props.view)
134
- )
135
- watch(
136
- () => viewOptions.value,
137
- (newValue: UI_I_OptionItem[]) => {
138
- if (newValue) selectedView.value = newValue[0].value
139
- },
140
- { immediate: true }
141
- )
142
-
143
- const customDatesData = ref<number[]>([])
144
- const sendUpdatedFilters = (): void => {
145
- const currentPeriod =
146
- selectedPeriod.value === 'custom_interval'
147
- ? customDatesData.value
148
- : getValidDateByOptionFunc(selectedPeriod.value)
149
- const filters: UI_I_MonitorGraphPayload = {
150
- period: currentPeriod,
151
- view: selectedView.value,
152
- periodName: selectedPeriod.value,
153
- }
154
-
155
- emits('update-filters', filters)
156
- }
157
- watch(
158
- () => [selectedPeriod.value, selectedView.value],
159
- () => {
160
- sendUpdatedFilters()
161
- },
162
- { immediate: true }
163
- )
164
- </script>
165
-
166
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <common-monitor-overview-filters-new
3
+ v-if="isNewView"
4
+ v-model:selected-period="selectedPeriod"
5
+ v-model:selected-view="selectedView"
6
+ :disabled-period-options="disabledPeriodOptions"
7
+ :period-options="periodOptions"
8
+ :is-show-custom-interval-button="isShowCustomIntervalButton"
9
+ :chart-title-date="chartTitleDate"
10
+ :view-options="viewOptions"
11
+ :valid-date-end="props.validDateEnd"
12
+ :is-show-interval-modal="isShowIntervalModal"
13
+ :selected-periods="props.selectedPeriods"
14
+ :format-date="props.formatDate"
15
+ :current-lang="props.currentLang"
16
+ :selected-node-name="props.selectedNodeName"
17
+ @submit-interval-modal="onSubmitIntervalModal"
18
+ @show-interval-modal="onShowIntervalModal"
19
+ @hide-interval-modal="onHideIntervalModal"
20
+ />
21
+ <common-monitor-overview-filters-old
22
+ v-else
23
+ v-model:selected-period="selectedPeriod"
24
+ v-model:selected-view="selectedView"
25
+ :disabled-period-options="disabledPeriodOptions"
26
+ :period-options="periodOptions"
27
+ :is-show-custom-interval-button="isShowCustomIntervalButton"
28
+ :chart-title-date="chartTitleDate"
29
+ :view-options="viewOptions"
30
+ :valid-date-end="props.validDateEnd"
31
+ :is-show-interval-modal="isShowIntervalModal"
32
+ :selected-periods="props.selectedPeriods"
33
+ :format-date="props.formatDate"
34
+ :current-lang="props.currentLang"
35
+ :selected-node-name="props.selectedNodeName"
36
+ @submit-interval-modal="onSubmitIntervalModal"
37
+ @show-interval-modal="onShowIntervalModal"
38
+ @hide-interval-modal="onHideIntervalModal"
39
+ />
40
+ </template>
41
+
42
+ <script setup lang="ts">
43
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
44
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
45
+ import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
46
+ import type { UI_T_OverviewViewType } from '~/components/common/monitor/overview/filters/lib/models/types'
47
+ import {
48
+ periodFunc,
49
+ viewFunc,
50
+ } from '~/components/common/monitor/overview/filters/lib/config/filterOptions'
51
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
52
+
53
+ const { $formattedDatetime, $store }: any = useNuxtApp()
54
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
55
+
56
+ const props = defineProps<{
57
+ startDate: number
58
+ endDate: number
59
+ chartType: 'spline' | 'pie'
60
+ view: UI_T_OverviewViewType
61
+ selectedPeriods: number[]
62
+ formatDate: string
63
+ currentLang: string
64
+ validDateEnd: number
65
+ selectedNodeName: string
66
+ formatTime?: string
67
+ }>()
68
+
69
+ const emits = defineEmits<{
70
+ (event: 'update-filters', value: UI_I_MonitorGraphPayload): void
71
+ (event: 'update-custom-date', value: number[]): void
72
+ }>()
73
+
74
+ const localization = computed<UI_I_Localization>(() => useLocal())
75
+
76
+ const selectedPeriod = ref<string>('')
77
+ const periodOptions = computed<UI_I_OptionItem[]>(() =>
78
+ periodFunc(localization.value)
79
+ )
80
+ watch(
81
+ () => periodOptions.value,
82
+ (newValue: UI_I_OptionItem[]) => {
83
+ if (newValue) selectedPeriod.value = newValue[0].value
84
+ },
85
+ { immediate: true }
86
+ )
87
+
88
+ const isShowCustomIntervalButton = computed<boolean>(
89
+ () => selectedPeriod.value === 'custom_interval'
90
+ )
91
+
92
+ const isShowIntervalModal = ref<boolean>(false)
93
+ const onShowIntervalModal = (): void => {
94
+ isShowIntervalModal.value = true
95
+ }
96
+ const onHideIntervalModal = (): void => {
97
+ isShowIntervalModal.value = false
98
+ }
99
+ const onSubmitIntervalModal = (customDates: number[]): void => {
100
+ customDatesData.value = customDates
101
+ sendUpdatedFilters()
102
+ onHideIntervalModal()
103
+ emits('update-custom-date', customDates)
104
+ }
105
+
106
+ const chartTitleDate = computed<string>(() => {
107
+ const startValue = props.startDate
108
+ const endValue = props.endDate
109
+ if (!startValue && !endValue) return ''
110
+
111
+ const start = $formattedDatetime(
112
+ startValue,
113
+ props.formatDate,
114
+ true,
115
+ '',
116
+ props.formatTime
117
+ )
118
+ const end = $formattedDatetime(
119
+ endValue,
120
+ props.formatDate,
121
+ true,
122
+ '',
123
+ props.formatTime
124
+ )
125
+ return `${start} - ${end}`
126
+ })
127
+
128
+ // const disabledPeriodOptions = computed<boolean>(
129
+ // () => props.chartType === 'pie' || !chartTitleDate.value
130
+ // )
131
+
132
+ const disabledPeriodOptions = computed<boolean>(() => props.chartType === 'pie')
133
+
134
+ const selectedView = ref<string>('')
135
+ const viewOptions = computed<UI_I_OptionItem[]>(() =>
136
+ viewFunc(localization.value, props.view)
137
+ )
138
+ watch(
139
+ () => viewOptions.value,
140
+ (newValue: UI_I_OptionItem[]) => {
141
+ if (newValue) selectedView.value = newValue[0].value
142
+ },
143
+ { immediate: true }
144
+ )
145
+
146
+ const customDatesData = ref<number[]>([])
147
+ const sendUpdatedFilters = (): void => {
148
+ const currentPeriod =
149
+ selectedPeriod.value === 'custom_interval'
150
+ ? customDatesData.value
151
+ : getValidDateByOptionFunc(selectedPeriod.value)
152
+ const filters: UI_I_MonitorGraphPayload = {
153
+ period: currentPeriod,
154
+ view: selectedView.value,
155
+ periodName: selectedPeriod.value,
156
+ }
157
+
158
+ emits('update-filters', filters)
159
+ }
160
+ watch(
161
+ () => [selectedPeriod.value, selectedView.value],
162
+ () => {
163
+ sendUpdatedFilters()
164
+ },
165
+ { immediate: true }
166
+ )
167
+ </script>
168
+
169
+ <style scoped lang="scss"></style>