bfg-common 1.4.184 → 1.4.185

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,228 +1,230 @@
1
- <template>
2
- <div class="horizontal-flex-container overview-chart-title-bar">
3
- <div class="horizontal-flex-container">
4
- <label for="periodSelect" class="label-select"
5
- >{{ localization.inventoryMonitor.period }}:</label
6
- >
7
- <div v-if="!disabledPeriodOptions" class="select">
8
- <select
9
- id="periodSelect"
10
- v-model="selectedPeriod"
11
- data-id="period-select"
12
- >
13
- <option
14
- v-for="(item, index) in periodOptions"
15
- :key="index"
16
- :value="item.value"
17
- >
18
- {{ item.text }}
19
- </option>
20
- </select>
21
- </div>
22
- <span v-else class="single-option">{{ periodOptions[0].text }}</span>
23
- </div>
24
- <div v-show="isShowCustomIntervalButton">
25
- <a
26
- id="show-interval-modal-button"
27
- data-id="show-interval-modal-button"
28
- @click="onShowIntervalModal"
29
- >{{ localization.inventoryMonitor.changeCustomInterval }}</a
30
- >
31
- </div>
32
- <div v-if="!disabledPeriodOptions" class="chart-title">
33
- {{ chartTitleDate }}
34
- </div>
35
- <div class="view-select-label horizontal-flex-container">
36
- <label for="viewSelect" class="label-select"
37
- >{{ localization.common.view }}:</label
38
- >
39
- <div class="select">
40
- <select id="viewSelect" v-model="selectedView" data-id="view-select">
41
- <option
42
- v-for="(item, index) in viewOptions"
43
- :key="index"
44
- :value="item.value"
45
- >
46
- {{ item.text }}
47
- </option>
48
- </select>
49
- </div>
50
- </div>
51
- </div>
52
-
53
- <common-monitor-overview-filters-custom-interval-modal
54
- v-if="isShowIntervalModal"
55
- :selected-periods="props.selectedPeriods"
56
- :format-date="props.formatDate"
57
- @hide="onHideIntervalModal"
58
- @submit="onSubmitIntervalModal"
59
- />
60
- </template>
61
-
62
- <script setup lang="ts">
63
- import type { UI_I_Localization } from '~/lib/models/interfaces'
64
- import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
65
- import type { UI_T_Project } from '~/lib/models/types'
66
- import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
67
- import type { UI_T_OverviewViewType } from '~/components/common/monitor/overview/filters/lib/models/types'
68
- import {
69
- periodFunc,
70
- viewFunc,
71
- } from '~/components/common/monitor/overview/filters/lib/config/filterOptions'
72
- import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
73
-
74
- const localization = computed<UI_I_Localization>(() => useLocal())
75
- const { $formattedDatetime } = useNuxtApp()
76
-
77
- const props = defineProps<{
78
- startDate: number
79
- endDate: number
80
- chartType: 'spline' | 'pie'
81
- view: UI_T_OverviewViewType
82
- selectedPeriods: number[]
83
- formatDate: string
84
- project: UI_T_Project
85
- formatTime?: string
86
- }>()
87
-
88
- const emits = defineEmits<{
89
- (event: 'update-filters', value: UI_I_MonitorGraphPayload): void
90
- (event: 'update-custom-date', value: number[]): void
91
- }>()
92
-
93
- const selectedPeriod = ref<string>('')
94
- const periodOptions = computed<UI_I_OptionItem[]>(() =>
95
- periodFunc(localization.value)
96
- )
97
- watch(
98
- () => periodOptions.value,
99
- (newValue: UI_I_OptionItem[]) => {
100
- if (newValue) selectedPeriod.value = newValue[0].value
101
- },
102
- { immediate: true }
103
- )
104
-
105
- const isShowCustomIntervalButton = computed<boolean>(
106
- () => selectedPeriod.value === 'custom_interval'
107
- )
108
-
109
- const isShowIntervalModal = ref<boolean>(false)
110
- const onShowIntervalModal = (): void => {
111
- isShowIntervalModal.value = true
112
- }
113
- const onHideIntervalModal = (): void => {
114
- isShowIntervalModal.value = false
115
- }
116
- const onSubmitIntervalModal = (customDates: number[]): void => {
117
- customDatesData.value = customDates
118
- sendUpdatedFilters()
119
- onHideIntervalModal()
120
- emits('update-custom-date', customDates)
121
- }
122
-
123
- const chartTitleDate = computed<string>(() => {
124
- const startValue = props.startDate
125
- const endValue = props.endDate
126
- if (!startValue && !endValue) return ''
127
-
128
- const start = $formattedDatetime(
129
- startValue,
130
- props.formatDate,
131
- true,
132
- '',
133
- props.formatTime
134
- )
135
- const end = $formattedDatetime(
136
- endValue,
137
- props.formatDate,
138
- true,
139
- '',
140
- props.formatTime
141
- )
142
- return `${start} - ${end}`
143
- })
144
-
145
- // const disabledPeriodOptions = computed<boolean>(
146
- // () => props.chartType === 'pie' || !chartTitleDate.value
147
- // )
148
-
149
- const disabledPeriodOptions = computed<boolean>(() => props.chartType === 'pie')
150
-
151
- const selectedView = ref<string>('')
152
- const viewOptions = computed<UI_I_OptionItem[]>(() =>
153
- viewFunc(localization.value, props.view, props.project)
154
- )
155
- watch(
156
- () => viewOptions.value,
157
- (newValue: UI_I_OptionItem[]) => {
158
- if (newValue) selectedView.value = newValue[0].value
159
- },
160
- { immediate: true }
161
- )
162
-
163
- const customDatesData = ref<number[]>([])
164
- const sendUpdatedFilters = (): void => {
165
- const currentPeriod =
166
- selectedPeriod.value === 'custom_interval'
167
- ? customDatesData.value
168
- : getValidDateByOptionFunc(selectedPeriod.value)
169
- const filters: UI_I_MonitorGraphPayload = {
170
- period: currentPeriod,
171
- view: selectedView.value,
172
- periodName: selectedPeriod.value,
173
- }
174
-
175
- emits('update-filters', filters)
176
- }
177
- watch(
178
- () => [selectedPeriod.value, selectedView.value],
179
- (newValue: string[]) => {
180
- newValue[0] !== 'custom_interval' && sendUpdatedFilters()
181
- },
182
- { immediate: true }
183
- )
184
- </script>
185
-
186
- <style scoped lang="scss">
187
- .horizontal-flex-container {
188
- display: flex;
189
- flex-direction: row;
190
- align-items: center;
191
- line-height: 20px;
192
- flex-shrink: 0;
193
- padding-top: 5px;
194
-
195
- .select select {
196
- height: 20px;
197
- margin: 5px;
198
- color: var(--global-font-color);
199
- }
200
- .single-option {
201
- margin-left: 5px;
202
- }
203
-
204
- .chart-title {
205
- color: var(--global-font-color);
206
- text-overflow: ellipsis;
207
- white-space: nowrap;
208
- overflow: hidden;
209
- margin: 6px;
210
- font-weight: 700;
211
- text-transform: uppercase;
212
- }
213
-
214
- #show-interval-modal-button {
215
- cursor: pointer;
216
- color: var(--dropdown-item-color);
217
- }
218
-
219
- .view-select-label {
220
- margin-left: auto;
221
- padding-right: 7px;
222
- padding-left: 7px;
223
- text-overflow: ellipsis;
224
- white-space: nowrap;
225
- align-items: center;
226
- }
227
- }
228
- </style>
1
+ <template>
2
+ <div class="horizontal-flex-container overview-chart-title-bar">
3
+ <div class="horizontal-flex-container">
4
+ <label for="periodSelect" class="label-select"
5
+ >{{ localization.inventoryMonitor.period }}:</label
6
+ >
7
+ <div v-if="!disabledPeriodOptions" class="select">
8
+ <select
9
+ id="periodSelect"
10
+ v-model="selectedPeriod"
11
+ data-id="period-select"
12
+ >
13
+ <option
14
+ v-for="(item, index) in periodOptions"
15
+ :key="index"
16
+ :value="item.value"
17
+ >
18
+ {{ item.text }}
19
+ </option>
20
+ </select>
21
+ </div>
22
+ <span v-else class="single-option">{{ periodOptions[0].text }}</span>
23
+ </div>
24
+ <div v-show="isShowCustomIntervalButton">
25
+ <a
26
+ id="show-interval-modal-button"
27
+ data-id="show-interval-modal-button"
28
+ @click="onShowIntervalModal"
29
+ >{{ localization.inventoryMonitor.changeCustomInterval }}</a
30
+ >
31
+ </div>
32
+ <div v-if="!disabledPeriodOptions" class="chart-title">
33
+ {{ chartTitleDate }}
34
+ </div>
35
+ <div class="view-select-label horizontal-flex-container">
36
+ <label for="viewSelect" class="label-select"
37
+ >{{ localization.common.view }}:</label
38
+ >
39
+ <div class="select">
40
+ <select id="viewSelect" v-model="selectedView" data-id="view-select">
41
+ <option
42
+ v-for="(item, index) in viewOptions"
43
+ :key="index"
44
+ :value="item.value"
45
+ >
46
+ {{ item.text }}
47
+ </option>
48
+ </select>
49
+ </div>
50
+ </div>
51
+ </div>
52
+
53
+ <common-monitor-overview-filters-custom-interval-modal
54
+ v-if="isShowIntervalModal"
55
+ :selected-periods="props.selectedPeriods"
56
+ :format-date="props.formatDate"
57
+ :current-lang="props.currentLang"
58
+ @hide="onHideIntervalModal"
59
+ @submit="onSubmitIntervalModal"
60
+ />
61
+ </template>
62
+
63
+ <script setup lang="ts">
64
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
65
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
66
+ import type { UI_T_Project } from '~/lib/models/types'
67
+ import type { UI_I_MonitorGraphPayload } from '~/components/common/monitor/lib/models/interfaces'
68
+ import type { UI_T_OverviewViewType } from '~/components/common/monitor/overview/filters/lib/models/types'
69
+ import {
70
+ periodFunc,
71
+ viewFunc,
72
+ } from '~/components/common/monitor/overview/filters/lib/config/filterOptions'
73
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/lib/config/getValidDateByOption'
74
+
75
+ const localization = computed<UI_I_Localization>(() => useLocal())
76
+ const { $formattedDatetime } = useNuxtApp()
77
+
78
+ const props = defineProps<{
79
+ startDate: number
80
+ endDate: number
81
+ chartType: 'spline' | 'pie'
82
+ view: UI_T_OverviewViewType
83
+ selectedPeriods: number[]
84
+ formatDate: string
85
+ project: UI_T_Project
86
+ currentLang: string
87
+ formatTime?: string
88
+ }>()
89
+
90
+ const emits = defineEmits<{
91
+ (event: 'update-filters', value: UI_I_MonitorGraphPayload): void
92
+ (event: 'update-custom-date', value: number[]): void
93
+ }>()
94
+
95
+ const selectedPeriod = ref<string>('')
96
+ const periodOptions = computed<UI_I_OptionItem[]>(() =>
97
+ periodFunc(localization.value)
98
+ )
99
+ watch(
100
+ () => periodOptions.value,
101
+ (newValue: UI_I_OptionItem[]) => {
102
+ if (newValue) selectedPeriod.value = newValue[0].value
103
+ },
104
+ { immediate: true }
105
+ )
106
+
107
+ const isShowCustomIntervalButton = computed<boolean>(
108
+ () => selectedPeriod.value === 'custom_interval'
109
+ )
110
+
111
+ const isShowIntervalModal = ref<boolean>(false)
112
+ const onShowIntervalModal = (): void => {
113
+ isShowIntervalModal.value = true
114
+ }
115
+ const onHideIntervalModal = (): void => {
116
+ isShowIntervalModal.value = false
117
+ }
118
+ const onSubmitIntervalModal = (customDates: number[]): void => {
119
+ customDatesData.value = customDates
120
+ sendUpdatedFilters()
121
+ onHideIntervalModal()
122
+ emits('update-custom-date', customDates)
123
+ }
124
+
125
+ const chartTitleDate = computed<string>(() => {
126
+ const startValue = props.startDate
127
+ const endValue = props.endDate
128
+ if (!startValue && !endValue) return ''
129
+
130
+ const start = $formattedDatetime(
131
+ startValue,
132
+ props.formatDate,
133
+ true,
134
+ '',
135
+ props.formatTime
136
+ )
137
+ const end = $formattedDatetime(
138
+ endValue,
139
+ props.formatDate,
140
+ true,
141
+ '',
142
+ props.formatTime
143
+ )
144
+ return `${start} - ${end}`
145
+ })
146
+
147
+ // const disabledPeriodOptions = computed<boolean>(
148
+ // () => props.chartType === 'pie' || !chartTitleDate.value
149
+ // )
150
+
151
+ const disabledPeriodOptions = computed<boolean>(() => props.chartType === 'pie')
152
+
153
+ const selectedView = ref<string>('')
154
+ const viewOptions = computed<UI_I_OptionItem[]>(() =>
155
+ viewFunc(localization.value, props.view, props.project)
156
+ )
157
+ watch(
158
+ () => viewOptions.value,
159
+ (newValue: UI_I_OptionItem[]) => {
160
+ if (newValue) selectedView.value = newValue[0].value
161
+ },
162
+ { immediate: true }
163
+ )
164
+
165
+ const customDatesData = ref<number[]>([])
166
+ const sendUpdatedFilters = (): void => {
167
+ const currentPeriod =
168
+ selectedPeriod.value === 'custom_interval'
169
+ ? customDatesData.value
170
+ : getValidDateByOptionFunc(selectedPeriod.value)
171
+ const filters: UI_I_MonitorGraphPayload = {
172
+ period: currentPeriod,
173
+ view: selectedView.value,
174
+ periodName: selectedPeriod.value,
175
+ }
176
+
177
+ emits('update-filters', filters)
178
+ }
179
+ watch(
180
+ () => [selectedPeriod.value, selectedView.value],
181
+ (newValue: string[]) => {
182
+ newValue[0] !== 'custom_interval' && sendUpdatedFilters()
183
+ },
184
+ { immediate: true }
185
+ )
186
+ </script>
187
+
188
+ <style scoped lang="scss">
189
+ .horizontal-flex-container {
190
+ display: flex;
191
+ flex-direction: row;
192
+ align-items: center;
193
+ line-height: 20px;
194
+ flex-shrink: 0;
195
+ padding-top: 5px;
196
+
197
+ .select select {
198
+ height: 20px;
199
+ margin: 5px;
200
+ color: var(--global-font-color);
201
+ }
202
+ .single-option {
203
+ margin-left: 5px;
204
+ }
205
+
206
+ .chart-title {
207
+ color: var(--global-font-color);
208
+ text-overflow: ellipsis;
209
+ white-space: nowrap;
210
+ overflow: hidden;
211
+ margin: 6px;
212
+ font-weight: 700;
213
+ text-transform: uppercase;
214
+ }
215
+
216
+ #show-interval-modal-button {
217
+ cursor: pointer;
218
+ color: var(--dropdown-item-color);
219
+ }
220
+
221
+ .view-select-label {
222
+ margin-left: auto;
223
+ padding-right: 7px;
224
+ padding-left: 7px;
225
+ text-overflow: ellipsis;
226
+ white-space: nowrap;
227
+ align-items: center;
228
+ }
229
+ }
230
+ </style>
@@ -1,245 +1,238 @@
1
- <template>
2
- <atoms-modal
3
- width="580px"
4
- class="add-permission"
5
- :show="true"
6
- :title="titleIntervalModal"
7
- :second-title="selectedItem"
8
- test-id="overview-custom-interval-modal"
9
- @hide="onHide"
10
- @submit="onSubmit"
11
- >
12
- <template #modalBody>
13
- <atoms-alert
14
- v-show="alertShow"
15
- status="alert-danger"
16
- :items="alertItems"
17
- test-id="overview-alert"
18
- @remove="alertShow = false"
19
- />
20
-
21
- <table>
22
- <tbody>
23
- <tr>
24
- <td class="text-right">
25
- <label class="custom-time-label">
26
- <span class="custom-time-label-text text-capitalize">
27
- {{ localization.common.from }}:
28
- </span>
29
- </label>
30
- </td>
31
- <td>
32
- <div class="flex-align-center input-row-container">
33
- <input
34
- id="current-date-from"
35
- v-model.lazy="currentDateFrom"
36
- data-id="current-date-from-input"
37
- type="text"
38
- class="chart-option-setting-row custom-time-input first-from"
39
- />
40
- <div class="section-datepicker">
41
- <atoms-datepicker
42
- v-model="dateFrom"
43
- :lang="currentLang"
44
- class="chart-option-setting-row custom-time-input"
45
- test-id="overview-first-date-datepicker"
46
- @update="onUpdateDateFrom"
47
- />
48
- </div>
49
- <input
50
- id="current-time-from"
51
- v-model="currentTimeFrom"
52
- data-id="current-time-from-input"
53
- type="text"
54
- class="chart-option-setting-row custom-time-input"
55
- />
56
- </div>
57
- </td>
58
- </tr>
59
- <tr>
60
- <td class="text-right">
61
- <label class="custom-time-label">
62
- <span class="custom-time-label-text text-capitalize">
63
- {{ localization.common.to }}:
64
- </span>
65
- </label>
66
- </td>
67
- <td>
68
- <div class="flex-align-center input-row-container">
69
- <input
70
- id="current-date-to"
71
- v-model.lazy="currentDateTo"
72
- data-id="current-date-to-input"
73
- type="text"
74
- class="chart-option-setting-row custom-time-input first-from"
75
- />
76
- <div class="section-datepicker">
77
- <atoms-datepicker
78
- v-model="dateTo"
79
- :lang="currentLang"
80
- class="chart-option-setting-row custom-time-input"
81
- test-id="overview-first-date-to-datepicker"
82
- @update="onUpdateDateTo"
83
- />
84
- </div>
85
- <input
86
- id="current-time-to"
87
- v-model="currentTimeTo"
88
- data-id="current-time-to-input"
89
- type="text"
90
- class="chart-option-setting-row custom-time-input"
91
- />
92
- </div>
93
- </td>
94
- </tr>
95
- <tr>
96
- <td></td>
97
- <td class="text-format-date">
98
- (date and time are in ISO 8601 format)
99
- </td>
100
- </tr>
101
- </tbody>
102
- </table>
103
- </template>
104
- </atoms-modal>
105
- </template>
106
-
107
- <script setup lang="ts">
108
- import { format } from 'date-fns'
109
- import type { UI_I_Localization } from '~/lib/models/interfaces'
110
- import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
111
-
112
- const props = defineProps<{
113
- formatDate: string
114
- selectedPeriods: number[]
115
- }>()
116
-
117
- const emits = defineEmits<{
118
- (event: 'hide'): void
119
- (event: 'submit', value: number[]): void
120
- }>()
121
-
122
- const { $store, $formattedDate, $formattedTime, $isDate, $getUnixByDate } =
123
- useNuxtApp()
124
-
125
- const localization = computed<UI_I_Localization>(() => useLocal())
126
-
127
- const titleIntervalModal = ref<string>(`${localization.value.common.timeRange}:`)
128
-
129
- const selectedItem = ref<string>('')
130
-
131
- const onHide = (): void => {
132
- emits('hide')
133
- }
134
-
135
- const yesterday = new Date().setDate(new Date().getDate() - 1)
136
- const dateFrom = ref<number>(yesterday)
137
- const dateTo = ref<number>(new Date().getTime())
138
-
139
- const currentDateFrom = ref<string>('')
140
- const currentDateTo = ref<string>('')
141
- const currentTimeFrom = ref<string>('')
142
- const currentTimeTo = ref<string>('')
143
-
144
- const getCurrentTime = (): void => {
145
- if (!props.selectedPeriods.length) {
146
- currentDateFrom.value = $formattedDate(yesterday, props.formatDate)
147
- currentDateTo.value = $formattedDate(new Date(), props.formatDate)
148
-
149
- const currentTime = format(new Date(), 'H:mm:ss')
150
- currentTimeFrom.value = currentTime
151
- currentTimeTo.value = currentTime
152
-
153
- return
154
- }
155
-
156
- currentDateFrom.value = $formattedDate(
157
- props.selectedPeriods[0],
158
- props.formatDate
159
- )
160
- currentDateTo.value = $formattedDate(
161
- props.selectedPeriods[1],
162
- props.formatDate
163
- )
164
- currentTimeFrom.value = $formattedTime(props.selectedPeriods[0], '', true)
165
- currentTimeTo.value = $formattedTime(props.selectedPeriods[1], '', true)
166
- }
167
-
168
- const timeFormatUpdater = computed<number>(
169
- () => $store.getters['main/getTimeFormatUpdater']
170
- )
171
- const currentLang = ref<string>(useLocalStorage('lang') || 'ru_RU')
172
- watch(timeFormatUpdater, () => {
173
- currentLang.value = useLocalStorage('lang') || 'ru_RU'
174
- getCurrentTime()
175
- })
176
-
177
- const onUpdateDateFrom = (val: number): void => {
178
- if (!val) return
179
-
180
- currentDateFrom.value = $formattedDate(new Date(val), props.formatDate)
181
- }
182
- watch(currentDateFrom, (newValue) => {
183
- if (!newValue) return
184
-
185
- if ($isDate(newValue)) dateFrom.value = $getUnixByDate(newValue)
186
- })
187
-
188
- const onUpdateDateTo = (val: number): void => {
189
- if (!val) return
190
-
191
- currentDateTo.value = $formattedDate(new Date(val), props.formatDate)
192
- }
193
- watch(currentDateTo, (newValue) => {
194
- if (!newValue) return
195
-
196
- if ($isDate(newValue)) dateTo.value = $getUnixByDate(newValue)
197
- })
198
-
199
- const alertShow = ref<boolean>(false)
200
- const alertItems = ref<string[]>([])
201
-
202
- const onSubmit = (): void => {
203
- alertItems.value = []
204
- alertShow.value = false
205
-
206
- if (!dateFrom.value || !dateTo.value) return
207
-
208
- const result = checkDateFunc(
209
- localization.value,
210
- currentDateFrom.value,
211
- currentDateTo.value,
212
- currentTimeFrom.value,
213
- currentTimeTo.value
214
- )
215
-
216
- if (typeof result === 'string') {
217
- alertShow.value = true
218
- alertItems.value.push(result)
219
- return
220
- }
221
-
222
- emits('submit', [result[0], result[1]])
223
- onHide()
224
- }
225
-
226
- onMounted(() => {
227
- selectedItem.value = location.hostname
228
- getCurrentTime()
229
- })
230
- </script>
231
-
232
- <style scoped lang="scss">
233
- .input-row-container {
234
- padding-left: 5px;
235
-
236
- .custom-time-input {
237
- max-width: 120px;
238
- margin-right: 15px;
239
- }
240
- }
241
- .text-format-date {
242
- display: inline-block;
243
- margin-top: 5px;
244
- }
245
- </style>
1
+ <template>
2
+ <atoms-modal
3
+ width="580px"
4
+ class="add-permission"
5
+ :show="true"
6
+ :title="titleIntervalModal"
7
+ :second-title="selectedItem"
8
+ test-id="overview-custom-interval-modal"
9
+ @hide="onHide"
10
+ @submit="onSubmit"
11
+ >
12
+ <template #modalBody>
13
+ <atoms-alert
14
+ v-show="alertShow"
15
+ status="alert-danger"
16
+ :items="alertItems"
17
+ test-id="overview-alert"
18
+ @remove="alertShow = false"
19
+ />
20
+
21
+ <table>
22
+ <tbody>
23
+ <tr>
24
+ <td class="text-right">
25
+ <label class="custom-time-label">
26
+ <span class="custom-time-label-text text-capitalize">
27
+ {{ localization.common.from }}:
28
+ </span>
29
+ </label>
30
+ </td>
31
+ <td>
32
+ <div class="flex-align-center input-row-container">
33
+ <input
34
+ id="current-date-from"
35
+ v-model.lazy="currentDateFrom"
36
+ data-id="current-date-from-input"
37
+ type="text"
38
+ class="chart-option-setting-row custom-time-input first-from"
39
+ />
40
+ <div class="section-datepicker">
41
+ <atoms-datepicker
42
+ v-model="dateFrom"
43
+ :lang="props.currentLang"
44
+ class="chart-option-setting-row custom-time-input"
45
+ test-id="overview-first-date-datepicker"
46
+ @update="onUpdateDateFrom"
47
+ />
48
+ </div>
49
+ <input
50
+ id="current-time-from"
51
+ v-model="currentTimeFrom"
52
+ data-id="current-time-from-input"
53
+ type="text"
54
+ class="chart-option-setting-row custom-time-input"
55
+ />
56
+ </div>
57
+ </td>
58
+ </tr>
59
+ <tr>
60
+ <td class="text-right">
61
+ <label class="custom-time-label">
62
+ <span class="custom-time-label-text text-capitalize">
63
+ {{ localization.common.to }}:
64
+ </span>
65
+ </label>
66
+ </td>
67
+ <td>
68
+ <div class="flex-align-center input-row-container">
69
+ <input
70
+ id="current-date-to"
71
+ v-model.lazy="currentDateTo"
72
+ data-id="current-date-to-input"
73
+ type="text"
74
+ class="chart-option-setting-row custom-time-input first-from"
75
+ />
76
+ <div class="section-datepicker">
77
+ <atoms-datepicker
78
+ v-model="dateTo"
79
+ :lang="props.currentLang"
80
+ class="chart-option-setting-row custom-time-input"
81
+ test-id="overview-first-date-to-datepicker"
82
+ @update="onUpdateDateTo"
83
+ />
84
+ </div>
85
+ <input
86
+ id="current-time-to"
87
+ v-model="currentTimeTo"
88
+ data-id="current-time-to-input"
89
+ type="text"
90
+ class="chart-option-setting-row custom-time-input"
91
+ />
92
+ </div>
93
+ </td>
94
+ </tr>
95
+ <tr>
96
+ <td></td>
97
+ <td class="text-format-date">
98
+ (date and time are in ISO 8601 format)
99
+ </td>
100
+ </tr>
101
+ </tbody>
102
+ </table>
103
+ </template>
104
+ </atoms-modal>
105
+ </template>
106
+
107
+ <script setup lang="ts">
108
+ import { format } from 'date-fns'
109
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
110
+ import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
111
+
112
+ const props = defineProps<{
113
+ formatDate: string
114
+ selectedPeriods: number[]
115
+ currentLang: string
116
+ }>()
117
+
118
+ const emits = defineEmits<{
119
+ (event: 'hide'): void
120
+ (event: 'submit', value: number[]): void
121
+ }>()
122
+
123
+ const { $formattedDate, $formattedTime, $isDate, $getUnixByDate } = useNuxtApp()
124
+
125
+ const localization = computed<UI_I_Localization>(() => useLocal())
126
+
127
+ const titleIntervalModal = ref<string>(
128
+ `${localization.value.common.timeRange}:`
129
+ )
130
+
131
+ const selectedItem = ref<string>('')
132
+
133
+ const onHide = (): void => {
134
+ emits('hide')
135
+ }
136
+
137
+ const yesterday = new Date().setDate(new Date().getDate() - 1)
138
+ const dateFrom = ref<number>(yesterday)
139
+ const dateTo = ref<number>(new Date().getTime())
140
+
141
+ const currentDateFrom = ref<string>('')
142
+ const currentDateTo = ref<string>('')
143
+ const currentTimeFrom = ref<string>('')
144
+ const currentTimeTo = ref<string>('')
145
+
146
+ const getCurrentTime = (): void => {
147
+ if (!props.selectedPeriods.length) {
148
+ currentDateFrom.value = $formattedDate(yesterday, props.formatDate)
149
+ currentDateTo.value = $formattedDate(new Date(), props.formatDate)
150
+
151
+ const currentTime = format(new Date(), 'H:mm:ss')
152
+ currentTimeFrom.value = currentTime
153
+ currentTimeTo.value = currentTime
154
+
155
+ return
156
+ }
157
+
158
+ currentDateFrom.value = $formattedDate(
159
+ props.selectedPeriods[0],
160
+ props.formatDate
161
+ )
162
+ currentDateTo.value = $formattedDate(
163
+ props.selectedPeriods[1],
164
+ props.formatDate
165
+ )
166
+ currentTimeFrom.value = $formattedTime(props.selectedPeriods[0], '', true)
167
+ currentTimeTo.value = $formattedTime(props.selectedPeriods[1], '', true)
168
+ }
169
+
170
+ const onUpdateDateFrom = (val: number): void => {
171
+ if (!val) return
172
+
173
+ currentDateFrom.value = $formattedDate(new Date(val), props.formatDate)
174
+ }
175
+ watch(currentDateFrom, (newValue) => {
176
+ if (!newValue) return
177
+
178
+ if ($isDate(newValue)) dateFrom.value = $getUnixByDate(newValue)
179
+ })
180
+
181
+ const onUpdateDateTo = (val: number): void => {
182
+ if (!val) return
183
+
184
+ currentDateTo.value = $formattedDate(new Date(val), props.formatDate)
185
+ }
186
+ watch(currentDateTo, (newValue) => {
187
+ if (!newValue) return
188
+
189
+ if ($isDate(newValue)) dateTo.value = $getUnixByDate(newValue)
190
+ })
191
+
192
+ const alertShow = ref<boolean>(false)
193
+ const alertItems = ref<string[]>([])
194
+
195
+ const onSubmit = (): void => {
196
+ alertItems.value = []
197
+ alertShow.value = false
198
+
199
+ if (!dateFrom.value || !dateTo.value) return
200
+
201
+ const result = checkDateFunc(
202
+ localization.value,
203
+ currentDateFrom.value,
204
+ currentDateTo.value,
205
+ currentTimeFrom.value,
206
+ currentTimeTo.value
207
+ )
208
+
209
+ if (typeof result === 'string') {
210
+ alertShow.value = true
211
+ alertItems.value.push(result)
212
+ return
213
+ }
214
+
215
+ emits('submit', [result[0], result[1]])
216
+ onHide()
217
+ }
218
+
219
+ onMounted(() => {
220
+ selectedItem.value = location.hostname
221
+ getCurrentTime()
222
+ })
223
+ </script>
224
+
225
+ <style scoped lang="scss">
226
+ .input-row-container {
227
+ padding-left: 5px;
228
+
229
+ .custom-time-input {
230
+ max-width: 120px;
231
+ margin-right: 15px;
232
+ }
233
+ }
234
+ .text-format-date {
235
+ display: inline-block;
236
+ margin-top: 5px;
237
+ }
238
+ </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.184",
4
+ "version": "1.4.185",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",