Skip to content

feat(web-ui): per-network connect toggle, one file for the Networks page - #685

Merged
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:feature/web28
Jul 29, 2026
Merged

feat(web-ui): per-network connect toggle, one file for the Networks page#685
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:feature/web28

Conversation

@ngosang

@ngosang ngosang commented Jul 29, 2026

Copy link
Copy Markdown
Member

The Networks tab strip carried a single ConnectButton that toggled ED2K and Kad together, while each tab had its own state-blind Connect/Disconnect buttons. That mirrored neither the REST API (already symmetric via POST /networks/{connect,disconnect} with {network: "ed2k"|"kad"|"both"}) nor amulegui after #663/#677, and it meant only the global button reflected the actual connection state.

Each network tab now owns one state-aware toggle for its own network. Colour and label follow the real state from the SSE status_changed event — a red/amber/green plug reading "ED2K: Connected", "Kad: Connecting…" — while the click performs the opposite action. "connecting" counts as up, so a Kad that is running-but-not-routing (the backend collapses that into "connecting") stays stoppable; this matches CKadDlg::OnBnClickedDisconnectKad. There is no confirmation dialog, matching the buttons it replaces. Disconnecting both networks at once is no longer offered.

Kad's "Connect from known clients" button is not lost: it issued the same EC_OP_KAD_START the toggle does, exactly as amulegui's ID_KNOWNNODECONNECT handler is a bare StartKad() call. "Bootstrap from node" is a genuinely different operation (EC_OP_KAD_BOOTSTRAP_FROM_IP) and is untouched, as is the per-row connect that dials one specific server.

The page is now a single view file. servers.js, kad.js, ed2k.js and logs.js were imported by networks.js and nothing else, so splitting them only bought a five-request, two-wave waterfall behind the lazy route import in app.js RouteView — the browser had to parse networks.js before it could discover the other four. At 410 lines the merged file sits alongside preferences.js (411) and download-detail.js (429), which are single-file multi-tab views already; Networks was the only page split up. split-detail.js stays separate, being shared with Downloads and Shared files.

Merging also let some duplication and dead code go:

  • stat() was defined identically in kad.js and ed2k.js; one copy remains, and the two log panels now share a logBox() helper.
  • Three data.ensureStatus() calls in the panels were no-ops. Shell already calls it unconditionally for every route (app.js) and it is guarded by statusActive, so Ed2kInfoPanel no longer needs an effect at all.
  • NetworkConnectButton lives in the view rather than components.js: it is Networks-only, and keeping it in components.js would have shipped it eagerly to every page.
  • app.css: the button is now a .btn, so the tool-btn-derived sizing and the dead .tabs-extra .conn-btn overrides are gone. The state colours and .tabs-extra itself stay (still used by the Downloads category filters).
  • i18n: no new keys — networks_tab_ed2k/_kad and app_connect* already cover the label. Eight keys left with no reference are removed, and the missing networks_kad_conn_disabled is added; without it the Kad info panel printed a raw key string whenever Kad was stopped.

The Networks tab strip carried a single ConnectButton that toggled ED2K and
Kad together, while each tab had its own state-blind Connect/Disconnect
buttons. That mirrored neither the REST API (already symmetric via
POST /networks/{connect,disconnect} with {network: "ed2k"|"kad"|"both"}) nor
amulegui after amule-project#663/amule-project#677, and it meant only the global button reflected the
actual connection state.

Each network tab now owns one state-aware toggle for its own network. Colour
and label follow the real state from the SSE status_changed event — a
red/amber/green plug reading "ED2K: Connected", "Kad: Connecting…" — while the
click performs the opposite action. "connecting" counts as up, so a Kad that is
running-but-not-routing (the backend collapses that into "connecting") stays
stoppable; this matches CKadDlg::OnBnClickedDisconnectKad. There is no
confirmation dialog, matching the buttons it replaces. Disconnecting both
networks at once is no longer offered.

Kad's "Connect from known clients" button is not lost: it issued the same
EC_OP_KAD_START the toggle does, exactly as amulegui's ID_KNOWNNODECONNECT
handler is a bare StartKad() call. "Bootstrap from node" is a genuinely
different operation (EC_OP_KAD_BOOTSTRAP_FROM_IP) and is untouched, as is the
per-row connect that dials one specific server.

The page is now a single view file. servers.js, kad.js, ed2k.js and logs.js
were imported by networks.js and nothing else, so splitting them only bought a
five-request, two-wave waterfall behind the lazy route import in app.js
RouteView — the browser had to parse networks.js before it could discover the
other four. At 410 lines the merged file sits alongside preferences.js (411)
and download-detail.js (429), which are single-file multi-tab views already;
Networks was the only page split up. split-detail.js stays separate, being
shared with Downloads and Shared files.

Merging also let some duplication and dead code go:

- stat() was defined identically in kad.js and ed2k.js; one copy remains, and
  the two log panels now share a logBox() helper.
- Three data.ensureStatus() calls in the panels were no-ops. Shell already
  calls it unconditionally for every route (app.js) and it is guarded by
  statusActive, so Ed2kInfoPanel no longer needs an effect at all.
- NetworkConnectButton lives in the view rather than components.js: it is
  Networks-only, and keeping it in components.js would have shipped it
  eagerly to every page.
- app.css: the button is now a .btn, so the tool-btn-derived sizing and the
  dead .tabs-extra .conn-btn overrides are gone. The state colours and
  .tabs-extra itself stay (still used by the Downloads category filters).
- i18n: no new keys — networks_tab_ed2k/_kad and app_connect* already cover
  the label. Eight keys left with no reference are removed, and the missing
  networks_kad_conn_disabled is added; without it the Kad info panel printed
  a raw key string whenever Kad was stopped.
@ngosang

ngosang commented Jul 29, 2026

Copy link
Copy Markdown
Member Author
imagen imagen

@ngosang
ngosang merged commit 80cc8f0 into amule-org:master Jul 29, 2026
14 checks passed
@ngosang
ngosang deleted the feature/web28 branch July 29, 2026 00:06
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