diff --git a/client/stillbox/src/app/app.routes.ts b/client/stillbox/src/app/app.routes.ts index a904bb2..c5ba17d 100644 --- a/client/stillbox/src/app/app.routes.ts +++ b/client/stillbox/src/app/app.routes.ts @@ -76,6 +76,12 @@ export const routes: Routes = [ import('./alerts/alerts.component').then((m) => m.AlertsComponent), data: { title: 'Alerts' }, }, + { + path: 'shares', + loadComponent: () => + import('./shares/shares.component').then((m) => m.SharesComponent), + data: { title: 'Shares' }, + }, ], }, ]; diff --git a/client/stillbox/src/app/calls/calls.component.ts b/client/stillbox/src/app/calls/calls.component.ts index 573dab8..9e03243 100644 --- a/client/stillbox/src/app/calls/calls.component.ts +++ b/client/stillbox/src/app/calls/calls.component.ts @@ -11,7 +11,7 @@ import { PrefsService } from '../prefs/prefs.service'; import { MatIconModule } from '@angular/material/icon'; import { SelectionModel } from '@angular/cdk/collections'; import { MatCheckboxModule } from '@angular/material/checkbox'; -import { BehaviorSubject, Subscription } from 'rxjs'; +import { BehaviorSubject, Subject, Subscription } from 'rxjs'; import { switchMap } from 'rxjs/operators'; import { CallsListParams, @@ -115,9 +115,7 @@ export class CallsComponent { subscriptions = new Subscription(); pageWindow = 0; - fetchCalls = new BehaviorSubject( - this.buildParams(this.curPage, this.curPage.pageIndex), - ); + fetchCalls = new Subject(); constructor( private callsSvc: CallsService, @@ -180,6 +178,7 @@ export class CallsComponent { } setPage(p: PageEvent, force?: boolean) { + console.log("setpage") this.selection.clear(); this.curPage = p; if (p && p!.pageSize != this.perPage) { @@ -195,16 +194,19 @@ 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)); } @@ -243,6 +245,7 @@ export class CallsComponent { this.fetchCalls .pipe( switchMap((params) => { + console.log("gc switchmap"); return this.callsSvc.getCalls(params); }), ) diff --git a/client/stillbox/src/app/navigation/navigation.component.ts b/client/stillbox/src/app/navigation/navigation.component.ts index 9c58f8a..8923bf9 100644 --- a/client/stillbox/src/app/navigation/navigation.component.ts +++ b/client/stillbox/src/app/navigation/navigation.component.ts @@ -101,6 +101,11 @@ export class NavigationComponent { url: '/alerts', icon: 'notifications', }, + { + name: 'Shares', + url: '/shares', + icon: 'share', + }, ]; toggleFilterPanel() { diff --git a/client/stillbox/src/app/shares/shares.component.html b/client/stillbox/src/app/shares/shares.component.html new file mode 100644 index 0000000..9f6f00b --- /dev/null +++ b/client/stillbox/src/app/shares/shares.component.html @@ -0,0 +1 @@ +

shares works!

diff --git a/client/stillbox/src/app/shares/shares.component.scss b/client/stillbox/src/app/shares/shares.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/client/stillbox/src/app/shares/shares.component.spec.ts b/client/stillbox/src/app/shares/shares.component.spec.ts new file mode 100644 index 0000000..a995779 --- /dev/null +++ b/client/stillbox/src/app/shares/shares.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SharesComponent } from './shares.component'; + +describe('SharesComponent', () => { + let component: SharesComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SharesComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SharesComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/stillbox/src/app/shares/shares.component.ts b/client/stillbox/src/app/shares/shares.component.ts new file mode 100644 index 0000000..dcd17d0 --- /dev/null +++ b/client/stillbox/src/app/shares/shares.component.ts @@ -0,0 +1,11 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-shares', + imports: [], + templateUrl: './shares.component.html', + styleUrl: './shares.component.scss' +}) +export class SharesComponent { + +} diff --git a/client/stillbox/src/app/talkgroups/talkgroups.service.ts b/client/stillbox/src/app/talkgroups/talkgroups.service.ts index bca0b81..9eb25f8 100644 --- a/client/stillbox/src/app/talkgroups/talkgroups.service.ts +++ b/client/stillbox/src/app/talkgroups/talkgroups.service.ts @@ -27,20 +27,15 @@ export interface TalkgroupsPaginated { }) export class TalkgroupService { private readonly _getTalkgroup = new Map>(); - private tgs$: Observable; + private tgs$!: Observable; private tags$!: Observable; private fetchAll = new BehaviorSubject<'fetch'>('fetch'); private subscriptions = new Subscription(); constructor(private http: HttpClient) { - this.tgs$ = this.fetchAll.pipe( - switchMap(() => this.getTalkgroups()), - shareReplay(), - ); this.tags$ = this.fetchAll.pipe( switchMap(() => this.getAllTags()), shareReplay(), ); - this.fillTgMap(); } ngOnDestroy() { @@ -51,7 +46,7 @@ export class TalkgroupService { return this.http.get('/api/talkgroup/tags'); } - getTalkgroups(): Observable { + getTalkgroups(share: Share | null): Observable { return this.http.get('/api/talkgroup/'); } @@ -60,6 +55,9 @@ export class TalkgroupService { tg: number, share: Share | null = null, ): Observable { + if (this._getTalkgroup.size < 1) { + this.fillTgMap(share); + } const key = this.tgKey(sys, tg); if (!this._getTalkgroup.get(key)) { let rs = new ReplaySubject(); @@ -103,7 +101,11 @@ export class TalkgroupService { return this.http.post('/api/talkgroup/', pagination); } - fillTgMap() { + fillTgMap(share: Share | null) { + this.tgs$ = this.fetchAll.pipe( + switchMap(() => this.getTalkgroups(share)), + shareReplay(), + ); this.subscriptions.add( this.tgs$.subscribe((tgs) => { tgs.forEach((tg) => {