wip
This commit is contained in:
parent
f14e50d258
commit
04b0d0b5de
8 changed files with 63 additions and 12 deletions
|
@ -76,6 +76,12 @@ export const routes: Routes = [
|
||||||
import('./alerts/alerts.component').then((m) => m.AlertsComponent),
|
import('./alerts/alerts.component').then((m) => m.AlertsComponent),
|
||||||
data: { title: 'Alerts' },
|
data: { title: 'Alerts' },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'shares',
|
||||||
|
loadComponent: () =>
|
||||||
|
import('./shares/shares.component').then((m) => m.SharesComponent),
|
||||||
|
data: { title: 'Shares' },
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { PrefsService } from '../prefs/prefs.service';
|
||||||
import { MatIconModule } from '@angular/material/icon';
|
import { MatIconModule } from '@angular/material/icon';
|
||||||
import { SelectionModel } from '@angular/cdk/collections';
|
import { SelectionModel } from '@angular/cdk/collections';
|
||||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||||
import { BehaviorSubject, Subscription } from 'rxjs';
|
import { BehaviorSubject, Subject, Subscription } from 'rxjs';
|
||||||
import { switchMap } from 'rxjs/operators';
|
import { switchMap } from 'rxjs/operators';
|
||||||
import {
|
import {
|
||||||
CallsListParams,
|
CallsListParams,
|
||||||
|
@ -115,9 +115,7 @@ export class CallsComponent {
|
||||||
|
|
||||||
subscriptions = new Subscription();
|
subscriptions = new Subscription();
|
||||||
pageWindow = 0;
|
pageWindow = 0;
|
||||||
fetchCalls = new BehaviorSubject<CallsListParams>(
|
fetchCalls = new Subject<CallsListParams>();
|
||||||
this.buildParams(this.curPage, this.curPage.pageIndex),
|
|
||||||
);
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private callsSvc: CallsService,
|
private callsSvc: CallsService,
|
||||||
|
@ -180,6 +178,7 @@ export class CallsComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
setPage(p: PageEvent, force?: boolean) {
|
setPage(p: PageEvent, force?: boolean) {
|
||||||
|
console.log("setpage")
|
||||||
this.selection.clear();
|
this.selection.clear();
|
||||||
this.curPage = p;
|
this.curPage = p;
|
||||||
if (p && p!.pageSize != this.perPage) {
|
if (p && p!.pageSize != this.perPage) {
|
||||||
|
@ -195,16 +194,19 @@ export class CallsComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
getCalls(p: PageEvent, force?: boolean) {
|
getCalls(p: PageEvent, force?: boolean) {
|
||||||
|
console.log("getcalls")
|
||||||
const pageStart = p.pageIndex * p.pageSize;
|
const pageStart = p.pageIndex * p.pageSize;
|
||||||
const serverPage = Math.floor(pageStart / reqPageSize) + 1;
|
const serverPage = Math.floor(pageStart / reqPageSize) + 1;
|
||||||
this.pageWindow = pageStart % reqPageSize;
|
this.pageWindow = pageStart % reqPageSize;
|
||||||
if (serverPage == this.currentServerPage && !force && this.currentSet) {
|
if (serverPage == this.currentServerPage && !force && this.currentSet) {
|
||||||
|
console.log("currentset");
|
||||||
this.callsResult.next(
|
this.callsResult.next(
|
||||||
this.callsResult
|
this.callsResult
|
||||||
? this.currentSet.slice(this.pageWindow, this.pageWindow + p.pageSize)
|
? this.currentSet.slice(this.pageWindow, this.pageWindow + p.pageSize)
|
||||||
: [],
|
: [],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
console.log("not currentset");
|
||||||
this.currentServerPage = serverPage;
|
this.currentServerPage = serverPage;
|
||||||
this.fetchCalls.next(this.buildParams(p, serverPage));
|
this.fetchCalls.next(this.buildParams(p, serverPage));
|
||||||
}
|
}
|
||||||
|
@ -243,6 +245,7 @@ export class CallsComponent {
|
||||||
this.fetchCalls
|
this.fetchCalls
|
||||||
.pipe(
|
.pipe(
|
||||||
switchMap((params) => {
|
switchMap((params) => {
|
||||||
|
console.log("gc switchmap");
|
||||||
return this.callsSvc.getCalls(params);
|
return this.callsSvc.getCalls(params);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
@ -101,6 +101,11 @@ export class NavigationComponent {
|
||||||
url: '/alerts',
|
url: '/alerts',
|
||||||
icon: 'notifications',
|
icon: 'notifications',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Shares',
|
||||||
|
url: '/shares',
|
||||||
|
icon: 'share',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
toggleFilterPanel() {
|
toggleFilterPanel() {
|
||||||
|
|
1
client/stillbox/src/app/shares/shares.component.html
Normal file
1
client/stillbox/src/app/shares/shares.component.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<p>shares works!</p>
|
0
client/stillbox/src/app/shares/shares.component.scss
Normal file
0
client/stillbox/src/app/shares/shares.component.scss
Normal file
23
client/stillbox/src/app/shares/shares.component.spec.ts
Normal file
23
client/stillbox/src/app/shares/shares.component.spec.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { SharesComponent } from './shares.component';
|
||||||
|
|
||||||
|
describe('SharesComponent', () => {
|
||||||
|
let component: SharesComponent;
|
||||||
|
let fixture: ComponentFixture<SharesComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [SharesComponent]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(SharesComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
11
client/stillbox/src/app/shares/shares.component.ts
Normal file
11
client/stillbox/src/app/shares/shares.component.ts
Normal file
|
@ -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 {
|
||||||
|
|
||||||
|
}
|
|
@ -27,20 +27,15 @@ export interface TalkgroupsPaginated {
|
||||||
})
|
})
|
||||||
export class TalkgroupService {
|
export class TalkgroupService {
|
||||||
private readonly _getTalkgroup = new Map<string, ReplaySubject<Talkgroup>>();
|
private readonly _getTalkgroup = new Map<string, ReplaySubject<Talkgroup>>();
|
||||||
private tgs$: Observable<Talkgroup[]>;
|
private tgs$!: Observable<Talkgroup[]>;
|
||||||
private tags$!: Observable<string[]>;
|
private tags$!: Observable<string[]>;
|
||||||
private fetchAll = new BehaviorSubject<'fetch'>('fetch');
|
private fetchAll = new BehaviorSubject<'fetch'>('fetch');
|
||||||
private subscriptions = new Subscription();
|
private subscriptions = new Subscription();
|
||||||
constructor(private http: HttpClient) {
|
constructor(private http: HttpClient) {
|
||||||
this.tgs$ = this.fetchAll.pipe(
|
|
||||||
switchMap(() => this.getTalkgroups()),
|
|
||||||
shareReplay(),
|
|
||||||
);
|
|
||||||
this.tags$ = this.fetchAll.pipe(
|
this.tags$ = this.fetchAll.pipe(
|
||||||
switchMap(() => this.getAllTags()),
|
switchMap(() => this.getAllTags()),
|
||||||
shareReplay(),
|
shareReplay(),
|
||||||
);
|
);
|
||||||
this.fillTgMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
@ -51,7 +46,7 @@ export class TalkgroupService {
|
||||||
return this.http.get<string[]>('/api/talkgroup/tags');
|
return this.http.get<string[]>('/api/talkgroup/tags');
|
||||||
}
|
}
|
||||||
|
|
||||||
getTalkgroups(): Observable<Talkgroup[]> {
|
getTalkgroups(share: Share | null): Observable<Talkgroup[]> {
|
||||||
return this.http.get<Talkgroup[]>('/api/talkgroup/');
|
return this.http.get<Talkgroup[]>('/api/talkgroup/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +55,9 @@ export class TalkgroupService {
|
||||||
tg: number,
|
tg: number,
|
||||||
share: Share | null = null,
|
share: Share | null = null,
|
||||||
): Observable<Talkgroup> {
|
): Observable<Talkgroup> {
|
||||||
|
if (this._getTalkgroup.size < 1) {
|
||||||
|
this.fillTgMap(share);
|
||||||
|
}
|
||||||
const key = this.tgKey(sys, tg);
|
const key = this.tgKey(sys, tg);
|
||||||
if (!this._getTalkgroup.get(key)) {
|
if (!this._getTalkgroup.get(key)) {
|
||||||
let rs = new ReplaySubject<Talkgroup>();
|
let rs = new ReplaySubject<Talkgroup>();
|
||||||
|
@ -103,7 +101,11 @@ export class TalkgroupService {
|
||||||
return this.http.post<TalkgroupsPaginated>('/api/talkgroup/', pagination);
|
return this.http.post<TalkgroupsPaginated>('/api/talkgroup/', pagination);
|
||||||
}
|
}
|
||||||
|
|
||||||
fillTgMap() {
|
fillTgMap(share: Share | null) {
|
||||||
|
this.tgs$ = this.fetchAll.pipe(
|
||||||
|
switchMap(() => this.getTalkgroups(share)),
|
||||||
|
shareReplay(),
|
||||||
|
);
|
||||||
this.subscriptions.add(
|
this.subscriptions.add(
|
||||||
this.tgs$.subscribe((tgs) => {
|
this.tgs$.subscribe((tgs) => {
|
||||||
tgs.forEach((tg) => {
|
tgs.forEach((tg) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue