Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
0a432c6d
Commit
0a432c6d
authored
3 weeks ago
by
ali asaria
Browse files
Options
Downloads
Patches
Plain Diff
allow moving nodes and saving their position
parent
65aeb5a3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/renderer/components/Experiment/Workflows/WorkflowCanvas.tsx
+18
-17
18 additions, 17 deletions
...nderer/components/Experiment/Workflows/WorkflowCanvas.tsx
src/renderer/lib/transformerlab-api-sdk.ts
+8
-0
8 additions, 0 deletions
src/renderer/lib/transformerlab-api-sdk.ts
with
26 additions
and
17 deletions
src/renderer/components/Experiment/Workflows/WorkflowCanvas.tsx
+
18
−
17
View file @
0a432c6d
...
...
@@ -13,7 +13,6 @@ import { PlusCircleIcon } from 'lucide-react';
import
{
useCallback
,
useEffect
}
from
'
react
'
;
import
CustomNode
from
'
./CustomNode
'
;
import
*
as
chatAPI
from
'
../../../lib/transformerlab-api-sdk
'
;
import
{
mutate
}
from
'
swr
'
;
const
nodeTypes
=
{
customNode
:
CustomNode
};
...
...
@@ -55,10 +54,13 @@ function generateNodes(workflow: any): any[] {
template
:
node
.
template
,
metadata
:
node
?.
metadata
,
};
const
savedPosition
=
node
?.
metadata
?.
position
||
{
x
:
0
,
y
:
position
};
const
nextNode
=
{
id
:
node
.
id
,
type
:
'
customNode
'
,
position
:
{
x
:
0
,
y
:
p
osition
}
,
position
:
savedP
osition
,
data
:
data
,
};
out
.
push
(
nextNode
);
...
...
@@ -97,6 +99,9 @@ function generateEdges(workflow: any) {
for
(
let
i
=
0
;
i
<
workflowConfig
.
nodes
.
length
;
i
++
)
{
const
currentNode
=
workflowConfig
.
nodes
[
i
];
if
(
!
Array
.
isArray
(
currentNode
.
out
))
{
continue
;
}
currentNode
.
out
.
forEach
((
nextId
)
=>
{
out
.
push
({
id
:
currentNode
.
id
+
nextId
,
...
...
@@ -150,21 +155,17 @@ const Flow = ({
},
[
reactFlowInstance
,
selectedWorkflow
]);
const
onNodeDragStop
=
useCallback
(
async
(
event
,
node
)
=>
{
// Save all current node positions
const
allCurrentPositions
=
nodes
.
map
((
n
)
=>
({
id
:
n
.
id
,
position
:
n
.
position
,
}));
// Save to your backend or storage
// for (const node of allCurrentPositions) {
// console.log('update node: ' + node?.id);
// await fetch(
// chatAPI.Endpoints.Workflows.UpdateNode(workflowId, node?.id, {
// position: node.position,
// })
// );
// }
const
metadata
=
JSON
.
stringify
({
position
:
node
.
position
,
});
await
fetch
(
chatAPI
.
Endpoints
.
Workflows
.
EditNodeMetadata
(
workflowId
,
node
?.
id
,
metadata
)
);
mutateWorkflows
();
},
[]);
return
(
...
...
This diff is collapsed.
Click to expand it.
src/renderer/lib/transformerlab-api-sdk.ts
+
8
−
0
View file @
0a432c6d
...
...
@@ -1042,6 +1042,14 @@ Endpoints.Workflows = {
nodeId
+
'
&node=
'
+
node
,
EditNodeMetadata
:
(
workflowId
:
string
,
nodeId
:
string
,
metadata
:
string
)
=>
API_URL
()
+
'
workflows/edit_node_metadata/
'
+
workflowId
+
'
?node_id=
'
+
nodeId
+
'
&metadata=
'
+
metadata
,
RunWorkflow
:
(
workflowId
:
string
)
=>
API_URL
()
+
'
workflows/start/
'
+
workflowId
,
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment