diff --git a/components/process-flow/ApiNodeConfiguration.vue b/components/process-flow/ApiNodeConfiguration.vue index e32c927..01f8d1c 100644 --- a/components/process-flow/ApiNodeConfiguration.vue +++ b/components/process-flow/ApiNodeConfiguration.vue @@ -2,7 +2,7 @@

API Call Configuration

-
+ -
+
@@ -30,6 +32,7 @@ id="apiMethod" v-model="localNodeData.apiMethod" class="form-control" + @change="saveChanges" > @@ -47,37 +50,112 @@ type="text" class="form-control" placeholder="https://example.com/api/endpoint" + @blur="saveChanges" /> You can use process variables with curly braces: https://example.com/api/users/{userId}
+
- - - You can use process variables with curly braces: { "userId": "{userId}" } +
+
+ + + + +
+ +
+ + Use variables in curly braces, e.g.: { "userId": "{userId}" } + + +
+
Preview with Current Values:
+
+
{{ getPreviewWithValues('requestBody') }}
+
+
+
- +
+
+ + + + +
+ +
+ + Use variables in curly braces, e.g.: { "Authorization": "Bearer {accessToken}" } + + + +
+
Preview with Current Values:
+
+
{{ getPreviewWithValues('headers') }}
+
+
+
@@ -85,18 +163,17 @@ id="outputVariable" v-model="localNodeData.outputVariable" class="form-control flex-grow" + @change="saveChanges" > - - - +
-
- -
- - -
-
- +
@@ -133,18 +196,17 @@ id="errorVariable" v-model="localNodeData.errorVariable" class="form-control flex-grow" + @change="saveChanges" > - - - +
- -
- - - Test API Call - + +
+
+ + + {{ isLoading ? 'Testing...' : 'Test API Call' }} + +
+ + Testing API endpoint... +
+
+ + +
+
+
+ + + {{ testResult.success ? 'API Call Successful' : 'API Call Failed' }} + +
+ +
+ + +
+
Response stored in variable: {{ localNodeData.outputVariable }}
+
+
{{ JSON.stringify(testResult.data, null, 2) }}
+
+
+ + +
+
Error stored in variable: {{ localNodeData.errorVariable }}
+
+
{{ JSON.stringify(testResult.error, null, 2) }}
+
+
+
\ No newline at end of file diff --git a/components/process-flow/ProcessFlowCanvas.vue b/components/process-flow/ProcessFlowCanvas.vue index 43b5219..df2f1e4 100644 --- a/components/process-flow/ProcessFlowCanvas.vue +++ b/components/process-flow/ProcessFlowCanvas.vue @@ -311,48 +311,52 @@ const onDragOver = (event) => { event.dataTransfer.dropEffect = 'copy'; }; -// Add a method to update a node in the flow -const updateNode = (nodeId, updates) => { - if (!nodeId) return; +// Define methods to expose to parent components +defineExpose({ + updateNode, + addNode, + removeNode, + fitView +}); + +// Update an existing node +function updateNode(nodeId, newData) { + const nodeToUpdate = nodes.value.find(node => node.id === nodeId); + if (!nodeToUpdate) return; - // console.log('ProcessFlowCanvas: Updating node:', nodeId, updates); - - // Find the node in Vue Flow nodes - const nodeIndex = nodes.value.findIndex(n => n.id === nodeId); - if (nodeIndex === -1) { - console.warn(`Node with ID ${nodeId} not found in flow`); - return; + // Update the node properties + if (newData.label) { + nodeToUpdate.label = newData.label; } - // Update the node with new values - const node = nodes.value[nodeIndex]; + // Update the node data + if (newData.data) { + nodeToUpdate.data = { + ...nodeToUpdate.data, + ...newData.data + }; + } - // Ensure label is consistently set in both places - const updatedLabel = updates.label || node.label; - const updatedData = { - ...node.data, - ...(updates.data || {}), - label: updatedLabel // Ensure label is also in data - }; + // Update node internals to trigger re-render + updateNodeInternals([nodeId]); - // Update the node directly to avoid triggering watchers unnecessarily - Object.assign(nodes.value[nodeIndex], { - label: updatedLabel, - data: updatedData - }); - - // Notify Vue Flow to update the node's internals - updateNodeInternals(nodeId); - - // console.log('Node updated:', updatedData); - - return updatedData; -}; + return nodeToUpdate; +} -// Expose methods to parent components -defineExpose({ - updateNode -}); +// Add a new node to the canvas +function addNode(node) { + addNodes([node]); + return node; +} + +// Remove a node from the canvas +function removeNode(nodeId) { + const nodeToRemove = nodes.value.find(node => node.id === nodeId); + if (!nodeToRemove) return; + + removeNodes([nodeToRemove]); + return nodeToRemove; +}