diff --git a/client/stillbox/src/app/calls/calls.component.html b/client/stillbox/src/app/calls/calls.component.html index 3cbc7a4..7c2891d 100644 --- a/client/stillbox/src/app/calls/calls.component.html +++ b/client/stillbox/src/app/calls/calls.component.html @@ -169,7 +169,11 @@ - +
diff --git a/client/stillbox/src/app/calls/calls.component.ts b/client/stillbox/src/app/calls/calls.component.ts index 5ff0ae1..c82e9f4 100644 --- a/client/stillbox/src/app/calls/calls.component.ts +++ b/client/stillbox/src/app/calls/calls.component.ts @@ -394,7 +394,7 @@ export class CallsComponent { add: this.selection.selected.map((s, i, a) => { s.incidents++; return s.id; - }), + }), }) .subscribe({ next: () => { diff --git a/client/stillbox/src/app/incidents/incident/incident.component.html b/client/stillbox/src/app/incidents/incident/incident.component.html index b60261d..e9b8612 100644 --- a/client/stillbox/src/app/incidents/incident/incident.component.html +++ b/client/stillbox/src/app/incidents/incident/incident.component.html @@ -1,7 +1,12 @@ @let inc = inc$ | async;
-

{{ inc?.name }}

+

+ {{ inc?.name }} + playlist_play +

diff --git a/client/stillbox/src/app/talkgroup.ts b/client/stillbox/src/app/talkgroup.ts index 2aba962..7c8b2f7 100644 --- a/client/stillbox/src/app/talkgroup.ts +++ b/client/stillbox/src/app/talkgroup.ts @@ -15,12 +15,19 @@ export class AlertTime { } export class AlertRule { - times: AlertTime[]; - mult: number; + times!: string[]; + mult!: number; - constructor(times: AlertTime[], mult: number) { - this.times = times; - this.mult = mult; + public getTimes(): AlertTime[] { + let timesProc = []; + this.times.forEach((tm) => { + let sr = tm.split('+'); + timesProc.push({ + time: sr[0], + duration: sr[1], + }); + }); + return timesProc; } } @@ -84,6 +91,10 @@ export class Talkgroup { icon?: string, ) { this.iconSvg = this.iconMap(this.metadata?.icon!); + this.alert_rules = this.alert_rules.map((x) => + Object.assign(new AlertRule(), x), + ); + console.log(this.alert_rules); } iconMap(icon: string): string { diff --git a/client/stillbox/src/app/talkgroups/talkgroup-record/alert-rule-builder/alert-rule-builder.component.html b/client/stillbox/src/app/talkgroups/talkgroup-record/alert-rule-builder/alert-rule-builder.component.html index 845b56a..41284f9 100644 --- a/client/stillbox/src/app/talkgroups/talkgroup-record/alert-rule-builder/alert-rule-builder.component.html +++ b/client/stillbox/src/app/talkgroups/talkgroup-record/alert-rule-builder/alert-rule-builder.component.html @@ -1,30 +1,21 @@
@for (rule of rules; track $index) { -
- - - - - - - - - - @for (time of rule.times; track $index) { - - - - - } @empty { - - - - } - +
+
StartDuration
- {{ time.time }} - - {{ time.duration }} -
No times
+ + + + + + + + + + + + + +
Time{{ time.time }}Duration{{ time.duration }}Multiplier{{ rule.mult }}
} @empty { diff --git a/client/stillbox/src/app/talkgroups/talkgroup-record/alert-rule-builder/alert-rule-builder.component.ts b/client/stillbox/src/app/talkgroups/talkgroup-record/alert-rule-builder/alert-rule-builder.component.ts index 5f9a30a..56b6a1d 100644 --- a/client/stillbox/src/app/talkgroups/talkgroup-record/alert-rule-builder/alert-rule-builder.component.ts +++ b/client/stillbox/src/app/talkgroups/talkgroup-record/alert-rule-builder/alert-rule-builder.component.ts @@ -1,18 +1,43 @@ -import { Component, Input, Output, EventEmitter } from '@angular/core'; -import { AlertRule } from '../../../talkgroup'; +import { + Component, + Input, + Output, + EventEmitter, + Pipe, + PipeTransform, +} from '@angular/core'; +import { AlertRule, AlertTime } from '../../../talkgroup'; +import { MatTableModule } from '@angular/material/table'; + +@Pipe({ + name: 'ruleTimes', + standalone: true, + pure: true, +}) +export class AlertRulePipe implements PipeTransform { + transform(rule: AlertRule, args?: any): AlertTime[] { + return rule.getTimes(); + } +} @Component({ selector: 'alert-rule-builder', - imports: [], + imports: [MatTableModule, AlertRulePipe], templateUrl: './alert-rule-builder.component.html', styleUrl: './alert-rule-builder.component.scss', }) export class AlertRuleBuilderComponent { - @Input() rules: AlertRule[] = []; + @Input() rules!: AlertRule[]; @Output() rulesChange: EventEmitter = new EventEmitter< AlertRule[] >(); + displayedColumns = ['time', 'duration', 'multiplier']; + + ngOnInit() { + this.rules = this.rules; + } + emit() { this.rulesChange.emit(this.rules); } diff --git a/client/stillbox/src/app/talkgroups/talkgroup-record/talkgroup-record.component.ts b/client/stillbox/src/app/talkgroups/talkgroup-record/talkgroup-record.component.ts index 60e0504..ae0937c 100644 --- a/client/stillbox/src/app/talkgroups/talkgroup-record/talkgroup-record.component.ts +++ b/client/stillbox/src/app/talkgroups/talkgroup-record/talkgroup-record.component.ts @@ -7,6 +7,7 @@ import { IconMap, iconMapping, TGID, + AlertRule, } from '../../talkgroup'; import { COMMA, ENTER } from '@angular/cdk/keycodes'; import { TalkgroupService } from '../talkgroups.service'; @@ -157,6 +158,10 @@ export class TalkgroupRecordComponent { .getTalkgroup(Number(this.tgid.sys), Number(this.tgid.tg)) .pipe( tap((tg) => { + console.log('tap run'); + tg.alert_rules = tg.alert_rules + ? tg.alert_rules.map((x) => Object.assign(new AlertRule(), x)) + : []; this.form.patchValue(tg); this.form.controls['tagInput'].setValue(''); this.form.controls['tagsControl'].setValue(this.tg?.tags ?? []); diff --git a/client/stillbox/src/app/talkgroups/talkgroups.service.ts b/client/stillbox/src/app/talkgroups/talkgroups.service.ts index c309d01..0896b64 100644 --- a/client/stillbox/src/app/talkgroups/talkgroups.service.ts +++ b/client/stillbox/src/app/talkgroups/talkgroups.service.ts @@ -33,7 +33,10 @@ export class TalkgroupService { private subscriptions = new Subscription(); constructor(private http: HttpClient) { this.tgs$ = this.fetchAll.pipe(switchMap(() => this.getTalkgroups())); - this.tags$ = this.fetchAll.pipe(switchMap(() => this.getAllTags())); + this.tags$ = this.fetchAll.pipe( + switchMap(() => this.getAllTags()), + shareReplay(), + ); this.fillTgMap(); } @@ -52,11 +55,8 @@ export class TalkgroupService { getTalkgroup(sys: number, tg: number): Observable { const key = this.tgKey(sys, tg); if (!this._getTalkgroup.get(key)) { - return this.tgs$.pipe( - switchMap((talkg) => - talkg.filter((tgv) => tgv.tgid == tg && tgv.system_id == sys), - ), - ); + let rs = new ReplaySubject(); + this._getTalkgroup.set(key, rs); } return this._getTalkgroup.get(key)!; } diff --git a/pkg/auth/jwt.go b/pkg/auth/jwt.go index 4dc8bf6..99c2ba7 100644 --- a/pkg/auth/jwt.go +++ b/pkg/auth/jwt.go @@ -245,6 +245,7 @@ func (a *Auth) routeAuth(w http.ResponseWriter, r *http.Request) { Path: "/", HttpOnly: true, Secure: true, + MaxAge: 60 * 60 * 24 * 30, // one month } cookie.Domain = r.Host diff --git a/pkg/database/incidents.sql.go b/pkg/database/incidents.sql.go index 28a46a2..d422db0 100644 --- a/pkg/database/incidents.sql.go +++ b/pkg/database/incidents.sql.go @@ -180,6 +180,7 @@ FROM incidents_calls ic, LATERAL ( FROM swept_calls sc WHERE sc.id = ic.swept_call_id ) c WHERE ic.incident_id = $1 +ORDER BY ic.call_date ASC ` type GetIncidentCallsRow struct { diff --git a/pkg/rest/incidents.go b/pkg/rest/incidents.go index e69f5f2..7488aeb 100644 --- a/pkg/rest/incidents.go +++ b/pkg/rest/incidents.go @@ -202,7 +202,7 @@ func (ia *incidentsAPI) getCallsM3U(w http.ResponseWriter, r *http.Request) { return } - var b bytes.Buffer + b := new(bytes.Buffer) callUrl := common.PtrTo(*ia.baseURL) @@ -220,7 +220,7 @@ func (ia *incidentsAPI) getCallsM3U(w http.ResponseWriter, r *http.Request) { callUrl.Path = "/api/call/" + c.ID.String() - fmt.Fprintf(w, "#EXTINF:%d,%s%s (%s)\n%s\n\n", + fmt.Fprintf(b, "#EXTINF:%d,%s%s (%s)\n%s\n\n", c.Duration.Seconds(), tg.StringTag(true), from, diff --git a/sql/postgres/queries/incidents.sql b/sql/postgres/queries/incidents.sql index f504919..214a123 100644 --- a/sql/postgres/queries/incidents.sql +++ b/sql/postgres/queries/incidents.sql @@ -141,7 +141,8 @@ FROM incidents_calls ic, LATERAL ( sc.transcript FROM swept_calls sc WHERE sc.id = ic.swept_call_id ) c -WHERE ic.incident_id = @id; +WHERE ic.incident_id = @id +ORDER BY ic.call_date ASC; -- name: GetIncident :one SELECT