Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | <script setup lang="ts"> import { ref } from 'vue' import type { Component } from 'vue' import { PlayCircle, Webhook, Clock, Bot, Globe, Code } from 'lucide-vue-next' import { NODE_TYPES } from '../../composables/node/useNodeHelpers' interface NodeTemplate { type: string label: string icon: Component iconColor: string defaultData: any } const emit = defineEmits<{ addNode: [template: NodeTemplate] }>() const nodeTemplates = ref<NodeTemplate[]>([ { type: NODE_TYPES.MANUAL_TRIGGER, label: 'Manual Trigger', icon: PlayCircle, iconColor: 'var(--rf-color-green)', defaultData: { label: 'Manual Trigger', description: 'Start workflow manually', }, }, { type: NODE_TYPES.WEBHOOK_TRIGGER, label: 'Webhook', icon: Webhook, iconColor: 'var(--rf-color-primary)', defaultData: { label: 'Webhook', path: '/webhook/endpoint', auth: { type: 'none', }, }, }, { type: NODE_TYPES.SCHEDULE_TRIGGER, label: 'Schedule', icon: Clock, iconColor: 'var(--rf-color-warning)', defaultData: { label: 'Schedule', cron: '0 0 * * * *', // 6-field format: sec min hour day month weekday (every hour) timezone: 'UTC', }, }, { type: NODE_TYPES.AGENT, label: 'AI Agent', icon: Bot, iconColor: 'var(--rf-color-purple)', defaultData: { label: 'AI Agent', model: 'gpt-4.1', prompt: 'You are a helpful assistant', temperature: 0.7, input: '', api_key: '', tools: [], }, }, { type: NODE_TYPES.HTTP_REQUEST, label: 'HTTP Request', icon: Globe, iconColor: 'var(--rf-color-blue)', defaultData: { label: 'HTTP Request', method: 'GET', url: 'https://api.example.com', }, }, { type: NODE_TYPES.PYTHON, label: 'Python Script', icon: Code, iconColor: 'var(--rf-color-green)', defaultData: { label: 'Python', code: `import json import sys input_data = json.load(sys.stdin) result = {"output": "Hello from Python"} print(json.dumps(result))`, dependencies: [], }, }, ]) const handleDragStart = (event: DragEvent, template: NodeTemplate) => { if (event.dataTransfer) { event.dataTransfer.effectAllowed = 'move' event.dataTransfer.setData('application/vueflow', JSON.stringify(template)) } } const handleClick = (template: NodeTemplate) => { emit('addNode', template) } </script> <template> <div class="node-toolbar"> <h3 class="toolbar-title">Node Toolbar</h3> <div class="node-list"> <div v-for="template in nodeTemplates" :key="template.type" class="node-item" :draggable="true" @dragstart="handleDragStart($event, template)" @click="handleClick(template)" > <div class="node-icon" :style="{ background: `linear-gradient(135deg, ${template.iconColor}, ${template.iconColor})` }"> <component :is="template.icon" :size="20" /> </div> <span class="node-label">{{ template.label }}</span> </div> </div> <div class="toolbar-hint">Drag or click add node</div> </div> </template> <style lang="scss" scoped> .node-toolbar { position: absolute; right: var(--rf-spacing-md); top: var(--rf-spacing-md); background: var(--rf-color-bg-container); backdrop-filter: blur(16px); border: 1px solid var(--rf-color-border-base); border-radius: var(--rf-radius-md); box-shadow: var(--rf-shadow-card); padding: var(--rf-spacing-lg); width: var(--rf-size-lg); z-index: 10; } .toolbar-title { margin: 0 0 var(--rf-spacing-md) 0; font-size: var(--rf-font-size-base); font-weight: var(--rf-font-weight-semibold); color: var(--rf-color-text-primary); } .node-list { display: flex; flex-direction: column; gap: var(--rf-spacing-sm); } .node-item { display: flex; align-items: center; gap: var(--rf-spacing-md); padding: var(--rf-spacing-md); background: var(--rf-color-bg-secondary); border: 2px solid var(--rf-color-border-lighter); border-radius: var(--rf-radius-large); cursor: move; transition: all var(--rf-transition-fast) var(--rf-transition-func); backdrop-filter: blur(8px); } .node-item:hover { background: var(--rf-color-primary-bg-lighter); border-color: var(--rf-color-primary); transform: translateX(2px); box-shadow: var(--rf-shadow-base); } .node-item:active { transform: scale(0.98); } .node-icon { width: var(--rf-size-icon-lg); height: var(--rf-size-icon-lg); display: flex; align-items: center; justify-content: center; border-radius: var(--rf-radius-large); color: var(--rf-color-white); flex-shrink: 0; :deep(svg) { width: 20px; height: 20px; } } .node-label { font-size: var(--rf-font-size-sm); font-weight: var(--rf-font-weight-medium); color: var(--rf-color-text-regular); } .toolbar-hint { margin-top: var(--rf-spacing-md); font-size: var(--rf-font-size-xs); color: var(--rf-color-text-secondary); text-align: center; } </style> |