bfg-common 1.4.185 → 1.4.187

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,238 +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="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>
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>
@@ -34,6 +34,7 @@ export interface UI_I_Localization {
34
34
  storageDevice: UI_I_ArbitraryObject<string>
35
35
  scheduledTasks: UI_I_ArbitraryObject<string>
36
36
  license: UI_I_ArbitraryObject<string>
37
+ events: UI_I_ArbitraryObject<string>
37
38
  }
38
39
  export interface UI_I_SendTaskParams {
39
40
  method: string
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.185",
4
+ "version": "1.4.187",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",