feat(gui): Add link deletion and DAG cycle validation to Visual DAG
This commit is contained in:
29
src/gui_2.py
29
src/gui_2.py
@@ -572,6 +572,13 @@ class App:
|
|||||||
self._handle_mma_respond(approved=False, abort=True)
|
self._handle_mma_respond(approved=False, abort=True)
|
||||||
imgui.close_current_popup()
|
imgui.close_current_popup()
|
||||||
imgui.end_popup()
|
imgui.end_popup()
|
||||||
|
# Cycle Detected Popup
|
||||||
|
if imgui.begin_popup_modal("Cycle Detected!", None, imgui.WindowFlags_.always_auto_resize)[0]:
|
||||||
|
imgui.text_colored(imgui.ImVec4(1, 0.3, 0.3, 1), "The dependency graph contains a cycle!")
|
||||||
|
imgui.text("Please remove the circular dependency.")
|
||||||
|
if imgui.button("OK"):
|
||||||
|
imgui.close_current_popup()
|
||||||
|
imgui.end_popup()
|
||||||
if self.show_script_output:
|
if self.show_script_output:
|
||||||
if self._trigger_script_blink:
|
if self._trigger_script_blink:
|
||||||
self._trigger_script_blink = False
|
self._trigger_script_blink = False
|
||||||
@@ -1583,6 +1590,28 @@ class App:
|
|||||||
tid = str(t.get('id', '??'))
|
tid = str(t.get('id', '??'))
|
||||||
for dep in t.get('depends_on', []):
|
for dep in t.get('depends_on', []):
|
||||||
ed.link(abs(hash(dep + "_" + tid)), abs(hash(dep + "_out")), abs(hash(tid + "_in")))
|
ed.link(abs(hash(dep + "_" + tid)), abs(hash(dep + "_out")), abs(hash(tid + "_in")))
|
||||||
|
# Handle link deletion
|
||||||
|
if ed.begin_delete():
|
||||||
|
deleted = ed.get_deleted_link()
|
||||||
|
if deleted:
|
||||||
|
link_id = deleted[0]
|
||||||
|
for t in self.active_tickets:
|
||||||
|
tid = str(t.get('id', ''))
|
||||||
|
for d in t.get('depends_on', []):
|
||||||
|
if abs(hash(d + "_" + tid)) == link_id:
|
||||||
|
t['depends_on'] = [dep for dep in t['depends_on'] if dep != d]
|
||||||
|
self._push_mma_state_update()
|
||||||
|
break
|
||||||
|
ed.end_delete()
|
||||||
|
# Validate DAG after any changes
|
||||||
|
try:
|
||||||
|
from src.dag_engine import TrackDAG
|
||||||
|
ticket_dicts = [{'id': str(t.get('id', '')), 'depends_on': t.get('depends_on', [])} for t in self.active_tickets]
|
||||||
|
temp_dag = TrackDAG(ticket_dicts)
|
||||||
|
if temp_dag.has_cycle():
|
||||||
|
imgui.open_popup("Cycle Detected!")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
ed.end()
|
ed.end()
|
||||||
ed.set_current_editor(None)
|
ed.set_current_editor(None)
|
||||||
# 5. Add Ticket Form
|
# 5. Add Ticket Form
|
||||||
|
|||||||
46
temp_edit3.py
Normal file
46
temp_edit3.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
with open('src/gui_2.py', 'r', encoding='utf-8', newline='') as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
old = ''' # Handle link deletion
|
||||||
|
if ed.begin_delete():
|
||||||
|
deleted = ed.get_deleted_link()
|
||||||
|
if deleted:
|
||||||
|
link_id = deleted[0]
|
||||||
|
for t in self.active_tickets:
|
||||||
|
tid = str(t.get('id', ''))
|
||||||
|
for d in t.get('depends_on', []):
|
||||||
|
if abs(hash(d + "_" + tid)) == link_id:
|
||||||
|
t['depends_on'] = [dep for dep in t['depends_on'] if dep != d]
|
||||||
|
self._push_mma_state_update()
|
||||||
|
break
|
||||||
|
ed.end_delete()
|
||||||
|
ed.end()'''
|
||||||
|
|
||||||
|
new = ''' # Handle link deletion
|
||||||
|
if ed.begin_delete():
|
||||||
|
deleted = ed.get_deleted_link()
|
||||||
|
if deleted:
|
||||||
|
link_id = deleted[0]
|
||||||
|
for t in self.active_tickets:
|
||||||
|
tid = str(t.get('id', ''))
|
||||||
|
for d in t.get('depends_on', []):
|
||||||
|
if abs(hash(d + "_" + tid)) == link_id:
|
||||||
|
t['depends_on'] = [dep for dep in t['depends_on'] if dep != d]
|
||||||
|
self._push_mma_state_update()
|
||||||
|
break
|
||||||
|
ed.end_delete()
|
||||||
|
# Validate DAG after any changes
|
||||||
|
try:
|
||||||
|
from src.dag_engine import TrackDAG
|
||||||
|
ticket_dicts = [{'id': str(t.get('id', '')), 'depends_on': t.get('depends_on', [])} for t in self.active_tickets]
|
||||||
|
temp_dag = TrackDAG(ticket_dicts)
|
||||||
|
if temp_dag.has_cycle():
|
||||||
|
imgui.open_popup("Cycle Detected!")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
ed.end()'''
|
||||||
|
|
||||||
|
content = content.replace(old, new)
|
||||||
|
with open('src/gui_2.py', 'w', encoding='utf-8', newline='') as f:
|
||||||
|
f.write(content)
|
||||||
|
print('Done')
|
||||||
20
temp_edit4.py
Normal file
20
temp_edit4.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
with open('src/gui_2.py', 'r', encoding='utf-8', newline='') as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
old = ''' imgui.end_popup()
|
||||||
|
if self.show_script_output:'''
|
||||||
|
|
||||||
|
new = ''' imgui.end_popup()
|
||||||
|
# Cycle Detected Popup
|
||||||
|
if imgui.begin_popup_modal("Cycle Detected!", None, imgui.WindowFlags_.always_auto_resize)[0]:
|
||||||
|
imgui.text_colored(imgui.ImVec4(1, 0.3, 0.3, 1), "The dependency graph contains a cycle!")
|
||||||
|
imgui.text("Please remove the circular dependency.")
|
||||||
|
if imgui.button("OK"):
|
||||||
|
imgui.close_current_popup()
|
||||||
|
imgui.end_popup()
|
||||||
|
if self.show_script_output:'''
|
||||||
|
|
||||||
|
content = content.replace(old, new)
|
||||||
|
with open('src/gui_2.py', 'w', encoding='utf-8', newline='') as f:
|
||||||
|
f.write(content)
|
||||||
|
print('Done')
|
||||||
Reference in New Issue
Block a user