bfg-common 1.4.884 → 1.4.885

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,175 +1,173 @@
1
- <template>
2
- <div>
3
- <common-monitor-overview-filters-custom-interval-modal-new
4
- v-if="isNewView"
5
- v-model:alert-show="alertShow"
6
- v-model:current-date-from="currentDateFrom"
7
- v-model:date-from="dateFrom"
8
- v-model:current-time-from="currentTimeFrom"
9
- v-model:current-date-to="currentDateTo"
10
- v-model:date-to="dateTo"
11
- v-model:current-time-to="currentTimeTo"
12
- :title-interval-modal="titleIntervalModal"
13
- :selected-item-name="selectedItemName"
14
- :current-lang="currentLang"
15
- :alert-items="alertItems"
16
- :format-date="props.formatDate"
17
- @update-date-from="onUpdateDateFrom"
18
- @update-date-to="onUpdateDateTo"
19
- @submit="onSubmit"
20
- @hide="onHide"
21
- />
22
- <common-monitor-overview-filters-custom-interval-modal-old
23
- v-else
24
- v-model:alert-show="alertShow"
25
- v-model:current-date-from="currentDateFrom"
26
- v-model:date-from="dateFrom"
27
- v-model:current-time-from="currentTimeFrom"
28
- v-model:current-date-to="currentDateTo"
29
- v-model:date-to="dateTo"
30
- v-model:current-time-to="currentTimeTo"
31
- :title-interval-modal="titleIntervalModal"
32
- :selected-item-name="selectedItemName"
33
- :current-lang="currentLang"
34
- :alert-items="alertItems"
35
- @update-date-from="onUpdateDateFrom"
36
- @update-date-to="onUpdateDateTo"
37
- @submit="onSubmit"
38
- @hide="onHide"
39
- />
40
- </div>
41
- </template>
42
-
43
- <script setup lang="ts">
44
- import { format } from 'date-fns'
45
- import type { UI_I_Localization } from '~/lib/models/interfaces'
46
- import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
47
-
48
- const props = defineProps<{
49
- formatDate: string
50
- selectedPeriods: number[]
51
- currentLang: string
52
- validDateEnd: number
53
- }>()
54
-
55
- const emits = defineEmits<{
56
- (event: 'hide'): void
57
- (event: 'submit', value: number[]): void
58
- }>()
59
-
60
- const { $store, $formattedDate, $formattedTime, $isDate, $getUnixByDate } =
61
- useNuxtApp()
62
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
63
-
64
- const localization = computed<UI_I_Localization>(() => useLocal())
65
-
66
- const titleIntervalModal = ref<string>(
67
- `${localization.value.common.timeRange}:`
68
- )
69
-
70
- const selectedItemName = ref<string>('')
71
-
72
- const onHide = (): void => {
73
- getCurrentTime()
74
- emits('hide')
75
- }
76
-
77
- const yesterday = new Date().setDate(new Date().getDate() - 1)
78
- const dateFrom = ref<number>(yesterday)
79
- const dateTo = ref<number>(new Date().getTime())
80
-
81
- const currentDateFrom = ref<string>('')
82
- const currentDateTo = ref<string>('')
83
- const currentTimeFrom = ref<string>('')
84
- const currentTimeTo = ref<string>('')
85
-
86
- const getCurrentTime = (): void => {
87
- if (!props.selectedPeriods.length) {
88
- currentDateFrom.value = $formattedDate(yesterday, props.formatDate)
89
- currentDateTo.value = $formattedDate(props.validDateEnd, props.formatDate)
90
-
91
- currentTimeFrom.value = format(new Date(), 'H:mm:ss')
92
- currentTimeTo.value = format(props.validDateEnd, 'H:mm:ss')
93
-
94
- return
95
- }
96
-
97
- currentDateFrom.value = $formattedDate(
98
- props.selectedPeriods[0],
99
- props.formatDate
100
- )
101
- currentDateTo.value = $formattedDate(
102
- props.selectedPeriods[1],
103
- props.formatDate
104
- )
105
- currentTimeFrom.value = $formattedTime(props.selectedPeriods[0], '', true)
106
- currentTimeTo.value = $formattedTime(props.selectedPeriods[1], '', true)
107
- }
108
-
109
- const onUpdateDateFrom = (val: number): void => {
110
- if (!val) return
111
-
112
- currentDateFrom.value = $formattedDate(new Date(val), props.formatDate)
113
- }
114
- watch(currentDateFrom, (newValue) => {
115
- if (!newValue) return
116
-
117
- if ($isDate(newValue)) dateFrom.value = $getUnixByDate(newValue)
118
- })
119
-
120
- const onUpdateDateTo = (val: number): void => {
121
- if (!val) return
122
-
123
- currentDateTo.value = $formattedDate(new Date(val), props.formatDate)
124
- }
125
- watch(currentDateTo, (newValue) => {
126
- if (!newValue) return
127
-
128
- if ($isDate(newValue)) dateTo.value = $getUnixByDate(newValue)
129
- })
130
-
131
- const alertShow = ref<boolean>(false)
132
- const alertItems = ref<string[]>([])
133
-
134
- const onSubmit = (): void => {
135
- alertItems.value = []
136
- alertShow.value = false
137
-
138
- if (!dateFrom.value || !dateTo.value) return
139
-
140
- const result = checkDateFunc(
141
- localization.value,
142
- currentDateFrom.value,
143
- currentDateTo.value,
144
- currentTimeFrom.value,
145
- currentTimeTo.value,
146
- props.validDateEnd,
147
- props.formatDate
148
- )
149
-
150
- if (typeof result === 'string') {
151
- alertShow.value = true
152
- alertItems.value.push(result)
153
- return
154
- }
155
-
156
- emits('submit', [result[0], result[1]])
157
- onHide()
158
- }
159
-
160
- watch(
161
- () => [props.selectedPeriods, props.currentLang],
162
- (): void => {
163
- getCurrentTime()
164
- },
165
- { deep: true }
166
- )
167
-
168
- onMounted(() => {
169
- selectedItemName.value = location.hostname
170
- getCurrentTime()
171
- onSubmit()
172
- })
173
- </script>
174
-
175
- <style scoped lang="scss"></style>
1
+ <template>
2
+ <div>
3
+ <common-monitor-overview-filters-custom-interval-modal-new
4
+ v-if="isNewView"
5
+ v-model:alert-show="alertShow"
6
+ v-model:current-date-from="currentDateFrom"
7
+ v-model:date-from="dateFrom"
8
+ v-model:current-time-from="currentTimeFrom"
9
+ v-model:current-date-to="currentDateTo"
10
+ v-model:date-to="dateTo"
11
+ v-model:current-time-to="currentTimeTo"
12
+ :title-interval-modal="titleIntervalModal"
13
+ :selected-node-name="props.selectedNodeName"
14
+ :current-lang="currentLang"
15
+ :alert-items="alertItems"
16
+ :format-date="props.formatDate"
17
+ @update-date-from="onUpdateDateFrom"
18
+ @update-date-to="onUpdateDateTo"
19
+ @submit="onSubmit"
20
+ @hide="onHide"
21
+ />
22
+ <common-monitor-overview-filters-custom-interval-modal-old
23
+ v-else
24
+ v-model:alert-show="alertShow"
25
+ v-model:current-date-from="currentDateFrom"
26
+ v-model:date-from="dateFrom"
27
+ v-model:current-time-from="currentTimeFrom"
28
+ v-model:current-date-to="currentDateTo"
29
+ v-model:date-to="dateTo"
30
+ v-model:current-time-to="currentTimeTo"
31
+ :title-interval-modal="titleIntervalModal"
32
+ :selected-node-name="props.selectedNodeName"
33
+ :current-lang="currentLang"
34
+ :alert-items="alertItems"
35
+ @update-date-from="onUpdateDateFrom"
36
+ @update-date-to="onUpdateDateTo"
37
+ @submit="onSubmit"
38
+ @hide="onHide"
39
+ />
40
+ </div>
41
+ </template>
42
+
43
+ <script setup lang="ts">
44
+ import { format } from 'date-fns'
45
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
46
+ import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/lib/config/dateChecker'
47
+
48
+ const props = defineProps<{
49
+ formatDate: string
50
+ selectedPeriods: number[]
51
+ currentLang: string
52
+ validDateEnd: number
53
+ selectedNodeName: string
54
+ }>()
55
+
56
+ const emits = defineEmits<{
57
+ (event: 'hide'): void
58
+ (event: 'submit', value: number[]): void
59
+ }>()
60
+
61
+ const { $store, $formattedDate, $formattedTime, $isDate, $getUnixByDate } =
62
+ useNuxtApp()
63
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
64
+
65
+ const localization = computed<UI_I_Localization>(() => useLocal())
66
+
67
+ const titleIntervalModal = ref<string>(
68
+ `${localization.value.common.timeRange}:`
69
+ )
70
+
71
+ const onHide = (): void => {
72
+ getCurrentTime()
73
+ emits('hide')
74
+ }
75
+
76
+ const yesterday = new Date().setDate(new Date().getDate() - 1)
77
+ const dateFrom = ref<number>(yesterday)
78
+ const dateTo = ref<number>(new Date().getTime())
79
+
80
+ const currentDateFrom = ref<string>('')
81
+ const currentDateTo = ref<string>('')
82
+ const currentTimeFrom = ref<string>('')
83
+ const currentTimeTo = ref<string>('')
84
+
85
+ const getCurrentTime = (): void => {
86
+ if (!props.selectedPeriods.length) {
87
+ currentDateFrom.value = $formattedDate(yesterday, props.formatDate)
88
+ currentDateTo.value = $formattedDate(props.validDateEnd, props.formatDate)
89
+
90
+ currentTimeFrom.value = format(new Date(), 'H:mm:ss')
91
+ currentTimeTo.value = format(props.validDateEnd, 'H:mm:ss')
92
+
93
+ return
94
+ }
95
+
96
+ currentDateFrom.value = $formattedDate(
97
+ props.selectedPeriods[0],
98
+ props.formatDate
99
+ )
100
+ currentDateTo.value = $formattedDate(
101
+ props.selectedPeriods[1],
102
+ props.formatDate
103
+ )
104
+ currentTimeFrom.value = $formattedTime(props.selectedPeriods[0], '', true)
105
+ currentTimeTo.value = $formattedTime(props.selectedPeriods[1], '', true)
106
+ }
107
+
108
+ const onUpdateDateFrom = (val: number): void => {
109
+ if (!val) return
110
+
111
+ currentDateFrom.value = $formattedDate(new Date(val), props.formatDate)
112
+ }
113
+ watch(currentDateFrom, (newValue) => {
114
+ if (!newValue) return
115
+
116
+ if ($isDate(newValue)) dateFrom.value = $getUnixByDate(newValue)
117
+ })
118
+
119
+ const onUpdateDateTo = (val: number): void => {
120
+ if (!val) return
121
+
122
+ currentDateTo.value = $formattedDate(new Date(val), props.formatDate)
123
+ }
124
+ watch(currentDateTo, (newValue) => {
125
+ if (!newValue) return
126
+
127
+ if ($isDate(newValue)) dateTo.value = $getUnixByDate(newValue)
128
+ })
129
+
130
+ const alertShow = ref<boolean>(false)
131
+ const alertItems = ref<string[]>([])
132
+
133
+ const onSubmit = (): void => {
134
+ alertItems.value = []
135
+ alertShow.value = false
136
+
137
+ if (!dateFrom.value || !dateTo.value) return
138
+
139
+ const result = checkDateFunc(
140
+ localization.value,
141
+ currentDateFrom.value,
142
+ currentDateTo.value,
143
+ currentTimeFrom.value,
144
+ currentTimeTo.value,
145
+ props.validDateEnd,
146
+ props.formatDate
147
+ )
148
+
149
+ if (typeof result === 'string') {
150
+ alertShow.value = true
151
+ alertItems.value.push(result)
152
+ return
153
+ }
154
+
155
+ emits('submit', [result[0], result[1]])
156
+ onHide()
157
+ }
158
+
159
+ watch(
160
+ () => [props.selectedPeriods, props.currentLang],
161
+ (): void => {
162
+ getCurrentTime()
163
+ },
164
+ { deep: true }
165
+ )
166
+
167
+ onMounted(() => {
168
+ getCurrentTime()
169
+ onSubmit()
170
+ })
171
+ </script>
172
+
173
+ <style scoped lang="scss"></style>