From bfb5b14ea07bbd313229516b0126997b874c7d8d Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 24 May 2026 10:35:29 +0200 Subject: [PATCH] webui: render NTP empty state gracefully when not configured MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NTP page showed a red "Failed to fetch NTP data" banner whenever /data/ietf-ntp:ntp returned 404 — which is the normal RESTCONF response when NTP isn't configured at all. Treat 404 as the not-configured case and render the empty-state card with a Configure → link, mirroring the DHCP status page. Signed-off-by: Joachim Wiberg --- src/webui/internal/handlers/ntp.go | 8 ++++++-- src/webui/templates/pages/ntp.html | 13 ++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/webui/internal/handlers/ntp.go b/src/webui/internal/handlers/ntp.go index 0b456ffa..2f230c83 100644 --- a/src/webui/internal/handlers/ntp.go +++ b/src/webui/internal/handlers/ntp.go @@ -86,8 +86,12 @@ func (h *NTPHandler) Overview(w http.ResponseWriter, r *http.Request) { } `json:"ietf-ntp:ntp"` } if err := h.RC.Get(ctx, "/data/ietf-ntp:ntp", &raw); err != nil { - log.Printf("restconf ntp: %v", err) - data.Error = "Failed to fetch NTP data" + // 404 = NTP container absent (not configured). Render the empty-state + // section instead of a red error banner. + if !restconf.IsNotFound(err) { + log.Printf("restconf ntp: %v", err) + data.Error = "Failed to fetch NTP data" + } } else { ss := raw.NTP.ClockState.SystemStatus synced := strings.Contains(ss.ClockState, "synchronized") && diff --git a/src/webui/templates/pages/ntp.html b/src/webui/templates/pages/ntp.html index ccb7034a..17934c79 100644 --- a/src/webui/templates/pages/ntp.html +++ b/src/webui/templates/pages/ntp.html @@ -32,8 +32,8 @@ {{end}} - {{if .NTP.Associations}}

Associations

+ {{if .NTP.Associations}}
@@ -63,12 +63,19 @@
{{else}} -

No associations.

+

No upstream associations to display.

{{end}} {{else if not .Error}}
-

NTP data not available.

+
NTP + Configure → +
+

NTP is not configured.

{{end}} {{end}}