diff --git a/scripts/export_data_graph.py b/scripts/export_data_graph.py new file mode 100644 index 0000000..c905915 --- /dev/null +++ b/scripts/export_data_graph.py @@ -0,0 +1,61 @@ +from neo4j import GraphDatabase +import json + +# Replace these credentials with your Neo4j database info +uri = "bolt://localhost:7687" +username = "neo4j" +password = "Ke7Rk7jB:Jn2Uz:" + +driver = GraphDatabase.driver(uri, auth=(username, password)) + +def export_graph_to_json(): + with driver.session() as session: + # Query for all nodes and their properties + nodes_query = """ + MATCH (n) + RETURN elementId(n) as id, labels(n) as labels, properties(n) as properties + """ + nodes_result = session.run(nodes_query) + + # Query for all relationships and their properties + relationships_query = """ + MATCH (start)-[r:CONTAINS]->(end) + RETURN id(r) as id, type(r) as type, properties(r) as properties, + elementId(start) as startNode, elementId(end) as endNode + """ + relationships_result = session.run(relationships_query) + + # Build the JSON structure + data = {"nodes": [], "relationships": []} + + # Process nodes + for record in nodes_result: + node = { + "id": record["id"], + "labels": record["labels"], + "properties": record["properties"] + } + data["nodes"].append(node) + + # Process relationships + for record in relationships_result: + relationship = { + "id": record["id"], + "type": record["type"], + "properties": record["properties"], + "startNode": record["startNode"], + "endNode": record["endNode"] + } + data["relationships"].append(relationship) + + # Output to JSON file + with open("textgrad_graph_export.json", "w") as f: + json.dump(data, f, indent=4) + + print("Export completed. JSON saved as textgrad_graph_export.json.") + +# Run the export +export_graph_to_json() + +# Close the driver connection +driver.close() \ No newline at end of file diff --git a/unoplat-code-confluence-query-engine/unoplat_code_confluence_query_engine/query_engine_style.tcss b/unoplat-code-confluence-query-engine/unoplat_code_confluence_query_engine/query_engine_style.tcss index 84c502c..4b22692 100644 --- a/unoplat-code-confluence-query-engine/unoplat_code_confluence_query_engine/query_engine_style.tcss +++ b/unoplat-code-confluence-query-engine/unoplat_code_confluence_query_engine/query_engine_style.tcss @@ -99,4 +99,42 @@ Checkbox { #history-placeholder { height: 1fr; +} + +ExistingCodebaseList { + align: center middle; +} + +ExistingCodebaseList > Container { + width: 40%; + height: 40%; + border: thick $primary; + background: $surface; + padding: 1 2; +} + +#existing-codebases-title { + background: $primary; + color: $text; + padding: 1; + text-align: center; + margin-bottom: 1; + content-align: center middle; + align: center middle; + width: 100%; +} + +#list-container { + height: 100%; + border: solid $primary; + padding: 1; +} + +ListView { + height: 100%; + border: none; +} + +#async-list { + height: 1fr; } \ No newline at end of file diff --git a/unoplat-code-confluence-query-engine/unoplat_code_confluence_query_engine/screens/existing_codebase_list.py b/unoplat-code-confluence-query-engine/unoplat_code_confluence_query_engine/screens/existing_codebase_list.py index a2ac2d8..8bcb033 100644 --- a/unoplat-code-confluence-query-engine/unoplat_code_confluence_query_engine/screens/existing_codebase_list.py +++ b/unoplat-code-confluence-query-engine/unoplat_code_confluence_query_engine/screens/existing_codebase_list.py @@ -1,31 +1,31 @@ - from textual.screen import ModalScreen from textual.app import ComposeResult -from textual.widgets import Button, Label, DirectoryTree +from textual.widgets import Button, Label, ListView, ListItem, Header, Footer from textual.containers import Container from processing.query_engine_process import QueryEngineProcess -import os -from widgets.json_directory_tree import JSONDirectoryTree -from textual.widgets import ListView, ListItem from textual.binding import Binding + class ExistingCodebaseList(ModalScreen): BINDINGS = [ - Binding("ctrl+q", "request_quit", "Quit",show=True,priority=True), - ] + Binding("ctrl+q", "request_quit", "Quit", show=True, priority=True), + ] - def action_request_quit(self) -> None: - self.app.pop_screen() - def __init__(self, query_engine_process: QueryEngineProcess, **kwargs): super().__init__(**kwargs) self.query_engine_process = query_engine_process def compose(self) -> ComposeResult: - yield Container( - ListView(id="async-list"), - id="list-container" - ) + yield Header(show_clock=True) + yield Container( + Label("Existing Codebases", id="existing-codebases-title"), + ListView(id="async-list"), + id="list-container" + ) + yield Footer() + + def action_request_quit(self) -> None: + self.app.pop_screen() async def on_mount(self) -> None: await self.load_data() @@ -35,5 +35,4 @@ async def load_data(self) -> None: codebases_list: list = await self.query_engine_process.load_existing_codebases() list_items = [ListItem(Label(codebase)) for codebase in codebases_list] list_view.extend(list_items) - - +