bfg-common 1.6.68 → 1.6.69
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,461 +1,461 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
:class="{
|
|
4
|
-
'diagram-container-new': isNewView,
|
|
5
|
-
'diagram-container': !isNewView,
|
|
6
|
-
'diagram-in-portlet': props.inPortlet,
|
|
7
|
-
}"
|
|
8
|
-
>
|
|
9
|
-
<common-diagram-main-header
|
|
10
|
-
v-if="!props.inPortlet"
|
|
11
|
-
:project="props.project"
|
|
12
|
-
:is-show-diagram="props.isShowDiagram"
|
|
13
|
-
:diagram-name="props.diagramData.diagramName"
|
|
14
|
-
:test-id="props.diagramData.testId"
|
|
15
|
-
@toggle-diagram="emits('toggle-diagram')"
|
|
16
|
-
@show-modal="onShowModal"
|
|
17
|
-
/>
|
|
18
|
-
|
|
19
|
-
<div
|
|
20
|
-
:class="[
|
|
21
|
-
'diagrams',
|
|
22
|
-
{
|
|
23
|
-
'is-show-diagram': props.isShowDiagram,
|
|
24
|
-
},
|
|
25
|
-
]"
|
|
26
|
-
>
|
|
27
|
-
<div class="diagram-second-container">
|
|
28
|
-
<svg
|
|
29
|
-
v-if="props.diagramData && props.isShowDiagram"
|
|
30
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
31
|
-
:height="diagramHeight"
|
|
32
|
-
:width="diagramWidth"
|
|
33
|
-
:viewBox="viewBox"
|
|
34
|
-
:preserveAspectRatio="preserveAspectRatio"
|
|
35
|
-
:class="svgClasses"
|
|
36
|
-
@click.capture="onClickDiagram"
|
|
37
|
-
>
|
|
38
|
-
<common-diagram-main-switch
|
|
39
|
-
:networks-count="props.networksCount"
|
|
40
|
-
:main-rect-height="props.mainRectHeight"
|
|
41
|
-
:main-switch-line="props.mainSwitchLine"
|
|
42
|
-
:selected-main-line="props.selectedMainLine"
|
|
43
|
-
:is-visible-line="hasActiveAdapter"
|
|
44
|
-
:is-selected-linked-with-adapter="isSelectedLinkedWithAdapter"
|
|
45
|
-
:adapter-line-y="props.adaptersWithPositions.adaptersConnectLineY"
|
|
46
|
-
:first-and-last-network-lines-y="firstAndLastNetworkLinesY"
|
|
47
|
-
:networks-with-positions="props.networksWithPositions"
|
|
48
|
-
/>
|
|
49
|
-
<common-diagram-main-adapter
|
|
50
|
-
:networks-count="props.networksCount"
|
|
51
|
-
:adapters-with-positions="props.adaptersWithPositions"
|
|
52
|
-
:selected-main-line="props.selectedMainLine"
|
|
53
|
-
:selected-port="props.selectedPort"
|
|
54
|
-
:selected-adapter="props.selectedAdapter"
|
|
55
|
-
:selected-network="props.selectedNetwork"
|
|
56
|
-
:is-visible-line="hasActiveAdapter"
|
|
57
|
-
:is-dark-mode="props.isDarkMode"
|
|
58
|
-
:test-id="props.diagramData.testId"
|
|
59
|
-
:is-selected-linked-with-adapter="isSelectedLinkedWithAdapter"
|
|
60
|
-
:networks-with-positions="props.networksWithPositions"
|
|
61
|
-
:first-and-last-network-lines-y="firstAndLastNetworkLinesY"
|
|
62
|
-
:in-network-lines-y="inNetworkLinesY"
|
|
63
|
-
@toggle-adapters="onToggleAdapters"
|
|
64
|
-
@select-adapter="onSelectAdapter"
|
|
65
|
-
@show-modal="onShowModal"
|
|
66
|
-
/>
|
|
67
|
-
<template v-if="!!props.networksWithPositions.length">
|
|
68
|
-
<template
|
|
69
|
-
v-for="network in props.networksWithPositions"
|
|
70
|
-
:key="network.id"
|
|
71
|
-
>
|
|
72
|
-
<common-diagram-main-network
|
|
73
|
-
:network="network"
|
|
74
|
-
:selected-port="props.selectedPort"
|
|
75
|
-
:selected-adapter="props.selectedAdapter"
|
|
76
|
-
:selected-network="props.selectedNetwork"
|
|
77
|
-
:selected-main-line="props.selectedMainLine"
|
|
78
|
-
:diagram-id="props.diagramData.id"
|
|
79
|
-
:in-portlet="props.inPortlet"
|
|
80
|
-
:is-visible-line="hasActiveAdapter"
|
|
81
|
-
:is-dark-mode="props.isDarkMode"
|
|
82
|
-
:first-and-last-network-lines-y="firstAndLastNetworkLinesY"
|
|
83
|
-
:adapter-line-y="
|
|
84
|
-
props.adaptersWithPositions.adaptersConnectLineY
|
|
85
|
-
"
|
|
86
|
-
:adapters-positions-y="adaptersPositionsY"
|
|
87
|
-
@toggle-ports="onTogglePorts"
|
|
88
|
-
@select-port="onSelectPort"
|
|
89
|
-
@select-network="onSelectNetwork"
|
|
90
|
-
@show-modal="onShowModal"
|
|
91
|
-
/>
|
|
92
|
-
</template>
|
|
93
|
-
</template>
|
|
94
|
-
<template v-else>
|
|
95
|
-
<common-diagram-main-network-no-network />
|
|
96
|
-
</template>
|
|
97
|
-
<common-diagram-main-switch-selected
|
|
98
|
-
:selected-switch-line-y="props.selectedSwitchLineY"
|
|
99
|
-
:is-visible-line="hasActiveAdapter && isSelectedLinkedWithAdapter"
|
|
100
|
-
:adapters-positions-y="adaptersPositionsY"
|
|
101
|
-
:adapter-line-y="props.adaptersWithPositions.adaptersConnectLineY"
|
|
102
|
-
:is-highlighted-adapter-line="isHighlightedAdapterLine"
|
|
103
|
-
:in-network-lines-y="inNetworkLinesY"
|
|
104
|
-
/>
|
|
105
|
-
</svg>
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
<div
|
|
110
|
-
v-if="isNewView && props.isShowDiagram && !props.inPortlet"
|
|
111
|
-
class="virtual-switch-remove"
|
|
112
|
-
>
|
|
113
|
-
<ui-button
|
|
114
|
-
:test-id="`${props.diagramData.testId}-remove`"
|
|
115
|
-
variant="text"
|
|
116
|
-
type="error"
|
|
117
|
-
is-without-sizes
|
|
118
|
-
is-without-height
|
|
119
|
-
v-permission="'Networks.RemoveSwitch'"
|
|
120
|
-
@click="emits('show-modal', 'switch-remove')"
|
|
121
|
-
>
|
|
122
|
-
<span class="virtual-switch-remove-btn">
|
|
123
|
-
<ui-icon name="delete" width="20" height="20" />
|
|
124
|
-
{{ localization.common.remove }}
|
|
125
|
-
</span>
|
|
126
|
-
</ui-button>
|
|
127
|
-
</div>
|
|
128
|
-
</template>
|
|
129
|
-
|
|
130
|
-
<script setup lang="ts">
|
|
131
|
-
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
132
|
-
import type {
|
|
133
|
-
UI_I_AdaptersWithPositions,
|
|
134
|
-
UI_I_DiagramData,
|
|
135
|
-
UI_I_ModalsInitialData,
|
|
136
|
-
UI_I_NetworksWithPositions,
|
|
137
|
-
UI_I_SelectedAdapter,
|
|
138
|
-
UI_I_SelectedPort,
|
|
139
|
-
UI_I_SwitchLine,
|
|
140
|
-
UI_I_Network,
|
|
141
|
-
} from '~/components/common/diagramMain/lib/models/interfaces'
|
|
142
|
-
import type { UI_T_Project } from '~/lib/models/types'
|
|
143
|
-
import { UI_E_PositionsY } from '~/components/common/diagramMain/lib/models/enums'
|
|
144
|
-
|
|
145
|
-
const props = defineProps<{
|
|
146
|
-
diagramData: UI_I_DiagramData
|
|
147
|
-
isShowDiagram: boolean
|
|
148
|
-
inPortlet: boolean
|
|
149
|
-
networksWithPositions: UI_I_NetworksWithPositions[]
|
|
150
|
-
mainRectHeight: number
|
|
151
|
-
mainSwitchLine: UI_I_SwitchLine
|
|
152
|
-
selectedMainLine: boolean
|
|
153
|
-
adaptersWithPositions: UI_I_AdaptersWithPositions
|
|
154
|
-
selectedPort: UI_I_SelectedPort
|
|
155
|
-
selectedAdapter: UI_I_SelectedAdapter
|
|
156
|
-
selectedNetwork: string
|
|
157
|
-
selectedSwitchLineY: UI_I_SwitchLine
|
|
158
|
-
isDarkMode: boolean
|
|
159
|
-
networksCount: number
|
|
160
|
-
project: UI_T_Project
|
|
161
|
-
}>()
|
|
162
|
-
|
|
163
|
-
const emits = defineEmits<{
|
|
164
|
-
(event: 'click-diagram', ev: MouseEvent): void
|
|
165
|
-
(event: 'toggle-adapters'): void
|
|
166
|
-
(event: 'select-adapter', adapterId: string): void
|
|
167
|
-
(
|
|
168
|
-
event: 'show-modal',
|
|
169
|
-
value: string,
|
|
170
|
-
properties?: UI_I_ModalsInitialData
|
|
171
|
-
): void
|
|
172
|
-
(
|
|
173
|
-
event: 'toggle-ports',
|
|
174
|
-
id: string,
|
|
175
|
-
newState: boolean,
|
|
176
|
-
diagramId: string
|
|
177
|
-
): void
|
|
178
|
-
(event: 'select-port', networkId: string, portId: string): void
|
|
179
|
-
(event: 'select-network', networkId: string): void
|
|
180
|
-
(event: 'toggle-diagram'): void
|
|
181
|
-
}>()
|
|
182
|
-
|
|
183
|
-
const { $store }: any = useNuxtApp()
|
|
184
|
-
|
|
185
|
-
const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
|
|
186
|
-
|
|
187
|
-
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
188
|
-
|
|
189
|
-
const inNetworkLinesY = computed(() => {
|
|
190
|
-
const linesY = []
|
|
191
|
-
props.networksWithPositions.forEach((net, index) => {
|
|
192
|
-
;(!!props.selectedAdapter.connectedPorts.find(
|
|
193
|
-
(net2) => net2.networkId === net.id && net2.ports.length === 0
|
|
194
|
-
) ||
|
|
195
|
-
props.selectedNetwork === net.id) &&
|
|
196
|
-
linesY.push(net.connectLineY)
|
|
197
|
-
|
|
198
|
-
net.toggle
|
|
199
|
-
? net.ports.forEach((port) => {
|
|
200
|
-
;((props.selectedPort.portId === port.id &&
|
|
201
|
-
props.selectedPort.networkId === net.id &&
|
|
202
|
-
net.activeAdapters.length > 0) ||
|
|
203
|
-
!!props.selectedAdapter.connectedPorts.find(
|
|
204
|
-
(net2) =>
|
|
205
|
-
net2.networkId === net.id && net2.ports.includes(port.id)
|
|
206
|
-
)) &&
|
|
207
|
-
linesY.push(port.portPosition + 7.5)
|
|
208
|
-
})
|
|
209
|
-
: !!props.selectedAdapter.connectedPorts.find(
|
|
210
|
-
(net2) => net2.networkId === net.id && net2.ports.length !== 0
|
|
211
|
-
) && linesY.push(net.portsPosition + 7.5)
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
return linesY.sort((a, b) => a - b)
|
|
215
|
-
})
|
|
216
|
-
|
|
217
|
-
const isOpenedAdapterBlockAndNoSelectedNetwork = computed<boolean>(
|
|
218
|
-
() =>
|
|
219
|
-
!props.adaptersWithPositions.toggle && props.selectedPort.networkId !== '-1'
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
const hasNoAdaptersAndNoSelectedNetwork = computed<boolean>(() => {
|
|
223
|
-
return (
|
|
224
|
-
props.adaptersWithPositions.adapters?.length === 0 &&
|
|
225
|
-
props.selectedNetwork !== '-1'
|
|
226
|
-
)
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
const isHighlightedOptimizePart = computed(
|
|
230
|
-
() =>
|
|
231
|
-
!props.selectedMainLine && !isOpenedAdapterBlockAndNoSelectedNetwork.value
|
|
232
|
-
)
|
|
233
|
-
|
|
234
|
-
const isHighlightedAdapterLine = computed<boolean>(
|
|
235
|
-
() =>
|
|
236
|
-
isSelectedLinkedWithAdapter.value &&
|
|
237
|
-
!(
|
|
238
|
-
isHighlightedOptimizePart.value &&
|
|
239
|
-
!hasNoAdaptersAndNoSelectedNetwork.value
|
|
240
|
-
)
|
|
241
|
-
)
|
|
242
|
-
|
|
243
|
-
const firstAndLastNetworkLinesY = computed(() => {
|
|
244
|
-
const networkLinesY = props.networksWithPositions
|
|
245
|
-
.filter((n) => n.activeAdapters.length > 0 && n.state.state !== 3)
|
|
246
|
-
.map((n) => n.connectLineY)
|
|
247
|
-
.sort((a, b) => a - b)
|
|
248
|
-
|
|
249
|
-
return {
|
|
250
|
-
firstNetworkY: networkLinesY[0],
|
|
251
|
-
lastNetworkY: networkLinesY[networkLinesY.length - 1],
|
|
252
|
-
}
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
const adaptersPositionsY = computed(() =>
|
|
256
|
-
props.adaptersWithPositions.adapters.reduce((result, ad) => {
|
|
257
|
-
let isAdapterActiveOnAnyNetwork = false
|
|
258
|
-
props.networksWithPositions.forEach(
|
|
259
|
-
(network: UI_I_NetworksWithPositions) =>
|
|
260
|
-
network.activeAdapters.includes(props.selectedAdapter.adapterId) &&
|
|
261
|
-
(isAdapterActiveOnAnyNetwork = true)
|
|
262
|
-
)
|
|
263
|
-
|
|
264
|
-
const isVisible =
|
|
265
|
-
(props.selectedPort.activeAdapters.includes(ad.id) ||
|
|
266
|
-
(props.selectedAdapter.adapterId === ad.id &&
|
|
267
|
-
isAdapterActiveOnAnyNetwork)) &&
|
|
268
|
-
!!props.networksCount
|
|
269
|
-
|
|
270
|
-
if (isVisible) {
|
|
271
|
-
return [...result, ad.adapterPosition]
|
|
272
|
-
}
|
|
273
|
-
return result
|
|
274
|
-
}, [])
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
const svgClasses = computed(() => [
|
|
278
|
-
'diagram-svg',
|
|
279
|
-
{
|
|
280
|
-
'diagram-portlet': !props.inPortlet,
|
|
281
|
-
},
|
|
282
|
-
])
|
|
283
|
-
|
|
284
|
-
const preserveAspectRatio = computed<string | undefined>(() =>
|
|
285
|
-
props.inPortlet ? 'xMinYMin' : undefined
|
|
286
|
-
)
|
|
287
|
-
|
|
288
|
-
const svgHeight = computed<number>(
|
|
289
|
-
() =>
|
|
290
|
-
UI_E_PositionsY.DIAGRAM_TOP +
|
|
291
|
-
props.mainRectHeight +
|
|
292
|
-
UI_E_PositionsY.DIAGRAM_BOTTOM
|
|
293
|
-
)
|
|
294
|
-
|
|
295
|
-
const viewBox = computed<string>(() =>
|
|
296
|
-
props.inPortlet ? '0 0 725 1' : `0 0 725 ${svgHeight.value}`
|
|
297
|
-
)
|
|
298
|
-
|
|
299
|
-
const diagramHeight = computed<number>(() =>
|
|
300
|
-
props.inPortlet ? svgHeight.value / 1.28 : svgHeight.value
|
|
301
|
-
)
|
|
302
|
-
|
|
303
|
-
const diagramWidth = computed<number>(() => (props.inPortlet ? 560 : 725))
|
|
304
|
-
|
|
305
|
-
const hasActiveAdapter = computed<boolean>(() => {
|
|
306
|
-
let flag = false
|
|
307
|
-
props.diagramData?.networks.forEach(
|
|
308
|
-
(network: UI_I_Network) =>
|
|
309
|
-
network.activeAdapters.length > 0 && (flag = true)
|
|
310
|
-
)
|
|
311
|
-
return flag
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
const isSelectedLinkedWithAdapter = computed<boolean>(() => {
|
|
315
|
-
if (props.selectedNetwork && props.selectedNetwork !== '-1') {
|
|
316
|
-
const selectedNetworkData = props.networksWithPositions.find(
|
|
317
|
-
(network: UI_I_NetworksWithPositions) =>
|
|
318
|
-
network.id === props.selectedNetwork
|
|
319
|
-
)
|
|
320
|
-
|
|
321
|
-
if (!selectedNetworkData) return false
|
|
322
|
-
|
|
323
|
-
return (
|
|
324
|
-
selectedNetworkData.activeAdapters.length > 0 &&
|
|
325
|
-
selectedNetworkData.state.state !== 3
|
|
326
|
-
)
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (props.selectedPort.portId && props.selectedPort.portId !== '-1') {
|
|
330
|
-
const selectedNetworkData = props.networksWithPositions.find(
|
|
331
|
-
(network: UI_I_NetworksWithPositions) =>
|
|
332
|
-
network.id === props.selectedPort.networkId
|
|
333
|
-
)
|
|
334
|
-
|
|
335
|
-
if (!selectedNetworkData) return false
|
|
336
|
-
|
|
337
|
-
return (
|
|
338
|
-
selectedNetworkData.activeAdapters.length > 0 &&
|
|
339
|
-
selectedNetworkData.state.state !== 3
|
|
340
|
-
)
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (props.selectedAdapter.adapterId !== '-1' || props.selectedMainLine)
|
|
344
|
-
return true
|
|
345
|
-
|
|
346
|
-
return false
|
|
347
|
-
})
|
|
348
|
-
|
|
349
|
-
const onClickDiagram = (ev: MouseEvent) => emits('click-diagram', ev)
|
|
350
|
-
const onToggleAdapters = () => emits('toggle-adapters')
|
|
351
|
-
const onSelectAdapter = (adapterId: string) =>
|
|
352
|
-
emits('select-adapter', adapterId)
|
|
353
|
-
const onShowModal = (value: string, properties?: UI_I_ModalsInitialData) =>
|
|
354
|
-
emits('show-modal', value, properties)
|
|
355
|
-
const onTogglePorts = (
|
|
356
|
-
id: string,
|
|
357
|
-
isToggle: boolean,
|
|
358
|
-
diagramId: string
|
|
359
|
-
): void => {
|
|
360
|
-
emits('toggle-ports', id, isToggle, diagramId)
|
|
361
|
-
}
|
|
362
|
-
const onSelectPort = (networkId: string, portId: string): void => {
|
|
363
|
-
emits('select-port', networkId, portId)
|
|
364
|
-
}
|
|
365
|
-
const onSelectNetwork = (networkId: string): void => {
|
|
366
|
-
emits('select-network', networkId)
|
|
367
|
-
}
|
|
368
|
-
</script>
|
|
369
|
-
|
|
370
|
-
<style scoped lang="scss">
|
|
371
|
-
.diagram {
|
|
372
|
-
&-container {
|
|
373
|
-
//display: flex;
|
|
374
|
-
//justify-content: center;
|
|
375
|
-
.diagram-second-container {
|
|
376
|
-
display: flex;
|
|
377
|
-
justify-content: center;
|
|
378
|
-
min-width: 725px;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
&.diagram-in-portlet {
|
|
382
|
-
.diagram-second-container {
|
|
383
|
-
min-width: 560px;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
.diagram-portlet {
|
|
388
|
-
margin-top: 10px;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
.diagram {
|
|
394
|
-
&-container-new:not(.diagram-in-portlet) {
|
|
395
|
-
.diagrams.is-show-diagram {
|
|
396
|
-
margin-top: 24px;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
.diagram-second-container {
|
|
400
|
-
overflow-x: auto;
|
|
401
|
-
display: flex;
|
|
402
|
-
justify-content: center;
|
|
403
|
-
min-width: 760px;
|
|
404
|
-
|
|
405
|
-
&.diagram-in-portlet {
|
|
406
|
-
.diagram-second-container {
|
|
407
|
-
min-width: 560px;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
.diagram-svg {
|
|
412
|
-
margin: 22.5px 17.5px;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
&-container-new.diagram-in-portlet {
|
|
417
|
-
.diagram-portlet {
|
|
418
|
-
margin-top: 10px;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
.diagrams {
|
|
424
|
-
overflow-y: auto;
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
.virtual-switch-remove {
|
|
428
|
-
padding: 16px 0 0;
|
|
429
|
-
display: flex;
|
|
430
|
-
justify-content: flex-end;
|
|
431
|
-
|
|
432
|
-
&-btn {
|
|
433
|
-
height: 20px;
|
|
434
|
-
font-weight: 500;
|
|
435
|
-
font-size: 14px;
|
|
436
|
-
line-height: 17px;
|
|
437
|
-
letter-spacing: 0;
|
|
438
|
-
display: flex;
|
|
439
|
-
align-items: center;
|
|
440
|
-
column-gap: 8px;
|
|
441
|
-
color: var(--text-red);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
</style>
|
|
445
|
-
<style lang="scss">
|
|
446
|
-
.diagram-actions__popup.navbar-dropdown-menu {
|
|
447
|
-
transform: translate(-30px, -20px);
|
|
448
|
-
|
|
449
|
-
.btn {
|
|
450
|
-
border-radius: 0;
|
|
451
|
-
border-bottom: 1px solid transparent;
|
|
452
|
-
|
|
453
|
-
span {
|
|
454
|
-
font-size: 14px;
|
|
455
|
-
}
|
|
456
|
-
&:active {
|
|
457
|
-
box-shadow: none;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="{
|
|
4
|
+
'diagram-container-new': isNewView,
|
|
5
|
+
'diagram-container': !isNewView,
|
|
6
|
+
'diagram-in-portlet': props.inPortlet,
|
|
7
|
+
}"
|
|
8
|
+
>
|
|
9
|
+
<common-diagram-main-header
|
|
10
|
+
v-if="!props.inPortlet"
|
|
11
|
+
:project="props.project"
|
|
12
|
+
:is-show-diagram="props.isShowDiagram"
|
|
13
|
+
:diagram-name="props.diagramData.diagramName"
|
|
14
|
+
:test-id="props.diagramData.testId"
|
|
15
|
+
@toggle-diagram="emits('toggle-diagram')"
|
|
16
|
+
@show-modal="onShowModal"
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<div
|
|
20
|
+
:class="[
|
|
21
|
+
'diagrams',
|
|
22
|
+
{
|
|
23
|
+
'is-show-diagram': props.isShowDiagram,
|
|
24
|
+
},
|
|
25
|
+
]"
|
|
26
|
+
>
|
|
27
|
+
<div class="diagram-second-container">
|
|
28
|
+
<svg
|
|
29
|
+
v-if="props.diagramData && props.isShowDiagram"
|
|
30
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
31
|
+
:height="diagramHeight"
|
|
32
|
+
:width="diagramWidth"
|
|
33
|
+
:viewBox="viewBox"
|
|
34
|
+
:preserveAspectRatio="preserveAspectRatio"
|
|
35
|
+
:class="svgClasses"
|
|
36
|
+
@click.capture="onClickDiagram"
|
|
37
|
+
>
|
|
38
|
+
<common-diagram-main-switch
|
|
39
|
+
:networks-count="props.networksCount"
|
|
40
|
+
:main-rect-height="props.mainRectHeight"
|
|
41
|
+
:main-switch-line="props.mainSwitchLine"
|
|
42
|
+
:selected-main-line="props.selectedMainLine"
|
|
43
|
+
:is-visible-line="hasActiveAdapter"
|
|
44
|
+
:is-selected-linked-with-adapter="isSelectedLinkedWithAdapter"
|
|
45
|
+
:adapter-line-y="props.adaptersWithPositions.adaptersConnectLineY"
|
|
46
|
+
:first-and-last-network-lines-y="firstAndLastNetworkLinesY"
|
|
47
|
+
:networks-with-positions="props.networksWithPositions"
|
|
48
|
+
/>
|
|
49
|
+
<common-diagram-main-adapter
|
|
50
|
+
:networks-count="props.networksCount"
|
|
51
|
+
:adapters-with-positions="props.adaptersWithPositions"
|
|
52
|
+
:selected-main-line="props.selectedMainLine"
|
|
53
|
+
:selected-port="props.selectedPort"
|
|
54
|
+
:selected-adapter="props.selectedAdapter"
|
|
55
|
+
:selected-network="props.selectedNetwork"
|
|
56
|
+
:is-visible-line="hasActiveAdapter"
|
|
57
|
+
:is-dark-mode="props.isDarkMode"
|
|
58
|
+
:test-id="props.diagramData.testId"
|
|
59
|
+
:is-selected-linked-with-adapter="isSelectedLinkedWithAdapter"
|
|
60
|
+
:networks-with-positions="props.networksWithPositions"
|
|
61
|
+
:first-and-last-network-lines-y="firstAndLastNetworkLinesY"
|
|
62
|
+
:in-network-lines-y="inNetworkLinesY"
|
|
63
|
+
@toggle-adapters="onToggleAdapters"
|
|
64
|
+
@select-adapter="onSelectAdapter"
|
|
65
|
+
@show-modal="onShowModal"
|
|
66
|
+
/>
|
|
67
|
+
<template v-if="!!props.networksWithPositions.length">
|
|
68
|
+
<template
|
|
69
|
+
v-for="network in props.networksWithPositions"
|
|
70
|
+
:key="network.id"
|
|
71
|
+
>
|
|
72
|
+
<common-diagram-main-network
|
|
73
|
+
:network="network"
|
|
74
|
+
:selected-port="props.selectedPort"
|
|
75
|
+
:selected-adapter="props.selectedAdapter"
|
|
76
|
+
:selected-network="props.selectedNetwork"
|
|
77
|
+
:selected-main-line="props.selectedMainLine"
|
|
78
|
+
:diagram-id="props.diagramData.id"
|
|
79
|
+
:in-portlet="props.inPortlet"
|
|
80
|
+
:is-visible-line="hasActiveAdapter"
|
|
81
|
+
:is-dark-mode="props.isDarkMode"
|
|
82
|
+
:first-and-last-network-lines-y="firstAndLastNetworkLinesY"
|
|
83
|
+
:adapter-line-y="
|
|
84
|
+
props.adaptersWithPositions.adaptersConnectLineY
|
|
85
|
+
"
|
|
86
|
+
:adapters-positions-y="adaptersPositionsY"
|
|
87
|
+
@toggle-ports="onTogglePorts"
|
|
88
|
+
@select-port="onSelectPort"
|
|
89
|
+
@select-network="onSelectNetwork"
|
|
90
|
+
@show-modal="onShowModal"
|
|
91
|
+
/>
|
|
92
|
+
</template>
|
|
93
|
+
</template>
|
|
94
|
+
<template v-else>
|
|
95
|
+
<common-diagram-main-network-no-network />
|
|
96
|
+
</template>
|
|
97
|
+
<common-diagram-main-switch-selected
|
|
98
|
+
:selected-switch-line-y="props.selectedSwitchLineY"
|
|
99
|
+
:is-visible-line="hasActiveAdapter && isSelectedLinkedWithAdapter"
|
|
100
|
+
:adapters-positions-y="adaptersPositionsY"
|
|
101
|
+
:adapter-line-y="props.adaptersWithPositions.adaptersConnectLineY"
|
|
102
|
+
:is-highlighted-adapter-line="isHighlightedAdapterLine"
|
|
103
|
+
:in-network-lines-y="inNetworkLinesY"
|
|
104
|
+
/>
|
|
105
|
+
</svg>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<div
|
|
110
|
+
v-if="isNewView && props.isShowDiagram && !props.inPortlet"
|
|
111
|
+
class="virtual-switch-remove"
|
|
112
|
+
>
|
|
113
|
+
<ui-button
|
|
114
|
+
:test-id="`${props.diagramData.testId}-remove`"
|
|
115
|
+
variant="text"
|
|
116
|
+
type="error"
|
|
117
|
+
is-without-sizes
|
|
118
|
+
is-without-height
|
|
119
|
+
v-permission="'Networks.RemoveSwitch'"
|
|
120
|
+
@click="emits('show-modal', 'switch-remove')"
|
|
121
|
+
>
|
|
122
|
+
<span class="virtual-switch-remove-btn">
|
|
123
|
+
<ui-icon name="delete" width="20" height="20" />
|
|
124
|
+
{{ localization.common.remove }}
|
|
125
|
+
</span>
|
|
126
|
+
</ui-button>
|
|
127
|
+
</div>
|
|
128
|
+
</template>
|
|
129
|
+
|
|
130
|
+
<script setup lang="ts">
|
|
131
|
+
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
132
|
+
import type {
|
|
133
|
+
UI_I_AdaptersWithPositions,
|
|
134
|
+
UI_I_DiagramData,
|
|
135
|
+
UI_I_ModalsInitialData,
|
|
136
|
+
UI_I_NetworksWithPositions,
|
|
137
|
+
UI_I_SelectedAdapter,
|
|
138
|
+
UI_I_SelectedPort,
|
|
139
|
+
UI_I_SwitchLine,
|
|
140
|
+
UI_I_Network,
|
|
141
|
+
} from '~/components/common/diagramMain/lib/models/interfaces'
|
|
142
|
+
import type { UI_T_Project } from '~/lib/models/types'
|
|
143
|
+
import { UI_E_PositionsY } from '~/components/common/diagramMain/lib/models/enums'
|
|
144
|
+
|
|
145
|
+
const props = defineProps<{
|
|
146
|
+
diagramData: UI_I_DiagramData
|
|
147
|
+
isShowDiagram: boolean
|
|
148
|
+
inPortlet: boolean
|
|
149
|
+
networksWithPositions: UI_I_NetworksWithPositions[]
|
|
150
|
+
mainRectHeight: number
|
|
151
|
+
mainSwitchLine: UI_I_SwitchLine
|
|
152
|
+
selectedMainLine: boolean
|
|
153
|
+
adaptersWithPositions: UI_I_AdaptersWithPositions
|
|
154
|
+
selectedPort: UI_I_SelectedPort
|
|
155
|
+
selectedAdapter: UI_I_SelectedAdapter
|
|
156
|
+
selectedNetwork: string
|
|
157
|
+
selectedSwitchLineY: UI_I_SwitchLine
|
|
158
|
+
isDarkMode: boolean
|
|
159
|
+
networksCount: number
|
|
160
|
+
project: UI_T_Project
|
|
161
|
+
}>()
|
|
162
|
+
|
|
163
|
+
const emits = defineEmits<{
|
|
164
|
+
(event: 'click-diagram', ev: MouseEvent): void
|
|
165
|
+
(event: 'toggle-adapters'): void
|
|
166
|
+
(event: 'select-adapter', adapterId: string): void
|
|
167
|
+
(
|
|
168
|
+
event: 'show-modal',
|
|
169
|
+
value: string,
|
|
170
|
+
properties?: UI_I_ModalsInitialData
|
|
171
|
+
): void
|
|
172
|
+
(
|
|
173
|
+
event: 'toggle-ports',
|
|
174
|
+
id: string,
|
|
175
|
+
newState: boolean,
|
|
176
|
+
diagramId: string
|
|
177
|
+
): void
|
|
178
|
+
(event: 'select-port', networkId: string, portId: string): void
|
|
179
|
+
(event: 'select-network', networkId: string): void
|
|
180
|
+
(event: 'toggle-diagram'): void
|
|
181
|
+
}>()
|
|
182
|
+
|
|
183
|
+
const { $store }: any = useNuxtApp()
|
|
184
|
+
|
|
185
|
+
const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
|
|
186
|
+
|
|
187
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
188
|
+
|
|
189
|
+
const inNetworkLinesY = computed(() => {
|
|
190
|
+
const linesY = []
|
|
191
|
+
props.networksWithPositions.forEach((net, index) => {
|
|
192
|
+
;(!!props.selectedAdapter.connectedPorts.find(
|
|
193
|
+
(net2) => net2.networkId === net.id && net2.ports.length === 0
|
|
194
|
+
) ||
|
|
195
|
+
props.selectedNetwork === net.id) &&
|
|
196
|
+
linesY.push(net.connectLineY)
|
|
197
|
+
|
|
198
|
+
net.toggle
|
|
199
|
+
? net.ports.forEach((port) => {
|
|
200
|
+
;((props.selectedPort.portId === port.id &&
|
|
201
|
+
props.selectedPort.networkId === net.id &&
|
|
202
|
+
net.activeAdapters.length > 0) ||
|
|
203
|
+
!!props.selectedAdapter.connectedPorts.find(
|
|
204
|
+
(net2) =>
|
|
205
|
+
net2.networkId === net.id && net2.ports.includes(port.id)
|
|
206
|
+
)) &&
|
|
207
|
+
linesY.push(port.portPosition + 7.5)
|
|
208
|
+
})
|
|
209
|
+
: !!props.selectedAdapter.connectedPorts.find(
|
|
210
|
+
(net2) => net2.networkId === net.id && net2.ports.length !== 0
|
|
211
|
+
) && linesY.push(net.portsPosition + 7.5)
|
|
212
|
+
})
|
|
213
|
+
|
|
214
|
+
return linesY.sort((a, b) => a - b)
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
const isOpenedAdapterBlockAndNoSelectedNetwork = computed<boolean>(
|
|
218
|
+
() =>
|
|
219
|
+
!props.adaptersWithPositions.toggle && props.selectedPort.networkId !== '-1'
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
const hasNoAdaptersAndNoSelectedNetwork = computed<boolean>(() => {
|
|
223
|
+
return (
|
|
224
|
+
props.adaptersWithPositions.adapters?.length === 0 &&
|
|
225
|
+
props.selectedNetwork !== '-1'
|
|
226
|
+
)
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
const isHighlightedOptimizePart = computed(
|
|
230
|
+
() =>
|
|
231
|
+
!props.selectedMainLine && !isOpenedAdapterBlockAndNoSelectedNetwork.value
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
const isHighlightedAdapterLine = computed<boolean>(
|
|
235
|
+
() =>
|
|
236
|
+
isSelectedLinkedWithAdapter.value &&
|
|
237
|
+
!(
|
|
238
|
+
isHighlightedOptimizePart.value &&
|
|
239
|
+
!hasNoAdaptersAndNoSelectedNetwork.value
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
const firstAndLastNetworkLinesY = computed(() => {
|
|
244
|
+
const networkLinesY = props.networksWithPositions
|
|
245
|
+
.filter((n) => n.activeAdapters.length > 0 && n.state.state !== 3)
|
|
246
|
+
.map((n) => n.connectLineY)
|
|
247
|
+
.sort((a, b) => a - b)
|
|
248
|
+
|
|
249
|
+
return {
|
|
250
|
+
firstNetworkY: networkLinesY[0],
|
|
251
|
+
lastNetworkY: networkLinesY[networkLinesY.length - 1],
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
const adaptersPositionsY = computed(() =>
|
|
256
|
+
props.adaptersWithPositions.adapters.reduce((result, ad) => {
|
|
257
|
+
let isAdapterActiveOnAnyNetwork = false
|
|
258
|
+
props.networksWithPositions.forEach(
|
|
259
|
+
(network: UI_I_NetworksWithPositions) =>
|
|
260
|
+
network.activeAdapters.includes(props.selectedAdapter.adapterId) &&
|
|
261
|
+
(isAdapterActiveOnAnyNetwork = true)
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
const isVisible =
|
|
265
|
+
(props.selectedPort.activeAdapters.includes(ad.id) ||
|
|
266
|
+
(props.selectedAdapter.adapterId === ad.id &&
|
|
267
|
+
isAdapterActiveOnAnyNetwork)) &&
|
|
268
|
+
!!props.networksCount
|
|
269
|
+
|
|
270
|
+
if (isVisible) {
|
|
271
|
+
return [...result, ad.adapterPosition]
|
|
272
|
+
}
|
|
273
|
+
return result
|
|
274
|
+
}, [])
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
const svgClasses = computed(() => [
|
|
278
|
+
'diagram-svg',
|
|
279
|
+
{
|
|
280
|
+
'diagram-portlet': !props.inPortlet,
|
|
281
|
+
},
|
|
282
|
+
])
|
|
283
|
+
|
|
284
|
+
const preserveAspectRatio = computed<string | undefined>(() =>
|
|
285
|
+
props.inPortlet ? 'xMinYMin' : undefined
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
const svgHeight = computed<number>(
|
|
289
|
+
() =>
|
|
290
|
+
UI_E_PositionsY.DIAGRAM_TOP +
|
|
291
|
+
props.mainRectHeight +
|
|
292
|
+
UI_E_PositionsY.DIAGRAM_BOTTOM
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
const viewBox = computed<string>(() =>
|
|
296
|
+
props.inPortlet ? '0 0 725 1' : `0 0 725 ${svgHeight.value}`
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
const diagramHeight = computed<number>(() =>
|
|
300
|
+
props.inPortlet ? svgHeight.value / 1.28 : svgHeight.value
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
const diagramWidth = computed<number>(() => (props.inPortlet ? 560 : 725))
|
|
304
|
+
|
|
305
|
+
const hasActiveAdapter = computed<boolean>(() => {
|
|
306
|
+
let flag = false
|
|
307
|
+
props.diagramData?.networks.forEach(
|
|
308
|
+
(network: UI_I_Network) =>
|
|
309
|
+
network.activeAdapters.length > 0 && (flag = true)
|
|
310
|
+
)
|
|
311
|
+
return flag
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
const isSelectedLinkedWithAdapter = computed<boolean>(() => {
|
|
315
|
+
if (props.selectedNetwork && props.selectedNetwork !== '-1') {
|
|
316
|
+
const selectedNetworkData = props.networksWithPositions.find(
|
|
317
|
+
(network: UI_I_NetworksWithPositions) =>
|
|
318
|
+
network.id === props.selectedNetwork
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
if (!selectedNetworkData) return false
|
|
322
|
+
|
|
323
|
+
return (
|
|
324
|
+
selectedNetworkData.activeAdapters.length > 0 &&
|
|
325
|
+
selectedNetworkData.state.state !== 3
|
|
326
|
+
)
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (props.selectedPort.portId && props.selectedPort.portId !== '-1') {
|
|
330
|
+
const selectedNetworkData = props.networksWithPositions.find(
|
|
331
|
+
(network: UI_I_NetworksWithPositions) =>
|
|
332
|
+
network.id === props.selectedPort.networkId
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
if (!selectedNetworkData) return false
|
|
336
|
+
|
|
337
|
+
return (
|
|
338
|
+
selectedNetworkData.activeAdapters.length > 0 &&
|
|
339
|
+
selectedNetworkData.state.state !== 3
|
|
340
|
+
)
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (props.selectedAdapter.adapterId !== '-1' || props.selectedMainLine)
|
|
344
|
+
return true
|
|
345
|
+
|
|
346
|
+
return false
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
const onClickDiagram = (ev: MouseEvent) => emits('click-diagram', ev)
|
|
350
|
+
const onToggleAdapters = () => emits('toggle-adapters')
|
|
351
|
+
const onSelectAdapter = (adapterId: string) =>
|
|
352
|
+
emits('select-adapter', adapterId)
|
|
353
|
+
const onShowModal = (value: string, properties?: UI_I_ModalsInitialData) =>
|
|
354
|
+
emits('show-modal', value, properties)
|
|
355
|
+
const onTogglePorts = (
|
|
356
|
+
id: string,
|
|
357
|
+
isToggle: boolean,
|
|
358
|
+
diagramId: string
|
|
359
|
+
): void => {
|
|
360
|
+
emits('toggle-ports', id, isToggle, diagramId)
|
|
361
|
+
}
|
|
362
|
+
const onSelectPort = (networkId: string, portId: string): void => {
|
|
363
|
+
emits('select-port', networkId, portId)
|
|
364
|
+
}
|
|
365
|
+
const onSelectNetwork = (networkId: string): void => {
|
|
366
|
+
emits('select-network', networkId)
|
|
367
|
+
}
|
|
368
|
+
</script>
|
|
369
|
+
|
|
370
|
+
<style scoped lang="scss">
|
|
371
|
+
.diagram {
|
|
372
|
+
&-container {
|
|
373
|
+
//display: flex;
|
|
374
|
+
//justify-content: center;
|
|
375
|
+
.diagram-second-container {
|
|
376
|
+
display: flex;
|
|
377
|
+
justify-content: center;
|
|
378
|
+
min-width: 725px;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
&.diagram-in-portlet {
|
|
382
|
+
.diagram-second-container {
|
|
383
|
+
min-width: 560px;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.diagram-portlet {
|
|
388
|
+
margin-top: 10px;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.diagram {
|
|
394
|
+
&-container-new:not(.diagram-in-portlet) {
|
|
395
|
+
.diagrams.is-show-diagram {
|
|
396
|
+
margin-top: 24px;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.diagram-second-container {
|
|
400
|
+
overflow-x: auto;
|
|
401
|
+
display: flex;
|
|
402
|
+
justify-content: center;
|
|
403
|
+
min-width: 760px;
|
|
404
|
+
|
|
405
|
+
&.diagram-in-portlet {
|
|
406
|
+
.diagram-second-container {
|
|
407
|
+
min-width: 560px;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.diagram-svg {
|
|
412
|
+
margin: 22.5px 17.5px;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
&-container-new.diagram-in-portlet {
|
|
417
|
+
.diagram-portlet {
|
|
418
|
+
margin-top: 10px;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.diagrams {
|
|
424
|
+
overflow-y: auto;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.virtual-switch-remove {
|
|
428
|
+
padding: 16px 0 0;
|
|
429
|
+
display: flex;
|
|
430
|
+
justify-content: flex-end;
|
|
431
|
+
|
|
432
|
+
&-btn {
|
|
433
|
+
height: 20px;
|
|
434
|
+
font-weight: 500;
|
|
435
|
+
font-size: 14px;
|
|
436
|
+
line-height: 17px;
|
|
437
|
+
letter-spacing: 0;
|
|
438
|
+
display: flex;
|
|
439
|
+
align-items: center;
|
|
440
|
+
column-gap: 8px;
|
|
441
|
+
color: var(--text-red);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
</style>
|
|
445
|
+
<style lang="scss">
|
|
446
|
+
.diagram-actions__popup.navbar-dropdown-menu {
|
|
447
|
+
transform: translate(-30px, -20px);
|
|
448
|
+
|
|
449
|
+
.btn {
|
|
450
|
+
border-radius: 0;
|
|
451
|
+
border-bottom: 1px solid transparent;
|
|
452
|
+
|
|
453
|
+
span {
|
|
454
|
+
font-size: 14px;
|
|
455
|
+
}
|
|
456
|
+
&:active {
|
|
457
|
+
box-shadow: none;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
</style>
|