Skip to content

Commit 248c8fc

Browse files
authored
GSAP lib and animated lines (#2189)
* ADD: gsap lib and line animation * ADD: svg line component * ADD: connection configs * FIX: format * FIX: lint
1 parent 08e46ec commit 248c8fc

7 files changed

Lines changed: 364 additions & 158 deletions

File tree

launcher/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"evilscan": "^1.9.1",
4747
"file-saver": "^2.0.5",
4848
"geoip-lite": "^1.4.7",
49+
"gsap": "^3.12.7",
4950
"jszip": "^3.10.1",
5051
"leader-line-new": "^1.1.9",
5152
"lodash": "^4.17.21",

launcher/src/components/UI/edit-page/components/edit/ConfigBody.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ const emit = defineEmits([
8383
"confirmConsensus",
8484
"infoModal",
8585
"modifyService",
86-
"removeLines",
8786
"lineDraw",
87+
"removeLines",
8888
]);
8989
9090
const manageStore = useNodeManage();
@@ -116,12 +116,12 @@ onMounted(() => {
116116
117117
// Methods
118118
119-
const removeLines = () => {
120-
emit("removeLines");
119+
const lineDraw = (item) => {
120+
emit("lineDraw", item);
121121
};
122122
123-
const lineDraw = (service) => {
124-
emit("lineDraw", service);
123+
const removeLines = () => {
124+
emit("removeLines");
125125
};
126126
127127
const onDrop = (event) => {

launcher/src/components/UI/edit-page/components/edit/EditBody.vue

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,25 @@
1010
@confirm-consensus="confirmConsensus"
1111
@info-modal="infoModal"
1212
@modify-service="modifyService"
13+
@line-draw="lineDrawHandler"
1314
@remove-lines="removeConnectionLines"
1415
/>
1516
<SetupBody v-else @delete-setup="deleteSetup" @connect-setup="connectSetup" @setup-infos="setupInfos" @open-configs="openConfigs" />
17+
<ConnectionLine
18+
v-for="connection in activeConnections"
19+
:key="connection.id"
20+
:start="{
21+
element: connection.start.element,
22+
position: connection.start.position,
23+
}"
24+
:end="{
25+
element: connection.end.element,
26+
position: connection.end.position,
27+
}"
28+
color="#DBEF6A"
29+
:animated="true"
30+
:dashed="true"
31+
/>
1632
</div>
1733
</template>
1834

@@ -24,8 +40,10 @@ import SetupBody from "./SetupBody.vue";
2440
import ControlService from "@/store/ControlService";
2541
import { useNodeManage } from "@/store/nodeManage";
2642
import { useSetups } from "@/store/setups";
27-
import { computed, ref, watch } from "vue";
43+
import { computed, ref } from "vue";
2844
import { useMultiSetups } from "../../../../../composables/multiSetups";
45+
import ConnectionLine from "../../../../layers/ConnectionLine.vue";
46+
import { useConnectionLines } from "@/composables/useConnectionLines";
2947
3048
const { getSelectedSetup } = useMultiSetups();
3149
@@ -37,19 +55,17 @@ const emit = defineEmits([
3755
"confirmConsensus",
3856
"infoModal",
3957
"modifyService",
40-
4158
"openConfigs",
4259
"deleteSetup",
4360
]);
4461
4562
//Pinia stores
4663
const manageStore = useNodeManage();
4764
const setupStore = useSetups();
48-
65+
const { activeConnections, lineDrawHandler, removeConnectionLines } = useConnectionLines();
4966
// refs
5067
5168
const isOverDropZone = ref(false);
52-
// const isLineDrawHandlerReady = ref(false);
5369
5470
// computed & watchers properties
5571
// eslint-disable-next-line no-unused-vars
@@ -63,25 +79,8 @@ const displayDropZone = computed(() => {
6379
return dropClass;
6480
});
6581
66-
watch(
67-
() => manageStore.isLineHidden,
68-
(newValue) => {
69-
if (newValue) {
70-
removeConnectionLines();
71-
}
72-
}
73-
);
74-
7582
// methods
7683
77-
const removeConnectionLines = () => {
78-
// Remove all existing connections
79-
manageStore.lines.forEach((line) => {
80-
line.remove();
81-
});
82-
manageStore.lines = [];
83-
};
84-
8584
const onDrop = (event) => {
8685
isOverDropZone.value = false;
8786
manageStore.isLineHidden = true;

launcher/src/components/UI/node-page/NodeScreen.vue

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import { useNodeStore } from "@/store/theNode";
5454
import { saveAs } from "file-saver";
5555
import JSZip from "jszip";
5656
import { onMounted, onUnmounted, ref, watchEffect } from "vue";
57-
import { useRouter } from "vue-router";
5857
import { useRefreshNodeStats } from "../../../composables/monitoring";
5958
import { useMultiSetups } from "../../../composables/multiSetups";
6059
import { useListKeys } from "../../../composables/validators";
@@ -71,7 +70,7 @@ const nodeStore = useNodeStore();
7170
const headerStore = useNodeHeader();
7271
const serviceStore = useServices();
7372
const controlStore = useControlStore();
74-
const router = useRouter();
73+
7574
const footerStore = useFooter();
7675
const setupStore = useSetups();
7776
const { updateDom } = useMultiSetups();
@@ -89,15 +88,6 @@ let pollingPings = null;
8988
//***************** Watchers *****************
9089
9190
//Computed & Watchers
92-
// TODO: maybe add watchSSV from service.js here?
93-
94-
watchEffect(() => {
95-
if (router.currentRoute.value.path !== "/node") {
96-
nodeStore.isLineHidden = true;
97-
} else {
98-
nodeStore.isLineHidden = false;
99-
}
100-
});
10191
10292
watchEffect(() => {
10393
if (headerStore.openModalFromNodeAlert) {

launcher/src/components/UI/node-page/components/node/NodeBody.vue

Lines changed: 18 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
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";
2540
import { useServices } from "@/store/services";
2641
import ControlService from "@/store/ControlService";
2742
28-
import LeaderLine from "leader-line-new";
2943
import { useSetups } from "@/store/setups";
44+
import ConnectionLine from "../../../../layers/ConnectionLine.vue";
45+
import { useConnectionLines } from "@/composables/useConnectionLines";
3046
3147
const emit = defineEmits(["openExpert", "openLog", "setupState", "exportSetup"]);
3248
3349
// Refs
3450
const isPluginLogPageActive = ref(false);
3551
const itemToLogs = ref({});
3652
const loadingClients = ref(false);
37-
const isLineDrawHandlerReady = ref(false);
3853
3954
// Store and router
4055
const setupStore = useSetups();
4156
const nodeStore = useNodeStore();
4257
const serviceStore = useServices();
58+
const { activeConnections, lineDrawHandler, removeConnectionLines } = useConnectionLines();
4359
4460
watchEffect(() => {
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-
17572
const openLog = (item) => {
17673
emit("openLog", item);
17774
};

0 commit comments

Comments
 (0)