Hierarchy Builder

Sensor Data
README

Sensor Data

Select a node in the tree to view sensor data.

Hierarchy Builder Instructions

Welcome to the Hierarchy Builder, a tool for managing a hierarchical structure of nodes (Company → Site → Plant → Asset → Collection Point) stored in a PostgreSQL database. Use the tree interface to perform CRUD operations and duplicate nodes.

Getting Started

  • View the Hierarchy: The tree on the left displays nodes with their names and levels (e.g., "Acme Corp (Company)"). Expand/collapse nodes to navigate.
  • Interact with Nodes: Right-click any node to open a context menu with options: Add Child Node, Edit Node, Duplicate Node, and Delete Node.

Operations

Add a New Node

  1. Right-click a node (e.g., "NY Plant A") and select Add Child Node.
  2. In the modal, enter the Node Name (e.g., "New Sensor").
  3. The Parent Node is pre-filled based on your selection.
  4. Select a Level from the dropdown (e.g., "Collection Point"). Only valid levels below the parent’s level are available.
  5. Click Save. The tree will refresh to show the new node.

Edit a Node

  1. Right-click a node (e.g., "New Sensor") and select Edit Node.
  2. Update the Node Name or Level in the modal.
  3. Click Save to apply changes.

Duplicate a Node

  1. Right-click a node (e.g., "New York Site") and select Duplicate Node.
  2. Confirm the action. The node and its entire subtree (children, grandchildren, etc.) will be duplicated under the same parent with the suffix "(Copy)" added to the root node’s name.
  3. The tree will refresh to show the duplicated subtree.

Delete a Node

  1. Right-click a node and select Delete Node.
  2. Confirm the action. Only nodes without children can be deleted.
  3. The tree will refresh, and the node will be removed.

Integration with Grafana

  • This tool integrates with a Grafana dashboard using the Interactive Tree Panel.
  • In Grafana, ensure the panel uses the query: SELECT id, parent_id, name FROM hierarchy;
  • Map fields: Node ID (id), Parent ID (parent_id), Node Label (name).
  • Enable auto-refresh (e.g., 10 seconds) in Dashboard settings to reflect changes.

Troubleshooting

  • Tree Not Loading: Check the browser console (F12) and server logs (docker logs hierarchy-builder-1). Ensure the PostgreSQL database is accessible.
  • Error Messages: Errors appear in the modal (red text). Common issues include invalid levels or missing fields.
  • Database Issues: Verify the database connection in app.py and reset the sequence if needed:
    SELECT setval('hierarchy_id_seq', (SELECT MAX(id) FROM hierarchy) + 1);

Support

For issues or enhancements, contact the administrator or check the server logs for detailed error messages.