Compare commits

..

40 commits

Author SHA1 Message Date
31f7c51196 beore preline 2024-11-08 18:45:57 -05:00
db71d22e8b sidebar 2024-11-08 18:45:57 -05:00
ff37dd731f remove notifications 2024-11-08 18:45:57 -05:00
b1abe13ce1 wip 2024-11-08 18:45:57 -05:00
03a2722feb Fix login form 2024-11-08 18:45:57 -05:00
8fa4a0aa16 before coreui 2024-11-08 18:45:57 -05:00
de361cf23c kindof working 2024-11-08 18:45:57 -05:00
67905c92be wip 2024-11-08 18:45:57 -05:00
60641fbfee nice 2024-11-08 18:45:57 -05:00
40c5e3b238 wip 2024-11-08 18:45:57 -05:00
d051723d7b Prettier 2024-11-08 18:45:57 -05:00
4d402778b0 Login works 2024-11-08 18:45:57 -05:00
eb7ac86759 Initial admin UI 2024-11-08 18:45:57 -05:00
e4e819ee90 use square 2024-11-08 10:14:47 -05:00
2615da9ef8 add paren 2024-11-08 10:13:51 -05:00
2153dc8434 Use single template with named subs 2024-11-08 07:19:13 -05:00
6ea61bf820 Merge pull request '#28 per backend notification templates' (#29) from pernotifytmpl into trunk
Reviewed-on: #29
2024-11-07 23:18:53 -05:00
bdee792d75 #28 per backend notification templates 2024-11-07 23:17:16 -05:00
d0c398f6f7 Clean up tg ID stuff 2024-11-07 12:53:20 -05:00
c423749f26 Make clear that it is milliseconds 2024-11-06 20:55:48 -05:00
3b8a50d3e8 Merge pull request 'REST and other improvements' (#27) from rest into trunk
Reviewed-on: #27
2024-11-06 20:50:39 -05:00
3f133e152a UUID is part of Call and is generated by us.
Closes #8
2024-11-06 20:47:10 -05:00
c4df60a89a Change ws route 2024-11-06 20:17:13 -05:00
c1a258f63c Change login route, add form 2024-11-06 20:13:46 -05:00
65cddbcc0d Don't apply talkgroup weight twice
Also tag ID fields
2024-11-06 14:20:15 -05:00
fb2387c212 API begin 2024-11-04 23:42:09 -05:00
170970e92d wip 2024-11-04 11:49:03 -05:00
ea2cbfede5 Revert weight during score 2024-11-04 11:48:31 -05:00
fcd2cda803 Use mapstructure for notify config 2024-11-03 19:49:10 -05:00
4873da2851 Actually return multiplier 2024-11-03 19:22:38 -05:00
01d16d4cba Don't apply multiplier twice 2024-11-03 19:20:34 -05:00
c83e2f1df7 Merge pull request 'Scale scores during score operation.' (#25) from scorescale into trunk
Reviewed-on: #25
2024-11-03 19:13:27 -05:00
90d61aed73 Scale scores during score operation.
Closes #24.
2024-11-03 19:11:45 -05:00
db5067c055 Change error name 2024-11-03 14:16:26 -05:00
20dff10db8 Granular locking 2024-11-03 14:11:38 -05:00
5d348e7888 Merge pull request 'Big reorg' (#23) from rest into trunk
Reviewed-on: #23
2024-11-03 13:46:10 -05:00
d917e13c4f Embed 2024-11-03 09:45:51 -05:00
5338bb0071 Use sqlc.embed 2024-11-03 08:44:34 -05:00
882d9fbefa Reorg 2024-11-03 08:17:28 -05:00
c3233f1bc8 Split out talkgroups 2024-11-03 07:58:41 -05:00
2 changed files with 29 additions and 7 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,15 +50,31 @@ var alertFm = template.FuncMap{
"highest": highest, "highest": highest,
} }
const defaultBodyTemplStr = `{{ range . -}} const (
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 defaultBodyTemplate = template.Must(template.New("body").Funcs(common.FuncMap).Funcs(alertFm).Parse(defaultBodyTemplStr)) var (
defaultTemplate *template.Template
)
var defaultSubjectTemplStr = `Stillbox Alert ({{ highest . }}` func init() {
var defaultSubjectTemplate = template.Must(template.New("subject").Funcs(common.FuncMap).Funcs(alertFm).Parse(defaultSubjectTemplStr)) defaultTemplate = template.New("notification")
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) {
@ -125,7 +141,10 @@ func (n *notifier) addService(cfg config.NotifyService) (err error) {
switch cfg.SubjectTemplate { switch cfg.SubjectTemplate {
case nil: case nil:
be.subject = defaultSubjectTemplate be.subject = defaultTemplate.Lookup("subject")
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 {
@ -135,7 +154,10 @@ func (n *notifier) addService(cfg config.NotifyService) (err error) {
switch cfg.BodyTemplate { switch cfg.BodyTemplate {
case nil: case nil:
be.body = defaultBodyTemplate be.body = defaultTemplate.Lookup("body")
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 {