Skip to content

Commit 3e044a7

Browse files
feat(flashforge): F6 — i18n connection states + CODEMAP entry
Final polish for the FlashForge live integration: i18n: 4 connection-state keys added in 9 locales via npm run i18n:add • ffgConnConnecting / Connected / Offline / Reconnecting These are reserved for the surfaced connection-status text once the live block grows a header row beyond the global Online / Offline pill. For now the existing snapStatusOnline / Offline / Connecting keys double-duty in renderFfgOnlineBadge so brand parity stays free. CODEMAP.md: • Bird's-eye structure now lists the FlashForge block at L7288-8345 • New section "FlashForge Live (HTTP polling)" documenting the function anchors per sub-block (ping, polling lifecycle, parser, renderer, filament-edit sheet, Apply branch) • Cross-cutting wiring callouts so future contributors find the grid-card + side-card + sheet hooks without grepping • "Find X by feature" cookbook gains 3 FlashForge entries (HTTP polling, live block UI, filament edit) • Line ranges past the FlashForge block intentionally left as `…` — they shifted by ~1100 lines and the precise ranges are tracked by the next CODEMAP refresh Verified clean: • node --check renderer/inventory.js → no syntax errors • npm run i18n:check → 9 locales × 571 keys • git status → only the expected files changed (renderer/inventory.js, renderer/inventory.html, renderer/CODEMAP.md, renderer/locales/*.json)
1 parent fd78737 commit 3e044a7

10 files changed

Lines changed: 88 additions & 17 deletions

File tree

‎renderer/CODEMAP.md‎

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ L2918-4283 Spool detail panel + per-spool modals
2020
L4284-5072 App-level UI (resize, debug, settings, language, friends, …)
2121
L5073-5532 Storage / scales / 3D printers (subscribe + render printers grid)
2222
L5533-7216 Snapmaker Live integration (Moonraker WebSocket)
23-
L7217-9344 Add-printer flow (mDNS → port-scan → Add by IP → manual probe)
24-
L9345-11327 Storage view (rack rendering, drag-drop, masonry, rack-edit modal)
25-
L11328-11765 Friend view (friend's inventory in main interface)
26-
L11766-12027 Display-name setup + Friends system (requests, accept, blacklist)
27-
L12028-12204 Public/private key helpers + late utilities
28-
L12205-12389 Init bootstrap (loadLocales → loadLookups → wire DOM → start)
29-
L12389 })(); // IIFE closes
23+
L7288-8345 FlashForge Live integration (HTTP polling + filament edit)
24+
L8347-… Add-printer flow (mDNS → port-scan → Add by IP → manual probe)
25+
… Storage view (rack rendering, drag-drop, masonry, rack-edit modal)
26+
… Friend view (friend's inventory in main interface)
27+
… Display-name setup + Friends system (requests, accept, blacklist)
28+
… Public/private key helpers + late utilities
29+
… Init bootstrap (loadLocales → loadLookups → wire DOM → start)
30+
} })(); // IIFE closes
3031
```
3132

3233
---
@@ -161,7 +162,38 @@ Big section divider at L5533. Ported from the Flutter `SnapmakerWebSocketPage`.
161162

162163
---
163164

164-
## Add-printer flow (L7217-9344)
165+
## FlashForge Live (HTTP polling) (L7288-8345)
166+
167+
Big section divider at L7288. Mirrors the Snapmaker block (`snap*` →
168+
`ffg*` prefix). Polls `POST http://<ip>:8898/detail` every 2 s with
169+
`{ serialNumber, checkCode }` body. Filament changes go to
170+
`POST http://<ip>:8898/control` with `cmd: "msConfig_cmd"` (matlStation)
171+
or `cmd: "ipdMsConfig_cmd"` (independent extruder).
172+
173+
| L | What | Anchors |
174+
|---|---|---|
175+
| 7288-7320 | Per-printer state map (`_ffgConns`, `_ffgPings`); `ffgKey`, `ffgIsOnline`, `ffgBaseUrl`, `ffgAuthBody` | |
176+
| 7321-7370 | **`ffgPingPrinter`** — 2.5 s POST probe used for the printer-grid online dot. 30 s cache. | `ffgPingPrinter`, `ffgPingAllPrinters` |
177+
| 7371-7385 | Surgical DOM update of online badges (grid card + side card) | `ffgRefreshOnlineUI`, `renderFfgOnlineBadge` |
178+
| 7386-7450 | **Polling lifecycle** — `ffgConnect` opens a 2 s `setInterval`, `ffgDisconnect` tears it down. Capped exponential backoff on offline. | `ffgConnect`, `ffgDisconnect`, `ffgScheduleReconnect` |
179+
| 7451-7510 | **`ffgPollOnce`** — single `fetch` POST `/detail`, parses JSON, dispatches to `ffgMergeStatus` | `ffgPollOnce` |
180+
| 7511-7650 | **`ffgMergeStatus`** — full `/detail` parser. Error contract (-2 / sn / pwd), then field extraction (temps, filament matlStation vs indep, print job, camera). Throttles SN/password toasts to one per session per printer. | `ffgMergeStatus`, `ffgWarnOnce` |
181+
| 7651-7670 | rAF-coalesced re-renders. Full re-render on status change (camera swap), live-only on data change. | `ffgNotifyChange` |
182+
| 7671-7820 | **Live block render** — `renderFlashforgeLiveInner()` returns the side-card inner HTML. Reuses `.snap-*` CSS classes for visual parity. | `renderFlashforgeLiveInner`, `ffgFmtTempSolo`, `ffgIsActiveState`, `ffgStateLabel`, `ffgFmtDuration` |
183+
| 7821-7880 | **Filament-edit catalogue** — vendor → materials map, color presets aliased to `SNAP_FIL_COLOR_PRESETS` | `FFG_FIL_VENDOR_MATERIALS`, `ffgSortMaterials` |
184+
| 7881-7960 | Bottom-sheet open/close + sub-pickers (filament, colour). Mirrors Snapmaker's `sfe*` flow with `ffe*` prefix. | `openFlashforgeFilamentEdit`, `closeFlashforgeFilamentEdit`, `ffeOpenFilamentSheet`, `ffeOpenColorSheet`, `ffeUpdateSummary`, `ffeRenderColorGrid` |
185+
| 7961-8050 | Click delegation on vendor / material lists + colour grid + native colour picker overlay | |
186+
| 8051-8345 | **Apply (`POST /control`)** — branches on matlStation vs independent extruder. Optimistic local patch of `conn.data.filaments` so the colour square updates immediately. | `$("ffgFilEditSave") click` |
187+
188+
Wiring (cross-cutting with Snapmaker):
189+
- `renderPrintersView` (L5300+) emits `renderFfgOnlineBadge` and triggers `ffgPingPrinter` for FlashForge cards.
190+
- `openPrinterDetail` / `closePrinterDetail` (L5475+) call `ffgConnect` / `ffgDisconnect`.
191+
- `renderPrinterDetail` (L6800+) builds `#ffgLive`, swaps the side-card hero camera for an MJPEG `<img>` when `ffgConn.data.camera.url` is non-empty.
192+
- HTML parallel sheets at `inventory.html` L460+ (`#ffgFilEditSheet`, `#ffgFilamentSheet`, `#ffgColorSheet`).
193+
194+
---
195+
196+
## Add-printer flow (L8347+)
165197

166198
| L | What | Anchors |
167199
|---|---|---|
@@ -271,6 +303,9 @@ Most common navigation tasks → start here:
271303
| Touch the printer detail card | `renderPrinterDetail` L6798 |
272304
| Touch the Snapmaker WS layer | `snapConnect` L5640, `snapMergeStatus` L5793 |
273305
| Touch the Snapmaker live block UI | `renderSnapmakerLiveInner` L6520 |
306+
| Touch the FlashForge HTTP polling | `ffgConnect` L7390, `ffgPollOnce` L7460, `ffgMergeStatus` L7515 |
307+
| Touch the FlashForge live block UI | `renderFlashforgeLiveInner` L7700 |
308+
| Touch the FlashForge filament edit sheet | `openFlashforgeFilamentEdit` L7900, Apply at `$("ffgFilEditSave")` L8060 |
274309
| Touch the bottom-sheet filament edit | `openSnapFilamentEdit` L5971, color grid L6244 |
275310
| Touch the Add-printer scan flow | mDNS L8030, port-scan L8131, one-click add L8241 |
276311
| Touch the Add by IP widget | L8634 |

‎renderer/locales/de.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,5 +589,9 @@
589589
"ffgCameraAlt": "FlashForge-Kamerastream",
590590
"ffgFilEditTitle": "Filament wechseln",
591591
"ffgFilEditApply": "Anwenden",
592-
"ffgErrNetwork": "Drucker nicht erreichbar — IP und Netzwerk prüfen."
592+
"ffgErrNetwork": "Drucker nicht erreichbar — IP und Netzwerk prüfen.",
593+
"ffgConnConnecting": "Verbindung…",
594+
"ffgConnConnected": "Verbunden",
595+
"ffgConnOffline": "Offline",
596+
"ffgConnReconnecting": "Erneut verbinden…"
593597
}

‎renderer/locales/en.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,5 +586,9 @@
586586
"ffgCameraAlt": "FlashForge camera stream",
587587
"ffgFilEditTitle": "Change filament",
588588
"ffgFilEditApply": "Apply",
589-
"ffgErrNetwork": "Cannot reach the printer — check IP and network."
589+
"ffgErrNetwork": "Cannot reach the printer — check IP and network.",
590+
"ffgConnConnecting": "Connecting…",
591+
"ffgConnConnected": "Connected",
592+
"ffgConnOffline": "Offline",
593+
"ffgConnReconnecting": "Reconnecting…"
590594
}

‎renderer/locales/es.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,5 +589,9 @@
589589
"ffgCameraAlt": "Transmisión de cámara FlashForge",
590590
"ffgFilEditTitle": "Cambiar filamento",
591591
"ffgFilEditApply": "Aplicar",
592-
"ffgErrNetwork": "No se puede alcanzar la impresora — comprueba la IP y la red."
592+
"ffgErrNetwork": "No se puede alcanzar la impresora — comprueba la IP y la red.",
593+
"ffgConnConnecting": "Conectando…",
594+
"ffgConnConnected": "Conectada",
595+
"ffgConnOffline": "Sin conexión",
596+
"ffgConnReconnecting": "Reconectando…"
593597
}

‎renderer/locales/fr.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,5 +589,9 @@
589589
"ffgCameraAlt": "Flux caméra FlashForge",
590590
"ffgFilEditTitle": "Changer le filament",
591591
"ffgFilEditApply": "Appliquer",
592-
"ffgErrNetwork": "Imprimante injoignable — vérifiez l'IP et le réseau."
592+
"ffgErrNetwork": "Imprimante injoignable — vérifiez l'IP et le réseau.",
593+
"ffgConnConnecting": "Connexion…",
594+
"ffgConnConnected": "Connectée",
595+
"ffgConnOffline": "Hors ligne",
596+
"ffgConnReconnecting": "Reconnexion…"
593597
}

‎renderer/locales/it.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,5 +589,9 @@
589589
"ffgCameraAlt": "Stream camera FlashForge",
590590
"ffgFilEditTitle": "Cambia filamento",
591591
"ffgFilEditApply": "Applica",
592-
"ffgErrNetwork": "Impossibile raggiungere la stampante — controlla IP e rete."
592+
"ffgErrNetwork": "Impossibile raggiungere la stampante — controlla IP e rete.",
593+
"ffgConnConnecting": "Connessione…",
594+
"ffgConnConnected": "Connessa",
595+
"ffgConnOffline": "Offline",
596+
"ffgConnReconnecting": "Riconnessione…"
593597
}

‎renderer/locales/pl.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,5 +600,9 @@
600600
"ffgCameraAlt": "Strumień kamery FlashForge",
601601
"ffgFilEditTitle": "Zmień filament",
602602
"ffgFilEditApply": "Zastosuj",
603-
"ffgErrNetwork": "Nie można połączyć się z drukarką — sprawdź IP i sieć."
603+
"ffgErrNetwork": "Nie można połączyć się z drukarką — sprawdź IP i sieć.",
604+
"ffgConnConnecting": "Łączenie…",
605+
"ffgConnConnected": "Połączona",
606+
"ffgConnOffline": "Offline",
607+
"ffgConnReconnecting": "Ponowne łączenie…"
604608
}

‎renderer/locales/pt-pt.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,5 +601,9 @@
601601
"ffgCameraAlt": "Transmissão da câmara FlashForge",
602602
"ffgFilEditTitle": "Trocar filamento",
603603
"ffgFilEditApply": "Aplicar",
604-
"ffgErrNetwork": "Não foi possível alcançar a impressora — verifique o IP e a rede."
604+
"ffgErrNetwork": "Não foi possível alcançar a impressora — verifique o IP e a rede.",
605+
"ffgConnConnecting": "A ligar…",
606+
"ffgConnConnected": "Ligada",
607+
"ffgConnOffline": "Offline",
608+
"ffgConnReconnecting": "A reconectar…"
605609
}

‎renderer/locales/pt.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,5 +601,9 @@
601601
"ffgCameraAlt": "Transmissão da câmera FlashForge",
602602
"ffgFilEditTitle": "Trocar filamento",
603603
"ffgFilEditApply": "Aplicar",
604-
"ffgErrNetwork": "Não foi possível alcançar a impressora — verifique o IP e a rede."
604+
"ffgErrNetwork": "Não foi possível alcançar a impressora — verifique o IP e a rede.",
605+
"ffgConnConnecting": "Conectando…",
606+
"ffgConnConnected": "Conectada",
607+
"ffgConnOffline": "Offline",
608+
"ffgConnReconnecting": "Reconectando…"
605609
}

‎renderer/locales/zh.json‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,5 +589,9 @@
589589
"ffgCameraAlt": "FlashForge 摄像头视频流",
590590
"ffgFilEditTitle": "更换耗材",
591591
"ffgFilEditApply": "应用",
592-
"ffgErrNetwork": "无法连接到打印机 — 请检查 IP 和网络。"
592+
"ffgErrNetwork": "无法连接到打印机 — 请检查 IP 和网络。",
593+
"ffgConnConnecting": "连接中…",
594+
"ffgConnConnected": "已连接",
595+
"ffgConnOffline": "离线",
596+
"ffgConnReconnecting": "重新连接中…"
593597
}

0 commit comments

Comments
 (0)