feat: Web frontend console with one-click checkin and scan-login - #13
Open
Lwn666 wants to merge 2 commits into
Open
feat: Web frontend console with one-click checkin and scan-login#13Lwn666 wants to merge 2 commits into
Lwn666 wants to merge 2 commits into
Conversation
- internal/server/web/: static SPA (account cards / checkin / scan login) - internal/server/web_extra.go: embed static assets + route /, /web/* and local API - internal/server/local_api.go: LocalAPI with POST /api/checkin, /api/login/start|poll - internal/login/login.go: OAuth device flow library (same flow as cmd/login, importable) - cmd/server/main.go: mount Web UI unless WEB_DISABLED=1 (LOGIN_DISABLED=1 disables login API) Web UI reads accounts from GET /status, no changes to upstream handler.
…upstream build would fail without this)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an embedded web frontend console: account overview, one-click checkin, and scan-to-login.
This is a purely additive feature — it does NOT modify any existing upstream handler logic. The web UI reads account data from the existing
GET /statusendpoint, and local API routes are mounted via a wrapping middleware.What is included
internal/server/web/go:embedinternal/server/web_extra.goWrapWebmiddleware: routes/,/web/*to frontend,/api/checkin+/api/login/*to LocalAPI, everything else passes through to upstream handlerinternal/server/local_api.goLocalAPIstruct:POST /api/checkin(triggers scheduler checkin round),POST /api/login/start+GET /api/login/poll(OAuth device flow)internal/login/login.gocmd/loginbut importable from the server (the CLI ispackage main, not importable)cmd/server/main.govar handler http.Handler = h; if os.Getenv("WEB_DISABLED") != "1" { ... WrapWeb(...) }DockerfileCOPY config.example.json /app/config.jsoninstead ofCOPY config.json(which is gitignored and does not exist in the repo — a fresh clone would fail to build)Design notes
internal/server/handler.go, pool, scheduler or upstream.WrapWebis a wrapping middleware,LocalAPIis a separate struct.WEB_DISABLED=1disables the whole UI;LOGIN_DISABLED=1disables just the scan-login API.writeJSON,writeOpenAIError,Pool.Add/SetCredits/Disable,Scheduler.RunCheckinNow,Upstream.UserResource,auth.Auth) already exist in upstream.cfg.AuthDir.Test
go build ./...✓go test ./...✓docker build✓ (CI on the fork passes)Screenshot
Account overview shows stat cards (accounts/healthy/disabled/credits) + per-account cards with nickname, UID, credits, status badge, one-click refresh and checkin.