Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,6 @@ step_details = {
|
|
16 |
}
|
17 |
node_data = json.dumps(step_details)
|
18 |
|
19 |
-
# 👇 Use triple quotes carefully — this version closes correctly
|
20 |
html_content = f"""
|
21 |
<div id="cy" style="width: 100%; height: 500px; border:1px solid #ccc;"></div>
|
22 |
|
@@ -45,4 +44,76 @@ cytoscape.use(window.cytoscapeDagre);
|
|
45 |
|
46 |
const cy = cytoscape({{
|
47 |
container: document.getElementById('cy'),
|
48 |
-
layout:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
}
|
17 |
node_data = json.dumps(step_details)
|
18 |
|
|
|
19 |
html_content = f"""
|
20 |
<div id="cy" style="width: 100%; height: 500px; border:1px solid #ccc;"></div>
|
21 |
|
|
|
44 |
|
45 |
const cy = cytoscape({{
|
46 |
container: document.getElementById('cy'),
|
47 |
+
layout: {{
|
48 |
+
name: 'dagre',
|
49 |
+
rankDir: 'LR',
|
50 |
+
nodeSep: 50,
|
51 |
+
edgeSep: 30,
|
52 |
+
rankSep: 100
|
53 |
+
}},
|
54 |
+
style: [
|
55 |
+
{{
|
56 |
+
selector: 'node',
|
57 |
+
style: {{
|
58 |
+
'label': 'data(label)',
|
59 |
+
'text-valign': 'center',
|
60 |
+
'text-halign': 'center',
|
61 |
+
'background-color': '#0077B6',
|
62 |
+
'color': 'white',
|
63 |
+
'font-size': '14px',
|
64 |
+
'text-wrap': 'wrap',
|
65 |
+
'text-max-width': 100,
|
66 |
+
'shape': 'roundrectangle',
|
67 |
+
'padding': '10px'
|
68 |
+
}}
|
69 |
+
}},
|
70 |
+
{{
|
71 |
+
selector: 'edge',
|
72 |
+
style: {{
|
73 |
+
'width': 3,
|
74 |
+
'line-color': '#aaa',
|
75 |
+
'target-arrow-color': '#aaa',
|
76 |
+
'target-arrow-shape': 'triangle'
|
77 |
+
}}
|
78 |
+
}}
|
79 |
+
],
|
80 |
+
elements: [
|
81 |
+
{{ data: {{ id: 'lodged', label: '1. Claim Lodged' }} }},
|
82 |
+
{{ data: {{ id: 'fraud', label: '2. Fraud Check' }} }},
|
83 |
+
{{ data: {{ id: 'coverage', label: '3. Coverage Check' }} }},
|
84 |
+
{{ data: {{ id: 'builder', label: '4. Builder Assignment' }} }},
|
85 |
+
{{ data: {{ id: 'schedule', label: '5. Schedule Repairs' }} }},
|
86 |
+
{{ data: {{ id: 'payment', label: '6. Authorise Payment' }} }},
|
87 |
+
{{ data: {{ id: 'settle', label: '7. Settle Claim' }} }},
|
88 |
+
{{ data: {{ source: 'lodged', target: 'fraud' }} }},
|
89 |
+
{{ data: {{ source: 'fraud', target: 'coverage' }} }},
|
90 |
+
{{ data: {{ source: 'coverage', target: 'builder' }} }},
|
91 |
+
{{ data: {{ source: 'builder', target: 'schedule' }} }},
|
92 |
+
{{ data: {{ source: 'schedule', target: 'payment' }} }},
|
93 |
+
{{ data: {{ source: 'payment', target: 'settle' }} }}
|
94 |
+
]
|
95 |
+
}});
|
96 |
+
|
97 |
+
const tooltip = document.getElementById('tooltip');
|
98 |
+
|
99 |
+
cy.on('tap', 'node', function(evt) {{
|
100 |
+
const nodeId = evt.target.id();
|
101 |
+
const description = stepDetails[nodeId] || "No info available.";
|
102 |
+
const rect = document.getElementById('cy').getBoundingClientRect();
|
103 |
+
const pos = evt.originalEvent;
|
104 |
+
|
105 |
+
tooltip.style.left = (pos.clientX - rect.left + 10) + 'px';
|
106 |
+
tooltip.style.top = (pos.clientY - rect.top + 10) + 'px';
|
107 |
+
tooltip.innerHTML = '<strong>' + evt.target.data('label') + '</strong><br>' + description;
|
108 |
+
tooltip.style.display = 'block';
|
109 |
+
}});
|
110 |
+
|
111 |
+
cy.on('tap', function(event) {{
|
112 |
+
if (event.target === cy) {{
|
113 |
+
tooltip.style.display = 'none';
|
114 |
+
}}
|
115 |
+
}});
|
116 |
+
</script>
|
117 |
+
"""
|
118 |
+
|
119 |
+
components.html(html_content, height=550, scrolling=False)
|