diff --git a/.gitignore b/.gitignore index 0371853..cf9faf4 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,7 @@ artefactory-*.tar # Temporary files, for example, from tests. /tmp/ -/drafts +/.drafts /.elixir_ls .DS_Store diff --git a/artefact_kino/CHANGELOG.md b/artefact_kino/CHANGELOG.md index 41b18e7..fc2038c 100644 --- a/artefact_kino/CHANGELOG.md +++ b/artefact_kino/CHANGELOG.md @@ -5,6 +5,10 @@ SPDX-License-Identifier: MIT # Changelog +## 0.1.4 — 2026-05-05 + +- Inspector panel collapsible (matching the Export panel); both default collapsed to give the graph more room on bigger artefacts; selecting a node or relationship in the graph auto-expands the Inspector. Bumps `artefact` requirement to `~> 0.1.4` for convenience. + ## 0.1.3 — 2026-04-30 - Compatible with `artefact ~> 0.1.3` diff --git a/artefact_kino/README.md b/artefact_kino/README.md index 53d2bb6..781bf50 100644 --- a/artefact_kino/README.md +++ b/artefact_kino/README.md @@ -18,7 +18,9 @@ ArtefactKino is a viewer, not an editor. It renders three panels side by side: - **Graph** (heartside) — an interactive vis-network graph. Nodes are colour-coded by label, with colours blended for multi-label nodes using circular hue averaging in linear RGB space. Layout strategies: Physics, Hierarchical, Radial. - **Inspector** — tabbed Elixir view of the artefact struct, nodes table, and relationships table. Clicking a node or relationship in the graph navigates to and highlights the corresponding row. -- **Export** — CREATE Cypher, MERGE Cypher, and Arrows JSON. Click any panel to select all text for easy copying. The export panel is collapsible to give more space to the graph and inspector. +- **Export** — CREATE Cypher, MERGE Cypher, Arrows JSON, and Mermaid source. Click any panel to select all text for easy copying. + +The Inspector and Export panels are both collapsible and start collapsed by default to give the graph room on bigger artefacts; selecting a node or relationship in the graph auto-expands the Inspector. MERGE Cypher upserts nodes by uuid — safe to run repeatedly. CREATE always makes new nodes. See the [CreateMerge artefact](https://github.com/diffo-dev/artefactory) for a visual explanation of the difference. diff --git a/artefact_kino/lib/artefact_kino.ex b/artefact_kino/lib/artefact_kino.ex index 42b4b16..0075e27 100644 --- a/artefact_kino/lib/artefact_kino.ex +++ b/artefact_kino/lib/artefact_kino.ex @@ -31,30 +31,35 @@ defmodule ArtefactKino do defp build_data(artefact, default) do %{ - nodes: vis_nodes(artefact), - edges: vis_edges(artefact), + nodes: vis_nodes(artefact), + edges: vis_edges(artefact), create_cypher: Artefact.Cypher.create(artefact), - merge_cypher: Artefact.Cypher.merge(artefact), - arrows_json: Artefact.Arrows.to_json(artefact), - mermaid: Artefact.Mermaid.export(artefact), - default: Atom.to_string(default), - title: artefact.title || artefact.base_label || "Artefact", - description: artefact.description, + merge_cypher: Artefact.Cypher.merge(artefact), + arrows_json: Artefact.Arrows.to_json(artefact), + mermaid: Artefact.Mermaid.export(artefact), + default: Atom.to_string(default), + title: artefact.title || artefact.base_label || "Artefact", + description: artefact.description, artefact_rows: artefact_rows(artefact), - nodes_rows: nodes_rows(artefact), - rels_rows: rels_rows(artefact) + nodes_rows: nodes_rows(artefact), + rels_rows: rels_rows(artefact) } end defp vis_nodes(%Artefact{graph: graph, base_label: base_label}) do Enum.map(graph.nodes, fn node -> - all_labels = Enum.uniq(node.labels ++ if(base_label, do: [base_label], else: [])) + all_labels = Enum.uniq(node.labels ++ if(base_label, do: [base_label], else: [])) semantic_labels = Enum.reject(node.labels, &(&1 == base_label)) - name = Map.get(node.properties, "name", node.id) - label = if semantic_labels == [], do: name, else: "#{name}\n#{Enum.join(semantic_labels, " ")}" - tooltip = node.properties + name = Map.get(node.properties, "name", node.id) + + label = + if semantic_labels == [], do: name, else: "#{name}\n#{Enum.join(semantic_labels, " ")}" + + tooltip = + node.properties |> Enum.map(fn {k, v} -> "#{k}: #{v}" end) |> Enum.join("\n") + %{id: node.id, label: label, labels: all_labels, title: "#{node.uuid}\n#{tooltip}"} end) end @@ -69,21 +74,21 @@ defmodule ArtefactKino do defp artefact_rows(%Artefact{} = a) do [ - %{key: "id", value: a.id}, - %{key: "uuid", value: a.uuid}, - %{key: "title", value: inspect(a.title)}, + %{key: "id", value: a.id}, + %{key: "uuid", value: a.uuid}, + %{key: "title", value: inspect(a.title)}, %{key: "description", value: inspect(a.description)}, - %{key: "base_label", value: inspect(a.base_label)}, - %{key: "metadata", value: inspect(a.metadata, pretty: true)} + %{key: "base_label", value: inspect(a.base_label)}, + %{key: "metadata", value: inspect(a.metadata, pretty: true)} ] end defp nodes_rows(%Artefact{graph: graph}) do Enum.map(graph.nodes, fn n -> %{ - id: n.id, - uuid: n.uuid, - labels: Enum.join(n.labels, ", "), + id: n.id, + uuid: n.uuid, + labels: Enum.join(n.labels, ", "), properties: inspect(n.properties) } end) @@ -94,10 +99,10 @@ defmodule ArtefactKino do |> Enum.with_index() |> Enum.map(fn {r, idx} -> %{ - idx: idx, - from: r.from_id, - type: r.type, - to: r.to_id, + idx: idx, + from: r.from_id, + type: r.type, + to: r.to_id, properties: inspect(r.properties) } end) @@ -219,11 +224,12 @@ defmodule ArtefactKino do -