bfg-common 1.4.322 → 1.4.324

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,110 +1,42 @@
1
1
  <template>
2
2
  <Teleport to="body">
3
- <atoms-modal
4
- width="864px"
5
- :show="true"
6
- :title="`${brandName}® ${props.projectName}`"
7
- test-id="about-modal"
8
- >
9
- <template #modalHeader>
10
- <div class="flex-align-center">
11
- <h3 class="modal-title">{{ brandName }}® {{ props.projectName }}</h3>
12
- <span class="separator" />
13
- <h4 class="secondary-title">
14
- {{ props.projectName }} Web Client, version: {{ version }}
15
- </h4>
16
- <span
17
- v-if="props.isBetaVersion"
18
- class="beta-version badge badge-info"
19
- >{{ localization.common.beta }}</span
20
- >
21
- <span v-else-if="isDev" class="beta-version badge badge-info"
22
- >Dev</span
23
- >
24
- </div>
25
- <button id="about-modal-button-close" class="close">
26
- <atoms-the-icon
27
- data-id="about-modal-button-close-icon"
28
- class="close-icon"
29
- name="close"
30
- @click="() => emits('hide')"
31
- />
32
- </button>
33
- </template>
34
-
35
- <template #modalBody>
36
- <div class="about-vsphere-dialog-legal-section">
37
- <p>{{ aboutHeadingText }}</p>
38
- <p>{{ localization.layout.aboutSubtitle }}</p>
39
- </div>
40
-
41
- <div class="about-vsphere-dialog-legal-section description">
42
- {{ aboutDesc1 }}
43
- (<a
44
- id="about-description-link"
45
- data-id="about-description-link"
46
- :href="url"
47
- target="_blank"
48
- >{{ url }}</a
49
- >){{ aboutDesc2 }}
50
- </div>
51
- </template>
52
-
53
- <template #modalFooter>
54
- <span></span>
55
- </template>
56
- </atoms-modal>
3
+ <common-layout-the-header-help-menu-about-new
4
+ v-if="isNewView"
5
+ :version="props.version"
6
+ :is-beta-version="props.isBeta"
7
+ :is-dev="props.isDev"
8
+ :project-name="props.projectName"
9
+ :url="companyWebSitePath"
10
+ @hide="emits('hide')"
11
+ />
12
+
13
+ <common-layout-the-header-help-menu-about-old
14
+ v-else
15
+ :version="props.version"
16
+ :is-beta-version="props.isBeta"
17
+ :is-dev="props.isDev"
18
+ :project-name="props.projectName"
19
+ :url="companyWebSitePath"
20
+ @hide="emits('hide')"
21
+ />
57
22
  </Teleport>
58
23
  </template>
59
24
 
60
25
  <script lang="ts" setup>
61
- import type { UI_I_Localization } from '~/lib/models/interfaces'
62
-
63
26
  const props = defineProps<{
64
27
  version: string
65
- isBetaVersion: boolean
28
+ isBeta: boolean
66
29
  isDev: boolean
67
30
  projectName: string
68
31
  }>()
69
-
70
32
  const emits = defineEmits<{
71
33
  (event: 'hide'): void
72
34
  }>()
73
35
 
74
- const config = useRuntimeConfig()
36
+ const { $store }: any = useNuxtApp()
75
37
 
76
- const brandName = computed<string>(
77
- () => config.public[`TRADEMARK_${useEnvLanguage()}`]
78
- )
79
- const companyName = computed<string>(
80
- () => config.public[`COMPANY_NAME_${useEnvLanguage()}`]
81
- )
82
- const aboutHeadingText = computed<string>(() =>
83
- localization.value.layout.aboutHeading.replaceAll('{companyName}', companyName.value)
84
- )
85
- const aboutDesc1 = computed<string>(() =>
86
- localization.value.layout.aboutDesc1
87
- .replaceAll('{companyName}', companyName.value)
88
- .replaceAll('{trademark}', brandName.value)
89
- )
90
- const aboutDesc2 = computed<string>(() =>
91
- localization.value.layout.aboutDesc2
92
- .replaceAll('{companyName}', companyName.value)
93
- .replaceAll('{trademark}', brandName.value)
94
- )
95
38
 
96
- const localization = computed<UI_I_Localization>(() => useLocal())
39
+ const companyWebSitePath = ref<string>('https://iridium-soft.com/')
97
40
 
98
- const url = ref<string>('https://iridium-soft.com/')
41
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
99
42
  </script>
100
-
101
- <style lang="scss" scoped>
102
- .modal-title {
103
- color: var(--main-color-mode);
104
- }
105
- .description {
106
- padding-top: 10px;
107
- font-size: 13px;
108
- line-height: 19px;
109
- }
110
- </style>
@@ -11,7 +11,7 @@
11
11
  <common-layout-the-header-help-menu-about
12
12
  v-if="isShowAbout"
13
13
  :version="version"
14
- :is-beta-version="isBeta"
14
+ :is-beta="isBeta"
15
15
  :is-dev="isDev"
16
16
  :project-name="props.projectName"
17
17
  @hide="isShowAbout = false"
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <ui-modal
3
+ test-id="about-modal"
4
+ width="720px"
5
+ :title="`${brandName}® ${props.projectName}`"
6
+ :subtitle="`${props.projectName} Web Client, version: ${props.version}`"
7
+ class="about-modal"
8
+ @hide="onHideModal"
9
+ >
10
+ <template #content>
11
+ <ui-modal-block-standard>
12
+ <div>
13
+ <p>{{ aboutHeadingText }}</p>
14
+
15
+ <p>{{ localization.layout.aboutSubtitle }}</p>
16
+ </div>
17
+
18
+ <div class="about-modal__description">
19
+ {{ aboutDesc1 }}
20
+
21
+ (<a
22
+ id="about-description-link"
23
+ data-id="about-description-link"
24
+ :href="url"
25
+ target="_blank"
26
+ >
27
+ {{ props.url }} </a
28
+ >)
29
+
30
+ {{ aboutDesc2 }}
31
+ </div>
32
+ </ui-modal-block-standard>
33
+ </template>
34
+ <template #footerContent><span /></template>
35
+ </ui-modal>
36
+ </template>
37
+
38
+ <script lang="ts" setup>
39
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
40
+
41
+ const props = defineProps<{
42
+ version: string
43
+ isBetaVersion: boolean
44
+ isDev: boolean
45
+ projectName: string
46
+ url: string
47
+ }>()
48
+ const emits = defineEmits<{
49
+ (event: 'hide'): void
50
+ }>()
51
+
52
+ const localization = computed<UI_I_Localization>(() => useLocal())
53
+ const config = useRuntimeConfig()
54
+
55
+ const brandName = computed<string>(
56
+ () => config.public[`TRADEMARK_${useEnvLanguage()}`]
57
+ )
58
+ const companyName = computed<string>(
59
+ () => config.public[`COMPANY_NAME_${useEnvLanguage()}`]
60
+ )
61
+
62
+ const aboutHeadingText = computed<string>(() =>
63
+ localization.value.layout.aboutHeading.replaceAll(
64
+ '{companyName}',
65
+ companyName.value
66
+ )
67
+ )
68
+
69
+ const aboutDesc1 = computed<string>(() =>
70
+ localization.value.layout.aboutDesc1
71
+ .replaceAll('{companyName}', companyName.value)
72
+ .replaceAll('{trademark}', brandName.value)
73
+ )
74
+ const aboutDesc2 = computed<string>(() =>
75
+ localization.value.layout.aboutDesc2
76
+ .replaceAll('{companyName}', companyName.value)
77
+ .replaceAll('{trademark}', brandName.value)
78
+ )
79
+
80
+ const onHideModal = (): void => {
81
+ emits('hide')
82
+ }
83
+ </script>
84
+
85
+ <style lang="scss" scoped>
86
+ .about-modal {
87
+ &__description {
88
+ }
89
+ }
90
+ </style>
@@ -0,0 +1,110 @@
1
+ <template>
2
+ <Teleport to="body">
3
+ <atoms-modal
4
+ width="864px"
5
+ :show="true"
6
+ :title="`${brandName}® ${props.projectName}`"
7
+ test-id="about-modal"
8
+ >
9
+ <template #modalHeader>
10
+ <div class="flex-align-center">
11
+ <h3 class="modal-title">{{ brandName }}® {{ props.projectName }}</h3>
12
+ <span class="separator" />
13
+ <h4 class="secondary-title">
14
+ {{ props.projectName }} Web Client, version: {{ version }}
15
+ </h4>
16
+ <span
17
+ v-if="props.isBetaVersion"
18
+ class="beta-version badge badge-info"
19
+ >{{ localization.common.beta }}</span
20
+ >
21
+ <span v-else-if="isDev" class="beta-version badge badge-info"
22
+ >Dev</span
23
+ >
24
+ </div>
25
+ <button id="about-modal-button-close" class="close">
26
+ <atoms-the-icon
27
+ data-id="about-modal-button-close-icon"
28
+ class="close-icon"
29
+ name="close"
30
+ @click="() => emits('hide')"
31
+ />
32
+ </button>
33
+ </template>
34
+
35
+ <template #modalBody>
36
+ <div class="about-vsphere-dialog-legal-section">
37
+ <p>{{ aboutHeadingText }}</p>
38
+ <p>{{ localization.layout.aboutSubtitle }}</p>
39
+ </div>
40
+
41
+ <div class="about-vsphere-dialog-legal-section description">
42
+ {{ aboutDesc1 }}
43
+ (<a
44
+ id="about-description-link"
45
+ data-id="about-description-link"
46
+ :href="url"
47
+ target="_blank"
48
+ >{{ props.url }}</a
49
+ >){{ aboutDesc2 }}
50
+ </div>
51
+ </template>
52
+
53
+ <template #modalFooter>
54
+ <span></span>
55
+ </template>
56
+ </atoms-modal>
57
+ </Teleport>
58
+ </template>
59
+
60
+ <script lang="ts" setup>
61
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
62
+
63
+ const props = defineProps<{
64
+ version: string
65
+ isBetaVersion: boolean
66
+ isDev: boolean
67
+ projectName: string
68
+ url: string
69
+ }>()
70
+ const emits = defineEmits<{
71
+ (event: 'hide'): void
72
+ }>()
73
+
74
+ const localization = computed<UI_I_Localization>(() => useLocal())
75
+ const config = useRuntimeConfig()
76
+
77
+ const brandName = computed<string>(
78
+ () => config.public[`TRADEMARK_${useEnvLanguage()}`]
79
+ )
80
+ const companyName = computed<string>(
81
+ () => config.public[`COMPANY_NAME_${useEnvLanguage()}`]
82
+ )
83
+ const aboutHeadingText = computed<string>(() =>
84
+ localization.value.layout.aboutHeading.replaceAll(
85
+ '{companyName}',
86
+ companyName.value
87
+ )
88
+ )
89
+ const aboutDesc1 = computed<string>(() =>
90
+ localization.value.layout.aboutDesc1
91
+ .replaceAll('{companyName}', companyName.value)
92
+ .replaceAll('{trademark}', brandName.value)
93
+ )
94
+ const aboutDesc2 = computed<string>(() =>
95
+ localization.value.layout.aboutDesc2
96
+ .replaceAll('{companyName}', companyName.value)
97
+ .replaceAll('{trademark}', brandName.value)
98
+ )
99
+ </script>
100
+
101
+ <style lang="scss" scoped>
102
+ .modal-title {
103
+ color: var(--main-color-mode);
104
+ }
105
+ .description {
106
+ padding-top: 10px;
107
+ font-size: 13px;
108
+ line-height: 19px;
109
+ }
110
+ </style>
@@ -14,7 +14,6 @@
14
14
  <common-layout-the-header-user-menu-modals-change-password
15
15
  v-if="isShowChangePasswordModal"
16
16
  v-model="isShowChangePasswordModal"
17
- :new-view="props.newView"
18
17
  :hostname="props.hostname"
19
18
  :project="props.project"
20
19
  />
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <common-layout-the-header-user-menu-modals-change-password-new
3
- v-if="newView"
3
+ v-if="isNewView"
4
4
  v-model="form"
5
5
  :subtitle="props.hostname"
6
6
  :project="props.project"
@@ -29,7 +29,6 @@ import type { UI_T_Project } from '~/lib/models/types'
29
29
  import {} from '#build/components/common/layout/theHeader/userMenu/modals/changePassword/lib/models/interfaces'
30
30
 
31
31
  const props = defineProps<{
32
- newView: boolean
33
32
  hostname: string
34
33
  project: UI_T_Project
35
34
  }>()
@@ -43,6 +42,8 @@ const form = ref<UI_I_ChangePasswordForm>({
43
42
  new_password: '',
44
43
  confirm_password: '',
45
44
  })
45
+
46
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
46
47
  const onChangePassword = async (): Promise<void> => {
47
48
  const { current_password, new_password } = form.value
48
49
 
@@ -32,7 +32,7 @@
32
32
  :error="passwordErrorText"
33
33
  type="password"
34
34
  :autocomplete="'new-password'"
35
- ></ui-input>
35
+ />
36
36
 
37
37
  <ui-input
38
38
  v-model="modelLocal.new_password"
@@ -40,7 +40,7 @@
40
40
  :label="localization.common.newPassword"
41
41
  :error="newPasswordErrorText"
42
42
  type="password"
43
- ></ui-input>
43
+ />
44
44
 
45
45
  <ui-input
46
46
  v-model="modelLocal.confirm_password"
@@ -48,7 +48,7 @@
48
48
  :label="localization.common.confirmPassword"
49
49
  :error="confirmPasswordErrorText"
50
50
  type="password"
51
- ></ui-input>
51
+ />
52
52
  </div>
53
53
  </ui-modal-block-standard>
54
54
  </template>
@@ -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.322",
4
+ "version": "1.4.324",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",