bfg-common 1.4.188 → 1.4.189

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.
@@ -165,7 +165,9 @@ import type { UI_I_Items } from '~/components/atoms/datepicker/lib/models/interf
165
165
  import {
166
166
  getMonthsFunc,
167
167
  getWeekdaysFunc,
168
- } from '~/components/atoms/datepicker/lib/config/datapicker'
168
+ datepickerWidth,
169
+ datepickerHeight,
170
+ } from '~/components/atoms/datepicker/lib/config/datepicker'
169
171
  import { getShortMonths } from '~/components/atoms/datepicker/lib/config/allShortMonths'
170
172
 
171
173
  const { $isDate } = useNuxtApp()
@@ -392,8 +394,15 @@ const showHideCalendar = (): void => {
392
394
  `.calendar-id-${uniqueId.value}`
393
395
  ) as HTMLElement
394
396
 
395
- calendarTop.value = element.getBoundingClientRect().y - 314 + 2
396
- calendarLeft.value = element.getBoundingClientRect().x - 278 / 2
397
+ const elementSizes = element.getBoundingClientRect()
398
+
399
+ const isOverTop = elementSizes.y - datepickerWidth + 2 < 0
400
+ // Set content top
401
+ if (!isOverTop) calendarTop.value = elementSizes.y - datepickerWidth + 2
402
+ else calendarTop.value = elementSizes.y + elementSizes.height + 2
403
+
404
+ // Set content left
405
+ calendarLeft.value = elementSizes.x - datepickerHeight / 2
397
406
 
398
407
  isShowCalendar.value = !isShowCalendar.value
399
408
  }
@@ -1,4 +1,4 @@
1
- import type{ UI_I_Localization } from '~/lib/models/interfaces'
1
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
2
2
 
3
3
  export const getMonthsFunc = (localization: UI_I_Localization): string[] => {
4
4
  return [
@@ -41,3 +41,6 @@ export const getWeekdaysFunc = (
41
41
 
42
42
  return result
43
43
  }
44
+
45
+ export const datepickerWidth = 314
46
+ export const datepickerHeight = 278
@@ -70,6 +70,7 @@
70
70
  import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
71
71
  import type { UI_T_Project } from '~/lib/models/types'
72
72
  import type { UI_T_TimeValue } from '~/components/common/layout/theHeader/userMenu/modals/preferences/timeFormat/lib/models/types'
73
+ import { checkIsTokenExpired } from '~/lib/utils/token'
73
74
 
74
75
  const props = defineProps<{
75
76
  isShowMainMenu: boolean
@@ -90,6 +91,8 @@ const props = defineProps<{
90
91
  newViewLocal: boolean
91
92
  timeFormat: string
92
93
  isDarkTheme: boolean
94
+ isPauseReconnect: boolean
95
+ expireTimeFromState: number
93
96
  }>()
94
97
 
95
98
  const emits = defineEmits<{
@@ -106,7 +109,55 @@ const emits = defineEmits<{
106
109
  (event: 'update-remote-console', value: string): void
107
110
  (event: 'update-vm-clusters', value: boolean): void
108
111
  (event: 'submit-preferences'): void
112
+ (event: 'show-redirect-login-modal', value: boolean): void
113
+ (event: 'show-reconnect-modal', value: boolean): void
109
114
  }>()
115
+
116
+ const inactivityTimer = ref<NodeJS.Timeout | undefined>(undefined)
117
+ const inactivityTimeout = ref<number>(20 * 60 * 1000)
118
+
119
+ const startInactivityTimer = (): void => {
120
+ inactivityTimer.value = setTimeout(() => {
121
+ // Проверяем если isPauseReconnect истина то не показываем модальное окно переподключения,
122
+ // к примеру если загружаем файл и он загружается дольше чем срабатывает таймаут
123
+ if (props.isPauseReconnect) {
124
+ startInactivityTimer()
125
+ return
126
+ }
127
+
128
+ const expireTime =
129
+ props.expireTimeFromState || useLocalStorage('accessTokenExpiredTime')
130
+
131
+ const isExpiredToken = checkIsTokenExpired(expireTime)
132
+
133
+ isExpiredToken && emits('show-redirect-login-modal', true)
134
+
135
+ if (!isExpiredToken) {
136
+ emits('show-reconnect-modal', true)
137
+ startInactivityTimer()
138
+ }
139
+
140
+ console.log('Пользователь бездействует!')
141
+ }, inactivityTimeout.value)
142
+ }
143
+
144
+ const resetInactivityTimer = (): void => {
145
+ // Сброс таймера бездействия при каждом действии пользователя
146
+ inactivityTimer.value !== null && clearTimeout(inactivityTimer.value)
147
+ startInactivityTimer()
148
+ }
149
+
150
+ onMounted(() => {
151
+ document.addEventListener('mousemove', resetInactivityTimer)
152
+
153
+ startInactivityTimer()
154
+ })
155
+
156
+ onBeforeUnmount(() => {
157
+ document.removeEventListener('mousemove', resetInactivityTimer)
158
+
159
+ inactivityTimer.value !== null && clearTimeout(inactivityTimer.value)
160
+ })
110
161
  </script>
111
162
 
112
163
  <style scoped lang="scss"></style>
@@ -54,6 +54,7 @@
54
54
  v-if="isShowIntervalModal"
55
55
  :selected-periods="props.selectedPeriods"
56
56
  :format-date="props.formatDate"
57
+ :current-lang="props.currentLang"
57
58
  @hide="onHideIntervalModal"
58
59
  @submit="onSubmitIntervalModal"
59
60
  />
@@ -82,6 +83,7 @@ const props = defineProps<{
82
83
  selectedPeriods: number[]
83
84
  formatDate: string
84
85
  project: UI_T_Project
86
+ currentLang: string
85
87
  formatTime?: string
86
88
  }>()
87
89
 
@@ -40,7 +40,7 @@
40
40
  <div class="section-datepicker">
41
41
  <atoms-datepicker
42
42
  v-model="dateFrom"
43
- :lang="currentLang"
43
+ :lang="props.currentLang"
44
44
  class="chart-option-setting-row custom-time-input"
45
45
  test-id="overview-first-date-datepicker"
46
46
  @update="onUpdateDateFrom"
@@ -76,7 +76,7 @@
76
76
  <div class="section-datepicker">
77
77
  <atoms-datepicker
78
78
  v-model="dateTo"
79
- :lang="currentLang"
79
+ :lang="props.currentLang"
80
80
  class="chart-option-setting-row custom-time-input"
81
81
  test-id="overview-first-date-to-datepicker"
82
82
  @update="onUpdateDateTo"
@@ -112,6 +112,7 @@ import { checkDateFunc } from '~/components/common/monitor/overview/filters/cust
112
112
  const props = defineProps<{
113
113
  formatDate: string
114
114
  selectedPeriods: number[]
115
+ currentLang: string
115
116
  }>()
116
117
 
117
118
  const emits = defineEmits<{
@@ -119,12 +120,13 @@ const emits = defineEmits<{
119
120
  (event: 'submit', value: number[]): void
120
121
  }>()
121
122
 
122
- const { $store, $formattedDate, $formattedTime, $isDate, $getUnixByDate } =
123
- useNuxtApp()
123
+ const { $formattedDate, $formattedTime, $isDate, $getUnixByDate } = useNuxtApp()
124
124
 
125
125
  const localization = computed<UI_I_Localization>(() => useLocal())
126
126
 
127
- const titleIntervalModal = ref<string>(`${localization.value.common.timeRange}:`)
127
+ const titleIntervalModal = ref<string>(
128
+ `${localization.value.common.timeRange}:`
129
+ )
128
130
 
129
131
  const selectedItem = ref<string>('')
130
132
 
@@ -165,15 +167,6 @@ const getCurrentTime = (): void => {
165
167
  currentTimeTo.value = $formattedTime(props.selectedPeriods[1], '', true)
166
168
  }
167
169
 
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
170
  const onUpdateDateFrom = (val: number): void => {
178
171
  if (!val) return
179
172
 
@@ -0,0 +1,34 @@
1
+ // import type { API_I_Login } from '~/store/modules/auth/lib/models/interfaces'
2
+ //
3
+ // export const setTokensFunc = (data: API_I_Login): void => {
4
+ // const token = data.access_token || ''
5
+ // const expiredTime = data.at_expires || null
6
+ //
7
+ // useLocalStorage('accessTokenExpiredTime', expiredTime)
8
+ //
9
+ // const tokenCookie = useCookie('pnc-ui-token')
10
+ // tokenCookie.value = `Bearer ${token}`
11
+ //
12
+ // const refreshToken = data.refresh_token || ''
13
+ // const refreshTokenCookie = useCookie('pnc-ui-refresh-token')
14
+ // refreshTokenCookie.value = refreshToken
15
+ //
16
+ // const accessTokenExpiredTime = useCookie('token-expired-time')
17
+ // accessTokenExpiredTime.value = '' + expiredTime
18
+ // }
19
+
20
+ export const checkIsTokenExpired = (expireTime: number): boolean => {
21
+ const currentTimeMilliseconds = new Date().getTime()
22
+ const expireTimeMilliseconds = expireTime * 1000
23
+
24
+ return expireTimeMilliseconds < currentTimeMilliseconds
25
+ }
26
+ // export const clearToken = (): void => {
27
+ // const tokenCookie = useCookie('pnc-ui-token')
28
+ // const refreshTokenCookie = useCookie('pnc-ui-refresh-token')
29
+ // const expiredTime = useCookie('token-expired-time')
30
+ //
31
+ // tokenCookie.value = ''
32
+ // refreshTokenCookie.value = ''
33
+ // expiredTime.value = ''
34
+ // }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.188",
4
+ "version": "1.4.189",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",