B1: migrate UI wiring — /api/storage/migrate{,-app,/status} + settings & app pages
ServeStorageAPI gains POST /api/storage/migrate (whole-namespace), POST /api/storage/migrate-app (single app), GET /api/storage/migrate/status (poll). settings.html: the greyed migrate-all span becomes a real target-select + button + shared progress panel; app_info.html gains a per-app 'Áthelyezés másik tárhelyre' control. Both poll the shared status endpoint and render Hungarian phase progress. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -245,11 +245,61 @@ func (s *Server) ServeStorageAPI(w http.ResponseWriter, r *http.Request) {
|
||||
s.handleStorageRegister(w, r)
|
||||
case r.URL.Path == "/api/storage/activate" && r.Method == http.MethodPost:
|
||||
s.handleStorageActivate(w, r)
|
||||
case r.URL.Path == "/api/storage/migrate" && r.Method == http.MethodPost:
|
||||
s.handleStorageMigrate(w, r)
|
||||
case r.URL.Path == "/api/storage/migrate-app" && r.Method == http.MethodPost:
|
||||
s.handleStorageMigrateApp(w, r)
|
||||
case r.URL.Path == "/api/storage/migrate/status" && r.Method == http.MethodGet:
|
||||
s.handleStorageMigrateStatus(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
}
|
||||
|
||||
// handleStorageMigrate starts a whole-namespace migration (all apps + non-app content) off the source
|
||||
// drive onto the chosen target. Async: VALIDATE runs synchronously (a refusal is returned here and
|
||||
// changes nothing); the copy/redeploy/cleanup run in the background and the UI polls migrate/status.
|
||||
func (s *Server) handleStorageMigrate(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Source string `json:"source"`
|
||||
Target string `json:"target"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeDiskJSON(w, http.StatusBadRequest, false, "érvénytelen kérés", nil)
|
||||
return
|
||||
}
|
||||
id, err := s.stackMgr.MigrateAll(r.Context(), strings.TrimSpace(req.Source), strings.TrimSpace(req.Target))
|
||||
if err != nil {
|
||||
writeDiskJSON(w, http.StatusConflict, false, err.Error(), nil)
|
||||
return
|
||||
}
|
||||
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"started": true, "id": id})
|
||||
}
|
||||
|
||||
// handleStorageMigrateApp starts a single-app migration onto the chosen target.
|
||||
func (s *Server) handleStorageMigrateApp(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
App string `json:"app"`
|
||||
Target string `json:"target"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
writeDiskJSON(w, http.StatusBadRequest, false, "érvénytelen kérés", nil)
|
||||
return
|
||||
}
|
||||
id, err := s.stackMgr.MigrateApp(r.Context(), strings.TrimSpace(req.App), strings.TrimSpace(req.Target))
|
||||
if err != nil {
|
||||
writeDiskJSON(w, http.StatusConflict, false, err.Error(), nil)
|
||||
return
|
||||
}
|
||||
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"started": true, "id": id})
|
||||
}
|
||||
|
||||
// handleStorageMigrateStatus returns the live migration job (nil/idle when none is running) for the
|
||||
// progress panel poll.
|
||||
func (s *Server) handleStorageMigrateStatus(w http.ResponseWriter, r *http.Request) {
|
||||
writeDiskJSON(w, http.StatusOK, true, "", map[string]any{"job": s.stackMgr.MigrationStatus()})
|
||||
}
|
||||
|
||||
type storageProvReq struct {
|
||||
Device string `json:"device"`
|
||||
FSType string `json:"fstype"`
|
||||
|
||||
Reference in New Issue
Block a user