Skip to content

webui: Render hex strings using IdentifierComponent in json-tree#167

Open
gtom84 wants to merge 1 commit into
isc-projects:masterfrom
gtom84:feature/text-to-hex-in-user-context
Open

webui: Render hex strings using IdentifierComponent in json-tree#167
gtom84 wants to merge 1 commit into
isc-projects:masterfrom
gtom84:feature/text-to-hex-in-user-context

Conversation

@gtom84

@gtom84 gtom84 commented Jun 23, 2026

Copy link
Copy Markdown

Description

This PR improves the usability of the JSON tree viewer by automatically formatting raw hexadecimal values using the existing IdentifierComponent (app-identifier).

When viewing raw DHCP data returned by Kea (such as 00020000000005830100...), it is incredibly helpful to see the parsed ASCII representation inline instead of a continuous block of hex data. This change conditionally triggers the hex formatter if a primitive value matches hexadecimal patterns.

Changes

  • json-tree.component.ts: Implemented isHexString() logic. It filters out pure decimal strings to reduce false positives, ensures the string length is even, and requires a length $> 3$ (at least 2 bytes) or a explicit 0x prefix.
  • json-tree.component.html: Wrapped primitive text rendering in a condition that substitutes the raw string with <app-identifier> when hex formatting is applicable.
  • json-tree.component.spec.ts: Added specific test assertions verifying the hex classification boundaries (including null states, raw numbers, explicit 0x prefixes, and long Kea-specific hex outputs).

Testing Done

  • Ran npm run test (or the equivalent Angular CLI test runner for Stork webui) to verify the new test suites pass cleanly.
  • Confirmed that purely numeric strings (like standard IDs or counters) are not accidentally treated as hex unless they carry a 0x prefix.

Implements automatic detection of hex strings within the JSON tree viewer
and uses the `app-identifier` component to format them (e.g., with ASCII/text
decoding). This improves the readability of Kea DHCP hex values, such as options payloads
or flex-id, etc.

- Added `isHexString()` detection logic to JsonTreeComponent.
- Imported and embedded IdentifierComponent into json-tree templates.
- Added unit tests for hexadecimal pattern matching.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant