bfg-common 1.4.321 → 1.4.323

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.
@@ -13,7 +13,7 @@
13
13
  v-model="form"
14
14
  :hostname="props.hostname"
15
15
  :project="props.project"
16
- @apply="onChangePassword"
16
+ @change-password="onChangePassword"
17
17
  @hide="onHideModal"
18
18
  />
19
19
  </template>
@@ -46,12 +46,6 @@ const form = ref<UI_I_ChangePasswordForm>({
46
46
  const onChangePassword = async (): Promise<void> => {
47
47
  const { current_password, new_password } = form.value
48
48
 
49
-
50
- console.log(33333333);
51
- const asd = true
52
- if(asd) {
53
- return
54
- }
55
49
  onHideModal()
56
50
 
57
51
  const sendData: UI_I_ChangePasswordBodyRequest = {
@@ -1,7 +1,8 @@
1
1
  <template>
2
2
  <ui-modal
3
- test-id="change-password-modal"
3
+ show
4
4
  width="560px"
5
+ test-id="change-password-modal"
5
6
  :title="localization.common.changePassword"
6
7
  :subtitle="props.subtitle"
7
8
  class="change-password"
@@ -87,10 +87,9 @@
87
87
 
88
88
  <script setup lang="ts">
89
89
  import type { UI_I_Localization } from '~/lib/models/interfaces'
90
- import type { API_UI_I_Error } from '~/lib/models/store/interfaces'
91
90
  import type {
92
- UI_I_ChangePasswordBodyRequest,
93
91
  UI_I_FormChangePassword,
92
+ UI_I_ChangePasswordForm,
94
93
  } from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces'
95
94
  import type { UI_T_Project } from '~/lib/models/types'
96
95
  import { defaultFormFunc } from '~/components/common/layout/theHeader/userMenu/modals/changePassword/lib/config/form'
@@ -101,10 +100,12 @@ const props = defineProps<{
101
100
  }>()
102
101
  const emits = defineEmits<{
103
102
  (event: 'hide'): void
103
+ (event: 'change-password'): void
104
104
  }>()
105
+ const modelLocal = defineModel<UI_I_ChangePasswordForm>({ required: true })
105
106
 
106
107
  const localization = computed<UI_I_Localization>(() => useLocal())
107
- const { $store, $validation }: any = useNuxtApp()
108
+ const { $validation }: any = useNuxtApp()
108
109
  const validation = $validation.call({})
109
110
 
110
111
  const isValid = ref<boolean>(false)
@@ -141,40 +142,9 @@ const onChangePassword = async (): Promise<void> => {
141
142
  return
142
143
  }
143
144
 
144
- onHideModal()
145
-
146
- const sendData: UI_I_ChangePasswordBodyRequest = {
147
- current_password: password.value,
148
- new_password: newPassword.value,
149
- }
150
-
151
- let url = ''
152
- if (props.project === 'sphere') {
153
- const { id } = useLocalStorage('userData')
154
-
155
- url = `ui/users/${id}/passwd`
156
- } else if (props.project === 'procurator') {
157
- url = '/ui/passwd'
158
- }
159
-
160
- const { error } = await useMyFetch<never, API_UI_I_Error>(url, {
161
- method: 'POST',
162
- body: sendData,
163
- key: Date.now().toString(),
164
- })
165
-
166
- if (error.value?.data && error.value.data.error_code !== 0) {
167
- $store.dispatch('main/A_SHOW_NOTIFICATION', {
168
- status: 'error',
169
- headline: localization.value.common.operationFailed,
170
- messages: [
171
- {
172
- title: 'Error',
173
- descriptions: [error.value.data.error_message],
174
- },
175
- ],
176
- })
177
- }
145
+ modelLocal.value.current_password = password.value
146
+ modelLocal.value.new_password = newPassword.value
147
+ emits('change-password')
178
148
  }
179
149
 
180
150
  const showValidationErrors = (text: string): void => {
@@ -152,11 +152,11 @@ export const metricsFunc = (
152
152
  value: 'memory',
153
153
  testId: 'metric-item-memory-button',
154
154
  },
155
- {
156
- text: localization.common.datastore,
157
- value: 'datastore',
158
- testId: 'metric-item-datastore-button',
159
- },
155
+ // {
156
+ // text: localization.common.datastore,
157
+ // value: 'datastore',
158
+ // testId: 'metric-item-datastore-button',
159
+ // },
160
160
  // {
161
161
  // text: localization.common.power,
162
162
  // value: 'power',
@@ -62,6 +62,8 @@ watch(
62
62
  ([newValue1, newValue2]: [string, 'never' | 'on']) => {
63
63
  modelFrequencyLocal.value.isValid =
64
64
  newValue2 === 'never' ? false : !!newValue1
65
+
66
+ newValue2 === 'never' && (modelFrequencyLocal.value.frg_end_time = '')
65
67
  }
66
68
  )
67
69
  </script>
@@ -62,7 +62,8 @@ const getCorrectRuForm = (value: number | string, type: string): string => {
62
62
  export const validateField = (
63
63
  localization: UI_I_Localization,
64
64
  value: string,
65
- checkZero: boolean = false
65
+ checkZero: boolean = false,
66
+ checkDayRange: boolean = false // параметр для проверки диапазона дней
66
67
  ): string => {
67
68
  // Если поле пустое
68
69
  if (!value) {
@@ -74,7 +75,7 @@ export const validateField = (
74
75
  return localization.common.theValueTooSmall
75
76
  }
76
77
 
77
- if (value.length > 3) {
78
+ if (value.length > 3 ) {
78
79
  return localization.common.theValueTooLarge
79
80
  }
80
81
  // Если значение не является цифрой
@@ -82,6 +83,10 @@ export const validateField = (
82
83
  return localization.common.inputContainsInvalidCharacters
83
84
  }
84
85
 
86
+ if (checkDayRange && !/^([1-9]|[1-2][0-9]|3[0-1])$/.test(value)) {
87
+ return localization.common.theValueTooLarge
88
+ }
89
+
85
90
  return ''
86
91
  }
87
92
  export const validateDate = (
@@ -9,11 +9,11 @@
9
9
  v-model="model"
10
10
  />
11
11
 
12
- <div v-if="props.type === 'month'" class="">
12
+ <div v-if="props.type === 'month'">
13
13
  <div class="on-time__radio radio">
14
14
  <input
15
15
  id="on-time-monthly-by-day"
16
- v-model="selectedTimeMode"
16
+ v-model="model.frg_monthly_mode"
17
17
  data-id="on-time-monthly-by-day"
18
18
  type="radio"
19
19
  value="day"
@@ -49,7 +49,7 @@
49
49
  <div class="on-time__radio radio">
50
50
  <input
51
51
  id="on-time-monthly-by-week"
52
- v-model="selectedTimeMode"
52
+ v-model="model.frg_monthly_mode"
53
53
  data-id="on-time-monthly-by-week"
54
54
  type="radio"
55
55
  value="week"
@@ -115,8 +115,6 @@ const model = defineModel<UI_I_ScheduleNewTasksForm>({ required: true })
115
115
 
116
116
  const localization = computed<UI_I_Localization>(() => useLocal())
117
117
 
118
- const selectedTimeMode = ref<'day' | 'week'>('day')
119
-
120
118
  const frequencyOnWeeksDays = computed<UI_I_SelectInputItem[]>(() => {
121
119
  return frequencyOnWeeksDaysFunc(localization.value)
122
120
  })
@@ -125,7 +123,7 @@ const frequencyOnOrdinalNumber = computed<UI_I_SelectInputItem[]>(() => {
125
123
  })
126
124
 
127
125
  const isDisabledMonthlyDayField = computed<boolean>(
128
- () => selectedTimeMode.value === 'week'
126
+ () => model.value.frg_monthly_mode === 'week'
129
127
  )
130
128
 
131
129
  const isInitTimeIntervalValidation = ref<boolean>(false)
@@ -136,7 +134,12 @@ const schedulerOnDayErrorText = computed<string>(() => {
136
134
  if (!isInitTimeIntervalValidation.value || isDisabledMonthlyDayField.value)
137
135
  return ''
138
136
 
139
- return validateField(localization.value, model.value.frg_monthly_day, true)
137
+ return validateField(
138
+ localization.value,
139
+ model.value.frg_monthly_day,
140
+ true,
141
+ true
142
+ )
140
143
  })
141
144
  watch(
142
145
  schedulerOnDayErrorText,
@@ -7,31 +7,31 @@ export const frequencyOnWeeksDaysFunc = (
7
7
  return [
8
8
  {
9
9
  label: localization.common.sunday,
10
- value: 'sunday',
10
+ value: 6,
11
11
  },
12
12
  {
13
13
  label: localization.common.monday,
14
- value: 'monday',
14
+ value: 1,
15
15
  },
16
16
  {
17
17
  label: localization.common.tuesday,
18
- value: 'tuesday',
18
+ value: 2,
19
19
  },
20
20
  {
21
21
  label: localization.common.wednesday,
22
- value: 'wednesday',
22
+ value: 3,
23
23
  },
24
24
  {
25
25
  label: localization.common.thursday,
26
- value: 'thursday',
26
+ value: 4,
27
27
  },
28
28
  {
29
29
  label: localization.common.friday,
30
- value: 'friday',
30
+ value: 5,
31
31
  },
32
32
  {
33
33
  label: localization.common.saturday,
34
- value: 'saturday',
34
+ value: 0,
35
35
  },
36
36
  ]
37
37
  }
@@ -42,23 +42,23 @@ export const frequencyOnOrdinalNumberFunc = (
42
42
  return [
43
43
  {
44
44
  label: localization.scheduledTasks.first,
45
- value: '',
45
+ value: 1,
46
46
  },
47
47
  {
48
48
  label: localization.scheduledTasks.second,
49
- value: 'once',
49
+ value: 2,
50
50
  },
51
51
  {
52
52
  label: localization.scheduledTasks.third,
53
- value: 'after-startup',
53
+ value: 3,
54
54
  },
55
55
  {
56
56
  label: localization.scheduledTasks.fourth,
57
- value: 'hour',
57
+ value: 4,
58
58
  },
59
59
  {
60
60
  label: localization.common.last,
61
- value: 'day',
61
+ value: 5,
62
62
  },
63
63
  ]
64
64
  }
@@ -101,6 +101,7 @@ import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/
101
101
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
102
102
  import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/models/interfaces'
103
103
  import type { UI_T_FrequencyType } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/models/types'
104
+ import * as cron from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/utils'
104
105
  import { frequencyMethodFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/config/frequencyOptions'
105
106
 
106
107
  const props = defineProps<{
@@ -133,57 +134,6 @@ watch(
133
134
  },
134
135
  { deep: true }
135
136
  )
136
- /* TODO рефакторинг все методы надо рефакторить */
137
- const generateOnceCronExpression = (date: Date): any => {
138
- if (!date) return
139
-
140
- const minutes = date.getMinutes()
141
- const hours = date.getHours()
142
- const day = date.getDate()
143
- const month = date.getMonth() + 1 // В cron месяцы начинаются с 1 (январь = 1)
144
- const dayOfWeek = '*' // Для одноразовой задачи день недели неважен
145
-
146
- // Генерируем cron-выражение
147
- return `${minutes} ${hours} ${day} ${month} ${dayOfWeek} once`
148
- }
149
- const generateHourlyCronExpression = (delay: string, date: Date): any => {
150
- if (!date) return
151
-
152
- const minutes = date.getMinutes()
153
- const hours = date.getHours()
154
-
155
- // Генерируем cron-выражение
156
- return `${minutes} ${hours}/${delay} * * *`
157
- }
158
- const generateDaylyCronExpression = (delay: string, date: Date): string => {
159
- if (!date) return
160
-
161
- const minutes = date.getMinutes()
162
- const hours = date.getHours()
163
- const day = date.getDate()
164
-
165
- // Генерируем cron-выражение
166
- return `${minutes} ${hours} ${day}/${delay} * *`
167
- }
168
- const generateWeeklyCronExpression = (
169
- data: UI_I_ScheduleNewTasksForm
170
- ): string => {
171
- const { frg_on_week_days } = data
172
-
173
- // Генерируем cron-выражение
174
- return `* * * * ${frg_on_week_days.join(',')}`
175
- }
176
- const generateMonthlyCronExpression = (delay: string, date: Date): string => {
177
- if (!date) return
178
-
179
- const minutes = date.getMinutes()
180
- const hours = date.getHours()
181
- const day = date.getDate()
182
- const month = date.getMonth() + 1
183
-
184
- // Генерируем cron-выражение
185
- return `${minutes} ${hours} ${day} ${month}/${delay} *`
186
- }
187
137
 
188
138
  const generateCronExpression = (
189
139
  runType: UI_T_FrequencyType,
@@ -194,40 +144,27 @@ const generateCronExpression = (
194
144
  // Генерируем cron-выражение на основе runType
195
145
  switch (runType) {
196
146
  case 'once':
197
- cronExpression = generateOnceCronExpression(
198
- new Date(interval.frg_on_time)
147
+ const timestamp = Math.floor(
148
+ new Date(interval.frg_on_time).getTime() / 1000
199
149
  )
150
+ cronExpression = `* * * * * ${timestamp}:0-0-0-0:once`
200
151
  break
201
152
  case 'after-startup':
202
- const delay =
203
- interval.frg_after_startup === 0
204
- ? '*'
205
- : `*/${interval.frg_after_startup}`
206
- cronExpression = `${delay} * * * * after_procurator_startup` // Выполняется каждые N минут после запуска procurator_startup
153
+ const suffixDelay =
154
+ interval.frg_after_startup === 0 ? '' : `-${interval.frg_after_startup}`
155
+ cronExpression = `* * * * * after_procurator_startup${suffixDelay}` // Выполняется после запуска procurator_startup с задержой N минут
207
156
  break
208
157
  case 'hour':
209
- const hourlyDelay = interval.frg_interval
210
- cronExpression = generateHourlyCronExpression(
211
- hourlyDelay,
212
- new Date(interval.frg_start_on_time)
213
- )
158
+ cronExpression = cron.generateHourlyCronExpression(interval)
214
159
  break
215
160
  case 'day':
216
- const dayDelay = interval.frg_interval
217
- cronExpression = generateDaylyCronExpression(
218
- dayDelay,
219
- new Date(interval.frg_start_on_time)
220
- )
161
+ cronExpression = cron.generateDailyCronExpression(interval)
221
162
  break
222
163
  case 'week':
223
- cronExpression = generateWeeklyCronExpression(interval)
164
+ cronExpression = cron.generateWeeklyCronExpression(interval)
224
165
  break
225
166
  case 'month':
226
- const monthDelay = interval.frg_interval
227
- cronExpression = generateMonthlyCronExpression(
228
- monthDelay,
229
- new Date(interval.frg_start_on_time)
230
- )
167
+ cronExpression = cron.generateMonthlyCronExpression(interval)
231
168
  break
232
169
  default:
233
170
  cronExpression = '* * * * *'
@@ -0,0 +1,67 @@
1
+ import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
2
+
3
+ export const generateHourlyCronExpression = (
4
+ data: UI_I_ScheduleNewTasksForm
5
+ ): string => {
6
+ const startTimestamp = Math.floor(
7
+ new Date(data.frg_start_on_time).getTime() / 1000
8
+ )
9
+ const endTimestamp = Math.floor(new Date(data.frg_end_time).getTime() / 1000)
10
+
11
+ // Генерируем cron-выражение
12
+ return endTimestamp
13
+ ? `* * * * * ${startTimestamp}-${endTimestamp}:${data.frg_interval}-0-0-0`
14
+ : `* * * * * ${startTimestamp}:${data.frg_interval}-0-0-0`
15
+ }
16
+ export const generateWeeklyCronExpression = (
17
+ data: UI_I_ScheduleNewTasksForm
18
+ ): string => {
19
+ const { frg_on_week_days } = data
20
+
21
+ const startTimestamp = Math.floor(
22
+ new Date(data.frg_start_on_time).getTime() / 1000
23
+ )
24
+ const endTimestamp = Math.floor(new Date(data.frg_end_time).getTime() / 1000)
25
+ const daysOfWeek = frg_on_week_days.join(',')
26
+
27
+ return endTimestamp
28
+ ? `* * * * ${daysOfWeek} ${startTimestamp}-${endTimestamp}:0-0-0-${data.frg_interval}`
29
+ : `* * * * ${daysOfWeek} ${startTimestamp}:0-0-0-${data.frg_interval}`
30
+ }
31
+
32
+ export const generateDailyCronExpression = (
33
+ data: UI_I_ScheduleNewTasksForm
34
+ ): string => {
35
+ const startTimestamp = Math.floor(
36
+ new Date(data.frg_start_on_time).getTime() / 1000
37
+ )
38
+ const endTimestamp = Math.floor(new Date(data.frg_end_time).getTime() / 1000)
39
+
40
+ // Генерируем cron-выражение
41
+ return endTimestamp
42
+ ? `* * * * * ${startTimestamp}-${endTimestamp}:0-${data.frg_interval}-0-0`
43
+ : `* * * * * ${startTimestamp}:0-${data.frg_interval}-0-0`
44
+ }
45
+
46
+ export const generateMonthlyCronExpression = (
47
+ data: UI_I_ScheduleNewTasksForm
48
+ ): string => {
49
+ const { frg_interval, frg_monthly_day, frq_week_day, frq_ordinal_number } =
50
+ data
51
+
52
+ const startTimestamp = Math.floor(
53
+ new Date(data.frg_start_on_time).getTime() / 1000
54
+ )
55
+ const endTimestamp = Math.floor(new Date(data.frg_end_time).getTime() / 1000)
56
+
57
+ const daysOfWeek = `${frq_week_day}#${frq_ordinal_number}`
58
+
59
+ const timestamp = endTimestamp
60
+ ? `${startTimestamp}-${endTimestamp}`
61
+ : startTimestamp
62
+
63
+ // Генерируем cron-выражение
64
+ return data.frg_monthly_mode === 'week'
65
+ ? `* * * * * ${timestamp}:0-0-${frg_interval}-${daysOfWeek}`
66
+ : `* * ${frg_monthly_day} */${frg_interval} * ${timestamp}:0-0-0-0`
67
+ }
@@ -11,12 +11,13 @@ export const scheduledTaskDefaultFormFunc = (): UI_I_ScheduleNewTasksForm => {
11
11
  frequency: '',
12
12
  frg_after_startup: 0,
13
13
  frg_interval: 1,
14
- frg_end_time: null,
15
- frg_start_on_time: null,
16
- frg_monthly_day: 0,
14
+ frg_end_time: '',
15
+ frg_start_on_time: '',
16
+ frg_monthly_mode: 'day',
17
+ frg_monthly_day: 1,
17
18
  frq_week_day: '',
18
19
  frq_ordinal_number: '',
19
- frg_on_time: null,
20
+ frg_on_time: '',
20
21
  frg_on_week_days: [],
21
22
  }
22
23
  }
@@ -9,12 +9,13 @@ export interface UI_I_ScheduleNewTasksForm {
9
9
  toggle: boolean
10
10
  frg_after_startup: number
11
11
  frg_interval: number
12
- frg_end_time: number | null
13
- frg_start_on_time: number | null
12
+ frg_end_time: string
13
+ frg_start_on_time: string
14
+ frg_monthly_mode: 'day' | 'week'
14
15
  frg_monthly_day: number
15
16
  frq_ordinal_number: string
16
17
  frq_week_day: UI_T_FrequencyWeeksDays
17
- frg_on_time: number | null
18
+ frg_on_time: string
18
19
  frg_on_week_days: number[]
19
20
  cron: string
20
21
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.321",
4
+ "version": "1.4.323",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",