Skip to content

Commit e66ea2d

Browse files
authored
Merge pull request #15 from d3mocide/refactor-analysis-components-14135476400243220763
2 parents 319764f + 7e6060c commit e66ea2d

14 files changed

Lines changed: 1369 additions & 1295 deletions

REFACTORING_REPORT.md

Lines changed: 28 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ MeshRF is a full-stack RF propagation and link analysis application for LoRa mes
2828
|------|------|-------|----------|--------|
2929
| 1 | `src/components/Map/MapContainer.jsx` | 1173 | CRITICAL | **REFACTORED** |
3030
| 2 | `src/components/Layout/Sidebar.jsx` | 829 | CRITICAL | **REFACTORED** |
31-
| 3 | `src/components/Map/LinkAnalysisPanel.jsx` | 643 | HIGH | Pending |
32-
| 4 | `src/components/Map/UI/SiteAnalysisResultsPanel.jsx` | 609 | HIGH | Pending |
31+
| 3 | `src/components/Map/LinkAnalysisPanel.jsx` | 643 | HIGH | **REFACTORED** |
32+
| 4 | `src/components/Map/UI/SiteAnalysisResultsPanel.jsx` | 609 | HIGH | **REFACTORED** |
3333
| 5 | `src/components/Map/OptimizationLayer.jsx` | 517 | HIGH | Pending |
3434
| 6 | `rf-engine/server.py` | 475 | HIGH | **REFACTORED** |
3535
| 7 | `src/components/Map/UI/NodeManager.jsx` | 440 | MEDIUM | Pending |
3636
| 8 | `src/components/Map/OptimizationResultsPanel.jsx` | 435 | MEDIUM | Pending |
3737
| 9 | `src/components/Map/LinkLayer.jsx` | 429 | MEDIUM | Pending |
38-
| 10 | `rf-engine/tasks/viewshed.py` | 398 | MEDIUM | Pending |
38+
| 10 | `rf-engine/tasks/viewshed.py` | 398 | MEDIUM | **REFACTORED** |
3939
| 11 | `src/utils/rfMath.js` | 366 | LOW | Pending |
4040
| 12 | `src/components/Map/BatchNodesPanel.jsx` | 354 | MEDIUM | Pending |
4141
| 13 | `src/hooks/useViewshedTool.js` | 343 | MEDIUM | Pending |
@@ -89,54 +89,27 @@ MeshRF is a full-stack RF propagation and link analysis application for LoRa mes
8989

9090
#### 3. `src/components/Map/LinkAnalysisPanel.jsx` — 643 lines
9191

92-
**What it does**: Panel displaying point-to-point RF link analysis results — link budget, signal quality, Fresnel clearance, diffraction loss, model comparison, and drag/resize behaviour.
93-
94-
**Logical sections**:
95-
1. Status color/text logic (lines 36–72)
96-
2. Responsive sizing logic (lines 74–91)
97-
3. Panel drag/resize handlers (lines 93–250)
98-
4. Help modals (lines 260–450)
99-
5. JSX render (lines 450–643)
100-
101-
**Suggested split**:
102-
103-
```
104-
src/components/Map/
105-
├── LinkAnalysisPanel.jsx (~200 lines) — composition
106-
├── UI/
107-
│ ├── LinkStatusIndicator.jsx (~80 lines)
108-
│ ├── LinkBudgetDisplay.jsx (~100 lines)
109-
│ ├── FresnelZoneVisualization.jsx (~80 lines)
110-
│ └── ModelComparisonTable.jsx (~120 lines)
111-
└── hooks/
112-
├── useDraggablePanel.js (~100 lines)
113-
└── useResponsiveSize.js (~40 lines)
114-
```
92+
**Status**: Refactored (Phase 3)
93+
- **Extracted Components**:
94+
- `UI/LinkStatusIndicator.jsx`: Status header.
95+
- `UI/LinkBudgetDisplay.jsx`: Stats grid.
96+
- `UI/ModelComparisonTable.jsx`: Help/Info overlay.
97+
- **Extracted Hook**:
98+
- `hooks/useDraggablePanel.js`: Encapsulates drag and resize logic.
99+
- **Result**: `LinkAnalysisPanel.jsx` is now a clean composition (~200 lines).
115100

116101
---
117102

118103
#### 4. `src/components/Map/UI/SiteAnalysisResultsPanel.jsx` — 609 lines
119104

120-
**What it does**: Displays inter-node link matrix, mesh topology graph, and coverage redundancy analysis. Contains BFS path-finding algorithm inline.
121-
122-
**Logical sections**:
123-
1. Helper functions and status colors (lines 1–75)
124-
2. BFS mesh path-finding algorithm (lines 38–110)
125-
3. Component state and hooks (lines 120–200)
126-
4. Link matrix table (lines 240–450)
127-
5. Topology graph visualization (lines 460–609)
128-
129-
**Suggested split**:
130-
131-
```
132-
src/components/Map/UI/
133-
├── SiteAnalysisResultsPanel.jsx (~200 lines) — composition
134-
├── LinkMatrix.jsx (~150 lines)
135-
├── TopologyGraph.jsx (~150 lines)
136-
└── StatusBadge.jsx (~40 lines)
137-
src/utils/
138-
└── meshTopology.js (~100 lines) — BFS, connectivity algorithms
139-
```
105+
**Status**: Refactored (Phase 3)
106+
- **Extracted Components**:
107+
- `UI/SiteAnalysis/SitesTab.jsx`: Site list and details.
108+
- `UI/SiteAnalysis/LinksTab.jsx`: Link list and metrics.
109+
- `UI/SiteAnalysis/TopologyTab.jsx`: Mesh topology and path analysis.
110+
- **Extracted Utils**:
111+
- `utils/meshTopology.js`: BFS and connectivity algorithms.
112+
- **Result**: `SiteAnalysisResultsPanel.jsx` is now a clean orchestrator (~150 lines).
140113

141114
---
142115

@@ -233,16 +206,10 @@ src/utils/
233206

234207
#### 10. `rf-engine/tasks/viewshed.py` — 398 lines
235208

236-
**What it does**: Celery task for batch viewshed computation — multi-node processing, site ranking, PNG image generation, and Redis storage.
237-
238-
**Suggested split**:
239-
240-
```
241-
rf-engine/
242-
├── tasks/viewshed.py (~120 lines) — Celery task definition only
243-
├── processors/viewshed_proc.py (~150 lines) — computation and ranking logic
244-
└── utils/image_utils.py (~80 lines) — PNG encoding helpers
245-
```
209+
**Status**: Refactored (Phase 3)
210+
- **Extracted Logic**:
211+
- `rf-engine/core/viewshed_proc.py`: Contains the heavy calculation, grid manipulation, and image generation logic.
212+
- **Result**: `tasks/viewshed.py` is now a thin Celery task wrapper (~40 lines).
246213

247214
---
248215

@@ -321,14 +288,13 @@ src/hooks/
321288

322289
---
323290

324-
### Phase 3 — Analysis Components
291+
### Phase 3 — Analysis Components (COMPLETED)
325292

326-
5. **LinkAnalysisPanel.jsx** (643 → ~200 lines): Extract status, budget, Fresnel, and model comparison sub-components + `useDraggablePanel` hook.
327-
6. **SiteAnalysisResultsPanel.jsx** (609 → ~200 lines): Extract `LinkMatrix`, `TopologyGraph`, and move BFS algorithm to `meshTopology.js`.
328-
7. **viewshed.py** (398 → ~120 lines): Separate Celery task definition from processing logic and image utilities.
293+
5. **LinkAnalysisPanel.jsx** (643 → ~200 lines): Extracted `LinkStatusIndicator`, `LinkBudgetDisplay`, `ModelComparisonTable` and `useDraggablePanel` hook.
294+
6. **SiteAnalysisResultsPanel.jsx** (609 → ~200 lines): Extracted `SitesTab`, `LinksTab`, `TopologyTab` and moved topology logic to `meshTopology.js`.
295+
7. **viewshed.py** (398 → ~40 lines): Moved calculation logic to `rf-engine/core/viewshed_proc.py`.
329296

330-
**Expected effort**: 2–3 days
331-
**Risk**: Medium — analysis panels have complex prop drilling.
297+
**Status**: Completed.
332298

333299
---
334300

0 commit comments

Comments
 (0)