From d3c97c62fe310e9bf430ea9c9279f1d4d4074448 Mon Sep 17 00:00:00 2001 From: kisfenyo Date: Thu, 2 Jul 2026 19:34:27 +0200 Subject: [PATCH] =?UTF-8?q?storage=20IA:=20split=20/storage=20into=20Megha?= =?UTF-8?q?jt=C3=B3k=20+=20/storage/network=20(NAS)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User feedback on D1: the NAS-add button and the local-drive enrollment buttons sat side by side with no separation — two different storage classes interleaved on one page. Now two subpages under Tárhely: - /storage — Tárhely — Meghajtók: physical drive registry, migrate, wizard entry points (Új meghajtó inicializálása / Meglévő meghajtó csatolása), unified agent view, manual add. The enrollment buttons now live unambiguously in the local-drive context. - /storage/network — Tárhely — Hálózati tárhely (NAS): the NAS share list (NAS-megosztások) + add form + its JS (moved verbatim, incl. its own openDialog copy for the remove overlay). - layout.html: Tárhely main-nav item gains two always-visible nested sub-links (Meghajtók / Hálózati tárhely, .nav-links-nested CSS); parent stays highlighted on both. - handlers.go: NetworkStoragePaths moves out of storagePageData into the new networkStoragePageData (page key storage-network) + storageNetworkPageHandler; GET /storage/network route. - Tests: /storage must NOT render the NAS section, /storage/network renders it and nothing drive-related; inventory + no-native-confirm scans cover the new template. Both template gates green. --- controller/internal/web/handlers.go | 15 +- controller/internal/web/server.go | 2 + .../internal/web/settings_split_test.go | 11 +- controller/internal/web/templates/layout.html | 7 +- .../internal/web/templates/storage.html | 103 +------------- .../web/templates/storage_network.html | 130 ++++++++++++++++++ controller/internal/web/templates/style.css | 13 ++ 7 files changed, 172 insertions(+), 109 deletions(-) create mode 100644 controller/internal/web/templates/storage_network.html diff --git a/controller/internal/web/handlers.go b/controller/internal/web/handlers.go index c7f79cc..e7e2819 100644 --- a/controller/internal/web/handlers.go +++ b/controller/internal/web/handlers.go @@ -987,8 +987,14 @@ func (s *Server) storagePageData() map[string]interface{} { storageViews = append(storageViews, view) } data["StoragePaths"] = storageViews - // NAS network storage (Part A2) — separate section with the agent's per-share health (ok/idle/ - // unreachable/unknown). Distinct from the physical-drive list above; no drive lifecycle actions. + return data +} + +// networkStoragePageData builds the Tárhely → Hálózati tárhely (NAS) subpage: the NAS shares +// with the agent's per-share health (ok/idle/unreachable/unknown). Split from the physical +// drive page — the two storage classes were confusingly interleaved on one page. +func (s *Server) networkStoragePageData() map[string]interface{} { + data := s.settingsBaseData("storage-network", "Hálózati tárhely") data["NetworkStoragePaths"] = s.networkStorageItems(context.Background()) return data } @@ -1061,6 +1067,11 @@ func (s *Server) storagePageHandler(w http.ResponseWriter, r *http.Request) { s.executeTemplate(w, r, "storage", data) } +// storageNetworkPageHandler serves the Tárhely → Hálózati tárhely (NAS) subpage. +func (s *Server) storageNetworkPageHandler(w http.ResponseWriter, r *http.Request) { + s.executeTemplate(w, r, "storage_network", s.networkStoragePageData()) +} + // settingsNotificationsPageHandler serves GET /settings/notifications (the POST on the same // path is the save handler — dispatch is split in the router). func (s *Server) settingsNotificationsPageHandler(w http.ResponseWriter, r *http.Request) { diff --git a/controller/internal/web/server.go b/controller/internal/web/server.go index 965aa30..07ccc8a 100644 --- a/controller/internal/web/server.go +++ b/controller/internal/web/server.go @@ -264,6 +264,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { s.settingsHandler(w, r) case path == "/storage" && r.Method == http.MethodGet: s.storagePageHandler(w, r) + case path == "/storage/network" && r.Method == http.MethodGet: + s.storageNetworkPageHandler(w, r) case path == "/settings/notifications" && r.Method == http.MethodGet: s.settingsNotificationsPageHandler(w, r) case path == "/settings/security" && r.Method == http.MethodGet: diff --git a/controller/internal/web/settings_split_test.go b/controller/internal/web/settings_split_test.go index d2d3bd0..422e678 100644 --- a/controller/internal/web/settings_split_test.go +++ b/controller/internal/web/settings_split_test.go @@ -70,8 +70,11 @@ func TestSettingsSplitPagesRender(t *testing.T) { []string{"Jelszó módosítás", "Földrajzi korlátozás"}, []string{"Rendszer konfiguráció", "Adattárolók", "Értesítési szünet"}}, {"/storage", - []string{"Adattárolók", "Hálózati tárhely (NAS)"}, - []string{"Rendszer konfiguráció", "Jelszó módosítás", "Értesítési szünet"}}, + []string{"Adattárolók", "Tárhely — Meghajtók"}, + []string{"Rendszer konfiguráció", "Jelszó módosítás", "Értesítési szünet", "NAS-megosztások"}}, + {"/storage/network", + []string{"Tárhely — Hálózati tárhely (NAS)", "NAS-megosztások"}, + []string{"Adattárolók", "Rendszer konfiguráció", "Jelszó módosítás"}}, } for _, c := range cases { rec := getPage(t, s, c.path) @@ -110,7 +113,7 @@ func TestSettingsSectionInventory(t *testing.T) { "Kiszolgáló újraindítása", } var union strings.Builder - for _, f := range []string{"settings_system.html", "settings_notifications.html", "settings_security.html", "storage.html"} { + for _, f := range []string{"settings_system.html", "settings_notifications.html", "settings_security.html", "storage.html", "storage_network.html"} { b, err := templateFS.ReadFile("templates/" + f) if err != nil { t.Fatalf("read %s: %v", f, err) @@ -220,7 +223,7 @@ func TestStorageNoNativeConfirm(t *testing.T) { nativeRe := regexp.MustCompile(`(^|[^A-Za-z_.])(confirm|prompt)\(`) // allow the pre-existing type-to-confirm overlay helper names allow := regexp.MustCompile(`openConfirm|__closeConfirm|confirmEject|confirmWipe|typeToConfirm|confirm-`) - for _, f := range []string{"storage.html", "settings_system.html", "settings_notifications.html", "settings_security.html"} { + for _, f := range []string{"storage.html", "storage_network.html", "settings_system.html", "settings_notifications.html", "settings_security.html"} { b, err := templateFS.ReadFile("templates/" + f) if err != nil { t.Fatalf("read %s: %v", f, err) diff --git a/controller/internal/web/templates/layout.html b/controller/internal/web/templates/layout.html index e10aaad..8352f7e 100644 --- a/controller/internal/web/templates/layout.html +++ b/controller/internal/web/templates/layout.html @@ -23,7 +23,12 @@