Skip to content

Commit

Permalink
feat: open node on click
Browse files Browse the repository at this point in the history
  • Loading branch information
haidaraM committed Aug 29, 2021
1 parent fb71980 commit 11412eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ansibleplaybookgrapher/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,16 @@ class TaskNode(Node):
A task node. Can be pre_task, task or post_task
"""

def __init__(self, node_label: str, node_id: str = None):
def __init__(self, node_label: str, node_id: str = None, task_filepath: str = None):
"""
:param node_label:
:param node_id:
:param task_filepath: The path on the filesystem where the task is located. It should be something like
${absolute_path_to_the_file}:${task_line_number}
"""
super().__init__(node_label, node_id or generate_id("task_"))
self.task_filepath = task_filepath


class RoleNode(CompositeNode):
Expand Down
3 changes: 2 additions & 1 deletion ansibleplaybookgrapher/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def _add_task(self, task: Task, loop_counter: int, task_vars: Dict, node_type: s

task_name = clean_name(f"[{node_type}] " + self.template(task.get_name(), task_vars))

edge_node = EdgeNode(task_edge_name, parent_node, TaskNode(task_name, generate_id(f"{node_type}_")))
edge_node = EdgeNode(task_edge_name, parent_node,
TaskNode(task_name, generate_id(f"{node_type}_"), task.get_path()))
parent_node.add_node(target_composition=f"{node_type}s", node=edge_node)

return True
Expand Down

0 comments on commit 11412eb

Please sign in to comment.