bfg-common 1.5.18 → 1.5.20

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.
package/CODE_STYLE.md ADDED
@@ -0,0 +1,109 @@
1
+ ![JavaScript](https://img.shields.io/badge/JavaScript-F7DF1E?style=for-the-badge&logo=javascript&logoColor=black)
2
+ ## Javascript
3
+
4
+ ### Название переменных
5
+
6
+ Используем camelCase:
7
+ ```javascript
8
+ const theExample = 0
9
+ ```
10
+
11
+ Название переменных должно быть содержательным:
12
+ ```javascript
13
+ const desc = 'some description' // Плохо
14
+
15
+ const description = 'some description' // Хорошо
16
+ ```
17
+
18
+ Если переменная типа boolean, используем префиксы is или has:
19
+ ```javascript
20
+ const isDisabled = true
21
+
22
+ const hasName = false
23
+ ```
24
+
25
+ Приоритетно используем стрелочные функции:
26
+ ```javascript
27
+ const example = () => {...}
28
+ ```
29
+
30
+ ---
31
+
32
+ ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)
33
+ ## Typescript
34
+
35
+ ### Interface
36
+ Название интерфейсов начинаем с префикса **I_** (также есть **API_**, **UI_**, подробно об этом написано в файле PROJECT_STRUCTURE.md):
37
+ ```typescript
38
+ interface I_Example
39
+ ```
40
+
41
+ ### Type
42
+ Название типов начинаем с префикса **T_**:
43
+ ```typescript
44
+ type T_Example
45
+ ```
46
+
47
+ ### Enum
48
+ Название enum начинаем с префикса **E_**:
49
+ ```typescript
50
+ enum E_Example
51
+ ```
52
+
53
+ P.S. Нужно писать как можно более понятные типы.
54
+
55
+ ---
56
+
57
+ ![Vue.js](https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge&logo=vue.js&logoColor=4FC08D)
58
+ ## Vue
59
+
60
+ ### Название тегов
61
+ Используем kebab-case:
62
+ ```html
63
+ <the-button>Button</the-button>
64
+ ```
65
+
66
+ ### Название тега
67
+ Название тега не должно состоять из одного слова:
68
+ ```html
69
+ <example></example> // Плохо
70
+
71
+ <the-example></the-example> // Хорошо
72
+ ```
73
+
74
+ ### Использование "the" в названии тега
75
+ Если название тега, к примеру, icon, должно быть так:
76
+ ```html
77
+ <the-icon></the-icon>
78
+ ```
79
+
80
+ ### Использование самозакрывающихся тегов
81
+ Если в тег ничего не передаем, то используем его как самозакрывающийся:
82
+ ```html
83
+ <the-icon/>
84
+ ```
85
+
86
+ ### Props / Emits
87
+ Props пишем в kebab-case:
88
+ ```html
89
+ <the-example my-name="Name"/>
90
+ ```
91
+
92
+ Emits пишем в kebab-case, ключ первого аргумента всегда "event", а второго - "value":
93
+ ```javascript
94
+ const emits = defineEmits<{
95
+ (event: 'change-name', value: string): void
96
+ }>()
97
+ ```
98
+
99
+ ### Composition API
100
+ Так как у нас используется Composition API, нужно весь код группировать по блокам:
101
+ ```javascript
102
+ const isShowModal = ref<boolean>(false)
103
+ const toggleModal = (): void => isShowModal.value = !isShowModal.value
104
+
105
+ const errors = ref<string[]>([])
106
+ const updateErrors = (newErrors: string[]): void => {
107
+ errors.value = newErrors
108
+ }
109
+ ```
@@ -26,8 +26,35 @@
26
26
 
27
27
  ---
28
28
 
29
- ## models
30
- Папка в которой хронятся interfaces, types и enums глобальные и к примеру те которые нельзя создавать в plugins и т.п.
29
+ ## lib
30
+ Папка содержит глобальные утилиты, конфигурации и модели:
31
+
32
+ ### config
33
+ В папке config хранятся файлы типа *.ts, в них находятся конфигурации.
34
+ Название переменных в конфигурации заканчивается на Func, если это функция.
35
+ ```typescript
36
+ const exempleFunc = (localization: UI_I_localization): I_Exemple => {...}
37
+
38
+ const steps = [0, 1, 2, 3]
39
+ ```
40
+
41
+ ### models
42
+ Содержит interfaces, types и enums, глобальные и те, которые нельзя создавать в pages, store, plugins и т.п.
43
+
44
+ ### utils
45
+ Содержит вспомогательные утилиты и функции общего назначения
46
+
47
+ Структура папки lib:
48
+ ```
49
+ lib
50
+ |-config
51
+ | |-someConfig.ts
52
+ |-models
53
+ | |-interfaces.ts
54
+ | |-types.ts
55
+ | |-enums.ts
56
+ |-utils.ts
57
+ ```
31
58
 
32
59
  ---
33
60
 
@@ -40,3 +67,64 @@
40
67
  Можно ознакомится по документации nuxt 3
41
68
 
42
69
  ---
70
+
71
+ ## store (Vuex)
72
+ Стор у нас модульный, модули создаются как минимум по роутингу.
73
+
74
+ Основная структура такая:
75
+
76
+ ```
77
+ lib
78
+ |-config
79
+ | |-someConfig.ts
80
+ |-models
81
+ | |-interfaces.ts
82
+ | |-types.ts
83
+ | |-enums.ts
84
+ |-utils.ts
85
+ mappers
86
+ |-someMapper.ts
87
+ actions.ts
88
+ getters.ts
89
+ mutations.ts
90
+ state.ts
91
+ store.ts
92
+ ```
93
+
94
+ #### lib
95
+ В папке lib находятся:
96
+ - config - конфигурации store
97
+ - models - интерфейсы и типы для store
98
+ - utils.ts - вспомогательные функции
99
+
100
+ #### mappers
101
+ В папке mappers хранятся файлы .ts формата, в которых есть функции (мапперы), обрабатывающие ответ от бэка так, чтобы было удобно использовать на фронте.
102
+
103
+ Мапперы вызываются только из файла actions.ts и после обработки через mutations.ts попадают в state.
104
+
105
+ #### actions.ts
106
+ В этом файле в основном делаются запросы на бэк и обработка данных.
107
+
108
+ #### getters.ts
109
+ В этом файле есть методы, которые возвращают данные из state.
110
+
111
+ #### mutations.ts
112
+ В этом файле изменяем/обновляем данные из state.
113
+
114
+ #### state.ts
115
+ В этом файле хранятся переменные.
116
+
117
+ #### store.ts
118
+ В этом файле все собирается воедино.
119
+
120
+ ---
121
+
122
+ ## Название папок/файлов
123
+
124
+ Название всех папок пишем в camelCase.
125
+
126
+ Название всех файлов кроме *.vue(компонент) пишем camelCase
127
+
128
+ Название всех файлов в pages *.vue (компонент) пишем в kebab-case.
129
+
130
+ Название всех файлов вне pages *.vue (компонент) пишем в PascalCase.
@@ -1,43 +1,43 @@
1
1
  <template>
2
2
  <common-chart-options-modal-counters-timespan-form-new
3
- v-if="isNewView"
4
- v-model:local-selected-timespan="localSelectedTimespan"
5
- v-model:local-period-type="localPeriodType"
6
- v-model:local-last="localLast"
7
- v-model:local-selected-custom-time="localSelectedCustomTime"
8
- v-model:local-current-date-from="localCurrentDateFrom"
9
- v-model:current-time-from="currentTimeFrom"
10
- v-model:current-time-to="currentTimeTo"
11
- v-model:current-date-to="currentDateTo"
12
- :timespan-options="timespanOptions"
13
- :custom-time-options="customTimeOptions"
14
- :language="props.language"
15
- :error-last-input="props.errorLastInput"
16
- :error-date-from="props.errorDateFrom"
17
- :error-time-from="props.errorTimeFrom"
18
- :error-date-to="props.errorDateTo"
19
- :error-time-to="props.errorTimeTo"
3
+ v-if="isNewView"
4
+ v-model:local-selected-timespan="localSelectedTimespan"
5
+ v-model:local-period-type="localPeriodType"
6
+ v-model:local-last="localLast"
7
+ v-model:local-selected-custom-time="localSelectedCustomTime"
8
+ v-model:local-current-date-from="localCurrentDateFrom"
9
+ v-model:current-time-from="currentTimeFrom"
10
+ v-model:current-time-to="currentTimeTo"
11
+ v-model:current-date-to="currentDateTo"
12
+ :timespan-options="timespanOptions"
13
+ :custom-time-options="customTimeOptions"
14
+ :language="props.language"
15
+ :error-last-input="props.errorLastInput"
16
+ :error-date-from="props.errorDateFrom"
17
+ :error-time-from="props.errorTimeFrom"
18
+ :error-date-to="props.errorDateTo"
19
+ :error-time-to="props.errorTimeTo"
20
20
  />
21
21
  <common-chart-options-modal-counters-timespan-form-old
22
- v-else
23
- v-model:local-selected-timespan="localSelectedTimespan"
24
- v-model:local-period-type="localPeriodType"
25
- v-model:local-last="localLast"
26
- v-model:local-selected-custom-time="localSelectedCustomTime"
27
- v-model:local-current-date-from="localCurrentDateFrom"
28
- v-model:date-from="dateFrom"
29
- v-model:current-date-to="currentDateTo"
30
- v-model:date-to="dateTo"
31
- v-model:current-time-to="currentTimeTo"
32
- v-model:chart-type="chartType"
33
- :timespan-options="timespanOptions"
34
- :period-type-text="periodTypeText"
35
- :custom-time-options="customTimeOptions"
36
- :language="props.language"
37
- :current-time-from="currentTimeFrom"
38
- :chart-type-options="chartTypeOptions"
39
- @update-date-from="onUpdateDateFrom"
40
- @update-date-to="onUpdateDateTo"
22
+ v-else
23
+ v-model:local-selected-timespan="localSelectedTimespan"
24
+ v-model:local-period-type="localPeriodType"
25
+ v-model:local-last="localLast"
26
+ v-model:local-selected-custom-time="localSelectedCustomTime"
27
+ v-model:local-current-date-from="localCurrentDateFrom"
28
+ v-model:date-from="dateFrom"
29
+ v-model:current-date-to="currentDateTo"
30
+ v-model:date-to="dateTo"
31
+ v-model:current-time-from="currentTimeFrom"
32
+ v-model:current-time-to="currentTimeTo"
33
+ v-model:chart-type="chartType"
34
+ :timespan-options="timespanOptions"
35
+ :period-type-text="periodTypeText"
36
+ :custom-time-options="customTimeOptions"
37
+ :language="props.language"
38
+ :chart-type-options="chartTypeOptions"
39
+ @update-date-from="onUpdateDateFrom"
40
+ @update-date-to="onUpdateDateTo"
41
41
  />
42
42
  </template>
43
43
 
@@ -83,64 +83,64 @@ const emits = defineEmits<{
83
83
  }>()
84
84
 
85
85
  const { $store, $formattedDate, $isDate, $getTimeFormat, $getUnixByDate }: any =
86
- useNuxtApp()
86
+ useNuxtApp()
87
87
 
88
88
  const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
89
89
 
90
90
  const localization = computed<UI_I_Localization>(() => useLocal())
91
91
 
92
92
  const timespanOptions = computed<UI_I_OptionItem[]>(() =>
93
- timespanFunc(localization.value)
93
+ timespanFunc(localization.value)
94
94
  )
95
95
  const localSelectedTimespan = ref<string>(
96
- props.selectedTimespanType || timespanOptions.value[0].value
96
+ props.selectedTimespanType || timespanOptions.value[0].value
97
97
  )
98
98
  watch(
99
- () => props.selectedTimespanType,
100
- (newValue) => {
101
- localSelectedTimespan.value = newValue || timespanOptions.value[0].value
102
- }
99
+ () => props.selectedTimespanType,
100
+ (newValue) => {
101
+ localSelectedTimespan.value = newValue || timespanOptions.value[0].value
102
+ }
103
103
  )
104
104
  const localPeriodType = ref<string>('last')
105
105
  watch(
106
- () => props.periodType,
107
- (newValue) => {
108
- localPeriodType.value = newValue || 'last'
109
- },
110
- { immediate: true }
106
+ () => props.periodType,
107
+ (newValue) => {
108
+ localPeriodType.value = newValue || 'last'
109
+ },
110
+ { immediate: true }
111
111
  )
112
112
 
113
113
  watch(
114
- localSelectedTimespan,
115
- (newValue) => {
116
- emits('update-timespan-type', newValue)
117
- },
118
- { immediate: true }
114
+ localSelectedTimespan,
115
+ (newValue) => {
116
+ emits('update-timespan-type', newValue)
117
+ },
118
+ { immediate: true }
119
119
  )
120
120
 
121
121
  watch(
122
- localPeriodType,
123
- (newValue) => {
124
- const currentValue = newValue || 'period'
125
- emits('update-period-type', currentValue)
126
- },
127
- { immediate: true }
122
+ localPeriodType,
123
+ (newValue) => {
124
+ const currentValue = newValue || 'period'
125
+ emits('update-period-type', currentValue)
126
+ },
127
+ { immediate: true }
128
128
  )
129
129
 
130
130
  const localLast = ref<number>(1)
131
131
  watch(
132
- localLast,
133
- (newValue) => {
134
- emits('update-unit-count', newValue)
135
- },
136
- { immediate: true }
132
+ localLast,
133
+ (newValue) => {
134
+ emits('update-unit-count', newValue)
135
+ },
136
+ { immediate: true }
137
137
  )
138
138
  watch(
139
- () => props.unitsCount,
140
- (newValue) => {
141
- localLast.value = newValue > 0 ? newValue : 1
142
- },
143
- { immediate: true }
139
+ () => props.unitsCount,
140
+ (newValue) => {
141
+ localLast.value = newValue > 0 ? newValue : 1
142
+ },
143
+ { immediate: true }
144
144
  )
145
145
 
146
146
  const localSelectedCustomTime = ref<string>('hours')
@@ -150,23 +150,23 @@ const customTimeOptions = computed<UI_I_OptionItem[]>(() => {
150
150
  return customTimeFunc(localization.value, localLast.value, lang)
151
151
  })
152
152
  watch(
153
- () => props.selectedCustomTime,
154
- (newValue) => {
155
- localSelectedCustomTime.value = newValue || 'hours'
156
- },
157
- { immediate: true }
153
+ () => props.selectedCustomTime,
154
+ (newValue) => {
155
+ localSelectedCustomTime.value = newValue || 'hours'
156
+ },
157
+ { immediate: true }
158
158
  )
159
159
  watch(
160
- localSelectedCustomTime,
161
- (newValue) => {
162
- emits('update-custom-time', newValue)
163
- },
164
- { immediate: true }
160
+ localSelectedCustomTime,
161
+ (newValue) => {
162
+ emits('update-custom-time', newValue)
163
+ },
164
+ { immediate: true }
165
165
  )
166
166
 
167
167
  const chartType = ref<string>('line_graph')
168
168
  const chartTypeOptions = computed<UI_I_OptionItem[]>(() =>
169
- chartTypeFunc(localization.value)
169
+ chartTypeFunc(localization.value)
170
170
  )
171
171
 
172
172
  const periodTypeText = computed<string>(() => {
@@ -202,24 +202,24 @@ const setCurrentChartType = (): void => {
202
202
  }
203
203
 
204
204
  watch(
205
- () => props.selectedChartType,
206
- () => {
207
- setCurrentChartType()
208
- },
209
- { immediate: true }
205
+ () => props.selectedChartType,
206
+ () => {
207
+ setCurrentChartType()
208
+ },
209
+ { immediate: true }
210
210
  )
211
211
 
212
212
  watch(
213
- chartType,
214
- (newValue) => {
215
- let currentValue = 'spline'
213
+ chartType,
214
+ (newValue) => {
215
+ let currentValue = 'spline'
216
216
 
217
- if (newValue === 'line_graph') currentValue = 'spline'
218
- else if (newValue === 'stacked_graph') currentValue = 'area'
217
+ if (newValue === 'line_graph') currentValue = 'spline'
218
+ else if (newValue === 'stacked_graph') currentValue = 'area'
219
219
 
220
- emits('update-chart-type', currentValue)
221
- },
222
- { immediate: true }
220
+ emits('update-chart-type', currentValue)
221
+ },
222
+ { immediate: true }
223
223
  )
224
224
 
225
225
  const yesterday = new Date().setDate(new Date().getDate() - 1)
@@ -233,14 +233,14 @@ const currentTimeTo = ref<string>('')
233
233
 
234
234
  const getCurrentTime = (): void => {
235
235
  localCurrentDateFrom.value =
236
- props.customDateFrom || $formattedDate(yesterday, '')
236
+ props.customDateFrom || $formattedDate(yesterday, '')
237
237
  currentDateTo.value =
238
- props.customDateTo || $formattedDate(props.validDateEnd, '')
238
+ props.customDateTo || $formattedDate(props.validDateEnd, '')
239
239
 
240
240
  currentTimeFrom.value =
241
- props.customTimeFrom || format(new Date(), $getTimeFormat(true))
241
+ props.customTimeFrom || format(new Date(), $getTimeFormat(true))
242
242
  currentTimeTo.value =
243
- props.customTimeTo || format(props.validDateEnd, $getTimeFormat(true))
243
+ props.customTimeTo || format(props.validDateEnd, $getTimeFormat(true))
244
244
  }
245
245
 
246
246
  const onUpdateDateFrom = (value: number): void => {
@@ -0,0 +1,281 @@
1
+ <template>
2
+ <common-chart-options-modal-counters-timespan-form-new
3
+ v-if="isNewView"
4
+ v-model:local-selected-timespan="localSelectedTimespan"
5
+ v-model:local-period-type="localPeriodType"
6
+ v-model:local-last="localLast"
7
+ v-model:local-selected-custom-time="localSelectedCustomTime"
8
+ v-model:local-current-date-from="localCurrentDateFrom"
9
+ v-model:current-time-from="currentTimeFrom"
10
+ v-model:current-time-to="currentTimeTo"
11
+ v-model:current-date-to="currentDateTo"
12
+ :timespan-options="timespanOptions"
13
+ :custom-time-options="customTimeOptions"
14
+ :language="props.language"
15
+ :error-last-input="props.errorLastInput"
16
+ :error-date-from="props.errorDateFrom"
17
+ :error-time-from="props.errorTimeFrom"
18
+ :error-date-to="props.errorDateTo"
19
+ :error-time-to="props.errorTimeTo"
20
+ />
21
+ <common-chart-options-modal-counters-timespan-form-old
22
+ v-else
23
+ v-model:local-selected-timespan="localSelectedTimespan"
24
+ v-model:local-period-type="localPeriodType"
25
+ v-model:local-last="localLast"
26
+ v-model:local-selected-custom-time="localSelectedCustomTime"
27
+ v-model:local-current-date-from="localCurrentDateFrom"
28
+ v-model:date-from="dateFrom"
29
+ v-model:current-date-to="currentDateTo"
30
+ v-model:date-to="dateTo"
31
+ v-model:current-time-to="currentTimeTo"
32
+ v-model:chart-type="chartType"
33
+ :timespan-options="timespanOptions"
34
+ :period-type-text="periodTypeText"
35
+ :custom-time-options="customTimeOptions"
36
+ :language="props.language"
37
+ :current-time-from="currentTimeFrom"
38
+ :chart-type-options="chartTypeOptions"
39
+ @update-date-from="onUpdateDateFrom"
40
+ @update-date-to="onUpdateDateTo"
41
+ />
42
+ </template>
43
+
44
+ <script setup lang="ts">
45
+ import { format } from 'date-fns'
46
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
47
+ import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
48
+ import {
49
+ timespanFunc,
50
+ customTimeFunc,
51
+ chartTypeFunc,
52
+ } from '~/components/common/chartOptionsModal/counters/timespan/form/lib/config/dateForm'
53
+
54
+ const props = defineProps<{
55
+ language: string
56
+ selectedChartType: string
57
+ selectedTimespanType: string
58
+ unitsCount: number
59
+ periodType: string
60
+ selectedCustomTime: string
61
+ customDateFrom: string
62
+ customDateTo: string
63
+ customTimeFrom: string
64
+ customTimeTo: string
65
+ validDateEnd: number
66
+ errorLastInput?: string
67
+ errorDateFrom?: string
68
+ errorTimeFrom?: string
69
+ errorDateTo?: string
70
+ errorTimeTo?: string
71
+ }>()
72
+
73
+ const emits = defineEmits<{
74
+ (event: 'update-chart-type', value: string): void
75
+ (event: 'update-custom-time', value: string): void
76
+ (event: 'update-timespan-type', value: string): void
77
+ (event: 'update-unit-count', value: number): void
78
+ (event: 'update-period-type', value: string): void
79
+ (event: 'update-custom-date-from', value: string): void
80
+ (event: 'update-custom-date-to', value: string): void
81
+ (event: 'update-custom-time-from', value: string): void
82
+ (event: 'update-custom-time-to', value: string): void
83
+ }>()
84
+
85
+ const { $store, $formattedDate, $isDate, $getTimeFormat, $getUnixByDate }: any =
86
+ useNuxtApp()
87
+
88
+ const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
89
+
90
+ const localization = computed<UI_I_Localization>(() => useLocal())
91
+
92
+ const timespanOptions = computed<UI_I_OptionItem[]>(() =>
93
+ timespanFunc(localization.value)
94
+ )
95
+ const localSelectedTimespan = ref<string>(
96
+ props.selectedTimespanType || timespanOptions.value[0].value
97
+ )
98
+ watch(
99
+ () => props.selectedTimespanType,
100
+ (newValue) => {
101
+ localSelectedTimespan.value = newValue || timespanOptions.value[0].value
102
+ }
103
+ )
104
+ const localPeriodType = ref<string>('last')
105
+ watch(
106
+ () => props.periodType,
107
+ (newValue) => {
108
+ localPeriodType.value = newValue || 'last'
109
+ },
110
+ { immediate: true }
111
+ )
112
+
113
+ watch(
114
+ localSelectedTimespan,
115
+ (newValue) => {
116
+ emits('update-timespan-type', newValue)
117
+ },
118
+ { immediate: true }
119
+ )
120
+
121
+ watch(
122
+ localPeriodType,
123
+ (newValue) => {
124
+ const currentValue = newValue || 'period'
125
+ emits('update-period-type', currentValue)
126
+ },
127
+ { immediate: true }
128
+ )
129
+
130
+ const localLast = ref<number>(1)
131
+ watch(
132
+ localLast,
133
+ (newValue) => {
134
+ emits('update-unit-count', newValue)
135
+ },
136
+ { immediate: true }
137
+ )
138
+ watch(
139
+ () => props.unitsCount,
140
+ (newValue) => {
141
+ localLast.value = newValue > 0 ? newValue : 1
142
+ },
143
+ { immediate: true }
144
+ )
145
+
146
+ const localSelectedCustomTime = ref<string>('hours')
147
+ const customTimeOptions = computed<UI_I_OptionItem[]>(() => {
148
+ const lang = useLocalStorage('lang')
149
+
150
+ return customTimeFunc(localization.value, localLast.value, lang)
151
+ })
152
+ watch(
153
+ () => props.selectedCustomTime,
154
+ (newValue) => {
155
+ localSelectedCustomTime.value = newValue || 'hours'
156
+ },
157
+ { immediate: true }
158
+ )
159
+ watch(
160
+ localSelectedCustomTime,
161
+ (newValue) => {
162
+ emits('update-custom-time', newValue)
163
+ },
164
+ { immediate: true }
165
+ )
166
+
167
+ const chartType = ref<string>('line_graph')
168
+ const chartTypeOptions = computed<UI_I_OptionItem[]>(() =>
169
+ chartTypeFunc(localization.value)
170
+ )
171
+
172
+ const periodTypeText = computed<string>(() => {
173
+ let text = ''
174
+ const lang = useLocalStorage('lang')
175
+
176
+ if (lang !== 'ru_RU') text = localization.value.common.last
177
+ else text = getCorrectRuPeriodTypeText(localLast.value)
178
+
179
+ return text
180
+ })
181
+
182
+ const getCorrectRuPeriodTypeText = (hours: number): string => {
183
+ let prefix: string
184
+
185
+ if (!hours) return getCorrectRuPeriodTypeText.prefix
186
+
187
+ if (hours % 10 === 1 && hours % 100 !== 11) prefix = 'Последний'
188
+ else prefix = 'Последние'
189
+
190
+ getCorrectRuPeriodTypeText.prefix = prefix
191
+ return prefix
192
+ }
193
+
194
+ const setCurrentChartType = (): void => {
195
+ const selected = props.selectedChartType
196
+ let result = 'line_graph'
197
+
198
+ if (selected === 'spline') result = 'line_graph'
199
+ else if (selected === 'area') result = 'stacked_graph'
200
+
201
+ chartType.value = result
202
+ }
203
+
204
+ watch(
205
+ () => props.selectedChartType,
206
+ () => {
207
+ setCurrentChartType()
208
+ },
209
+ { immediate: true }
210
+ )
211
+
212
+ watch(
213
+ chartType,
214
+ (newValue) => {
215
+ let currentValue = 'spline'
216
+
217
+ if (newValue === 'line_graph') currentValue = 'spline'
218
+ else if (newValue === 'stacked_graph') currentValue = 'area'
219
+
220
+ emits('update-chart-type', currentValue)
221
+ },
222
+ { immediate: true }
223
+ )
224
+
225
+ const yesterday = new Date().setDate(new Date().getDate() - 1)
226
+ const dateFrom = ref<number>(yesterday)
227
+ const dateTo = ref<number>(new Date().getTime())
228
+
229
+ const localCurrentDateFrom = ref<string>('')
230
+ const currentDateTo = ref<string>('')
231
+ const currentTimeFrom = ref<string>('')
232
+ const currentTimeTo = ref<string>('')
233
+
234
+ const getCurrentTime = (): void => {
235
+ localCurrentDateFrom.value =
236
+ props.customDateFrom || $formattedDate(yesterday, '')
237
+ currentDateTo.value =
238
+ props.customDateTo || $formattedDate(props.validDateEnd, '')
239
+
240
+ currentTimeFrom.value =
241
+ props.customTimeFrom || format(new Date(), $getTimeFormat(true))
242
+ currentTimeTo.value =
243
+ props.customTimeTo || format(props.validDateEnd, $getTimeFormat(true))
244
+ }
245
+
246
+ const onUpdateDateFrom = (value: number): void => {
247
+ if (!value) return
248
+
249
+ localCurrentDateFrom.value = $formattedDate(new Date(value), '')
250
+ }
251
+ watch(localCurrentDateFrom, (newValue) => {
252
+ emits('update-custom-date-from', newValue)
253
+ if (!newValue) return
254
+
255
+ if ($isDate(newValue)) dateFrom.value = $getUnixByDate(newValue)
256
+ })
257
+
258
+ const onUpdateDateTo = (value: number): void => {
259
+ if (!value) return
260
+
261
+ currentDateTo.value = $formattedDate(new Date(value), '')
262
+ }
263
+ watch(currentDateTo, (newValue) => {
264
+ emits('update-custom-date-to', newValue)
265
+ if (!newValue) return
266
+
267
+ if ($isDate(newValue)) dateTo.value = $getUnixByDate(newValue)
268
+ })
269
+ watch(currentTimeFrom, (newValue) => {
270
+ emits('update-custom-time-from', newValue)
271
+ })
272
+ watch(currentTimeTo, (newValue) => {
273
+ emits('update-custom-time-to', newValue)
274
+ })
275
+
276
+ onMounted(() => {
277
+ getCurrentTime()
278
+ })
279
+ </script>
280
+
281
+ <style scoped lang="scss"></style>
@@ -1,4 +1,4 @@
1
- const lastTimestamp = 1740651960445
1
+ const lastTimestamp = 1744866033269
2
2
 
3
3
  export const useLocalStorage = (
4
4
  name: string,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.5.18",
4
+ "version": "1.5.20",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -35,7 +35,7 @@
35
35
  "@vueuse/components": "^10.1.2",
36
36
  "date-fns": "^2.29.3",
37
37
  "bfg-nuxt-3-graph": "1.0.21",
38
- "bfg-uikit": "1.0.375",
38
+ "bfg-uikit": "1.0.377",
39
39
  "html2canvas": "^1.4.1",
40
40
  "prettier-eslint": "^15.0.1"
41
41
  }
package/package.json~ ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "bfg-common",
3
+ "private": false,
4
+ "version": "1.5.19",
5
+ "scripts": {
6
+ "build": "nuxt build",
7
+ "dev": "nuxt dev --port=3002",
8
+ "generate": "nuxt generate",
9
+ "preview": "nuxt preview",
10
+ "postinstall": "nuxt prepare",
11
+ "minify": "node minify.js",
12
+ "prepublishOnly": "node minify.js"
13
+ },
14
+ "devDependencies": {
15
+ "@novnc/novnc": "1.4.0",
16
+ "@vueuse/core": "10.1.2",
17
+ "@vueuse/nuxt": "10.1.2",
18
+ "eslint-config-prettier": "^8.5.0",
19
+ "nuxt": "3.11.2",
20
+ "prettier": "2.7.1",
21
+ "sass": "^1.54.9",
22
+ "sass-loader": "^10.3.1",
23
+ "terser": "^5.22.0",
24
+ "vite-plugin-eslint": "^1.8.1",
25
+ "xterm": "^5.1.0",
26
+ "xterm-addon-attach": "^0.8.0",
27
+ "xterm-addon-fit": "^0.7.0",
28
+ "xterm-addon-serialize": "^0.9.0",
29
+ "xterm-addon-unicode11": "^0.5.0",
30
+ "xterm-addon-web-links": "^0.8.0",
31
+ "eslint-plugin-myrules": "file:./eslint"
32
+ },
33
+ "dependencies": {
34
+ "@nuxtjs/eslint-config-typescript": "^12.0.0",
35
+ "@vueuse/components": "^10.1.2",
36
+ "date-fns": "^2.29.3",
37
+ "bfg-nuxt-3-graph": "1.0.21",
38
+ "bfg-uikit": "1.0.377",
39
+ "html2canvas": "^1.4.1",
40
+ "prettier-eslint": "^15.0.1"
41
+ }
42
+ }