Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -214,6 +214,55 @@ with gr.Blocks(title="π¨ Visual Workflow Builder", theme=gr.themes.Soft(), css
|
|
214 |
|
215 |
# βββ Code View βββ
|
216 |
code_view = gr.Code(language="json", label="JSON Preview", lines=15)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
# βββ Event Handlers βββ
|
219 |
|
|
|
214 |
|
215 |
# βββ Code View βββ
|
216 |
code_view = gr.Code(language="json", label="JSON Preview", lines=15)
|
217 |
+
|
218 |
+
# HTML Fallback Viewer ν¨μ μ μ
|
219 |
+
def create_html_view(data):
|
220 |
+
"""JSONμ HTMLλ‘ μκ°ν"""
|
221 |
+
if not data:
|
222 |
+
return "<p>No workflow data</p>"
|
223 |
+
|
224 |
+
html = """
|
225 |
+
<div style='font-family: Arial, sans-serif; padding: 20px; background: #f5f5f5; border-radius: 8px;'>
|
226 |
+
<h3>Workflow Visualization</h3>
|
227 |
+
<div style='display: flex; gap: 20px; flex-wrap: wrap;'>
|
228 |
+
"""
|
229 |
+
|
230 |
+
# λ
Έλ νμ
|
231 |
+
nodes = data.get('nodes', [])
|
232 |
+
for node in nodes:
|
233 |
+
node_id = node.get('id', 'unknown')
|
234 |
+
label = node.get('data', {}).get('label', 'Node')
|
235 |
+
x = node.get('position', {}).get('x', 0)
|
236 |
+
y = node.get('position', {}).get('y', 0)
|
237 |
+
|
238 |
+
html += f"""
|
239 |
+
<div style='background: white; border: 2px solid #3b82f6; border-radius: 8px;
|
240 |
+
padding: 15px; margin: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
241 |
+
min-width: 150px;'>
|
242 |
+
<strong>ID:</strong> {node_id}<br>
|
243 |
+
<strong>Label:</strong> {label}<br>
|
244 |
+
<strong>Position:</strong> ({x}, {y})
|
245 |
+
</div>
|
246 |
+
"""
|
247 |
+
|
248 |
+
html += "</div>"
|
249 |
+
|
250 |
+
# μ£μ§ νμ
|
251 |
+
edges = data.get('edges', [])
|
252 |
+
if edges:
|
253 |
+
html += "<h4>Connections:</h4><ul>"
|
254 |
+
for edge in edges:
|
255 |
+
source = edge.get('source', '?')
|
256 |
+
target = edge.get('target', '?')
|
257 |
+
html += f"<li>{source} β {target}</li>"
|
258 |
+
html += "</ul>"
|
259 |
+
|
260 |
+
html += "</div>"
|
261 |
+
return html
|
262 |
+
|
263 |
+
# HTML Fallback Viewer
|
264 |
+
gr.Markdown("### π HTML Workflow Viewer (Fallback)")
|
265 |
+
html_viewer = gr.HTML(label="Workflow HTML View")
|
266 |
|
267 |
# βββ Event Handlers βββ
|
268 |
|