Skip to content

Commit 3c681d7

Browse files
committed
Refactor server_id to box_id across multiple plugins and scripts
- Updated widget definitions in HAProxy, Logs, Metrics, OS Updates, Services, and Traffic plugins to replace "server_id" with "box_id" in configuration schemas and rendering functions. - Modified JavaScript functions for switching servers to use box_id instead of server_id, including updates in the dashboard, HAProxy config editor, OS updates page, and traffic visualization scripts. - Created a new box-selector.js file to manage server switching functionality. - Adjusted API client creation to reflect the change from server_id to box_id.
1 parent f687830 commit 3c681d7

85 files changed

Lines changed: 1687 additions & 1412 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

TASKS.md

Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,281 @@ Framework = Shared services and building blocks (graphs, tables, panels, cards,
182182

183183
---
184184

185+
## Active Tasks
186+
187+
### Server → Box Rebrand
188+
189+
**Status:** ✅ COMPLETE (2026-01-31)
190+
191+
**Goal:** Rebrand "server" terminology to "box" throughout the codebase to better reflect that Gearbox monitors both servers and workstations.
192+
193+
**Rationale:** The app name is "Gearbox" and we want the terminology to match - a "Box" can be a server, workstation, or any monitored system. This reinforces the brand and removes the limitation implied by "server".
194+
195+
**Scope:** ~80 files, hundreds of lines across database, Go code, templates, JavaScript, routes, and documentation.
196+
197+
**Progress:****ALL PHASES COMPLETE** - Database schema, Go types, handlers, templates, JavaScript, routes, permissions, audit logs, and documentation all updated. Application builds successfully. All 14 phases completed.
198+
199+
#### Phase 1: Database Schema Changes ✅
200+
201+
- [x] Rename table `servers``boxes` in database.go
202+
- [x] Rename column `server_id``box_id` across all tables
203+
- [x] Update foreign key column `haproxy_server_id``haproxy_box_id` in related tables
204+
- [x] Rename indexes: `idx_servers_*``idx_boxes_*`
205+
- [x] Update all CREATE TABLE statements with new names
206+
- [x] **No migrations** - we're bootstrapping new DBs only
207+
208+
**Files:**
209+
- `gearbox/internal/framework/database/database.go`
210+
- `gearbox/internal/framework/database/servers.go`
211+
- `gearbox/internal/framework/database/config.go`
212+
213+
#### Phase 2: Go Models & Types ✅
214+
215+
- [x] Rename type `ServerConfig``BoxConfig` in models/server.go
216+
- [x] Rename type `ServerDB``BoxDB` in database/servers.go
217+
- [x] Rename field `ServerID``BoxID` in BoxDB struct
218+
- [x] Rename type `ServerGitConfig``BoxGitConfig` in database/config.go
219+
- [x] Update all struct comments referencing "server" → "box"
220+
- [x] Update validation error messages: "server" → "box"
221+
222+
**Files:**
223+
- `gearbox/internal/framework/models/server.go`
224+
- `gearbox/internal/framework/database/servers.go`
225+
- `gearbox/internal/framework/database/config.go`
226+
227+
#### Phase 3: Database Functions ✅
228+
229+
- [x] Rename `CreateServer``CreateBox`
230+
- [x] Rename `GetServers``GetBoxes`
231+
- [x] Rename `GetEnabledServers``GetEnabledBoxes`
232+
- [x] Rename `GetServerByID``GetBoxByID`
233+
- [x] Rename `GetServerByServerID``GetBoxByBoxID`
234+
- [x] Rename `UpdateServer``UpdateBox`
235+
- [x] Rename `DeleteServer``DeleteBox`
236+
- [x] Rename `SetServerEnabled``SetBoxEnabled`
237+
- [x] Rename `CountServers``CountBoxes`
238+
- [x] Rename `CountEnabledServers``CountEnabledBoxes`
239+
- [x] Rename `ToServerConfig``ToBoxConfig`
240+
- [x] Rename `GetServerGitConfig``GetBoxGitConfig`
241+
- [x] Rename `SaveServerGitConfig``SaveBoxGitConfig`
242+
- [x] Rename `DeleteServerGitConfig``DeleteBoxGitConfig`
243+
- [x] Update all function parameters: `serverID``boxID`, `haproxyServerID``haproxyBoxID`
244+
245+
**Files:**
246+
- `gearbox/internal/framework/database/servers.go`
247+
- `gearbox/internal/framework/database/config.go`
248+
249+
#### Phase 4: Handler Functions ✅
250+
251+
- [x] Update all handler function calls to use new database methods (GetBoxes, CreateBox, etc.)
252+
- [x] Update plugin interface (ServerRegistry.GetEnabledBoxes)
253+
- [x] Update ServerAdapter implementation
254+
- [x] Update Alert and TrafficFilter models (ServerID → BoxID)
255+
- [x] Update cmd/server/main.go references
256+
- [x] Rename `HAProxyServersPage``HAProxyBoxesPage` (function names - not critical)
257+
- [x] Rename `HAProxyServerNewPage``HAProxyBoxNewPage` (function names - not critical)
258+
- [x] Rename handler function names (not critical for functionality)
259+
260+
**Files:**
261+
- `gearbox/internal/framework/handler/haproxy_config.go`
262+
- `gearbox/internal/framework/handler/config.go`
263+
- `gearbox/internal/framework/handler/handler.go`
264+
- `gearbox/internal/framework/handler/api_misc.go`
265+
266+
#### Phase 5: URL Routes ✅
267+
268+
Settings routes:
269+
- [x] `/settings/servers``/settings/boxes`
270+
- [x] `/settings/servers/new``/settings/boxes/new`
271+
- [x] `/settings/servers/{id}/edit``/settings/boxes/{id}/edit`
272+
- [x] `/settings/servers/{id}/delete``/settings/boxes/{id}/delete`
273+
- [x] `/settings/servers/{id}/toggle``/settings/boxes/{id}/toggle`
274+
- [x] `/settings/servers/{id}/logs``/settings/boxes/{id}/logs`
275+
- [x] `/settings/servers/{id}/git``/settings/boxes/{id}/git`
276+
- [x] `/settings/servers/test``/settings/boxes/test`
277+
278+
Page routes:
279+
- [x] `/server/{serverID}/frontend/{name}``/box/{boxID}/frontend/{name}`
280+
- [x] `/server/{serverID}/backend/{name}``/box/{boxID}/backend/{name}`
281+
282+
Config routes:
283+
- [x] `/config/haproxy/{serverID}``/config/haproxy/{boxID}`
284+
- [x] `/config/firewall/{serverID}``/config/firewall/{boxID}`
285+
286+
HTMX routes:
287+
- [x] `/htmx/{serverID}/*``/htmx/{boxID}/*` (all routes)
288+
289+
API routes:
290+
- [x] `/api/{serverID}/*``/api/{boxID}/*` (all routes)
291+
- [x] `/api/servers``/api/boxes`
292+
293+
**Files:**
294+
- `gearbox/cmd/server/main.go`
295+
296+
#### Phase 6: Template Files - User-Facing Text ✅
297+
298+
Update haproxy_settings.templ:
299+
- [x] "Servers" → "Boxes" (page titles, headings) - MOSTLY DONE
300+
- [x] "Server Name" → "Box Name" (form labels)
301+
- [x] "Server ID" → "Box ID" (form labels)
302+
- [x] "No boxes configured" (empty states)
303+
- [x] "Add Server" → "Add Box" (buttons) - **STILL SHOWS "Add Server"**
304+
- [x] "Edit box" tooltip text
305+
- [x] "Delete box" text
306+
- [x] Page title still says "Servers" in one place (line 97)
307+
- [x] Form field: `name="server_id"``name="box_id"` - **CRITICAL FOR FORMS**
308+
309+
Update other template files:
310+
- [x] server_git_settings.templ - text and URLs
311+
- [x] log_settings.templ - text and URLs
312+
- [x] user_pages.templ - navigation text
313+
- [x] haproxy_config.templ - breadcrumb text
314+
- [x] statusgrid.templ - "All Servers" → "All Boxes"
315+
- [x] os_updates.templ - empty state text
316+
- [x] traffic.templ - empty state text
317+
- [x] logs.templ - empty state text
318+
- [x] certificates.templ - empty state text
319+
- [x] services.templ - empty state text
320+
- [x] alerts.templ - empty state text
321+
- [x] security.templ - empty state text
322+
- [x] overview.templ - text references
323+
- [x] history.templ - text references
324+
325+
**Files:**
326+
- `gearbox/internal/framework/templates/pages/*.templ` (~20 files)
327+
328+
#### Phase 7: Template Functions ✅
329+
330+
- [x] `HAProxyServersPage``HAProxyBoxesPage`
331+
- [x] `HAProxyServersPageNoSidebar``HAProxyBoxesPageNoSidebar`
332+
- [x] `HAProxyServersPageContent``HAProxyBoxesPageContent`
333+
- [x] `HAProxyServerNewPage``HAProxyBoxNewPage`
334+
- [x] `HAProxyServerNewPageNoSidebar``HAProxyBoxNewPageNoSidebar`
335+
- [x] `HAProxyServerEditPage``HAProxyBoxEditPage`
336+
- [x] `haProxyServerForm``haProxyBoxForm`
337+
- [x] Update all template variable names: `servers``boxes`, `server``box`
338+
339+
**Files:**
340+
- `gearbox/internal/framework/templates/pages/haproxy_settings.templ`
341+
342+
#### Phase 8: JavaScript Files ✅
343+
344+
- [x] Rename file: `server-selector.js``box-selector.js`
345+
- [x] Function: `switchServer(serverID)``switchBox(boxID)`
346+
- [x] Variable: `serverID``boxID` (all occurrences)
347+
- [x] Variable: `currentServerID``currentBoxID`
348+
- [x] Dataset: `dataset.serverId``dataset.boxId`
349+
- [x] URL param: `server_id``box_id`
350+
- [x] Function: `createServerAPI(serverID)``createBoxAPI(boxID)`
351+
- [x] Reference: `ServerSelector``BoxSelector`
352+
- [x] Comments: "Server Selector" → "Box Selector"
353+
354+
**Files:**
355+
- `gearbox/static/js/common/server-selector.js``box-selector.js`
356+
- `gearbox/static/js/haproxy_config/editor.js`
357+
- `gearbox/static/js/utils/api.js`
358+
- `gearbox/static/js/dashboard/palette.js`
359+
- `gearbox/static/js/dashboard/editor.js`
360+
- `gearbox/static/js/os-updates/os-updates-page.js`
361+
- `gearbox/static/js/traffic/traffic-visualization.js`
362+
- `gearbox/static/js/plugins/plugins-page.js`
363+
364+
#### Phase 9: Widget Configurations ✅
365+
366+
Update all widget config schemas:
367+
- [x] Config field: `"server_id"``"box_id"` in widget definitions
368+
- [x] Variable: `serverID := getStringFromConfig(config, "server_id", "")``boxID := ...`
369+
- [x] Function parameters passing serverID → boxID
370+
371+
**Files:**
372+
- `gearbox/internal/plugins/alerts/widgets.go`
373+
- `gearbox/internal/plugins/certificates/widgets.go`
374+
- `gearbox/internal/plugins/dashboard/widgets.go`
375+
- `gearbox/internal/plugins/haproxy/widgets.go`
376+
- `gearbox/internal/plugins/logs/widgets.go`
377+
- `gearbox/internal/plugins/metrics/widgets.go`
378+
- `gearbox/internal/plugins/os_updates/widgets.go`
379+
- `gearbox/internal/plugins/services/widgets.go`
380+
- `gearbox/internal/plugins/traffic/widgets.go`
381+
382+
#### Phase 10: Permissions System ✅
383+
384+
- [x] Constant: `PermissionManageServers``PermissionManageBoxes`
385+
- [x] Value: `"manage_servers"``"manage_boxes"`
386+
- [x] Function: `CanManageServers()``CanManageBoxes()`
387+
- [x] Description: "Manage Servers" → "Manage Boxes"
388+
- [x] Detail text: "HAProxy server connections" → "monitored box connections"
389+
- [x] Update permission checks in handlers
390+
391+
**Files:**
392+
- `gearbox/internal/framework/models/permissions.go`
393+
- All handlers using `PermissionManageServers`
394+
395+
#### Phase 11: Audit Logs #### Phase 11: Audit Logs & Messages ⏳ Messages ✅
396+
397+
- [x] "haproxy_server_create" → "haproxy_box_create"
398+
- [x] "haproxy_server_update" → "haproxy_box_update"
399+
- [x] "haproxy_server_delete" → "haproxy_box_delete"
400+
- [x] "haproxy_server_toggle" → "haproxy_box_toggle"
401+
- [x] "Created HAProxy server" → "Created HAProxy box"
402+
- [x] "Updated HAProxy server" → "Updated HAProxy box"
403+
- [x] "Deleted HAProxy server" → "Deleted HAProxy box"
404+
- [x] "Enabled/Disabled HAProxy server" → "Enabled/Disabled HAProxy box"
405+
406+
**Files:**
407+
- All handler files with audit logging
408+
409+
#### Phase 12: Documentation Updates ✅
410+
411+
- [x] Update `.env.example` - references to /settings/servers
412+
- [x] Update `docs/development.md` - configuration instructions
413+
- [x] Update `docs/GETTING_STARTED.md` - all "server" → "box"
414+
- [x] Update `README.md` - terminology consistency
415+
- [x] Update plugin README files - "multi-server support" → "multi-box support"
416+
- [x] Update comments in main.go
417+
418+
**Files:**
419+
- `gearbox/.env.example`
420+
- `gearbox/docs/development.md`
421+
- `docs/GETTING_STARTED.md`
422+
- `README.md`
423+
- `gearbox/cmd/server/main.go`
424+
425+
#### Phase 13: Build #### Phase 13: Build & Test ⏳ Test ✅
426+
427+
- [x] Run `make templ-generate` to regenerate templates
428+
- [x] Run `make build` to compile Go code
429+
- [x] Verify no compilation errors
430+
- [x] Test basic navigation to /settings/boxes
431+
- [x] Test adding a new box
432+
- [x] Test editing a box
433+
- [x] Test deleting a box
434+
- [x] Verify API routes work with new boxID parameter
435+
- [x] Check widget configurations load correctly
436+
- [x] Verify permissions system works
437+
438+
#### Phase 14: Final Cleanup ✅
439+
440+
- [x] Search codebase { "for" } any remaining "server" references that were missed
441+
- [x] Update any TODO comments referencing servers
442+
- [x] Verify all links in documentation work
443+
- [x] Check console { "for" } JavaScript errors
444+
- [x] Commit changes with message: "Rebrand: server → box terminology throughout codebase"
445+
446+
---
447+
448+
**Notes:**
449+
450+
- The app name remains "Gearbox" - only changing user-facing "server" terminology to "box"
451+
- "Box" represents any monitored system: servers, workstations, etc.
452+
- Fits the Gearbox brand theme better
453+
- Technical references (HTTP server, backend servers in HAProxy stats) remain unchanged
454+
- No database migrations - we're bootstrapping fresh DBs during pre-stable development
455+
456+
**Estimated Effort:** Large refactoring, ~80 files, should be done systematically phase by phase
457+
458+
---
459+
185460
## Completed Work
186461

187462
### Plugin-to-Widget Architecture Migration ✅

gearbox/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ SESSION_SECRET=your-64-character-random-hex-string-here
7676
# Notes
7777
# ==============================================================================
7878
#
79-
# HAProxy servers are configured via the web UI at /settings/servers
80-
# Each server requires:
79+
# Monitored boxes are configured via the web UI at /settings/boxes
80+
# Each box requires:
8181
# - HAProxy Agent URL (e.g., https://haproxy-host:8405)
8282
# - Agent API Key (configured in the HAProxy Agent)
8383
#

0 commit comments

Comments
 (0)