1212 />
1313 <SetupBody v-if =" ! setupStore .isConfigViewActive " @open-setup =" openSetup " @export-setup =" exportSetup " />
1414 <PluginLogs v-if =" isPluginLogPageActive " :item =" itemToLogs " @close-log =" closePluginLogsPage " />
15+ <ConnectionLine
16+ v-for =" connection in activeConnections "
17+ :key =" connection .id "
18+ :start =" {
19+ element: connection .start .element ,
20+ position: connection .start .position ,
21+ } "
22+ :end =" {
23+ element: connection .end .element ,
24+ position: connection .end .position ,
25+ } "
26+ color="#DBEF6A "
27+ :animated =" true "
28+ :dashed =" true "
29+ />
1530 </div >
1631</template >
1732
@@ -25,21 +40,22 @@ import { useNodeStore } from "@/store/theNode";
2540import { useServices } from " @/store/services" ;
2641import ControlService from " @/store/ControlService" ;
2742
28- import LeaderLine from " leader-line-new" ;
2943import { useSetups } from " @/store/setups" ;
44+ import ConnectionLine from " ../../../../layers/ConnectionLine.vue" ;
45+ import { useConnectionLines } from " @/composables/useConnectionLines" ;
3046
3147const emit = defineEmits ([" openExpert" , " openLog" , " setupState" , " exportSetup" ]);
3248
3349// Refs
3450const isPluginLogPageActive = ref (false );
3551const itemToLogs = ref ({});
3652const loadingClients = ref (false );
37- const isLineDrawHandlerReady = ref (false );
3853
3954// Store and router
4055const setupStore = useSetups ();
4156const nodeStore = useNodeStore ();
4257const serviceStore = useServices ();
58+ const { activeConnections , lineDrawHandler , removeConnectionLines } = useConnectionLines ();
4359
4460watchEffect (() => {
4561 if (nodeStore .skeletonLoading || serviceStore .installedServices .length === 0 ) {
@@ -49,129 +65,10 @@ watchEffect(() => {
4965 }
5066});
5167
52- watchEffect (() => {
53- if (nodeStore .isLineHidden ) {
54- removeConnectionLines ();
55- }
56- });
57-
5868// Lifecycle
5969
6070// Methods
6171
62- const oneWayConnection = (start , end , startSocket , endSocket ) => {
63- if (start && end) {
64- let newLine = new LeaderLine (start, end, { dash: { animation: true } }, { hide: true });
65- newLine .position ();
66- newLine .setOptions ({
67- size: 2 ,
68- color: " #DBEF6A" ,
69- endPlug: " behind" ,
70- startSocket: startSocket ? startSocket : " right" ,
71- endSocket: endSocket ? endSocket : " left" ,
72- });
73- nodeStore .lines .push (newLine);
74- }
75- };
76-
77- const lineDrawHandler = (item ) => {
78- let start;
79- let end;
80- if (item && ! item .displayPluginMenu ) {
81- switch (item .category ) {
82- case " execution" : {
83- const dependencies = serviceStore .installedServices .filter (
84- (s ) =>
85- s .config ? .dependencies ? .executionClients ? .length > 0 &&
86- s .config ? .dependencies ? .executionClients .some ((d ) => d .id === item .config ? .serviceID )
87- );
88- dependencies .forEach ((d ) => {
89- if (d .category === " consensus" ) {
90- start = d .ref ;
91- end = item .ref ;
92- if (start && end) {
93- oneWayConnection (end, start);
94- }
95- }
96- });
97- break ;
98- }
99- case " consensus" : {
100- const dependencies = serviceStore .installedServices .filter (
101- (s ) =>
102- (s .config ? .dependencies ? .consensusClients ? .length > 0 &&
103- s .config ? .dependencies ? .consensusClients .some ((d ) => d .id === item .config ? .serviceID )) ||
104- item .config ? .dependencies ? .executionClients .some ((d ) => d .id === s .config ? .serviceID )
105- );
106- dependencies .forEach ((d ) => {
107- if (d .category === " validator" ) {
108- start = d .ref ;
109- end = item .ref ;
110- if (start && end) {
111- oneWayConnection (end, start);
112- }
113- }
114- if (d .category === " execution" ) {
115- start = d .ref ;
116- end = item .ref ;
117- if (start && end) {
118- oneWayConnection (start, end);
119- }
120- }
121- });
122- break ;
123- }
124- case " validator" : {
125- const dependencies = serviceStore .installedServices .filter (
126- (s ) =>
127- item .config ? .dependencies ? .executionClients .some ((d ) => d .id === s .config ? .serviceID ) ||
128- item .config ? .dependencies ? .consensusClients .some ((d ) => d .id === s .config ? .serviceID ) ||
129- s .config ? .dependencies ? .consensusClients .some ((d ) => d .id === item .config ? .serviceID )
130- );
131- dependencies .forEach ((d ) => {
132- if (d .category === " validator" ) {
133- start = d .ref ;
134- end = item .ref ;
135- if (start && end) {
136- if (item .service === " CharonService" ) {
137- oneWayConnection (end, start, " left" , " left" );
138- } else {
139- oneWayConnection (start, end, " left" , " left" );
140- }
141- }
142- }
143- if (d .category === " execution" ) {
144- start = d .ref ;
145- end = item .ref ;
146- if (start && end) {
147- oneWayConnection (start, end);
148- }
149- }
150- if (d .category === " consensus" ) {
151- start = d .ref ;
152- end = item .ref ;
153- if (start && end) {
154- oneWayConnection (start, end);
155- }
156- }
157- });
158- break ;
159- }
160- }
161- } else if (item && item .displayPluginMenu ) {
162- removeConnectionLines ();
163- }
164- isLineDrawHandlerReady .value = true ;
165- };
166-
167- const removeConnectionLines = () => {
168- // Remove all existing connections
169- nodeStore .lines .forEach ((line ) => {
170- line .remove ();
171- });
172- nodeStore .lines = [];
173- };
174-
17572const openLog = (item ) => {
17673 emit (" openLog" , item);
17774};
0 commit comments