mirror of
https://github.com/lone-cloud/prism
synced 2026-06-04 04:04:44 -07:00
webpush improvements
This commit is contained in:
parent
66968834fb
commit
6027c1cac5
4 changed files with 46 additions and 10 deletions
|
|
@ -167,7 +167,9 @@ details[open] > .card-header::before {
|
||||||
border: 0.0625rem solid var(--border-color);
|
border: 0.0625rem solid var(--border-color);
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
white-space: nowrap;
|
white-space: normal;
|
||||||
|
word-break: break-all;
|
||||||
|
max-width: 20rem;
|
||||||
transition: opacity 0.2s;
|
transition: opacity 0.2s;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
|
@ -284,6 +286,10 @@ details[open] > .card-header::before {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badge-subscribed {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
.channel-signal.badge-active {
|
.channel-signal.badge-active {
|
||||||
background: var(--accent);
|
background: var(--accent);
|
||||||
color: var(--text-on-color);
|
color: var(--text-on-color);
|
||||||
|
|
@ -294,11 +300,21 @@ details[open] > .card-header::before {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channel-signal.badge-subscribed {
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--text-on-color);
|
||||||
|
}
|
||||||
|
|
||||||
.channel-webpush.badge-active {
|
.channel-webpush.badge-active {
|
||||||
background: var(--success);
|
background: var(--success);
|
||||||
color: var(--text-on-color);
|
color: var(--text-on-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channel-webpush.badge-subscribed {
|
||||||
|
background: var(--success);
|
||||||
|
color: var(--text-on-color);
|
||||||
|
}
|
||||||
|
|
||||||
.channel-telegram.badge-active {
|
.channel-telegram.badge-active {
|
||||||
background: var(--accent);
|
background: var(--accent);
|
||||||
color: var(--text-on-color);
|
color: var(--text-on-color);
|
||||||
|
|
@ -309,6 +325,11 @@ details[open] > .card-header::before {
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.channel-telegram.badge-subscribed {
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--text-on-color);
|
||||||
|
}
|
||||||
|
|
||||||
.app-actions {
|
.app-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"prism/service/notification"
|
||||||
"prism/service/util"
|
"prism/service/util"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"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")
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package server
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"prism/service/integration/signal"
|
"prism/service/integration/signal"
|
||||||
"prism/service/notification"
|
"prism/service/notification"
|
||||||
|
|
@ -128,14 +127,10 @@ func (s *Server) buildAppListData(apps []notification.App) []AppListItem {
|
||||||
webPushSubs := []SubscriptionItem{}
|
webPushSubs := []SubscriptionItem{}
|
||||||
for _, sub := range app.Subscriptions {
|
for _, sub := range app.Subscriptions {
|
||||||
if sub.Channel == notification.ChannelWebPush && sub.WebPush != nil {
|
if sub.Channel == notification.ChannelWebPush && sub.WebPush != nil {
|
||||||
item := SubscriptionItem{
|
webPushSubs = append(webPushSubs, SubscriptionItem{
|
||||||
ID: sub.ID,
|
ID: sub.ID,
|
||||||
Tooltip: sub.WebPush.Endpoint,
|
Tooltip: sub.WebPush.Endpoint,
|
||||||
}
|
})
|
||||||
if u, err := url.Parse(sub.WebPush.Endpoint); err == nil {
|
|
||||||
item.Hostname = u.Hostname()
|
|
||||||
}
|
|
||||||
webPushSubs = append(webPushSubs, item)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
{{range .Subscriptions}}
|
{{range .Subscriptions}}
|
||||||
<span class="channel-badge channel-{{$channel.Channel}} badge-subscribed">
|
<span class="channel-badge channel-{{$channel.Channel}} badge-subscribed">
|
||||||
{{$channel.Label}}{{if .Hostname}} ({{.Hostname}}){{end}}
|
{{$channel.Label}}
|
||||||
{{if .Tooltip}}<span class="tooltip">{{.Tooltip}}</span>{{end}}
|
{{if .Tooltip}}<span class="tooltip">{{.Tooltip}}</span>{{end}}
|
||||||
<button type="button" class="btn-delete-sub"
|
<button type="button" class="btn-delete-sub"
|
||||||
hx-delete="/apps/{{$app.AppName}}/subscriptions/{{.ID}}"
|
hx-delete="/apps/{{$app.AppName}}/subscriptions/{{.ID}}"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue