diff --git a/public/index.css b/public/index.css index 2daf747..fec1cc3 100644 --- a/public/index.css +++ b/public/index.css @@ -167,7 +167,9 @@ details[open] > .card-header::before { border: 0.0625rem solid var(--border-color); font-size: 0.875rem; font-weight: 400; - white-space: nowrap; + white-space: normal; + word-break: break-all; + max-width: 20rem; transition: opacity 0.2s; pointer-events: none; z-index: 10; @@ -284,6 +286,10 @@ details[open] > .card-header::before { pointer-events: none; } +.badge-subscribed { + cursor: default; +} + .channel-signal.badge-active { background: var(--accent); color: var(--text-on-color); @@ -294,11 +300,21 @@ details[open] > .card-header::before { background: transparent; } +.channel-signal.badge-subscribed { + background: var(--accent); + color: var(--text-on-color); +} + .channel-webpush.badge-active { background: var(--success); color: var(--text-on-color); } +.channel-webpush.badge-subscribed { + background: var(--success); + color: var(--text-on-color); +} + .channel-telegram.badge-active { background: var(--accent); color: var(--text-on-color); @@ -309,6 +325,11 @@ details[open] > .card-header::before { background: transparent; } +.channel-telegram.badge-subscribed { + background: var(--accent); + color: var(--text-on-color); +} + .app-actions { display: flex; gap: 0.5rem; diff --git a/service/server/handlers_apps.go b/service/server/handlers_apps.go index fe1b1c6..d2bea1e 100644 --- a/service/server/handlers_apps.go +++ b/service/server/handlers_apps.go @@ -4,6 +4,7 @@ import ( "encoding/json" "net/http" + "prism/service/notification" "prism/service/util" "github.com/go-chi/chi/v5" @@ -33,5 +34,24 @@ func (s *Server) handleGetApps(w http.ResponseWriter, r *http.Request) { } w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(apps) + json.NewEncoder(w).Encode(sanitizeApps(apps)) +} + +func sanitizeApps(apps []notification.App) []notification.App { + sanitized := make([]notification.App, len(apps)) + for i, app := range apps { + sanitized[i] = notification.App{ + AppName: app.AppName, + Subscriptions: make([]notification.Subscription, len(app.Subscriptions)), + } + for j, sub := range app.Subscriptions { + sanitized[i].Subscriptions[j] = sub + if sub.WebPush != nil { + sanitized[i].Subscriptions[j].WebPush = ¬ification.WebPushSubscription{ + Endpoint: sub.WebPush.Endpoint, + } + } + } + } + return sanitized } diff --git a/service/server/handlers_fragment.go b/service/server/handlers_fragment.go index 32ada42..b0d579c 100644 --- a/service/server/handlers_fragment.go +++ b/service/server/handlers_fragment.go @@ -3,7 +3,6 @@ package server import ( "bytes" "net/http" - "net/url" "prism/service/integration/signal" "prism/service/notification" @@ -128,14 +127,10 @@ func (s *Server) buildAppListData(apps []notification.App) []AppListItem { webPushSubs := []SubscriptionItem{} for _, sub := range app.Subscriptions { if sub.Channel == notification.ChannelWebPush && sub.WebPush != nil { - item := SubscriptionItem{ + webPushSubs = append(webPushSubs, SubscriptionItem{ ID: sub.ID, Tooltip: sub.WebPush.Endpoint, - } - if u, err := url.Parse(sub.WebPush.Endpoint); err == nil { - item.Hostname = u.Hostname() - } - webPushSubs = append(webPushSubs, item) + }) } } diff --git a/service/server/templates/app-list.html b/service/server/templates/app-list.html index 0ec272b..34015b7 100644 --- a/service/server/templates/app-list.html +++ b/service/server/templates/app-list.html @@ -31,7 +31,7 @@ {{else}} {{range .Subscriptions}} - {{$channel.Label}}{{if .Hostname}} ({{.Hostname}}){{end}} + {{$channel.Label}} {{if .Tooltip}}{{.Tooltip}}{{end}}