Show progress for uploads and updates, and reload when they are done
An uploaded bundle gets a progress bar over the page; a running update an overlay that follows its steps. A page that finished working, or that was sent to the login page by a restart, is loaded whole. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
This commit is contained in:
@@ -242,8 +242,34 @@ func unitRun(unit string) UpdateStatus {
|
||||
|
||||
func (s System) UpdateStatus() UpdateStatus { return unitRun("router-update.service") }
|
||||
|
||||
// updateProgress is how far router-update has come, from the last step its log
|
||||
// names: a share of the whole (the build at the end takes the longest, so the
|
||||
// bar is only a guide) and what it is doing.
|
||||
func updateProgress(log string) (int, string) {
|
||||
steps := []struct {
|
||||
marker string
|
||||
pct int
|
||||
what string
|
||||
}{
|
||||
{"router-update: verifying", 10, "Verifying the signature"},
|
||||
{"router-update: importing", 30, "Importing the release"},
|
||||
{"router-update: installed", 50, "Checking the version"},
|
||||
{"router-update: building and activating", 70, "Building and activating the new version"},
|
||||
}
|
||||
pct, what := 5, "Starting"
|
||||
best := -1
|
||||
for _, s := range steps {
|
||||
if i := strings.LastIndex(log, s.marker); i > best {
|
||||
best, pct, what = i, s.pct, s.what
|
||||
}
|
||||
}
|
||||
return pct, what
|
||||
}
|
||||
|
||||
type updateData struct {
|
||||
Installed Release
|
||||
Progress int // percent, while updating
|
||||
Step string // what it does now
|
||||
Status UpdateStatus
|
||||
URL string
|
||||
Offer *Available
|
||||
@@ -253,12 +279,14 @@ type updateData struct {
|
||||
|
||||
func (a *app) updateData() updateData {
|
||||
st := a.sys.Status()
|
||||
return updateData{
|
||||
d := updateData{
|
||||
Installed: a.sys.installedRelease(),
|
||||
Status: a.sys.UpdateStatus(),
|
||||
URL: a.sys.updateURL(),
|
||||
Pending: st.RollbackIn > 0,
|
||||
}
|
||||
d.Progress, d.Step = updateProgress(d.Status.Log)
|
||||
return d
|
||||
}
|
||||
|
||||
func (a *app) updatePage(w http.ResponseWriter, r *http.Request, sess session) {
|
||||
|
||||
Reference in New Issue
Block a user