From b41b5418d11f9835311da6a8b39614d9bb876a82 Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Fri, 7 Feb 2025 08:22:51 -0500 Subject: [PATCH] only when logged in --- .../stillbox/src/app/calls/calls.component.ts | 5 ---- .../stillbox/src/app/calls/calls.service.ts | 1 - .../incident/incident.component.html | 26 +++++++++++-------- .../stillbox/src/app/share/share.service.ts | 10 ++++--- .../src/app/shares/shares.component.spec.ts | 5 ++-- .../src/app/shares/shares.component.ts | 6 ++--- .../talkgroup-record.component.ts | 1 - .../src/app/talkgroups/talkgroups.service.ts | 22 +++++++++++----- 8 files changed, 41 insertions(+), 35 deletions(-) diff --git a/client/stillbox/src/app/calls/calls.component.ts b/client/stillbox/src/app/calls/calls.component.ts index dceda59..76b50df 100644 --- a/client/stillbox/src/app/calls/calls.component.ts +++ b/client/stillbox/src/app/calls/calls.component.ts @@ -180,7 +180,6 @@ export class CallsComponent { } setPage(p: PageEvent, force?: boolean) { - console.log("setpage") this.selection.clear(); this.curPage = p; if (p && p!.pageSize != this.perPage) { @@ -196,19 +195,16 @@ export class CallsComponent { } getCalls(p: PageEvent, force?: boolean) { - console.log("getcalls") const pageStart = p.pageIndex * p.pageSize; const serverPage = Math.floor(pageStart / reqPageSize) + 1; this.pageWindow = pageStart % reqPageSize; if (serverPage == this.currentServerPage && !force && this.currentSet) { - console.log("currentset"); this.callsResult.next( this.callsResult ? this.currentSet.slice(this.pageWindow, this.pageWindow + p.pageSize) : [], ); } else { - console.log("not currentset"); this.currentServerPage = serverPage; this.fetchCalls.next(this.buildParams(p, serverPage)); } @@ -248,7 +244,6 @@ export class CallsComponent { .pipe( debounceTime(500), switchMap((params) => { - console.log("gc switchmap"); return this.callsSvc.getCalls(params); }), ) diff --git a/client/stillbox/src/app/calls/calls.service.ts b/client/stillbox/src/app/calls/calls.service.ts index 1d6c8ee..1b433e8 100644 --- a/client/stillbox/src/app/calls/calls.service.ts +++ b/client/stillbox/src/app/calls/calls.service.ts @@ -131,7 +131,6 @@ export class SafePipe implements PipeTransform { return this._sanitizer.bypassSecurityTrustUrl(value); case 'resourceUrl': let res = this._sanitizer.bypassSecurityTrustResourceUrl(value); - console.log(res); return res; default: return this._sanitizer.bypassSecurityTrustHtml(value); diff --git a/client/stillbox/src/app/incidents/incident/incident.component.html b/client/stillbox/src/app/incidents/incident/incident.component.html index cd132ea..68e8c6e 100644 --- a/client/stillbox/src/app/incidents/incident/incident.component.html +++ b/client/stillbox/src/app/incidents/incident/incident.component.html @@ -7,18 +7,22 @@ >playlist_play - @if (share == null) { - - - - - + + + + }
diff --git a/client/stillbox/src/app/share/share.service.ts b/client/stillbox/src/app/share/share.service.ts index 1bebd1f..75d8a1f 100644 --- a/client/stillbox/src/app/share/share.service.ts +++ b/client/stillbox/src/app/share/share.service.ts @@ -10,10 +10,14 @@ import { ActivatedRoute, Router } from '@angular/router'; providedIn: 'root', }) export class ShareService { - constructor(private http: HttpClient, private router: Router, private route: ActivatedRoute) {} + constructor( + private http: HttpClient, + private router: Router, + private route: ActivatedRoute, + ) {} - inShare(): string|null { - if(this.router.url.startsWith('/s/')) { + inShare(): string | null { + if (this.router.url.startsWith('/s/')) { return this.route.snapshot.paramMap.get('id'); } diff --git a/client/stillbox/src/app/shares/shares.component.spec.ts b/client/stillbox/src/app/shares/shares.component.spec.ts index a995779..107f8aa 100644 --- a/client/stillbox/src/app/shares/shares.component.spec.ts +++ b/client/stillbox/src/app/shares/shares.component.spec.ts @@ -8,9 +8,8 @@ describe('SharesComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [SharesComponent] - }) - .compileComponents(); + imports: [SharesComponent], + }).compileComponents(); fixture = TestBed.createComponent(SharesComponent); component = fixture.componentInstance; diff --git a/client/stillbox/src/app/shares/shares.component.ts b/client/stillbox/src/app/shares/shares.component.ts index dcd17d0..8bbcdea 100644 --- a/client/stillbox/src/app/shares/shares.component.ts +++ b/client/stillbox/src/app/shares/shares.component.ts @@ -4,8 +4,6 @@ import { Component } from '@angular/core'; selector: 'app-shares', imports: [], templateUrl: './shares.component.html', - styleUrl: './shares.component.scss' + styleUrl: './shares.component.scss', }) -export class SharesComponent { - -} +export class SharesComponent {} 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 ae0937c..75efd33 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 @@ -158,7 +158,6 @@ 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)) : []; diff --git a/client/stillbox/src/app/talkgroups/talkgroups.service.ts b/client/stillbox/src/app/talkgroups/talkgroups.service.ts index 812edae..7fc6026 100644 --- a/client/stillbox/src/app/talkgroups/talkgroups.service.ts +++ b/client/stillbox/src/app/talkgroups/talkgroups.service.ts @@ -12,6 +12,7 @@ import { import { Talkgroup, TalkgroupUpdate, TGID } from '../talkgroup'; import { Share } from '../shares'; import { ShareService } from '../share/share.service'; +import { AuthService } from '../login/auth.service'; export interface Pagination { page: number; @@ -31,9 +32,13 @@ export class TalkgroupService { private readonly _getTalkgroup = new Map>(); private tgs$: Observable; private tags$!: Observable; - private fetchAll = new Subject(); + private fetchAll = new ReplaySubject(); private subscriptions = new Subscription(); - constructor(private http: HttpClient, private shareSvc: ShareService) { + constructor( + private http: HttpClient, + private shareSvc: ShareService, + private authSvc: AuthService, + ) { this.tgs$ = this.fetchAll.pipe( switchMap((share) => this.getTalkgroups(share)), shareReplay(), @@ -43,16 +48,17 @@ export class TalkgroupService { shareReplay(), ); let sh = this.shareSvc.inShare(); - console.log(sh); if (sh) { this.shareSvc.getShare(sh).subscribe(this.fetchAll); } else { - this.fetchAll.next(null); + if (this.authSvc.loggedIn) { + this.fetchAll.next(null); + } } this.fillTgMap(); } - setShare(share: Share|null) { + setShare(share: Share | null) { this.fetchAll.next(share); } @@ -64,8 +70,10 @@ export class TalkgroupService { return this.http.get('/api/talkgroup/tags'); } - getTalkgroups(share: Share|null): Observable { - return this.http.get(share ? `/share/${share.id}/talkgroups` : '/api/talkgroup/'); + getTalkgroups(share: Share | null): Observable { + return this.http.get( + share ? `/share/${share.id}/talkgroups` : '/api/talkgroup/', + ); } getTalkgroup(