Compare commits

..

33 commits

Author SHA1 Message Date
29054e8242 beore preline 2024-11-08 18:41:35 -05:00
50109bc283 sidebar 2024-11-08 18:41:35 -05:00
4bd8f3351a remove notifications 2024-11-08 18:41:35 -05:00
951e0459b8 wip 2024-11-08 18:41:35 -05:00
2ec7924e86 Fix login form 2024-11-08 18:41:35 -05:00
558a57e797 before coreui 2024-11-08 18:41:35 -05:00
6e0aade9d2 kindof working 2024-11-08 18:41:35 -05:00
c891a94c7b #28 per backend notification templates 2024-11-08 18:41:35 -05:00
21eabbc17a Clean up tg ID stuff 2024-11-08 18:41:35 -05:00
ab3219c434 Make clear that it is milliseconds 2024-11-08 18:41:35 -05:00
5ea44aebb9 UUID is part of Call and is generated by us.
Closes #8
2024-11-08 18:41:35 -05:00
f3364a93ec Change ws route 2024-11-08 18:41:35 -05:00
81135c29f0 Change login route, add form 2024-11-08 18:41:35 -05:00
6556c8049c Don't apply talkgroup weight twice
Also tag ID fields
2024-11-08 18:41:35 -05:00
08f1bd4ff0 API begin 2024-11-08 18:41:35 -05:00
58c1376146 wip 2024-11-08 18:41:35 -05:00
465e86a6bb Revert weight during score 2024-11-08 18:41:35 -05:00
10e4eff17a Use mapstructure for notify config 2024-11-08 18:41:35 -05:00
b40144447f Actually return multiplier 2024-11-08 18:41:35 -05:00
092b925a25 Don't apply multiplier twice 2024-11-08 18:41:35 -05:00
28ee194297 Scale scores during score operation.
Closes #24.
2024-11-08 18:41:35 -05:00
5bce1f4f9d Change error name 2024-11-08 18:41:35 -05:00
77cdacc917 Granular locking 2024-11-08 18:41:35 -05:00
7242782d39 Embed 2024-11-08 18:41:35 -05:00
8afc687d4f Use sqlc.embed 2024-11-08 18:41:35 -05:00
1f8fe24dd2 Reorg 2024-11-08 18:41:35 -05:00
8d32757334 Split out talkgroups 2024-11-08 18:41:35 -05:00
eebc3fdae2 wip 2024-11-03 07:21:14 -05:00
50663a561a nice 2024-11-03 07:21:14 -05:00
6b5e5dbdf1 wip 2024-11-03 07:21:14 -05:00
38300f247a Prettier 2024-11-03 07:21:14 -05:00
e198adb60b Login works 2024-11-03 07:21:14 -05:00
9fc4823159 Initial admin UI 2024-11-03 07:21:14 -05:00
2 changed files with 7 additions and 29 deletions

View file

@ -64,7 +64,7 @@ func Make(ctx context.Context, store talkgroups.Store, score trending.Score[talk
} }
if tgRecord.Talkgroup.Name != nil { if tgRecord.Talkgroup.Name != nil {
d.TGName = fmt.Sprintf("%s %s [%d]", tgRecord.System.Name, *tgRecord.Talkgroup.Name, score.ID.Talkgroup) d.TGName = fmt.Sprintf("%s %s (%d)", tgRecord.System.Name, *tgRecord.Talkgroup.Name, score.ID.Talkgroup)
} else { } else {
d.TGName = fmt.Sprintf("%s:%d", tgRecord.System.Name, int(score.ID.Talkgroup)) d.TGName = fmt.Sprintf("%s:%d", tgRecord.System.Name, int(score.ID.Talkgroup))
} }

View file

@ -50,31 +50,15 @@ var alertFm = template.FuncMap{
"highest": highest, "highest": highest,
} }
const ( const defaultBodyTemplStr = `{{ range . -}}
defaultBodyTemplStr = `{{ range . -}}
{{ .TGName }} is active with a score of {{ f .Score.Score 4 }}! ({{ f .Score.RecentCount 0 }}/{{ .Score.Count }} recent calls) {{ .TGName }} is active with a score of {{ f .Score.Score 4 }}! ({{ f .Score.RecentCount 0 }}/{{ .Score.Count }} recent calls)
{{ end -}}` {{ end -}}`
defaultSubjectTemplStr = `Stillbox Alert ({{ highest . }})`
)
var ( var defaultBodyTemplate = template.Must(template.New("body").Funcs(common.FuncMap).Funcs(alertFm).Parse(defaultBodyTemplStr))
defaultTemplate *template.Template
)
func init() { var defaultSubjectTemplStr = `Stillbox Alert ({{ highest . }}`
defaultTemplate = template.New("notification") var defaultSubjectTemplate = template.Must(template.New("subject").Funcs(common.FuncMap).Funcs(alertFm).Parse(defaultSubjectTemplStr))
defaultTemplate.Funcs(common.FuncMap).Funcs(alertFm)
_, err := defaultTemplate.New("body").Parse(defaultBodyTemplStr)
if err != nil {
panic(err)
}
_, err = defaultTemplate.New("subject").Parse(defaultSubjectTemplStr)
if err != nil {
panic(err)
}
}
// Send renders and sends the Alerts. // Send renders and sends the Alerts.
func (b *backend) Send(ctx context.Context, alerts []alert.Alert) (err error) { func (b *backend) Send(ctx context.Context, alerts []alert.Alert) (err error) {
@ -141,10 +125,7 @@ func (n *notifier) addService(cfg config.NotifyService) (err error) {
switch cfg.SubjectTemplate { switch cfg.SubjectTemplate {
case nil: case nil:
be.subject = defaultTemplate.Lookup("subject") be.subject = defaultSubjectTemplate
if be.subject == nil {
panic("subject template nil")
}
default: default:
be.subject, err = template.New("subject").Funcs(common.FuncMap).Funcs(alertFm).Parse(*cfg.SubjectTemplate) be.subject, err = template.New("subject").Funcs(common.FuncMap).Funcs(alertFm).Parse(*cfg.SubjectTemplate)
if err != nil { if err != nil {
@ -154,10 +135,7 @@ func (n *notifier) addService(cfg config.NotifyService) (err error) {
switch cfg.BodyTemplate { switch cfg.BodyTemplate {
case nil: case nil:
be.body = defaultTemplate.Lookup("body") be.body = defaultBodyTemplate
if be.body == nil {
panic("body template nil")
}
default: default:
be.body, err = template.New("body").Funcs(common.FuncMap).Funcs(alertFm).Parse(*cfg.BodyTemplate) be.body, err = template.New("body").Funcs(common.FuncMap).Funcs(alertFm).Parse(*cfg.BodyTemplate)
if err != nil { if err != nil {