Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node display #23

Merged
merged 19 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
77a043d
Fixed the location for storing of run data for a node
preet-bhadra Nov 12, 2024
a4d4345
Merge branch 'main' of https://github.com/sevn-ai/pyspur_dev into dyn…
preet-bhadra Nov 12, 2024
dd65c5f
Merge branch 'main' of https://github.com/sevn-ai/pyspur_dev into dyn…
preet-bhadra Nov 12, 2024
dacf46a
Merge branch 'main' of https://github.com/sevn-ai/pyspur_dev into dyn…
preet-bhadra Nov 12, 2024
895c84d
Merge branch 'main' of https://github.com/sevn-ai/pyspur_dev into dyn…
preet-bhadra Nov 12, 2024
f0f40a6
Fetching nodeTypes once on flowcanvas as well.
preet-bhadra Nov 12, 2024
a93ed6c
Fixed the location for the node types update in redux store
preet-bhadra Nov 12, 2024
9c5bef1
Made it sequential
preet-bhadra Nov 12, 2024
800d26e
Merge branch 'main' of https://github.com/sevn-ai/pyspur_dev into dyn…
preet-bhadra Nov 13, 2024
4545a8f
Partial run
preet-bhadra Nov 13, 2024
d7a16e5
Merge branch 'main' of https://github.com/sevn-ai/pyspur_dev into dyn…
preet-bhadra Nov 14, 2024
970f89e
v1: edge handling on node collapsing.
preet-bhadra Nov 14, 2024
b778da5
v1.1: ficed output handle massive offset.
preet-bhadra Nov 14, 2024
eb092ae
v1.3: matching the x-offset in collapse and non-collapse mode.
preet-bhadra Nov 14, 2024
8c48b29
v1.4: made the nodes compact on collapsing
preet-bhadra Nov 14, 2024
a9479ee
v1.5.1: fixed dependency issue.
preet-bhadra Nov 14, 2024
446daf1
Merge branch 'main' of https://github.com/sevn-ai/pyspur_dev into nod…
preet-bhadra Nov 14, 2024
3469b1f
Improved readibility and made inputNode consistent
preet-bhadra Nov 15, 2024
662b21a
Updated collapse button position and collapsed mode padding
preet-bhadra Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Header = ({ activePage }) => {
Object.entries(outputs).forEach(([nodeId, output_values]) => {
const node = nodes.find((node) => node.id === nodeId);
if (output_values) {
dispatch(updateNodeData({ id: nodeId, data: { run: { ...node.data.run, data: output_values } } }));
dispatch(updateNodeData({ id: nodeId, data: { run: { ...node.data.run, ...output_values } } }));
}
});
}
Expand Down
106 changes: 73 additions & 33 deletions frontend/src/components/nodes/BaseNode.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import {
Tooltip,
} from "@nextui-org/react";
import { Icon } from "@iconify/react";
import usePartialRun from '../../hooks/usePartialRun';

const BaseNode = ({ id, data = {}, children, style = {}, isInputNode = false }) => {
const [isCollapsed, setIsCollapsed] = useState(false);
const BaseNode = ({ isCollapsed, setIsCollapsed, id, data = {}, children, style = {}, isInputNode = false }) => {
const [showControls, setShowControls] = useState(false);
const [isTooltipHovered, setIsTooltipHovered] = useState(false);
const dispatch = useDispatch();

const hoveredNodeId = useSelector((state) => state.flow.hoveredNode);
const selectedNodeId = useSelector((state) => state.flow.selectedNode);

const { executePartialRun, loading, error, result } = usePartialRun();

const handleMouseEnter = () => {
dispatch(setHoveredNode({ nodeId: id }));
setShowControls(true);
Expand All @@ -41,6 +43,21 @@ const BaseNode = ({ id, data = {}, children, style = {}, isInputNode = false })
}
};

const handlePartialRun = () => {
const initialInputs = {
"input_node": { "user_message": "Give me geographical conditions of London" }
};
const partialOutputs = {
"input_node": { "user_message": "Hi There!" },
"node_1731411247373": { "response": "Hello, How are ya?" }
};
const rerunPredecessors = true;

const workflowId = window.location.pathname.split('/').pop();

executePartialRun(workflowId, id, initialInputs, partialOutputs, rerunPredecessors);
};

const isHovered = String(id) === String(hoveredNodeId);
const isSelected = String(id) === String(selectedNodeId);

Expand Down Expand Up @@ -70,17 +87,6 @@ const BaseNode = ({ id, data = {}, children, style = {}, isInputNode = false })
borderRadius: '12px',
fontSize: '0.75rem',
display: 'inline-block',
marginBottom: '8px',
};

const collapseButtonStyle = {
position: 'absolute',
right: '8px',
bottom: '4px',
minWidth: 'auto',
height: '20px',
padding: '0 8px',
fontSize: '0.7rem',
};

return (
Expand All @@ -93,29 +99,61 @@ const BaseNode = ({ id, data = {}, children, style = {}, isInputNode = false })
isHoverable
>
{data && data.title && (
<CardHeader style={{ position: 'relative', paddingBottom: '28px' }}>
<h3 className="text-lg font-semibold text-center">{data?.userconfig?.title || data?.title || 'Untitled'}</h3>
<div style={{ ...tagStyle, position: 'absolute', top: '8px', right: '8px' }} className="node-acronym-tag">
{acronym}
</div>
<Button
size="sm"
variant="flat"
style={collapseButtonStyle}
onClick={() => setIsCollapsed(!isCollapsed)}
<CardHeader
style={{
position: 'relative',
paddingTop: '8px',
paddingBottom: isCollapsed ? '0px' : '16px',
}}
>
<h3
className="text-lg font-semibold text-center"
style={{ marginBottom: isCollapsed ? '4px' : '8px' }}
>
{isCollapsed ? '▼' : '▲'}
</Button>
{data?.userconfig?.title || data?.title || 'Untitled'}
</h3>

{/* Container for the collapse button and acronym tag */}
<div
style={{
position: 'absolute',
top: '8px',
right: '8px',
display: 'flex',
alignItems: 'center',
}}
>
{/* Collapse Button */}
<Button
size="sm"
variant="flat"
style={{
minWidth: 'auto',
height: '24px',
padding: '0 8px',
fontSize: '0.8rem',
marginRight: '4px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
onClick={() => setIsCollapsed(!isCollapsed)}
>
{isCollapsed ? '▼' : '▲'}
</Button>

{/* Acronym Tag */}
<div style={{ ...tagStyle }} className="node-acronym-tag">
{acronym}
</div>
</div>
</CardHeader>
)}
<Divider />
{!isCollapsed && <Divider />}

{!isCollapsed &&
<CardBody
className="px-1"
>
{children}
</CardBody>}
<CardBody className="px-1">
{children}
</CardBody>
</Card>

{(showControls || isSelected) && (
Expand Down Expand Up @@ -146,6 +184,8 @@ const BaseNode = ({ id, data = {}, children, style = {}, isInputNode = false })
isIconOnly
radius="full"
variant="light"
onPress={handlePartialRun}
disabled={loading}
>
<Icon className="text-default-500" icon="solar:play-linear" width={22} />
</Button>
Expand All @@ -166,4 +206,4 @@ const BaseNode = ({ id, data = {}, children, style = {}, isInputNode = false })
);
};

export default BaseNode;
export default BaseNode;
Loading