Skip to content

Commit df614dd

Browse files
committed
Extract inline assets; add import/parsing features
Move inline CSS and JavaScript into external files and implement host/subnet import and parsing features. Added public/assets/css/styles.css (site styling) and public/assets/js/app.js (large refactor with parsing, import, export, session persistence, graph controls, path criteria, subnet inference, CSV/JSON handling, and device merge logic). Updated public/index.html to reference external assets and adjusted markup; updated ARCHITECTURE.md to reflect the new file structure, runtime state variables, and implemented enhancements. Also added scripts/openwrt_export_subnet_mappings.sh to assist with UCI subnet mapping exports.
1 parent 46d6b6e commit df614dd

5 files changed

Lines changed: 3103 additions & 2941 deletions

File tree

ARCHITECTURE.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ This is a visual analysis tool, not a full OpenWrt firewall simulator. The decis
1818
| Layer | Technology |
1919
| --- | --- |
2020
| Markup | HTML5 |
21-
| Styling | Inline CSS with custom properties and a dark theme |
22-
| Behaviour | Vanilla JavaScript |
21+
| Styling | `public/assets/css/styles.css` with custom properties and a dark theme |
22+
| Behaviour | `public/assets/js/app.js` using vanilla JavaScript |
2323
| Graph rendering | Cytoscape.js v3.30.4 from CDN |
24-
| Distribution | Static `public/index.html` |
24+
| Distribution | Static files under `public/` |
2525

2626
## File Structure
2727

@@ -32,12 +32,17 @@ openwrt-firewall-visualiser/
3232
├── scripts/
3333
│ └── openwrt_export_hosts.sh
3434
└── public/
35-
└── index.html # Complete single-file application
35+
├── index.html # Application markup and external asset references
36+
└── assets/
37+
├── css/
38+
│ └── styles.css
39+
└── js/
40+
└── app.js
3641
```
3742

3843
## Runtime State
3944

40-
The app keeps a small amount of global state inside `public/index.html`:
45+
The app keeps a small amount of global state inside `public/assets/js/app.js`:
4146

4247
| Variable | Purpose |
4348
| --- | --- |
@@ -46,6 +51,8 @@ The app keeps a small amount of global state inside `public/index.html`:
4651
| `cy` | Current Cytoscape graph instance |
4752
| `currentLayout` | Selected graph layout name |
4853
| `selectedTestPath` | Source and destination device indexes used by the path tester |
54+
| `selectedPathCriteria` | Optional protocol and destination-port criteria for path tests |
55+
| `subnetMappingsText` | CIDR-to-zone mappings used for host-zone inference |
4956
| `storageAvailable` | Guard for browsers where `localStorage` is blocked or unavailable |
5057

5158
## Data Model
@@ -83,6 +90,8 @@ interface Device {
8390
name: string;
8491
ip: string;
8592
zone: string;
93+
mac?: string;
94+
source?: string;
8695
}
8796

8897
interface Decision {
@@ -420,7 +429,7 @@ Relevant functions and elements:
420429

421430
## Implemented Future Enhancements
422431

423-
The following phases continue the roadmap sequence after Phase A-C and are now implemented in `public/index.html`.
432+
The following phases continue the roadmap sequence after Phase A-C and are now implemented across `public/index.html`, `public/assets/css/styles.css`, and `public/assets/js/app.js`.
424433

425434
### Phase D: Local Storage Lifecycle Management
426435

@@ -475,7 +484,7 @@ Objective: allow users to populate devices from existing network inventories ins
475484

476485
Requirements:
477486

478-
- Add a dedicated "Bulk Import Hosts" section.
487+
- Add a clearly labelled "Import" section with a "Bulk Import Hosts" subsection.
479488
- Support device inventory exports.
480489
- Support host lists.
481490
- Support DHCP exports.
@@ -508,6 +517,8 @@ Supported Linux neighbour table format:
508517

509518
Implemented details:
510519

520+
- Import controls are grouped separately from manual Devices and Subnet Mappings controls.
521+
- `renderImportChecklist()` shows first-time users which setup/import steps are currently populated.
511522
- `importBulkHosts()` imports the textarea content.
512523
- `parseBulkHosts()` parses host data line-by-line.
513524
- `parseHostLine()` handles host-list, neighbour/ARP, and DHCP lease formats.
@@ -557,6 +568,7 @@ zone = iot
557568
Implemented details:
558569

559570
- The `subnetMappings` textarea stores subnet-to-zone mappings.
571+
- The Subnet Mappings help box explains when the mappings are used, the manual `CIDR zone` format, and the exact UCI output expected by the UCI import field.
560572
- `parseSubnetMappings()` parses CIDR mappings.
561573
- `inferZoneForIp()` assigns zones during import when a host line has no explicit zone.
562574
- Unresolved imported hosts are counted in the import result panel.
@@ -639,6 +651,7 @@ Implemented improvements:
639651
- Show before/after impact for changed forwardings and rules.
640652
- Export Session uses a distinct positive-action button.
641653
- Import Session / Devices is a dedicated file-import control.
654+
- Import status is persisted with saved sessions so the checklist reflects restored state.
642655

643656
### Phase L: Usability
644657

@@ -647,6 +660,8 @@ Status: implemented.
647660
Implementation improvements:
648661

649662
- Loading the example now prompts before replacing the current state.
663+
- Devices, Subnet Mappings, and Import are separate left-panel sections.
664+
- Subnet Mappings has its own help button, with less ambiguous guidance about when subnet mappings are used.
650665
- Graph Visualiser has an expand/collapse button.
651666
- Export Graph PNG moved into the Graph Visualiser toolbar.
652667
- Device Relationship Map shows the first 15 relationships by default and adds a show-all/show-fewer control when needed.
@@ -655,11 +670,11 @@ Implementation improvements:
655670

656671
The current implementation is intentionally simple:
657672

658-
- Inline CSS.
659-
- Inline JavaScript.
660-
- No modules.
673+
- Static HTML, CSS, and JavaScript files.
674+
- No JavaScript modules.
661675
- No build tooling.
662676
- No npm dependencies.
677+
- Deployable to any static host by serving the `public/` directory.
663678

664679
When adding a feature, follow the phase order:
665680

@@ -684,4 +699,4 @@ Use this workflow after changes:
684699

685700
## Last Updated
686701

687-
2026-06-10
702+
2026-06-13

0 commit comments

Comments
 (0)