+
+{#if enableSourceHandle}
+
+{/if}
+
+{#if enableTargetHandle}
+
+{/if}
diff --git a/frontend/src/lib/components/graph/renderers/nodes/ResultNode.svelte b/frontend/src/lib/components/graph/renderers/nodes/ResultNode.svelte
new file mode 100644
index 0000000000..5dbf32743b
--- /dev/null
+++ b/frontend/src/lib/components/graph/renderers/nodes/ResultNode.svelte
@@ -0,0 +1,36 @@
+
+
+
+ {
+ data?.eventHandlers?.select(e.detail)
+ }}
+ />
+
diff --git a/frontend/src/lib/components/graph/renderers/nodes/branchAllEndNode.svelte b/frontend/src/lib/components/graph/renderers/nodes/branchAllEndNode.svelte
new file mode 100644
index 0000000000..d1c50554d0
--- /dev/null
+++ b/frontend/src/lib/components/graph/renderers/nodes/branchAllEndNode.svelte
@@ -0,0 +1,31 @@
+
+
+
+ {
+ data?.eventHandlers?.select(e.detail)
+ }}
+ />
+
diff --git a/frontend/src/lib/components/graph/renderers/nodes/branchOneEndNode.svelte b/frontend/src/lib/components/graph/renderers/nodes/branchOneEndNode.svelte
new file mode 100644
index 0000000000..ab446c74d3
--- /dev/null
+++ b/frontend/src/lib/components/graph/renderers/nodes/branchOneEndNode.svelte
@@ -0,0 +1,29 @@
+
+
+
+ {
+ data?.eventHandlers?.select(e.detail)
+ }}
+ />
+
diff --git a/frontend/src/lib/components/graph/renderers/utils.ts b/frontend/src/lib/components/graph/renderers/utils.ts
new file mode 100644
index 0000000000..8b393f1de9
--- /dev/null
+++ b/frontend/src/lib/components/graph/renderers/utils.ts
@@ -0,0 +1,32 @@
+import type { FlowStatusModule } from '$lib/gen'
+import type { GraphModuleState } from '../model'
+
+export function getStraightLinePath({ sourceX, sourceY, targetY }) {
+ return `M${sourceX},${sourceY} L${sourceX},${targetY - 100}`
+}
+
+export function computeBorderStatus(
+ branchIndex: number,
+ type: 'branchone' | 'branchall',
+ graphModuleState: GraphModuleState | undefined
+): FlowStatusModule['type'] | undefined {
+ if (type === 'branchone') {
+ const branchChosen = graphModuleState?.branchChosen
+
+ if (branchChosen === branchIndex) {
+ return graphModuleState?.type
+ }
+ } else {
+ let flow_jobs_success = graphModuleState?.flow_jobs_success
+ if (!flow_jobs_success) {
+ return 'WaitingForPriorSteps'
+ } else {
+ let status = flow_jobs_success?.[branchIndex]
+ if (status == undefined) {
+ return 'WaitingForExecutor'
+ } else {
+ return status ? 'Success' : 'Failure'
+ }
+ }
+ }
+}
diff --git a/frontend/src/lib/components/graph/svelvet/LICENSE b/frontend/src/lib/components/graph/svelvet/LICENSE
deleted file mode 100644
index 73a46f09bf..0000000000
--- a/frontend/src/lib/components/graph/svelvet/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2022 OSLabs Beta
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/frontend/src/lib/components/graph/svelvet/container/README.md b/frontend/src/lib/components/graph/svelvet/container/README.md
deleted file mode 100644
index 27a6c64fe7..0000000000
--- a/frontend/src/lib/components/graph/svelvet/container/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-# Container
-
-This folder contains two containers: Svelvet and Canvas.
-
-## Svelvet.svelte
-
-Svelvet.svelte is the top level component
diff --git a/frontend/src/lib/components/graph/svelvet/container/controllers/middleware.ts b/frontend/src/lib/components/graph/svelvet/container/controllers/middleware.ts
deleted file mode 100644
index bb3f8eb1cc..0000000000
--- a/frontend/src/lib/components/graph/svelvet/container/controllers/middleware.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-This file contains "middleware" functions that sanitize user input (UserNodeType and UserEdgeType). Put functions that
-maintain consistency between previous
-
-*/
-import { bottomCb, leftCb, rightCb, topCb } from '../../edges/controllers/anchorCbUser'
-import type { UserEdgeType, UserNodeType } from '../../types/types'
-
-/**
- * sanitizeUserNodesAndEdges will sanitize the data initially passed in to Svelvet component. For example, the node that user specified have an integar as its id but to instantiate a Node and be compatible with uuid we will need to convert the integar id to a string.
- * @param userNodes The array of nodes that have a UserNodeType
- * @param userEdges The array of edges that have a UserEdgeType
- * @returns An object of sanitized userNodes and userEdges
- */
-export function sanitizeUserNodesAndEdges(userNodes: UserNodeType[], userEdges: UserEdgeType[]) {
- convertIdToString(userNodes)
- convertEdgeIdsToString(userEdges)
- convertAnchorPositionsToCallbacks(userNodes, userEdges)
- setDefaultEdgeType(userEdges)
- return { userNodes, userEdges }
-}
-
-/**
- * setDefaultEdgeType ensures a default edge type of 'bezier' if the user does not set one, or sets a nonsense type.
- * @param userEdges The array of edges that have a UserEdgeType
- * @returns No return, the function edits the objects in place
- */
-function setDefaultEdgeType(userEdges) {
- for (let userEdge of userEdges) {
- if (!['smoothstep', 'step', 'bezier', 'straight'].includes(userEdge.type))
- userEdge.type = 'bezier'
- }
-}
-
-/**
- * convertAnchorPositionsToCallbacks
- * @description
- * WHY: This function is in order to maintain compliance with earlier versions of Svelvet.
- * HISTORY: In Svelvet<=5, anchor points were hard-coded onto each node. Each node had a "sourcePosition"
- * "targetPosition" where the edges would be attached. In Svelvet6, the store was re-designed
- * from the ground up into an object-relational data model where anchor points could be attached
- * at any point on the node using callbacks. This enabled features such as custom edge position,
- * adaptive edge positioning, and dynamic edges.
- * The purpose of this function is to parse the old way of specifying edge positions (as two source/target
- * anchors on the node) into the Svelvet6 (where anchors are separate objects) in order to maintain a
- * consistent user experience. However, we suggest that this functionality (parsing Svelvet5 syntax into
- * Svelvet6 syntax) be removed completely in favor of only using Svelvet6 syntax in order to reduce edge cases.
- */
-function convertAnchorPositionsToCallbacks(userNodes: UserNodeType[], userEdges: UserEdgeType[]) {
- // convert userNodes array into object for constant time lookup by id
- const userNodesObj: { [key: string]: UserNodeType } = {}
- for (let userNode of userNodes) userNodesObj[userNode.id] = userNode
-
- // iterate through userEdges, and check the source/target nodes.
- for (let userEdge of userEdges) {
- const userNodeSource = userNodesObj[userEdge.source]
- const userNodeTarget = userNodesObj[userEdge.target]
- if (!userNodeSource || !userNodeTarget) continue
- const sourcePosition = userNodeSource.sourcePosition
- const targetPosition = userNodeTarget.targetPosition
-
- const cbs = { left: leftCb, right: rightCb, top: topCb, bottom: bottomCb }
- if (sourcePosition) userEdge.sourceAnchorCb = cbs[sourcePosition]
- if (targetPosition) userEdge.targetAnchorCb = cbs[targetPosition]
- }
-}
-
-/**
- * Converts node id's to strings. For Svelvet<6, node id's were numbers. These were switched to strings for compatibility with uuid. This function does not return a new array, instead it mutates and sanitizes the original array.
- * @param userNodes The array of userNodes (not yet sanitized)
- */
-function convertIdToString(userNodes: UserNodeType[]) {
- userNodes = userNodes.map((node) => {
- node.id = node.id.toString()
- node.childNodes =
- node.childNodes === undefined ? [] : node.childNodes.map((childId) => childId.toString())
- return node
- })
-}
-
-/**
- * Converts source/target node id's to string. For Svelvet<6, id's were numbers. These were switched to strings for compatibility with uuid. This function does not return a new array, instead it mutates and sanitizes the original array.
- * @param userEdges The array of userEdges (not yet sanitized)
- */
-function convertEdgeIdsToString(userEdges: UserEdgeType[]) {
- userEdges = userEdges.map((edge) => {
- edge.source = edge.source.toString()
- edge.target = edge.target.toString()
- return edge
- })
-}
diff --git a/frontend/src/lib/components/graph/svelvet/container/models/index.ts b/frontend/src/lib/components/graph/svelvet/container/models/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/frontend/src/lib/components/graph/svelvet/container/views/GraphView.svelte b/frontend/src/lib/components/graph/svelvet/container/views/GraphView.svelte
deleted file mode 100644
index 1a8de47950..0000000000
--- a/frontend/src/lib/components/graph/svelvet/container/views/GraphView.svelte
+++ /dev/null
@@ -1,304 +0,0 @@
-
-
-
-
-
diff --git a/frontend/src/lib/components/graph/svelvet/customCss/controllers/getCss.ts b/frontend/src/lib/components/graph/svelvet/customCss/controllers/getCss.ts
deleted file mode 100644
index 16e68814cf..0000000000
--- a/frontend/src/lib/components/graph/svelvet/customCss/controllers/getCss.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-// Required for "custom css" feature
-
-import type { NodeType, StoreType } from '../../store/types/types'
-
-// WHAT: For a given node with a user-defined classname, see if there are any css properties for height and width
-// Get that height and width and set properties in node store. This is necessary for
-export const forceCssHeightAndWidth = (store: StoreType, node: NodeType) => {
- let width, height, innerText
- // Look through each CSS rule to find the one the user defined
- for (let i = 0; i < document.styleSheets.length; i++) {
- const styleSheet = document.styleSheets[i]
- const styleRules = styleSheet.cssRules
- for (let j = 0; j < styleRules.length; j++) {
- const rule = styleRules[j]
-
- // this is necessary to get rid of typescript warning for rule.selectorText
- if (!(rule instanceof CSSStyleRule)) continue
-
- if (rule.selectorText === `.${node.className}`) {
- const initialText = rule.cssText // getting the full text of the CSS rule
- const i = initialText.indexOf('{') // finding index of first bracket
- innerText = initialText.substring(i + 1, initialText.length - 1) // extracting the CSS to insert into inline style
- // Adjusting the width and height if they are set via the custom class
- const arr = innerText.split(' ')
- arr.forEach((str, i) => {
- if (str === 'width:') {
- width = str.concat(arr[i + 1]) // go through the array and join width and the number
- const w = parseInt(arr[i + 1]) // getting the number for the width
- width = w
- }
- if (str === 'height:') {
- height = str.concat(arr[i + 1]) // same as with the width
- const h = parseInt(arr[i + 1])
- height = h
- }
- })
- }
- }
- }
-
- // update the width/height of the node
- store.nodesStore.update((nodes) => {
- if (width !== undefined) nodes[node.id].width = width
- if (height !== undefined) nodes[node.id].height = height
- return { ...nodes }
- })
-
- // move the node a bit to force update to anchors, potential anchors
- node.setPositionFromMovement(0, 0)
-}
diff --git a/frontend/src/lib/components/graph/svelvet/d3/controllers/d3.ts b/frontend/src/lib/components/graph/svelvet/d3/controllers/d3.ts
deleted file mode 100644
index 8eec38fccd..0000000000
--- a/frontend/src/lib/components/graph/svelvet/d3/controllers/d3.ts
+++ /dev/null
@@ -1,91 +0,0 @@
-// import { zoom, zoomTransform } from 'd3-zoom';
-// import { select, selectAll } from 'd3-selection';
-import type { ZoomBehavior } from 'd3-zoom';
-import { get } from 'svelte/store';
-
-export function zoomInit(
- d3,
- canvasId,
- d3Zoom,
- d3Translate,
- initialLocation,
- initialZoom,
- d3Scale
-) {
- //set default zoom logic
- d3.select(`.Edges-${canvasId}`)
- //makes sure translation is default at center coordinates
- .transition()
- .duration(0)
- .call(d3Zoom.translateTo, 0, 0)
- //moves camera to coordinates
- .transition()
- .duration(0)
- .call(
- d3Zoom.translateTo,
- initialLocation.x / initialZoom,
- initialLocation.y / initialZoom
- )
- // zooms in on selected point
- .transition()
- .duration(0)
- .call(d3Zoom.scaleTo, initialZoom.toFixed(2));
- // updates d3Translate with d3 object with x, y, and k values to be sent down to the minimap to be further calculated further
- d3Translate = d3.zoomIdentity
- .translate(initialLocation.x, initialLocation.y)
- .scale(initialZoom.toFixed(2));
- d3.select(`.Nodes-${canvasId}`)
- .transition()
- .duration(0)
- .call(d3Zoom.translateTo, 0, 0)
- .transition()
- .duration(0)
- .call(
- d3Zoom.translateTo,
- initialLocation.x / initialZoom,
- initialLocation.y / initialZoom
- )
- .transition()
- .duration(0)
- .call(d3Zoom.scaleTo, initialZoom.toFixed(2));
- // sets D3 scale to current k of object
- d3Scale.set(d3.zoomTransform(d3.select(`.Nodes-${canvasId}`)).k);
- return d3Translate;
-}
-// create d3 instance conditionally based on boundary prop
-export function determineD3Instance(
- boundary,
- d3: { zoom: () => ZoomBehavior },
- nodeSelected,
- width,
- height,
- movementStore,
- backgroundStore,
- gridSize,
- dotSize,
- canvasId,
- d3Scale,
- handleZoom
-): ZoomBehavior {
- if (boundary) {
- return d3
- .zoom()
- .filter(() => !get(nodeSelected))
- .scaleExtent([0.4, 4]) // limits for zooming in/out
- .translateExtent([
- [0, 0],
- [boundary.x, boundary.y],
- ]) // world extent
- .extent([
- [0, 0],
- [width, height],
- ])
- .on('zoom', handleZoom);
- } else {
- return d3
- .zoom()
- .filter(() => !get(nodeSelected))
- .scaleExtent([0.4, 2])
- .on('zoom', handleZoom);
- }
-}
diff --git a/frontend/src/lib/components/graph/svelvet/edges/controllers/anchorCbDev.ts b/frontend/src/lib/components/graph/svelvet/edges/controllers/anchorCbDev.ts
deleted file mode 100644
index 342698f25f..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/controllers/anchorCbDev.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-import { rightCb, leftCb, topCb, bottomCb } from './anchorCbUser' // these are callbacks used to calculate anchor position relative to node
-import type { AnchorCbType } from '../../edges/types/types'
-import type { StoreType } from '../../store/types/types'
-
-import { getAnchors } from './util'
-import { getNodeById } from '../../nodes/controllers/util'
-export function fixedCbCreator(
- store: StoreType,
- edgeId: string,
- anchorId: string,
- userNodeId: string,
- positionCb: Function // positionCb should be a function that takes 4 arguments (x,y,width,height) and returns a 3-array [x,y,angle] that represents the x,y position of the anchor as well as it's angle with respect to it's node.
-) {
- const rn = fixedCb
- rn.type = 'fixed'
- return rn
-
- function fixedCb() {
- // get the two anchors
- const anchors = getAnchors(store, { edgeId: edgeId })
- if (anchors.length !== 2) throw `there should be two anchors per edge, have: ${anchors.length}`
- let [anchorSelf, anchorOther] = anchors
- if (anchorSelf.id !== anchorId) [anchorSelf, anchorOther] = [anchorOther, anchorSelf]
-
- const node = getNodeById(store, userNodeId)
- const { positionX, positionY, width, height } = node
- const [x, y, angle] = positionCb(positionX, positionY, width, height)
- anchorSelf.positionX = x
- anchorSelf.positionY = y
- anchorSelf.angle = angle
- // update the other anchor if it is a dynamic anchor
- // Note dyanamic anchor callbacks have a check that prevents an infinite loop
- if (anchorOther.callback.type === 'dynamic') anchorOther.callback()
- }
-}
-
-export function dynamicCbCreator(store: StoreType, edgeId: string, anchorId: string) {
- const rn = dynamicCb
- rn.type = 'dynamic'
- return rn
-
- function dynamicCb() {
- // get the two anchors
- const anchors = getAnchors(store, { edgeId: edgeId })
- if (anchors.length !== 2) throw `there should be two anchors per edge, have: ${anchors.length}`
-
- let [anchorSelf, anchorOther] = anchors
- if (anchorSelf.id !== anchorId) [anchorSelf, anchorOther] = [anchorOther, anchorSelf]
- // get the two nodes
- const nodeSelf = getNodeById(store, anchorSelf.nodeId)
- const nodeOther = getNodeById(store, anchorOther.nodeId)
- // get the midpoints
- const [xSelf, ySelf, xOther, yOther] = [
- nodeSelf.positionX + nodeSelf.width / 2,
- nodeSelf.positionY + nodeSelf.height / 2,
- nodeOther.positionX + nodeOther.width / 2,
- nodeOther.positionY + nodeOther.height / 2
- ]
-
- // record angle for later. We use this so we don't have an infinite loop
- let prevAngle = anchorSelf.angle
-
- // calculate the slope
- const slope = (ySelf - yOther) / (xSelf - xOther)
- // slope<1 means -45 to 45 degrees so left/right anchors
- if (Math.abs(slope) < 1) {
- // self node is on the left, other node is on the right
- if (nodeSelf.positionX < nodeOther.positionX) {
- const [selfX, selfY] = rightCb(
- nodeSelf.positionX,
- nodeSelf.positionY,
- nodeSelf.width,
- nodeSelf.height
- )
- leftCb(nodeOther.positionX, nodeOther.positionY, nodeOther.width, nodeOther.height)
- anchorSelf.setPosition(selfX, selfY)
- anchorSelf.angle = 0 // if the self node is on the left, the anchor should have orientation of 0 degrees on the unit circle
- } else {
- // in this case, the self node is on the right and the other node is on the left
- const [selfX, selfY] = leftCb(
- nodeSelf.positionX,
- nodeSelf.positionY,
- nodeSelf.width,
- nodeSelf.height
- )
- rightCb(nodeOther.positionX, nodeOther.positionY, nodeOther.width, nodeOther.height)
- anchorSelf.setPosition(selfX, selfY)
- anchorSelf.angle = 180
- }
- } else {
- if (nodeSelf.positionY < nodeOther.positionY) {
- // here the self node is above the other node
- const [selfX, selfY] = bottomCb(
- nodeSelf.positionX,
- nodeSelf.positionY,
- nodeSelf.width,
- nodeSelf.height
- )
- topCb(nodeOther.positionX, nodeOther.positionY, nodeOther.width, nodeOther.height)
- anchorSelf.setPosition(selfX, selfY)
- anchorSelf.angle = 270
- } else {
- const [selfX, selfY] = topCb(
- nodeSelf.positionX,
- nodeSelf.positionY,
- nodeSelf.width,
- nodeSelf.height
- )
- bottomCb(nodeOther.positionX, nodeOther.positionY, nodeOther.width, nodeOther.height)
- anchorSelf.setPosition(selfX, selfY)
- anchorSelf.angle = 90
- }
- }
-
- // if the anchor changed position, then do operation for other anchor
- // otherwise, don't do anything. This check is so we don't have an infinite loop
- if (prevAngle !== anchorSelf.angle) anchorOther.callback()
- }
-}
diff --git a/frontend/src/lib/components/graph/svelvet/edges/controllers/anchorCbUser.ts b/frontend/src/lib/components/graph/svelvet/edges/controllers/anchorCbUser.ts
deleted file mode 100644
index 69e4d86bcd..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/controllers/anchorCbUser.ts
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * These are callbacks used to define anchor positions relative to the node they are attached to.
- * These may be provided to developers as examples of how to write their own custom callbacks for adjustable anchors
- * It calculates the position of an anchor (x,y) coordinates given a node parameterized by (x,y,width, height)
- */
-
-/**
- * @function rightCb - This is a callback function to define the anchor position on the node to be on the right side of the node.
- * @param xNode - positionX of the attached node
- * @param yNode - positionY of the attached node
- * @param widthNode - width of the attached node
- * @param heightNode - height of the attached node
- * @returns [xAnchor, yAnchor, 0]
- * xAnchor - positionX for the anchor
- * yAnchor - positionY for the anchor
- * 0 - this is angle of the anchor with respect to the node. The right anchor should fall at 0 degrees on the unit circle.
- * @export rightCb
- */
-export const rightCb = (
- xNode: number,
- yNode: number,
- widthNode: number,
- heightNode: number
-) => {
- const xAnchor = xNode + widthNode;
- const yAnchor = yNode + heightNode / 2;
- return [xAnchor, yAnchor, 0];
-};
-
-/**
- * @function leftCb - This is a callback function to define the anchor position on the node to be on the left side of the node.
- * @param xNode - positionX of the attached node
- * @param yNode - positionY of the attached node
- * @param widthNode - width of the attached node
- * @param heightNode - height of the attached node
- * @returns [xAnchor, yAnchor, 180]
- * xAnchor - positionX for the anchor
- * yAnchor - positionY for the anchor
- * 180 - this is angle of the anchor with respect to the node. The left anchor should fall at 180 degrees on the unit circle.
- * @export leftCb
- */
-export const leftCb = (
- xNode: number,
- yNode: number,
- widthNode: number,
- heightNode: number
-) => {
- const xAnchor = xNode;
- const yAnchor = yNode + heightNode / 2;
- return [xAnchor, yAnchor, 180];
-};
-
-/**
- * @function topCb - This is a callback function to define the anchor position on the node to be on the top of the node.
- * @param xNode - positionX of the attached node
- * @param yNode - positionY of the attached node
- * @param widthNode - width of the attached node
- * @param heightNode - height of the attached node
- * @returns [xAnchor, yAnchor, 90]
- * xAnchor - positionX for the anchor
- * yAnchor - positionY for the anchor
- * 90 - this is angle of the anchor with respect to the node. The top anchor should fall at 90 degrees on the unit circle.
- * @export topCb
- */
-
-export const topCb = (
- xNode: number,
- yNode: number,
- widthNode: number,
- heightNode: number
-) => {
- const xAnchor = xNode + widthNode / 2;
- const yAnchor = yNode;
- return [xAnchor, yAnchor, 90];
-};
-
-/**
- * @function bottomCb - This is a callback function to define the anchor position on the node to be on the bottom of the node.
- * @param xNode - positionX of the attached node
- * @param yNode - positionY of the attached node
- * @param widthNode - width of the attached node
- * @param heightNode - height of the attached node
- * @returns - [xAnchor, yAnchor, 90]
- * xAnchor - positionX for the anchor
- * yAnchor - positionY for the anchor
- * 270 - this is angle of the anchor with respect to the node. The bottom anchor should fall at 270 degrees on the unit circle.
- * @export bottomCb
- */
-export const bottomCb = (
- xNode: number,
- yNode: number,
- widthNode: number,
- heightNode: number
-) => {
- const xAnchor = xNode + widthNode / 2;
- const yAnchor = yNode + heightNode;
- return [xAnchor, yAnchor, 270];
-};
diff --git a/frontend/src/lib/components/graph/svelvet/edges/controllers/util.ts b/frontend/src/lib/components/graph/svelvet/edges/controllers/util.ts
deleted file mode 100644
index 7fdb1281da..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/controllers/util.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import type { StoreType } from '../../store/types/types'
-import { get } from 'svelte/store'
-import type { AnchorType } from '../types/types'
-
-/**
- * Finds all Anchors that matches the conditions specified in the filter parameter from a Svelvet store and returns these Anchors in an array.
- *
- * @param store The Svelvet store containing the state of a Svelvet component
- * @param filter An object to specify conditions. Example: if filter = \{ sourceOrTarget: 'source', positionX: 35 \} then we will return all anchors with sourceOrTarget = source AND poxitionX = 35
- * @returns An array of Anchors that matches the conditions specified in the filter parameter
- */
-export function getAnchors(store: StoreType, filter?: { [key: string]: any }) {
- let anchors = Object.values(get(store.anchorsStore))
- // filter the array of anchors for elements that match filter
- // Example: if filter = {sourceOrTarget: 'source', positionX: 35} then we will
- //return all anchors with sourceOrTarget = source AND poxitionX = 35
- if (filter !== undefined) {
- anchors = anchors.filter((anchor) => {
- for (let filterKey in filter) {
- const filterValue = filter[filterKey]
- if (anchor[filterKey as keyof AnchorType] !== filterValue) return false
- }
- return true
- })
- }
- // return list of anchors
- return anchors
-}
-
-/**
- * Gets one anchor (source anchor or target anchor) from a given edge
- *
- * @param store The Svelvet store containing the state of the Svelvet component
- * @param edgeId The id of a given edge
- * @param sourceOrTarget A string of 'source' or 'target' to specify which anchor the function should return
- * @returns The source or target Anchor object of a given edge
- */
-export function getAnchorFromEdge(
- store: StoreType,
- edgeId: string,
- sourceOrTarget: 'source' | 'target'
-): AnchorType {
- getEdgeById(store, edgeId)
- const anchors = getAnchors(store, { edgeId: edgeId })
- if (anchors.length !== 2)
- throw `there should be two anchors for a given edge, there are ${anchors.length}`
- // there should be one source anchor and one target anchor. Return the source anchor
- const anchor = anchors.filter((anchor) => anchor.sourceOrTarget === sourceOrTarget)
- if (anchor.length !== 1) throw `there should only be one source/target anchor`
- return anchor[0]
-}
-
-/**
- * getEdgeById will look for the targeted Edge that has the same id provided in the Svelvet component store.
- *
- * @param store The Svelvet store containing the state of a Svelvet component
- * @param id The id of the targeted Node
- * @returns The targeted Edge object in store.edgesStore
- */
-export function getEdgeById(store: StoreType, id: string) {
- const edgesStore = get(store.edgesStore)
- const edge = edgesStore[id]
- if (edge === undefined) throw 'edge not found'
- return edge
-}
-
-/**
- * getAnchorById will look for the targeted Anchor that has the same id in the Svelvet component store.
- *
- * @param store The Svelvet store containing the state of a Svelvet component
- * @param id The id of the targeted Anchor
- * @returns The target Anchor object in store.anchorsStore
- */
-export function getAnchorById(store: StoreType, id: string) {
- const anchorsStore = get(store.anchorsStore)
- const anchor = anchorsStore[id]
- return anchor
-}
diff --git a/frontend/src/lib/components/graph/svelvet/edges/models/Anchor.ts b/frontend/src/lib/components/graph/svelvet/edges/models/Anchor.ts
deleted file mode 100644
index daa9b25b51..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/models/Anchor.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * This is where we create, update the Anchor store.
- */
-
-import type { AnchorCbType, AnchorType } from '../../edges/types/types';
-import { stores } from '../../store/models/store';
-import { getAnchors } from '../controllers/util';
-
-/** Class representing an Anchor that implements Anchortype.
- * @param {string} id The id of the Anchor
- * @param {string} nodeId The id of the Node which the instantiated Anchor will be attached to
- * @param {string} edgeId The id of the Edge which connects to the instantiated Anchor
- * @param {'source' | 'target'} sourceOrTarget Specify the Anchor is a source or target
- * @param {number} positionX The 'X' coordinate of the Anchor
- * @param {number} positionY The 'Y' coordinate of the Anchor
- * @param {function} callback The callback function that will determine the position of this Anchor
- * @param {string} canvasId The canvasId of the Svelvet component that will hold this Anchor
- * @param { number } angle This is the orientation of the anchor and is used to make sure bezier/step curves are rendered perpendicular to the node. Angles are defined along the unit circle. EX: 0 = right side of node, 180 = left side of node.
- */
-export class Anchor implements AnchorType {
- constructor(
- public id: string,
- public nodeId: string,
- public edgeId: string,
- public sourceOrTarget: 'source' | 'target',
- public positionX: number,
- public positionY: number,
- public callback: AnchorCbType,
- public canvasId: string,
- public angle: 0 | 90 | 180 | 270
- ) {}
-
- getOtherAnchorId() {
- const store = stores[this.canvasId];
- const anchors = getAnchors(store, { edgeId: this.edgeId });
- if (anchors.length !== 2)
- throw 'something is wrong, every anchor should have exactly one other associated anchor';
- const anchor = anchors.filter((anchor) => anchor.id !== this.id)[0];
- return anchor.id;
- }
-
- /**
- * setPositionFromNode will invoke the user-defined callback to calculate the position of the Anchor, set the position of the Anchor in the anchorsStore, and also update the Edge position accordingly.
- */
- setPositionFromNode() {
- // calculate the new position of the anchor using user-defined callback
- this.callback();
- const { edgesStore } = stores[this.canvasId];
- // update edges
- edgesStore.update((edges) => {
- const edge = edges[this.edgeId];
- if (this.sourceOrTarget === 'source') {
- edge.sourceX = this.positionX;
- edge.sourceY = this.positionY;
- } else {
- edge.targetX = this.positionX;
- edge.targetY = this.positionY;
- }
- return { ...edges };
- });
- }
- /**
- * updateEdges will update the edgesStore based on Anchor's change.
- */
- updateEdges() {
- const { edgesStore } = stores[this.canvasId];
- /** update edges by deconstructing edges store and setting its new vlue to stores[this.canvasID] */
-
- edgesStore.update((edges) => {
- const edge = edges[this.edgeId];
- // this means that no edge was found, just return without doing anything
-
- if (edge === undefined) {
- return { ...edges };
- }
- if (this.sourceOrTarget === 'source') {
- edge.sourceX = this.positionX;
- edge.sourceY = this.positionY;
- } else {
- edge.targetX = this.positionX;
- edge.targetY = this.positionY;
- }
- return { ...edges };
- });
- }
-
- /**
- * setPosition will update the positionX and positionY of the Anchor and also cascade changes to related Edge.
- * @param x The X coordinate of the new position for the Anchor
- * @param y The Y coordinate of the new position for the Anchor
- */
- setPosition(x: number, y: number) {
- this.positionX = x;
- this.positionY = y;
- this.updateEdges();
- }
-
- /**
- * Anchor.setPositionFromMovement works similarly to Anchor.setPosition. But setPosition is more powerful and we recommend using setPosition whenever possible and in the future, setPositionFromMovement can be removed.
- * @param movementX The mouse movement value on the X-axis
- * @param movementY The mouse movement value on the Y-axis
- */
- setPositionFromMovement(movementX: number, movementY: number) {
- this.positionX += movementX;
- this.positionY += movementY;
- const { edgesStore } = stores[this.canvasId];
- edgesStore.update((edges) => {
- const edge = edges[this.edgeId];
- if (this.sourceOrTarget === 'source') {
- edge.sourceX += movementX;
- edge.sourceY += movementY;
- } else {
- edge.targetX += movementX;
- edge.targetY += movementY;
- }
- return { ...edges };
- });
- }
-}
diff --git a/frontend/src/lib/components/graph/svelvet/edges/models/Edge.ts b/frontend/src/lib/components/graph/svelvet/edges/models/Edge.ts
deleted file mode 100644
index f6f6ca8339..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/models/Edge.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-import { findStore } from '../../store/models/store'
-import type { UserEdgeType } from '../../types/types'
-import type { EdgeType } from '../../store/types/types'
-
-import { stores } from '../../store/models/store'
-import { getAnchors, getAnchorFromEdge } from '../../edges/controllers/util'
-/**
- * Class Edge that implements EdgeType.
- * @param id The id of the Edge
- * @param sourceX The X coordinate of the source Anchor
- * @param sourceY The Y coordinate of the source Anchor
- * @param targetX The X coordinate of the target Anchor
- * @param targetY The Y coordinate of the target Anchor
- * @param canvasId The canvasId of the Svelvet component that holds the instantiated Edge
- * @param label The label of the Edge
- * @param type The type of the Edge (options: 'straight', 'smoothstep', 'step', or 'bezier'). If user doesn't specify, the type will default to 'bezier'.
- * @param labelBgColor The background color of the Edge label
- * @param labelTextColor The text color of the Edge label
- * @param edgeColor The color of the Edge
- * @param animate Boolean value to specify whether the Edge should be animated
- * @param noHandle Boolean value but looks like it is already depracated and can be removed without damage
- * @param arraw Boolean value to specify whether the Edge displays an arrow near its target Anchor
- */
-export class Edge implements EdgeType {
- constructor(
- public id: string,
- public sourceX: number,
- public sourceY: number,
- public targetX: number,
- public targetY: number,
- public canvasId: string,
- public label: string,
- public type: 'straight' | 'smoothstep' | 'step' | 'bezier',
- public labelBgColor: string,
- public labelTextColor: string,
- public edgeColor: string,
- public animate: boolean,
- public noHandle: boolean,
- public arrow: boolean,
- public clickCallback: Function,
- public className: string,
- public offset?: number
- ) {}
-
- /**
- * delete is going to delete the Edge and also delete associated Anchors
- */
- delete() {
- const store = stores[this.canvasId]
- const { anchorsStore, edgesStore } = store
- const sourceAnchor = getAnchorFromEdge(store, this.id, 'source') // this is a bit wasteful
- const targetAnchor = getAnchorFromEdge(store, this.id, 'target')
- anchorsStore.update((anchors) => {
- for (const anchorId in anchors) {
- if (anchorId === sourceAnchor.id || anchorId == targetAnchor.id) delete anchors[anchorId]
- }
- return { ...anchors }
- })
- edgesStore.update((edges) => {
- delete edges[this.id]
- return { ...edges }
- })
- }
-
- /**
- * setExportableData will construct an object that holds all the edge data that can be exported. This is needed for the Exporting Diagram feature.
- * @returns The object of exportable edge data. The format of the object should be as close as what user initially passes in to Svelvet.
- */
- setExportableData() {
- const exportableData: UserEdgeType = {
- id: this.id,
- label: this.label,
- type: this.type,
- labelBgColor: this.labelBgColor,
- labelTextColor: this.labelTextColor,
- edgeColor: this.edgeColor,
- animate: this.animate,
- noHandle: this.noHandle,
- arrow: this.arrow,
- source: 'dummy', // these will be set later
- target: 'dummy' // these will be set later
- }
-
- // set source, target on exportableData
- const store = findStore(this.canvasId)
- const anchors = getAnchors(store, { edgeId: this.id })
- if (anchors.length !== 2) throw 'there should be two anchors per edge'
- for (const anchor of anchors) {
- if (anchor.sourceOrTarget === 'target') exportableData.target = anchor.nodeId
- if (anchor.sourceOrTarget === 'source') exportableData.source = anchor.nodeId
- }
-
- return exportableData
- }
-}
diff --git a/frontend/src/lib/components/graph/svelvet/edges/types/types.ts b/frontend/src/lib/components/graph/svelvet/edges/types/types.ts
deleted file mode 100644
index 57917fc098..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/types/types.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-export type AnchorCbType = {
- (): void;
- type: 'dynamic' | 'fixed';
-};
-
-export interface AnchorType {
- id: string; // note that the user never specifies an anchor and they are generated dynamically. id will be a random string.
- nodeId: string;
- edgeId: string;
- sourceOrTarget: 'source' | 'target';
- positionX: number;
- positionY: number;
- callback: AnchorCbType; // callback is used to calculate positionX, positionY based on parent node's data, and set the anchor position // TODO: rename to something better
- angle: number;
- setPositionFromNode: Function;
- setPosition: Function;
- updateEdges: Function;
- getOtherAnchorId: Function;
-}
diff --git a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/BaseEdge.svelte b/frontend/src/lib/components/graph/svelvet/edges/views/Edges/BaseEdge.svelte
deleted file mode 100644
index 59b09bf80f..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/BaseEdge.svelte
+++ /dev/null
@@ -1,108 +0,0 @@
-
-
-
-
-
-
-
-
-
-{#if highlightEdgesOption}
- {}}
- />
-{/if}
-
-{#if arrow}
-
-{:else}
-
-{/if}
-
-{#if edgeTextProps.label}
-
-{/if}
-
-
diff --git a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/EdgeText.svelte b/frontend/src/lib/components/graph/svelvet/edges/views/Edges/EdgeText.svelte
deleted file mode 100644
index 8e2021f6df..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/EdgeText.svelte
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-{#if typeof label === 'undefined' || !label}
- {null}
-{:else}
-
-
-
- {label}
-
-
-{/if}
diff --git a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/SimpleBezierEdge.svelte b/frontend/src/lib/components/graph/svelvet/edges/views/Edges/SimpleBezierEdge.svelte
deleted file mode 100644
index e3c606ef8c..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/SimpleBezierEdge.svelte
+++ /dev/null
@@ -1,175 +0,0 @@
-
-
-
diff --git a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/SmoothStepEdge.svelte b/frontend/src/lib/components/graph/svelvet/edges/views/Edges/SmoothStepEdge.svelte
deleted file mode 100644
index 88ee91a754..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/SmoothStepEdge.svelte
+++ /dev/null
@@ -1,157 +0,0 @@
-
-
-
diff --git a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/StepEdge.svelte b/frontend/src/lib/components/graph/svelvet/edges/views/Edges/StepEdge.svelte
deleted file mode 100644
index 0e192fcd5f..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/StepEdge.svelte
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
diff --git a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/types.ts b/frontend/src/lib/components/graph/svelvet/edges/views/Edges/types.ts
deleted file mode 100644
index 48a97a8582..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/types.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import type { XYPosition, Position } from './utils';
-
-export interface Node {
- id: number;
- position: XYPosition;
- data: T;
- width: number;
- height: number;
- bgColor?: string;
- fontSize?: number;
- borderColor?: string;
- borderRadius?: number;
- textColor?: string;
- clickCallback?: Function;
- image?: boolean;
- src?: string;
- sourcePosition?: 'left' | 'right' | 'top' | 'bottom';
- targetPosition?: 'left' | 'right' | 'top' | 'bottom';
-}
-
-export interface Edge {
- id: string;
- source: number;
- target: number;
- label?: string;
- labelBgColor?: string;
- labelTextColor?: string;
- edgeColor?: string;
- type?: string;
- animate?: boolean;
- noHandle?: boolean;
- arrow?: boolean;
-}
-
-export interface DerivedEdge extends Edge {
- sourceX: number;
- sourceY: number;
- sourcePosition: Position;
- targetX: number;
- targetY: number;
- targetPosition: Position;
-}
-
-export interface EdgeProps extends DerivedEdge {
- path: string;
- centerX: number;
- centerY: number;
-}
-
-export interface EdgeTextProps {
- label?: any;
- labelBgColor?: string;
- labelTextColor?: string;
- centerX: number;
- centerY: number;
-}
-
-export type HandleType = 'source' | 'target';
diff --git a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/utils.ts b/frontend/src/lib/components/graph/svelvet/edges/views/Edges/utils.ts
deleted file mode 100644
index 8685e6e3e8..0000000000
--- a/frontend/src/lib/components/graph/svelvet/edges/views/Edges/utils.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-// enumerable values (static) set for Position
-export enum Position {
- Left = 'left',
- Right = 'right',
- Top = 'top',
- Bottom = 'bottom',
-}
-
-// interface for XYPosition to use in nodes and edges
-export interface XYPosition {
- x: number;
- y: number;
-}
-
-// type for z axis positioning with D3
-export type XYZPosition = XYPosition & { z: number };
-
-// interface for changing dimensions of Viewport
-export interface Dimensions {
- width: number;
- height: number;
-}
-
-// interface of Rect divs in zoompane
-export interface Rect extends Dimensions, XYPosition {}
-
-// interface of Box using XYPosition of nodes
-export interface Box extends XYPosition {
- x2: number;
- y2: number;
-}
-
-// D3 type array for Transform
-export type Transform = [number, number, number];
-
-//
-// export type CoordinateExtent = [[number, number], [number, number]];
-
-export interface GetCenterParams {
- sourceX: number;
- sourceY: number;
- targetX: number;
- targetY: number;
- sourcePosition?: Position;
- targetPosition?: Position;
-}
-//needed for getCenter funciotn
-const LeftOrRight = [Position.Left, Position.Right];
-//used to determine the position for edge text on a Smooth or Step Edge
-export const getCenter = ({
- sourceX,
- sourceY,
- targetX,
- targetY,
- sourcePosition = Position.Bottom,
- targetPosition = Position.Top,
-}: GetCenterParams): [number, number, number, number] => {
- const sourceIsLeftOrRight = LeftOrRight.includes(sourcePosition);
- const targetIsLeftOrRight = LeftOrRight.includes(targetPosition);
-
- // we expect flows to be horizontal or vertical (all handles left or right respectively top or bottom)
- // a mixed edge is when one the source is on the left and the target is on the top for example.
- const mixedEdge =
- (sourceIsLeftOrRight && !targetIsLeftOrRight) ||
- (targetIsLeftOrRight && !sourceIsLeftOrRight);
-
- if (mixedEdge) {
- const xOffset = sourceIsLeftOrRight ? Math.abs(targetX - sourceX) : 0;
- const centerX = sourceX > targetX ? sourceX - xOffset : sourceX + xOffset;
-
- const yOffset = sourceIsLeftOrRight ? 0 : Math.abs(targetY - sourceY);
- const centerY = sourceY < targetY ? sourceY + yOffset : sourceY - yOffset;
-
- return [centerX, centerY, xOffset, yOffset];
- }
-
- const xOffset = Math.abs(targetX - sourceX) / 2;
- const centerX = targetX < sourceX ? targetX + xOffset : targetX - xOffset;
-
- const yOffset = Math.abs(targetY - sourceY) / 2;
- const centerY = targetY < sourceY ? targetY + yOffset : targetY - yOffset;
-
- return [centerX, centerY, xOffset, yOffset];
-};
diff --git a/frontend/src/lib/components/graph/svelvet/nodes/controllers/util.ts b/frontend/src/lib/components/graph/svelvet/nodes/controllers/util.ts
deleted file mode 100644
index f3aff1d3b3..0000000000
--- a/frontend/src/lib/components/graph/svelvet/nodes/controllers/util.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import type { StoreType } from '../../store/types/types';
-import { get } from 'svelte/store';
-
-/**
- * getNodeById will look for the targeted Node that has the same id provided in the Svelvet component store.
- *
- * @param store The Svelvet store containing the state of a Svelvet component
- * @param id The id of the targeted Node
- * @returns The targeted Node object in store.nodesStore
- */
-
-export function getNodeById(store: StoreType, id: string) {
- const nodesStore = get(store.nodesStore);
- const node = nodesStore[id];
- return node;
-}
diff --git a/frontend/src/lib/components/graph/svelvet/nodes/models/Node.ts b/frontend/src/lib/components/graph/svelvet/nodes/models/Node.ts
deleted file mode 100644
index cbadfde187..0000000000
--- a/frontend/src/lib/components/graph/svelvet/nodes/models/Node.ts
+++ /dev/null
@@ -1,156 +0,0 @@
-/** this is where we create our node store */
-import type { NodeType } from '../../store/types/types'
-import { get } from 'svelte/store'
-import { stores } from '../../store/models/store'
-/** A Node class that implements NodeType interface
- * @param {string} id The id of the Node
- * @param {number} positionX The X-axis position of the Node (left top corner of the Node)
- * @param {number} positionY The Y-axis position of the Node (left top corner of the Node)
- * @param {number} width The width of the Node
- * @param {number} height The height of the Node
- * @param {string} bgColor The background color of the node
- * @param {object} data A data object that user can specify; possible keys are 'label' and 'custom';
- * @param {string} canvasId The canvasId of the Svelvet component that the instantiated Node will be on.
- * @param {string} borderColor The border color of the Node
- * @param {boolean} image A boolean set to true if the Node needs to display an image
- * @param {string} src The src link for the image; image and src are closely tied and a src link is only needed when image sets to true
- * @param {string} textColor The color of the text in the Node
- * @param {string} borderRadius The border radius of the Node
- * @param {string} childNodes An array of node ids that will be grouped as child nodes of this Node. This is for the GroupNodes feature. The current implementation of this feature works one way but not the other (when you drag the parent node, the child nodes will move as a group but when you drag the child node, the parent node would not move along)
- * @param {string} className The custom class name if user specifies. This is for the custom className feature for Node.
- */
-export class Node implements NodeType {
- constructor(
- public id: string,
- public positionX: number,
- public positionY: number,
- public width: number,
- public height: number,
- public bgColor: string,
- public data: object,
- public canvasId: string,
- public borderColor: string,
- public image: boolean,
- public src: string,
- public textColor: string,
- public borderRadius: number,
- public childNodes: string[],
- public className: string,
- public clickCallback: Function
- ) {}
-
- /**
- * setPositionFromMovement will update the positionX and positionY of the Node when user drags a Node around on the canvas, reflect the changes in real time in the nodesStore, and also cascade the changes to all relative elements like Anchors and Edges.
- * @param {number} movementX The mouse movement value on the X-axis
- * @param {number} movementY The mouse movement value on the Y-axis
- */
- setPositionFromMovement(movementX: number, movementY: number) {
- const { nodesStore, anchorsStore, potentialAnchorsStore, boundary, lockedOption } =
- stores[this.canvasId]
-
- if (get(lockedOption)) return // don't do anything if locked is enabled
-
- // boundary sets the boundary of the canvas, or else it is false if their is no boundary
- // check if out of bounds, and if so return without doing anything
- const boundaryObj = get(boundary)
- if (
- typeof boundaryObj === 'object' &&
- (this.positionX + this.width + movementX >= boundaryObj.x ||
- this.positionY + this.height + movementY >= boundaryObj.y ||
- this.positionY + movementY <= 0 ||
- this.positionX + movementX <= 0)
- )
- return
- //update all necessary data
- this.positionX += movementX
- this.positionY += movementY
-
- // update children
- nodesStore.update((nodes) => {
- if (this.childNodes)
- for (const childNodeId of this.childNodes)
- nodes[childNodeId].setPositionFromMovement(movementX, movementY)
- return { ...nodes }
- })
-
- //update all the anchors on the node in the anchorsStore
- anchorsStore.update((anchors) => {
- for (const anchorId in anchors) {
- if (anchors[anchorId].nodeId === this.id) {
- anchors[anchorId].setPositionFromNode()
- }
- }
- return { ...anchors }
- })
-
- //update all the anchors on the node in the anchorsStore
- potentialAnchorsStore.update((anchors) => {
- for (const anchorId in anchors) {
- if (anchors[anchorId].nodeId === this.id) {
- anchors[anchorId].callback() // we don't have to worry about setting partner anchors/etc;
- }
- }
- return { ...anchors }
- })
- }
-
- /**
- * setSizeFromMovement will update the width and height of the Node when user resizes the Node by dragging at the right bottom corner (where the ResizedNode attached), reflect the changes in real time in the nodesStore, and also cascade the changes to all relative elements like Anchors and potential Anchors.
- *
- * @param movementX The mouse movement value on the X-axis
- * @param movementY The mouse movement value on the Y-axis
- */
- setSizeFromMovement(movementX: number, movementY: number) {
- this.width += movementX
- this.height += movementY
-
- const { anchorsStore, potentialAnchorsStore } = stores[this.canvasId]
-
- //Updates the anchor so it follows the node's position as the dimensions change
- anchorsStore.update((anchors) => {
- for (const anchorId in anchors) {
- if (anchors[anchorId].nodeId === this.id) {
- anchors[anchorId].setPositionFromNode()
- //anchors[anchorId].setPosition(movementX, movementY);
- }
- }
- return { ...anchors }
- })
-
- //update all the anchors on the node in the anchorsStore
- potentialAnchorsStore.update((anchors) => {
- for (const anchorId in anchors) {
- if (anchors[anchorId].nodeId === this.id) {
- anchors[anchorId].callback() // we don't have to worry about setting partner anchors/etc;
- }
- }
- return { ...anchors }
- })
- }
-
- /**
- * setExportableData is going to construct an object that holds all the node data that can be exported. This method is used for Exporting Diagrams feature.
- *
- * @returns An object with all the exportable data of the Node. The format of this object should align with the original format of node data user provided.
- */
- setExportableData() {
- const exportableData = {
- id: this.id,
- // canvasId: this.canvasId,
- width: this.width,
- height: this.height,
- position: { x: this.positionX, y: this.positionY },
- data: this.data,
- bgColor: this.bgColor,
- borderColor: this.borderColor,
- textColor: this.textColor,
- borderRadius: this.borderRadius,
- image: this.image,
- src: this.src,
- childNodes: this.childNodes,
- customClassName: this.className
- }
-
- return exportableData
- }
-}
diff --git a/frontend/src/lib/components/graph/svelvet/nodes/views/Node.svelte b/frontend/src/lib/components/graph/svelvet/nodes/views/Node.svelte
deleted file mode 100644
index f409fe9d26..0000000000
--- a/frontend/src/lib/components/graph/svelvet/nodes/views/Node.svelte
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
- {#if node.image}
-
- {/if}
-
-
-
-
diff --git a/frontend/src/lib/components/graph/svelvet/store/controllers/storeApi.ts b/frontend/src/lib/components/graph/svelvet/store/controllers/storeApi.ts
deleted file mode 100644
index 3cbb7ffe93..0000000000
--- a/frontend/src/lib/components/graph/svelvet/store/controllers/storeApi.ts
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-
-
-Important functions (in order of how likely I think you are to use them):
-
-findStore(canvasId: string)
-- Input: canvasId. There can be multiple Svelvet canvases on the same page, and each has their own store
-- Returns: store
-- Notes: You will need to call this function on every component you make
-
-getNodes(store, filter)
-- Description: this function returns of list of Node objects
-- Input: store: the store where you get the list of Node objects from
-- filter: an object where you can filter the array. For example, if you want to find nodes with an id of 'sdf-2d3fs' and positionX=35, then you
- would set filter = {id: 'sdf-2d3fs, positionX: 35}.
- Right now, you can only test for equality.
-- Notes: This is a very mongoose way of retrieving information. Given the relational nature of our stores, maybe it would be better to use an SQL-like syntax
- This array is non-reactive (ie, you cannot use information from this array to force a re-render of a Svelte component)
-
-createStoreEmpty(canvasId: string)
-- Input: canvasId.
-- Returns: store
-- Notes. This should be called once every time you initialize a new Svelvet canvas, (ie, only in the Svelvet.svelte file)
-
-populateSvelvetStoreFromUserInput(canvasId, nodes, edges)
-- canvasId: this the the canvasId of the Svelvet component you are creating a store for
-- nodes: this is an array of objects containing node info that is defined by the user. NOTE THAT THE STRUCTURE DIFFERS FROM THE NODES CLASS
- The whole point of populateSvelvetStoreFromUserInput is to convert nodes into proper Svelvet Node objects. An example of nodes is in
- $routes/testingplayground/index.svelte
-- edges: same as nodes, this is an array of objects containing edge info THAT IS DIFFERENT FROM THE EDGE CLASS.
-- Returns: store
-*/
-import { findStore, stores } from '../models/store'
-import { writable } from 'svelte/store'
-
-import type { StoreType } from '../types/types'
-import type { UserNodeType, UserEdgeType } from '../../types/types'
-import { populateAnchorsStore, populateNodesStore, populateEdgesStore } from './util'
-
-
-/**
- * createStoreEmpty will initialize a new Svelvet store with a unique canvasId.
- * If you have multiple Svelvet components on the page, the stores object will look like the following example:
- * const stores = \{
- * canvasId-1: store of Svelvet component 1,
- * canvasId-2: store of Svelvet component 2,
- * canvasId-3: store of Svelvet component 3,
- * \}
- * Notes: This should be called once every time you initialize a new Svelvet canvas, (ie, only in the Svelvet.svelte file).
- * This function will initialize an empty store for the Svelvet component and should be followed by invoking populateSvelvetStoreFromUserInput to populate all the initial state from the user input.
- *
- * @param canvasId The canvasId of the newly created Svelvet component
- * @returns An empty store for the newly created Svelvet component.
- */
-export function createStoreEmpty(canvasId: string): StoreType {
- stores[canvasId] = {
- nodesStore: writable({}),
- edgesStore: writable({}),
- anchorsStore: writable({}),
- potentialAnchorsStore: writable({}),
- widthStore: writable(600),
- heightStore: writable(600),
- backgroundStore: writable(false),
- movementStore: writable(true),
- nodeSelected: writable(false),
- nodeIdSelected: writable(-1),
- d3Scale: writable(1),
- options: writable({}),
- temporaryEdgeStore: writable([]),
- nodeCreate: writable(false), // this option sets whether the "nodeEdit" feature is enabled
- boundary: writable(false),
- edgeEditModal: writable(null), // this is used for edgeEditModal feature. When an edge is right clicked, store.edgeEditModal is set to the edgeId string. This causes a modal to be rendered
- lockedOption: writable(false),
- editableOption: writable(false), // true if you want nodes/edges to be editable. See feature editEdges
- d3ZoomParameters: writable({}), // this stores d3 parameters x, y, and zoom. This isn't used for anything other than giving users a way to access d3 zoom parameters if they want to build on top of Svelvet
- highlightEdgesOption: writable(true) // option to turn on/off highlightable edges
- }
- return stores[canvasId]
-}
-
-/**
- * populateSvelvetStoreFromUserInput will populate all the states and set these states into the Svelvet store initialized by invoking createStoreEmpty
- *
- * @param canvasId The canvasId of the Svelvet component you are creating a store for
- * @param nodes This is an array of objects containing node info that is defined by the user. NOTE THAT THE STRUCTURE DIFFERS FROM THE NODES CLASS. The whole point of populateSvelvetStoreFromUserInput is to convert nodes into proper Svelvet Node objects. An example of nodes is in $routes/testingplayground/index.svelte
- * @param edges Same as nodes, this is an array of objects containing edge info THAT IS DIFFERENT FROM THE EDGE CLASS.
- */
-export function populateSvelvetStoreFromUserInput(
- canvasId: string,
- nodes: UserNodeType[],
- edges: UserEdgeType[]
-): void {
- // find the store
- const store = findStore(canvasId)
-
- // populate store.nodesStore with user nodes
- populateNodesStore(store, nodes, canvasId)
- // populate store.anchorsStore with anchors. Note the userdoes not explictly define anchors; anchors are calculated from the edges
- populateAnchorsStore(store, nodes, edges, canvasId)
- // populate edges
- populateEdgesStore(store, edges, canvasId)
-
-}
diff --git a/frontend/src/lib/components/graph/svelvet/store/controllers/userApi.ts b/frontend/src/lib/components/graph/svelvet/store/controllers/userApi.ts
deleted file mode 100644
index edeec17454..0000000000
--- a/frontend/src/lib/components/graph/svelvet/store/controllers/userApi.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { findStore } from '../models/store';
-import { get } from 'svelte/store';
-export function getD3PositionX(canvasId) {
- const store = findStore(canvasId);
- const width = get(store.widthStore);
- const x = width / 2 - get(store.d3ZoomParameters).x; // user input is shifted so that x=0, y=0 occurs in the center
- return x;
-}
-export function getD3PositionY(canvasId) {
- const store = findStore(canvasId);
- const height = get(store.heightStore);
- const y = height / 2 - get(store.d3ZoomParameters).y; // user input is shifted so that x=0, y=0 occurs in the center
- return y;
-}
-export function getD3Zoom(canvasId) {
- const store = findStore(canvasId);
- return get(store.d3ZoomParameters).k;
-}
diff --git a/frontend/src/lib/components/graph/svelvet/store/controllers/util.ts b/frontend/src/lib/components/graph/svelvet/store/controllers/util.ts
deleted file mode 100644
index bcd42fe9a1..0000000000
--- a/frontend/src/lib/components/graph/svelvet/store/controllers/util.ts
+++ /dev/null
@@ -1,215 +0,0 @@
-const pkStringGenerator = () => (Math.random() + 1).toString(36).substring(7) // these are callbacks used to calculate anchor position relative to node
-import { dynamicCbCreator, fixedCbCreator } from '../../edges/controllers/anchorCbDev'
-
-import type { AnchorCbType, AnchorType } from '../../edges/types/types'
-
-import type { UserEdgeType, UserNodeType } from '../../types/types'
-import type { EdgeType, NodeType, StoreType } from '../types/types'
-
-import { getAnchors } from '../../edges/controllers/util'
-import { Anchor } from '../../edges/models/Anchor'
-import { Edge } from '../../edges/models/Edge'
-import { Node } from '../../nodes/models/Node'
-
-/**
- * Creates an Anchor on the targeted Node with infomation the userNode holds
- * @param store An object containing the state of the Svelvet component. You can access the following through `store`: nodesStore, edgesStore, anchorsStore, etc.
- * @param userNode A node that the user specifies. This is NOT the same as a Node object.
- * @param sourceOrTarget User specified information of source or target
- * @param canvasId The id of the canvas that holds the Anchor and its attached Node
- * @param edge An edge that the user specifies. It should target the userNode as source or target. This is NOT the same as an Edge object
- * @returns An Anchor object
- */
-
-function createAnchor(
- store: StoreType,
- userNode: UserNodeType | null,
- sourceOrTarget: 'source' | 'target',
- canvasId: string,
- edge: UserEdgeType
-) {
- // edge case
- if (userNode === null) throw `you cannot create an anchor without a user node (for now)`
-
- const edgeId = edge.id
- const anchorId = pkStringGenerator()
-
- // userCb is the appropriate source or taret callback from userEdge object. It is
- // possible the user to NOT set userCb in which case userCb will be undefined
- let userCb: Function | undefined
- if (sourceOrTarget === 'target') userCb = edge.targetAnchorCb
- else userCb = edge.sourceAnchorCb
-
- // create anchor callbacks
-
- let cb: AnchorCbType
- if (userCb === undefined) cb = dynamicCbCreator(store, edgeId, anchorId)
- else cb = fixedCbCreator(store, edgeId, anchorId, userNode.id, userCb)
-
- // Create a new anchor.
- const anchor = new Anchor(
- anchorId,
- userNode.id,
- edgeId,
- sourceOrTarget,
- -1, // dummy variables for x,y,angle for now
- -1, // dummy variables for x,y,angle for now
- cb,
- canvasId,
- 0 // dummy variables for x,y,angle for now
- )
- // return
- return anchor
-}
-
-/**
- * Populates edgesStore of Edges. This function does not return the edgesStore. Instead it sets the nodesStore of Svelvet store.
- * @param store An object containing the state of the Svelvet component. You can access the following through `store`: nodesStore, edgesStore, anchorsStore, etc.
- * @param edges An edge that the user specifies. This is NOT the same as a Edge object.
- * @param canvasId The canvasId of the Svelvet component that holds the Edges
- */
-export function populateEdgesStore(store: StoreType, edges: UserEdgeType[], canvasId: string) {
- const edgesStore: { [key: string]: EdgeType } = {}
- for (let i = 0; i < edges.length; i++) {
- const userEdge = edges[i]
- // { id: 'e1-2', source: 1, type: 'straight', target: 2, label: 'e1-2' },
- // source is node.id for the source node
- // target is node.id for the target node
- // We need to get the anchors
- const { id: edgeId } = userEdge
-
- const anchors = getAnchors(store, { edgeId: edgeId })
- // check that we have two anchors for every edge
- if (anchors.length !== 2) throw 'We should have two anchors for every node'
- // check that we have 1 source anchor and 1 target anchor. Since sourceOrTarget is typed to be either 'source'
- // or 'target', it suffices to check whether there are two unique elements
- if (new Set(anchors.map((e) => e.sourceOrTarget)).size !== 2)
- throw 'we should have one source and one target anchor'
- // get source and target anchor
- let sourceAnchor, targetAnchor
- if (anchors[0].sourceOrTarget === 'source') {
- sourceAnchor = anchors[0]
- targetAnchor = anchors[1]
- } else {
- sourceAnchor = anchors[1]
- targetAnchor = anchors[0]
- }
-
- edgesStore[edgeId] = new Edge(
- edgeId,
- sourceAnchor.positionX,
- sourceAnchor.positionY,
- targetAnchor.positionX,
- targetAnchor.positionY,
- canvasId,
- userEdge.label === undefined ? '' : userEdge.label,
- userEdge.type === undefined ? 'bezier' : userEdge.type,
- userEdge.labelBgColor === undefined ? 'white' : userEdge.labelBgColor,
- userEdge.labelTextColor === undefined ? 'black' : userEdge.labelTextColor,
- userEdge.edgeColor === undefined ? 'black' : userEdge.edgeColor,
- userEdge.animate === undefined ? false : userEdge.animate,
- userEdge.noHandle === undefined ? false : userEdge.noHandle,
- userEdge.arrow === undefined ? false : userEdge.arrow,
- userEdge.clickCallback === undefined ? () => {} : userEdge.clickCallback,
- userEdge.className === undefined ? '' : userEdge.className,
- userEdge.offset
- )
- }
- store.edgesStore.set(edgesStore)
-}
-
-/**
- * Finds userNode (with UserNodeType; Not the same as the Node) by the node id from nodesStore
- * @param id The id of the Node in its nodesStore
- * @param userNodes The array of userNodes (NOT the same as Node object)
- * @returns The node that user specified or null if not found
- */
-function findUserNodeById(id: string, userNodes: UserNodeType[]): UserNodeType | null {
- for (let i = 0; i < userNodes.length; i++) {
- const userNode = userNodes[i]
- if (userNode.id === id) return userNode
- }
- return null
-}
-
-/**
- * Populates the anchorsStore. This will overwrite any data in the AnchorsStore.
- * @param store The Svelvet store containing the state of the Svelvet component
- * @param nodes An array of user specified nodes
- * @param edges An array of user specified edges
- * @param canvasId The canvasId of the Svelvet component that holds the nodes and edges
- */
-export function populateAnchorsStore(
- store: StoreType,
- nodes: UserNodeType[],
- edges: UserEdgeType[],
- canvasId: string
-) {
- // anchorsStore will populated and eventaully synchronized to store.anchorsStore
- const anchorsStore: { [key: string]: AnchorType } = {}
- // iterate through user edges. Note the user never explicitly defines anchors; we calculate anchors
- // from the user edge/node information
- for (let i = 0; i < edges.length; i++) {
- const userEdge = edges[i]
- // find the source and target userNodes. These will be used to create the nodeId foreign key and
- // determine placement of the anchor based on userNode.targetPosition, useNode.sourcePosition
- const { source: sourceNodeId, target: targetNodeId } = userEdge
- const sourceUserNode = findUserNodeById(sourceNodeId, nodes)
- const targetUserNode = findUserNodeById(targetNodeId, nodes)
- // create source anchor
- const sourceAnchor = createAnchor(store, sourceUserNode, 'source', canvasId, userEdge)
- // create target anchor
- const targetAnchor = createAnchor(store, targetUserNode, 'target', canvasId, userEdge)
- // store source and target anchors
- anchorsStore[sourceAnchor.id] = sourceAnchor
- anchorsStore[targetAnchor.id] = targetAnchor
- }
-
- //populates the anchorsStore
- store.anchorsStore.set(anchorsStore)
-
- // set anchor positions. We can only set anchor positions after anchorsStore and nodesStore
- // has been populated. TODO: maybe add a check to see that anchorsStore and NodesStore populated?
- const anchors = getAnchors(store)
- for (const anchor of anchors) anchor.callback()
-}
-
-/**
- * Populates the nodesStore. This will overwrite any data in the nodesStore.
- * @param store The Svelvet store containing the state of the Svelvet component
- * @param nodes An array of user specifed nodes
- * @param canvasId The canvasId of the Svelvet component that holds the nodes
- */
-export function populateNodesStore(store: StoreType, nodes: UserNodeType[], canvasId: string) {
- // this is the nodesStore object. THIS IS NOT THE SAME AS A NODESTORE
- const nodesStore: { [key: string]: NodeType } = {}
- // iterate through user nodes and create node objects
- for (let i = 0; i < nodes.length; i++) {
- const userNode: UserNodeType = nodes[i]
- const nodeId = userNode.id
-
- // TODO: move sanitizing default values to middleware
- const node = new Node(
- nodeId.toString(),
- userNode.position.x,
- userNode.position.y,
- userNode.width,
- userNode.height,
- userNode.bgColor ?? 'white',
- userNode.data,
- canvasId,
- userNode.borderColor === undefined ? 'black' : userNode.borderColor,
- userNode.image === undefined ? false : userNode.image,
- userNode.src === undefined ? '' : userNode.src,
- userNode.textColor === undefined ? '' : userNode.textColor,
- userNode.borderRadius === undefined ? 0 : userNode.borderRadius,
- userNode.childNodes === undefined ? [] : userNode.childNodes,
- userNode.className === undefined ? '' : userNode.className,
- userNode.clickCallback === undefined ? () => {} : userNode.clickCallback
- )
-
- nodesStore[nodeId] = node
- }
- // This is actually what sets the store
- store.nodesStore.set(nodesStore)
-}
diff --git a/frontend/src/lib/components/graph/svelvet/store/models/store.ts b/frontend/src/lib/components/graph/svelvet/store/models/store.ts
deleted file mode 100644
index 0765623a9a..0000000000
--- a/frontend/src/lib/components/graph/svelvet/store/models/store.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { StoreType } from '../types/types';
-
-
-export function findStore(canvasId: string): StoreType {
- return stores[canvasId]
-}
-/**
- `store` is a dictionary of Svelvet stores.
- * The reason why we have multiple Svelvet stores is to handle multiple canvases on the same page.
- * A Svelvet store is the single source of truth for a canvas state.
- * We discourage developers from interacting with stores directly; instead use the api methods in
- `src/lib/controllers/storeApi.ts`. However, if need to direct access you can do so by importing:
- `import { store } from 'src/lib/models/store';`
-*/
-export const stores: { [key: string]: StoreType } = {};
diff --git a/frontend/src/lib/components/graph/svelvet/store/types/types.ts b/frontend/src/lib/components/graph/svelvet/store/types/types.ts
deleted file mode 100644
index 8cd17b95a6..0000000000
--- a/frontend/src/lib/components/graph/svelvet/store/types/types.ts
+++ /dev/null
@@ -1,122 +0,0 @@
-import type { Writable } from 'svelte/store'
-import type { AnchorType } from '../../edges/types/types'
-
-export interface ResizeNodeType {
- id: string
- nodeId: string
- edgeId?: string
- canvasId: string
- anchorId?: string
- positionX: number
- positionY: number
- setPositionAndCascade: Function
- setPosition: Function
- delete: Function
-}
-
-/*
-Type for a single svelvet store
-*/
-export interface StoreType {
- nodesStore: Writable<{ [key: string]: NodeType }>
- edgesStore: Writable<{ [key: string]: EdgeType }>
- anchorsStore: Writable<{ [key: string]: AnchorType }>
- potentialAnchorsStore: Writable<{ [key: string]: PotentialAnchorType }>
- widthStore: Writable
- heightStore: Writable
- backgroundStore: Writable
- movementStore: Writable
- nodeIdSelected: Writable
- nodeSelected: Writable // this is used to stop d3 panning when node is being dragged
- d3Scale: Writable // for zoom and pan
- options: Writable<{ [key: string]: any }>
- temporaryEdgeStore: Writable
- nodeCreate: Writable // this option sets whether the "nodeEdit" feature is enabled
- boundary: Writable
- edgeEditModal: Writable // this options is used to place the edgeEdit modal when an edge is right-clicked. null is no modal, positionType if modal should be placed at position defined by postionType.x, positionType.y
- lockedOption: Writable
- editableOption: Writable
- d3ZoomParameters: Writable<{
- [key: string]: number
- }>
- highlightEdgesOption: Writable
-}
-
-export interface PositionType {
- x: number
- y: number
-}
-
-export interface NodeType {
- id: string
- width: number
- height: number
- positionX: number
- positionY: number
- bgColor: string
- data: {
- html?: any
- custom?: { component: any; props?: any; cb?: (e: string, detail: any) => void }
- img?: any
- label?: string
- }
- canvasId: string
- setPositionFromMovement: Function
- setSizeFromMovement: Function
- setExportableData: Function
- borderColor: string
- image: boolean
- src: string
- textColor: string
- borderRadius: number
- childNodes: string[]
- className: string //This is for custom className for node
- clickCallback: Function // user-supplied callback that executes when the node is clicked
-}
-
-export interface EdgeType {
- id: string
- sourceX: number
- sourceY: number
- targetX: number
- targetY: number
- canvasId: string
- label: string
- type: 'straight' | 'smoothstep' | 'step' | 'bezier'
- labelBgColor: string
- labelTextColor: string
- edgeColor: string
- animate: boolean
- noHandle: boolean
- arrow: boolean
- clickCallback: Function
- className: string
- delete: Function
- setExportableData: Function
-}
-
-export interface PotentialAnchorType {
- id: string
- nodeId: string
- callback: Function // callback is used to calculate positionX, positionY based on parent node's data, and set the anchor position // TODO: rename to something better
- positionX: number
- positionY: number
- angle: number
- canvasId: string
- delete: Function
-}
-
-export interface TemporaryEdgeType {
- id: string
- sourcePotentialAnchorId: string // this will always be set
- sourceX: number
- sourceY: number
- targetPotentialAnchorId: string | null // this will be null until the temporary edge reaches another temporary anchor
- targetX: number
- targetY: number
- canvasId: string
- type: string
- edgeColor: string
- createEdge: Function
- createNode: Function
-}
diff --git a/frontend/src/lib/components/graph/svelvet/types/README.md b/frontend/src/lib/components/graph/svelvet/types/README.md
deleted file mode 100644
index 85773d6efc..0000000000
--- a/frontend/src/lib/components/graph/svelvet/types/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Types
-
-This folder contains types exported to the user, as decribed in feature: `https://www.svelvet.io/docs/typescript/`
diff --git a/frontend/src/lib/components/graph/svelvet/types/index.ts b/frontend/src/lib/components/graph/svelvet/types/index.ts
deleted file mode 100644
index 22937de732..0000000000
--- a/frontend/src/lib/components/graph/svelvet/types/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-// this file exports user types
-import type { UserEdgeType, UserNodeType } from './types'
-export type { UserEdgeType, UserNodeType }
diff --git a/frontend/src/lib/components/graph/svelvet/types/types.ts b/frontend/src/lib/components/graph/svelvet/types/types.ts
deleted file mode 100644
index b24b3672ed..0000000000
--- a/frontend/src/lib/components/graph/svelvet/types/types.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-export interface UserNodeType {
- id: string
- width: number
- height: number
- bgColor?: string
- data: {
- html?: any
- custom?: { component: any; props?: any; cb?: (e: string, detail: any) => void }
- img?: any
- }
- position: { x: number; y: number }
- borderColor?: string | undefined
- image?: boolean
- src?: string
- textColor?: string
- targetPosition?: 'left' | 'right' | 'top' | 'bottom'
- sourcePosition?: 'left' | 'right' | 'top' | 'bottom'
- borderRadius?: number
- childNodes?: string[]
- className?: string
- clickCallback?: Function
-}
-
-export interface UserEdgeType {
- id: string
- source: string
- target: string
- sourceAnchorCb?: Function
- targetAnchorCb?: Function
- label?: string
- labelBgColor?: string
- labelTextColor?: string
- edgeColor?: string
- type?: 'straight' | 'smoothstep' | 'step' | 'bezier' | undefined
- animate?: boolean
- noHandle?: boolean
- arrow?: boolean
- clickCallback?: Function
- className?: string
- offset?: number
-}
-
-import { findStore } from '../store/models/store'
-import { get } from 'svelte/store'
-export function getD3PositionX(canvasId: string) {
- const store = findStore(canvasId)
- const width = get(store.widthStore)
- const x = width / 2 - get(store.d3ZoomParameters).x // user input is shifted so that x=0, y=0 occurs in the center
- return x
-}
-export function getD3PositionY(canvasId: string) {
- const store = findStore(canvasId)
- const height = get(store.heightStore)
- const y = height / 2 - get(store.d3ZoomParameters).y // user input is shifted so that x=0, y=0 occurs in the center
- return y
-}
-export function getD3Zoom(canvasId: string) {
- const store = findStore(canvasId)
- return get(store.d3ZoomParameters).k
-}
diff --git a/frontend/src/lib/components/graph/util.ts b/frontend/src/lib/components/graph/util.ts
index 0c870dad16..f3c3d1bbb3 100644
--- a/frontend/src/lib/components/graph/util.ts
+++ b/frontend/src/lib/components/graph/util.ts
@@ -9,16 +9,10 @@ export const NODE = {
}
}
-export function* createIdGenerator(): Generator {
- let id = 0
- while (true) {
- yield id++
- }
-}
-
export function getStateColor(
state: FlowStatusModule['type'] | undefined,
- isDark: boolean
+ isDark: boolean,
+ lightModeBackground: string = '#dfe6ee'
): string {
switch (state) {
case 'Success':
@@ -32,6 +26,6 @@ export function getStateColor(
case 'WaitingForExecutor':
return isDark ? '#ea580c' : 'rgb(255, 208, 193)'
default:
- return isDark ? '#2e3440' : '#fff'
+ return isDark ? '#2e3440' : lightModeBackground
}
}
diff --git a/frontend/src/routes/approve/[workspace]/[job]/[resume]/[hmac]/+page.svelte b/frontend/src/routes/approve/[workspace]/[job]/[resume]/[hmac]/+page.svelte
index a4e7e681d1..645bc58c20 100644
--- a/frontend/src/routes/approve/[workspace]/[job]/[resume]/[hmac]/+page.svelte
+++ b/frontend/src/routes/approve/[workspace]/[job]/[resume]/[hmac]/+page.svelte
@@ -9,7 +9,6 @@
import JobArgs from '$lib/components/JobArgs.svelte'
import { onDestroy, onMount } from 'svelte'
import Tooltip from '$lib/components/Tooltip.svelte'
- import FlowGraph from '$lib/components/graph/FlowGraph.svelte'
import SchemaForm from '$lib/components/SchemaForm.svelte'
import { enterpriseLicense, userStore, workspaceStore } from '$lib/stores'
import { LogIn, AlertTriangle } from 'lucide-svelte'
@@ -20,6 +19,7 @@
import { setLicense } from '$lib/enterpriseUtils'
import DisplayResult from '$lib/components/DisplayResult.svelte'
import ScheduleEditor from '$lib/components/ScheduleEditor.svelte'
+ import FlowGraphV2 from '$lib/components/graph/FlowGraphV2.svelte'
$workspaceStore = $page.params.workspace
let rd = $page.url.href.replace($page.url.origin, '')
@@ -286,7 +286,7 @@
{#if job && job.raw_flow && !completed}
Flow details
-
- import FlowGraph from '$lib/components/graph/FlowGraph.svelte'
+ import FlowGraphV2 from '$lib/components/graph/FlowGraphV2.svelte'
import { decodeState } from '$lib/utils'
let content = localStorage.getItem('svelvet')
@@ -8,7 +8,7 @@
: { modules: [], failureModule: undefined }
-
+