bfg-common 1.5.761 → 1.5.762

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.
@@ -86,45 +86,30 @@ const fields = ref<UI_I_PortProperties>({
86
86
  },
87
87
  })
88
88
 
89
- const setEnabledServiceDefault = (
90
- tcp: UI_T_TCP,
91
- currentFields: UI_I_PortProperties
92
- ): void => {
93
- tcp === 'default' &&
94
- (fields.value = {
95
- ...currentFields,
96
- services: servicesInitial,
97
- })
98
- }
99
-
100
- const setEnabledServiceProvisioning = (
89
+ const setEnabledService = (
101
90
  tcp: UI_T_TCP,
102
91
  currentFields: UI_I_PortProperties,
103
92
  newFields?: UI_I_PortProperties
104
93
  ): void => {
105
- tcp === 'provisioning' &&
106
- (fields.value = {
94
+ if (tcp === 'default') {
95
+ fields.value = {
96
+ ...currentFields,
97
+ services: useDeepCopy(servicesInitial),
98
+ }
99
+ } else if (servicesInitial.hasOwnProperty(tcp)) {
100
+ fields.value = {
107
101
  ...(newFields || currentFields),
108
102
  services: {
109
- ...servicesInitial,
110
- provisioning: true,
103
+ ...useDeepCopy(servicesInitial),
104
+ [tcp]: true,
111
105
  },
112
- })
113
- }
114
-
115
- const setEnabledServiceVMotion = (
116
- tcp: UI_T_TCP,
117
- currentFields: UI_I_PortProperties,
118
- newFields?: UI_I_PortProperties
119
- ): void => {
120
- tcp === '' &&
121
- (fields.value = {
106
+ }
107
+ } else {
108
+ fields.value = {
122
109
  ...(newFields || currentFields),
123
- services: {
124
- ...servicesInitial,
125
- vMotion: true,
126
- },
127
- })
110
+ services: useDeepCopy(servicesInitial),
111
+ }
112
+ }
128
113
  }
129
114
 
130
115
  let oldFields = useDeepCopy(fields.value)
@@ -134,9 +119,7 @@ watch(
134
119
  (newFields: UI_I_PortProperties) => {
135
120
  if (newFields.tcp && newFields.tcp !== oldFields.tcp) {
136
121
  emits('change-gateway-flag', false)
137
- setEnabledServiceDefault(newFields.tcp, fields.value)
138
- setEnabledServiceProvisioning(newFields.tcp, fields.value, newFields)
139
- setEnabledServiceVMotion(newFields.tcp, fields.value, newFields)
122
+ setEnabledService(newFields.tcp, fields.value, newFields)
140
123
  }
141
124
 
142
125
  oldFields.networkLabel !== newFields.networkLabel &&
@@ -184,9 +167,7 @@ watch(
184
167
  () => fields.value.tcp,
185
168
  (newTcp: UI_T_TCP, oldTcp: UI_T_TCP) => {
186
169
  if (newTcp !== oldTcp) {
187
- setEnabledServiceDefault(newTcp, fields.value)
188
- setEnabledServiceProvisioning(newTcp, fields.value)
189
- setEnabledServiceVMotion(newTcp, fields.value)
170
+ setEnabledService(newTcp, fields.value)
190
171
  }
191
172
  emits('change-port-properties', fields.value)
192
173
  }
@@ -196,7 +177,10 @@ watch(
196
177
  () => props.tcpStacks,
197
178
  (newValue: UI_I_TCPStack[]) => {
198
179
  if (fields.value.tcp === '') {
199
- fields.value.tcp = newValue?.[0]?.id || ''
180
+ fields.value.tcp =
181
+ newValue?.find?.((item) => item.id === 'default')?.id ||
182
+ newValue?.[0]?.id ||
183
+ ''
200
184
  }
201
185
  },
202
186
  { deep: true, immediate: true }
@@ -146,7 +146,7 @@
146
146
  <select id="tsp" v-model="fields.tcp" data-id="tsp-select">
147
147
  <template v-for="tcp in props.tcpStacks" :key="tcp.id">
148
148
  <option :value="tcp.id">
149
- {{ localization.common[tcp.id] }}
149
+ {{ localization.common[tcp.id] || tcp.id }}
150
150
  </option>
151
151
  </template>
152
152
  <!-- <option value="1">{{ localization.common.provisioning }}</option>-->
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.5.761",
4
+ "version": "1.5.762",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
package/plugins/time.ts CHANGED
@@ -1,58 +1,58 @@
1
- import { defineNuxtPlugin } from '#app'
2
- import type { UI_T_LangValue } from '~/lib/models/types'
3
- export default defineNuxtPlugin(() => {
4
- const time = function (): any {
5
- const self: any = {}
6
- self.millisecondsToHour = function (ms: number): number {
7
- return ~~(ms / 1000 / 60 / 60 / 24)
8
- }
9
- self.formatTime = (
10
- seconds: number,
11
- lang: UI_T_LangValue = 'ru_RU'
12
- ): string => {
13
- const units = {
14
- en_US: { s: 's', m: 'm', h: 'h' },
15
- ru_RU: { s: 'с', m: 'м', h: 'ч' },
16
- hy_AM: { s: 'վ', m: 'ր', h: 'ժ' },
17
- be_BY: { s: 'с', m: 'хв', h: 'г' },
18
- kk_KZ: { s: 'сек', m: 'мин', h: 'сағ' },
19
- zh_CHS: { s: '秒', m: '分', h: '时' },
20
- BROWSER: { s: 's', m: 'm', h: 'h' },
21
- }
22
-
23
- const unit = units[lang] || units.en_US
24
-
25
- if (seconds < 60) {
26
- return `${seconds}${unit.s}`
27
- }
28
-
29
- const hours = Math.floor(seconds / 3600)
30
- const minutes = Math.floor((seconds % 3600) / 60)
31
- const secs = seconds % 60
32
-
33
- let result = ''
34
-
35
- if (hours > 0) {
36
- result += `${hours}${unit.h} `
37
- }
38
-
39
- if (minutes > 0) {
40
- result += `${minutes}${unit.m} `
41
- }
42
-
43
- if (secs > 0) {
44
- result += `${secs}${unit.s}`
45
- }
46
-
47
- return result.trim()
48
- }
49
-
50
- return self
51
- }.call({})
52
-
53
- return {
54
- provide: {
55
- time,
56
- },
57
- }
58
- })
1
+ import { defineNuxtPlugin } from '#app'
2
+ import type { UI_T_LangValue } from '~/lib/models/types'
3
+ export default defineNuxtPlugin(() => {
4
+ const time = function (): any {
5
+ const self: any = {}
6
+ self.millisecondsToHour = function (ms: number): number {
7
+ return ~~(ms / 1000 / 60 / 60 / 24)
8
+ }
9
+ self.formatTime = (
10
+ seconds: number,
11
+ lang: UI_T_LangValue = 'ru_RU'
12
+ ): string => {
13
+ const units = {
14
+ en_US: { s: 's', m: 'm', h: 'h' },
15
+ ru_RU: { s: 'с', m: 'м', h: 'ч' },
16
+ hy_AM: { s: 'վ', m: 'ր', h: 'ժ' },
17
+ be_BY: { s: 'с', m: 'хв', h: 'г' },
18
+ kk_KZ: { s: 'сек', m: 'мин', h: 'сағ' },
19
+ zh_CHS: { s: '秒', m: '分', h: '时' },
20
+ BROWSER: { s: 's', m: 'm', h: 'h' },
21
+ }
22
+
23
+ const unit = units[lang] || units.en_US
24
+
25
+ if (seconds < 60) {
26
+ return `${seconds}${unit.s}`
27
+ }
28
+
29
+ const hours = Math.floor(seconds / 3600)
30
+ const minutes = Math.floor((seconds % 3600) / 60)
31
+ const secs = seconds % 60
32
+
33
+ let result = ''
34
+
35
+ if (hours > 0) {
36
+ result += `${hours}${unit.h} `
37
+ }
38
+
39
+ if (minutes > 0) {
40
+ result += `${minutes}${unit.m} `
41
+ }
42
+
43
+ if (secs > 0) {
44
+ result += `${secs}${unit.s}`
45
+ }
46
+
47
+ return result.trim()
48
+ }
49
+
50
+ return self
51
+ }.call({})
52
+
53
+ return {
54
+ provide: {
55
+ time,
56
+ },
57
+ }
58
+ })