bfg-common 1.3.203 → 1.3.205

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.
@@ -204,6 +204,8 @@
204
204
  :selected-standard-switch-id="selectedStandardSwitchId"
205
205
  :selected-switch-id="selectedSwitchId"
206
206
  :tcp-stacks="props.tcpStacks"
207
+ :tcp-stack-loading="props.tcpStackLoading"
208
+ :diagrams-data="props.diagramsData"
207
209
  @check-network-label="onCheckNetworkLabel"
208
210
  @get-existing-standard-switches="onGetExistingStandardSwitches"
209
211
  @get-tcp-stacks="onGetTcpStacks"
@@ -298,6 +300,8 @@ const props = withDefaults(
298
300
  networksList?: UI_I_Network[]
299
301
  isDarkMode: boolean
300
302
  tcpStacks?: UI_I_TCPStack[]
303
+ tcpStackLoading?: boolean
304
+ diagramsData?: UI_I_DiagramData[]
301
305
  }>(),
302
306
  {
303
307
  diagramData: null,
@@ -312,6 +316,8 @@ const props = withDefaults(
312
316
  freeAdapters: () => [],
313
317
  networksList: () => [],
314
318
  tcpStacks: () => [],
319
+ tcpStackLoading: false,
320
+ diagramsData: [],
315
321
  }
316
322
  )
317
323
 
@@ -573,8 +579,8 @@ const onCheckNetworkLabel = (
573
579
  const onGetExistingStandardSwitches = (cb: () => void) => {
574
580
  emits('get-existing-standard-switches', cb)
575
581
  }
576
- const onGetTcpStacks = (cb: () => void) => {
577
- emits('get-tcp-stacks', cb)
582
+ const onGetTcpStacks = () => {
583
+ emits('get-tcp-stacks')
578
584
  }
579
585
  const onGetFreeAdapters = (cb: () => void) => {
580
586
  emits('get-free-adapters', cb)
@@ -903,7 +909,7 @@ const emits = defineEmits<{
903
909
  hideModalCB: () => void,
904
910
  hideLoaderCB: () => void
905
911
  ): void
906
- (event: 'get-tcp-stacks', cb: () => void): void
912
+ (event: 'get-tcp-stacks'): void
907
913
  }>()
908
914
 
909
915
  const onTogglePorts = (
@@ -18,16 +18,16 @@ import {
18
18
  import { UI_T_Adapters } from '~/components/common/diagramMain/lib/models/types'
19
19
 
20
20
  export const hasPortAndNetwork = (
21
- selectedPort: UI_I_SelectedPort,
22
- id: string
21
+ selectedPort: UI_I_SelectedPort,
22
+ id: string
23
23
  ): boolean =>
24
- selectedPort.portId !== '-1' &&
25
- selectedPort.networkId !== '-1' &&
26
- selectedPort.networkId === id
24
+ selectedPort.portId !== '-1' &&
25
+ selectedPort.networkId !== '-1' &&
26
+ selectedPort.networkId === id
27
27
 
28
28
  export const networksPositions = (
29
- arr: number[],
30
- net: UI_I_NetworksWithPositions
29
+ arr: number[],
30
+ net: UI_I_NetworksWithPositions
31
31
  ): number[] => {
32
32
  if (net.ports.length === 0) return [...arr, net.connectLineY]
33
33
  if (!net.toggle) return [...arr, net.portsPosition + 7.5]
@@ -36,44 +36,44 @@ export const networksPositions = (
36
36
  ...arr,
37
37
  net.portsPosition + 22 + 7.5,
38
38
  net.networkType === UI_E_NetworkType.VCenter
39
- ? net.portsPosition + 22 + 12.5 + 32 * (net.portsCount - 1)
40
- : net.portsPosition + 22 + 7.5 + 22 * (net.portsCount - 1),
39
+ ? net.portsPosition + 22 + 12.5 + 32 * (net.portsCount - 1)
40
+ : net.portsPosition + 22 + 7.5 + 22 * (net.portsCount - 1),
41
41
  ]
42
42
  }
43
43
 
44
44
  export const getSelectedPortLinePositions = (
45
- selectedPortPosition: number | undefined,
46
- selectedNetworkData: UI_I_Network
45
+ selectedPortPosition: number | undefined,
46
+ selectedNetworkData: UI_I_Network
47
47
  ) =>
48
- selectedPortPosition
49
- ? selectedNetworkData.networkType === UI_E_NetworkType.VCenter
50
- ? selectedPortPosition + 12.5
51
- : selectedPortPosition + 7.5
52
- : 0
48
+ selectedPortPosition
49
+ ? selectedNetworkData.networkType === UI_E_NetworkType.VCenter
50
+ ? selectedPortPosition + 12.5
51
+ : selectedPortPosition + 7.5
52
+ : 0
53
53
 
54
54
  const selectedNetworkDataFunc = (
55
- networkId: string,
56
- networksWithPositions: UI_I_NetworksWithPositions[]
55
+ networkId: string,
56
+ networksWithPositions: UI_I_NetworksWithPositions[]
57
57
  ): UI_I_NetworksWithPositions | undefined =>
58
- networksWithPositions?.find(
59
- (network: UI_I_Network): boolean => network.id === networkId
60
- )
58
+ networksWithPositions?.find(
59
+ (network: UI_I_Network): boolean => network.id === networkId
60
+ )
61
61
 
62
62
  export const getSelectNetworkDataFunc = (
63
- networkId: string,
64
- networksWithPositions: UI_I_NetworksWithPositions[],
65
- adaptersWithPositions: UI_I_AdaptersWithPositions
63
+ networkId: string,
64
+ networksWithPositions: UI_I_NetworksWithPositions[],
65
+ adaptersWithPositions: UI_I_AdaptersWithPositions
66
66
  ): UI_I_SelectedSwitchPositions | undefined => {
67
67
  const selectedNetworkData: UI_I_NetworksWithPositions | undefined =
68
- selectedNetworkDataFunc(networkId, networksWithPositions)
68
+ selectedNetworkDataFunc(networkId, networksWithPositions)
69
69
 
70
70
  if (!selectedNetworkData) return
71
71
 
72
72
  const activeAdapters: string[] = selectedNetworkData.activeAdapters
73
73
  const adaptersPositions: number[] =
74
- adaptersWithPositions.adapters
75
- ?.filter((adapter: UI_T_Adapters) => activeAdapters?.includes(adapter.id))
76
- ?.map((adapter: UI_T_Adapters) => adapter.adapterPosition + 7.5) || []
74
+ adaptersWithPositions.adapters
75
+ ?.filter((adapter: UI_T_Adapters) => activeAdapters?.includes(adapter.id))
76
+ ?.map((adapter: UI_T_Adapters) => adapter.adapterPosition + 7.5) || []
77
77
  let selectedPositions: number[] = []
78
78
 
79
79
  if (!adaptersWithPositions.toggle) {
@@ -82,11 +82,11 @@ export const getSelectNetworkDataFunc = (
82
82
  selectedNetworkData.connectLineY,
83
83
  ]
84
84
  } else if (
85
- adaptersWithPositions.adapters === null ||
86
- adaptersWithPositions.adapters?.length === 0
85
+ adaptersWithPositions.adapters === null ||
86
+ adaptersWithPositions.adapters?.length === 0
87
87
  ) {
88
88
  selectedPositions = [47.5, selectedNetworkData.connectLineY].sort(
89
- (y1: number, y2: number) => y1 - y2
89
+ (y1: number, y2: number) => y1 - y2
90
90
  )
91
91
  } else {
92
92
  selectedPositions = [
@@ -109,28 +109,28 @@ export const getSelectNetworkDataFunc = (
109
109
  }
110
110
 
111
111
  export const getSelectPortDataFunc = (
112
- networkId: string,
113
- portId: string,
114
- networksWithPositions: UI_I_NetworksWithPositions[],
115
- adaptersWithPositions: UI_I_AdaptersWithPositions
112
+ networkId: string,
113
+ portId: string,
114
+ networksWithPositions: UI_I_NetworksWithPositions[],
115
+ adaptersWithPositions: UI_I_AdaptersWithPositions
116
116
  ): UI_I_SelectedSwitchPositions | undefined => {
117
117
  const selectedNetworkData: UI_I_NetworksWithPositions | undefined =
118
- selectedNetworkDataFunc(networkId, networksWithPositions)
118
+ selectedNetworkDataFunc(networkId, networksWithPositions)
119
119
 
120
120
  if (!selectedNetworkData) return
121
121
 
122
122
  const activeAdapters: string[] = selectedNetworkData.activeAdapters
123
123
  const adaptersPositions: number[] =
124
- adaptersWithPositions.adapters
125
- ?.filter((adapter: UI_T_Adapters) => activeAdapters?.includes(adapter.id))
126
- ?.map((adapter: UI_T_Adapters) => adapter.adapterPosition + 7.5) || []
124
+ adaptersWithPositions.adapters
125
+ ?.filter((adapter: UI_T_Adapters) => activeAdapters?.includes(adapter.id))
126
+ ?.map((adapter: UI_T_Adapters) => adapter.adapterPosition + 7.5) || []
127
127
  const selectedPortPosition: number | undefined =
128
- selectedNetworkData.ports.find(
129
- (el): boolean => el.id === portId
130
- )?.portPosition
128
+ selectedNetworkData.ports.find(
129
+ (el): boolean => el.id === portId
130
+ )?.portPosition
131
131
  const selectedPortLinePosition: number = getSelectedPortLinePositions(
132
- selectedPortPosition,
133
- selectedNetworkData
132
+ selectedPortPosition,
133
+ selectedNetworkData
134
134
  )
135
135
  let selectedPositions: number[] = []
136
136
 
@@ -142,7 +142,7 @@ export const getSelectPortDataFunc = (
142
142
  ]
143
143
  } else {
144
144
  selectedPositions = [...adaptersPositions, selectedPortLinePosition].sort(
145
- (y1: number, y2: number) => y1 - y2
145
+ (y1: number, y2: number) => y1 - y2
146
146
  )
147
147
  }
148
148
 
@@ -160,55 +160,55 @@ export const getSelectPortDataFunc = (
160
160
  }
161
161
 
162
162
  export const countAdaptersHeight = (
163
- diagramData: UI_I_DiagramData | null
163
+ diagramData: UI_I_DiagramData | null
164
164
  ): UI_I_AdaptersHeight => {
165
165
  const toggle: boolean = !!diagramData?.physicalAdapters?.toggle
166
166
  const adaptersCount: number =
167
- diagramData?.physicalAdapters?.adapters.length || 0
167
+ diagramData?.physicalAdapters?.adapters.length || 0
168
168
 
169
169
  return {
170
170
  height:
171
- UI_E_PositionsY.ADAPTER_FROM_RECT_TOP +
172
- (adaptersCount === 0
173
- ? UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT
174
- : toggle
175
- ? adaptersCount * UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT
176
- : 0) +
177
- UI_E_PositionsY.SPACE_FROM_RECT_BOTTOM,
171
+ UI_E_PositionsY.ADAPTER_FROM_RECT_TOP +
172
+ (adaptersCount === 0
173
+ ? UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT
174
+ : toggle
175
+ ? adaptersCount * UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT
176
+ : 0) +
177
+ UI_E_PositionsY.SPACE_FROM_RECT_BOTTOM,
178
178
  toggle,
179
179
  adaptersCount,
180
180
  }
181
181
  }
182
182
 
183
183
  export const getAdaptersPositions = (
184
- diagramData: UI_I_DiagramData | null,
185
- height: number
184
+ diagramData: UI_I_DiagramData | null,
185
+ height: number
186
186
  ): UI_I_AdaptersPositions => {
187
187
  const titlePosition: number =
188
- UI_E_PositionsY.DIAGRAM_TOP +
189
- UI_E_PositionsY.BETWEEN_RECTS +
190
- UI_E_PositionsY.TITLE_FROM_RECT_TOP
188
+ UI_E_PositionsY.DIAGRAM_TOP +
189
+ UI_E_PositionsY.BETWEEN_RECTS +
190
+ UI_E_PositionsY.TITLE_FROM_RECT_TOP
191
191
 
192
192
  const rectPosition: number =
193
- UI_E_PositionsY.DIAGRAM_TOP + UI_E_PositionsY.BETWEEN_RECTS
193
+ UI_E_PositionsY.DIAGRAM_TOP + UI_E_PositionsY.BETWEEN_RECTS
194
194
 
195
195
  const adaptersConnectLineY: number = rectPosition + height / 2
196
196
 
197
197
  const adapters: UI_T_Adapters[] | null =
198
- diagramData?.physicalAdapters?.adapters.map(
199
- (adapter: UI_I_Adapter, index: number) => {
200
- const adapterPosition: number =
201
- UI_E_PositionsY.DIAGRAM_TOP +
202
- UI_E_PositionsY.BETWEEN_RECTS +
203
- UI_E_PositionsY.ADAPTER_FROM_RECT_TOP +
204
- UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT * index
205
-
206
- return {
207
- ...adapter,
208
- adapterPosition,
209
- }
210
- }
211
- ) || null
198
+ diagramData?.physicalAdapters?.adapters.map(
199
+ (adapter: UI_I_Adapter, index: number) => {
200
+ const adapterPosition: number =
201
+ UI_E_PositionsY.DIAGRAM_TOP +
202
+ UI_E_PositionsY.BETWEEN_RECTS +
203
+ UI_E_PositionsY.ADAPTER_FROM_RECT_TOP +
204
+ UI_E_PositionsY.SINGLE_ADAPTER_HEIGHT * index
205
+
206
+ return {
207
+ ...adapter,
208
+ adapterPosition,
209
+ }
210
+ }
211
+ ) || null
212
212
 
213
213
  return {
214
214
  titlePosition,
@@ -219,10 +219,10 @@ export const getAdaptersPositions = (
219
219
  }
220
220
 
221
221
  export const makeSwitchSendData = (
222
- data: UI_I_DiagramData,
223
- adapterStatus: UI_I_AdapterStatus
224
- ): API_UI_I_SwitchItem | void => {
225
- if(!data.networking) return
222
+ data: UI_I_DiagramData,
223
+ adapterStatus: UI_I_AdapterStatus
224
+ ): API_UI_I_SwitchItem | null => {
225
+ if (!data.networking) return null
226
226
 
227
227
  return {
228
228
  id: data.id,