diff --git a/packages/components/nodes/utilities/StickyNote/StickyNote.ts b/packages/components/nodes/utilities/StickyNote/StickyNote.ts new file mode 100644 index 000000000..8b0ec208f --- /dev/null +++ b/packages/components/nodes/utilities/StickyNote/StickyNote.ts @@ -0,0 +1,40 @@ +import { INode, INodeParams } from '../../../src/Interface' + +class StickyNote implements INode { + label: string + name: string + version: number + description: string + type: string + icon: string + category: string + baseClasses: string[] + inputs: INodeParams[] + + constructor() { + this.label = 'Sticky Note' + this.name = 'stickyNote' + this.version = 1.0 + this.type = 'StickyNote' + this.icon = 'stickyNote.svg' + this.category = 'Utilities' + this.description = 'Add a sticky note' + this.inputs = [ + { + label: '', + name: 'note', + type: 'string', + rows: 1, + placeholder: 'Type something here', + optional: true + } + ] + this.baseClasses = [this.type] + } + + async init(): Promise { + return new StickyNote() + } +} + +module.exports = { nodeClass: StickyNote } diff --git a/packages/components/nodes/utilities/StickyNote/stickyNote.svg b/packages/components/nodes/utilities/StickyNote/stickyNote.svg new file mode 100644 index 000000000..81c45058d --- /dev/null +++ b/packages/components/nodes/utilities/StickyNote/stickyNote.svg @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/packages/components/src/Interface.ts b/packages/components/src/Interface.ts index 676618e57..d74ba1b4a 100644 --- a/packages/components/src/Interface.ts +++ b/packages/components/src/Interface.ts @@ -90,7 +90,7 @@ export interface INodeProperties { type: string icon: string version: number - category: string + category: string // TODO: use enum instead of string baseClasses: string[] description?: string filePath?: string diff --git a/packages/server/src/database/entities/Variable.ts b/packages/server/src/database/entities/Variable.ts index 88e0587d1..6af7a2378 100644 --- a/packages/server/src/database/entities/Variable.ts +++ b/packages/server/src/database/entities/Variable.ts @@ -1,9 +1,9 @@ /* eslint-disable */ import { Entity, Column, CreateDateColumn, UpdateDateColumn, PrimaryGeneratedColumn } from 'typeorm' -import { IVariable } from "../../Interface"; +import { IVariable } from '../../Interface' @Entity() -export class Variable implements IVariable{ +export class Variable implements IVariable { @PrimaryGeneratedColumn('uuid') id: string @@ -13,10 +13,9 @@ export class Variable implements IVariable{ @Column({ nullable: true, type: 'text' }) value: string - @Column({default: 'string', type: 'text'}) + @Column({ default: 'string', type: 'text' }) type: string - @CreateDateColumn() createdDate: Date diff --git a/packages/ui/src/ui-component/cards/NodeCardWrapper.js b/packages/ui/src/ui-component/cards/NodeCardWrapper.js new file mode 100644 index 000000000..7d7cafe59 --- /dev/null +++ b/packages/ui/src/ui-component/cards/NodeCardWrapper.js @@ -0,0 +1,21 @@ +// material-ui +import { styled } from '@mui/material/styles' + +// project imports +import MainCard from './MainCard' + +const NodeCardWrapper = styled(MainCard)(({ theme }) => ({ + background: theme.palette.card.main, + color: theme.darkTextPrimary, + border: 'solid 1px', + borderColor: theme.palette.primary[200] + 75, + width: '300px', + height: 'auto', + padding: '10px', + boxShadow: '0 2px 14px 0 rgb(32 40 45 / 8%)', + '&:hover': { + borderColor: theme.palette.primary.main + } +})) + +export default NodeCardWrapper diff --git a/packages/ui/src/ui-component/input/Input.js b/packages/ui/src/ui-component/input/Input.js index 3e5759386..e59f012ca 100644 --- a/packages/ui/src/ui-component/input/Input.js +++ b/packages/ui/src/ui-component/input/Input.js @@ -1,6 +1,6 @@ import { useState, useEffect, useRef } from 'react' import PropTypes from 'prop-types' -import { FormControl, OutlinedInput, Popover } from '@mui/material' +import { FormControl, OutlinedInput, InputBase, Popover } from '@mui/material' import SelectVariable from 'ui-component/json/SelectVariable' import { getAvailableNodesForVariable } from 'utils/genericHelper' @@ -50,29 +50,67 @@ export const Input = ({ inputParam, value, nodes, edges, nodeId, onChange, disab return ( <> - - { - setMyValue(e.target.value) - onChange(e.target.value) - }} - inputProps={{ - step: inputParam.step ?? 1, - style: { - height: inputParam.rows ? '90px' : 'inherit' - } - }} - /> - + {inputParam.name === 'note' ? ( + + { + setMyValue(e.target.value) + onChange(e.target.value) + }} + inputProps={{ + step: inputParam.step ?? 1, + style: { + border: 'none', + background: 'none', + color: '#212121' + } + }} + sx={{ + border: 'none', + background: 'none', + padding: '10px 14px', + textarea: { + '&::placeholder': { + color: '#616161' + } + } + }} + /> + + ) : ( + + { + setMyValue(e.target.value) + onChange(e.target.value) + }} + inputProps={{ + step: inputParam.step ?? 1, + style: { + height: inputParam.rows ? '90px' : 'inherit' + } + }} + /> + + )}
{inputParam?.acceptVariable && ( )(({ theme }) => ({ + [`& .${tooltipClasses.tooltip}`]: { + backgroundColor: theme.palette.nodeToolTip.background, + color: theme.palette.nodeToolTip.color, + boxShadow: theme.shadows[1] + } +})) + +export default NodeTooltip diff --git a/packages/ui/src/views/canvas/CanvasNode.js b/packages/ui/src/views/canvas/CanvasNode.js index e52de640c..44261f9c2 100644 --- a/packages/ui/src/views/canvas/CanvasNode.js +++ b/packages/ui/src/views/canvas/CanvasNode.js @@ -3,12 +3,13 @@ import { useContext, useState, useEffect } from 'react' import { useSelector } from 'react-redux' // material-ui -import { styled, useTheme } from '@mui/material/styles' +import { useTheme } from '@mui/material/styles' import { IconButton, Box, Typography, Divider, Button } from '@mui/material' -import Tooltip, { tooltipClasses } from '@mui/material/Tooltip' +import Tooltip from '@mui/material/Tooltip' // project imports -import MainCard from 'ui-component/cards/MainCard' +import NodeCardWrapper from '../../ui-component/cards/NodeCardWrapper' +import NodeTooltip from '../../ui-component/tooltip/NodeTooltip' import NodeInputHandler from './NodeInputHandler' import NodeOutputHandler from './NodeOutputHandler' import AdditionalParamsDialog from 'ui-component/dialog/AdditionalParamsDialog' @@ -19,28 +20,6 @@ import { baseURL } from 'store/constant' import { IconTrash, IconCopy, IconInfoCircle, IconAlertTriangle } from '@tabler/icons' import { flowContext } from 'store/context/ReactFlowContext' -const CardWrapper = styled(MainCard)(({ theme }) => ({ - background: theme.palette.card.main, - color: theme.darkTextPrimary, - border: 'solid 1px', - borderColor: theme.palette.primary[200] + 75, - width: '300px', - height: 'auto', - padding: '10px', - boxShadow: '0 2px 14px 0 rgb(32 40 45 / 8%)', - '&:hover': { - borderColor: theme.palette.primary.main - } -})) - -const LightTooltip = styled(({ className, ...props }) => )(({ theme }) => ({ - [`& .${tooltipClasses.tooltip}`]: { - backgroundColor: theme.palette.nodeToolTip.background, - color: theme.palette.nodeToolTip.color, - boxShadow: theme.shadows[1] - } -})) - // ===========================|| CANVAS NODE ||=========================== // const CanvasNode = ({ data }) => { @@ -93,7 +72,7 @@ const CanvasNode = ({ data }) => { return ( <> - { }} border={false} > - { - {data.outputAnchors.map((outputAnchor, index) => ( ))} - - + + { + const theme = useTheme() + const canvas = useSelector((state) => state.canvas) + const { deleteNode, duplicateNode } = useContext(flowContext) + const [inputParam] = data.inputParams + + const [open, setOpen] = useState(false) + + const handleClose = () => { + setOpen(false) + } + + const handleOpen = () => { + setOpen(true) + } + + return ( + <> + + + { + duplicateNode(data.id) + }} + sx={{ height: '35px', width: '35px', '&:hover': { color: theme?.palette.primary.main } }} + color={theme?.customization?.isDarkMode ? theme.colors?.paper : 'inherit'} + > + + + { + deleteNode(data.id) + }} + sx={{ height: '35px', width: '35px', '&:hover': { color: 'red' } }} + color={theme?.customization?.isDarkMode ? theme.colors?.paper : 'inherit'} + > + + + + } + placement='right-start' + > + + (data.inputs[inputParam.name] = newValue)} + value={data.inputs[inputParam.name] ?? inputParam.default ?? ''} + nodes={inputParam?.acceptVariable && reactFlowInstance ? reactFlowInstance.getNodes() : []} + edges={inputParam?.acceptVariable && reactFlowInstance ? reactFlowInstance.getEdges() : []} + nodeId={data.id} + /> + + + + + ) +} + +StickyNote.propTypes = { + data: PropTypes.object +} + +export default StickyNote diff --git a/packages/ui/src/views/canvas/index.js b/packages/ui/src/views/canvas/index.js index 9aa53cc62..29f83ea42 100644 --- a/packages/ui/src/views/canvas/index.js +++ b/packages/ui/src/views/canvas/index.js @@ -21,6 +21,7 @@ import { useTheme } from '@mui/material/styles' // project imports import CanvasNode from './CanvasNode' import ButtonEdge from './ButtonEdge' +import StickyNote from './StickyNote' import CanvasHeader from './CanvasHeader' import AddNodes from './AddNodes' import ConfirmDialog from 'ui-component/dialog/ConfirmDialog' @@ -46,7 +47,7 @@ import useNotifier from 'utils/useNotifier' // const import { FLOWISE_CREDENTIAL_ID } from 'store/constant' -const nodeTypes = { customNode: CanvasNode } +const nodeTypes = { customNode: CanvasNode, stickyNote: StickyNote } const edgeTypes = { buttonedge: ButtonEdge } // ==============================|| CANVAS ||============================== // @@ -276,7 +277,7 @@ const Canvas = () => { const newNode = { id: newNodeId, position, - type: 'customNode', + type: nodeData.type !== 'StickyNote' ? 'customNode' : 'stickyNote', data: initNode(nodeData, newNodeId) } diff --git a/packages/ui/src/views/marketplaces/MarketplaceCanvas.js b/packages/ui/src/views/marketplaces/MarketplaceCanvas.js index 7ce29451f..613f3cdbd 100644 --- a/packages/ui/src/views/marketplaces/MarketplaceCanvas.js +++ b/packages/ui/src/views/marketplaces/MarketplaceCanvas.js @@ -11,10 +11,10 @@ import { useTheme } from '@mui/material/styles' // project imports import MarketplaceCanvasNode from './MarketplaceCanvasNode' - import MarketplaceCanvasHeader from './MarketplaceCanvasHeader' +import StickyNote from '../canvas/StickyNote' -const nodeTypes = { customNode: MarketplaceCanvasNode } +const nodeTypes = { customNode: MarketplaceCanvasNode, stickyNote: StickyNote } const edgeTypes = { buttonedge: '' } // ==============================|| CANVAS ||============================== //