diff --git a/client/stillbox/src/app/calls/calls.component.html b/client/stillbox/src/app/calls/calls.component.html index 92cca66..67a38fd 100644 --- a/client/stillbox/src/app/calls/calls.component.html +++ b/client/stillbox/src/app/calls/calls.component.html @@ -76,12 +76,14 @@ } -
- - -
+
+ + +
diff --git a/client/stillbox/src/app/calls/calls.component.scss b/client/stillbox/src/app/calls/calls.component.scss index 5cc386b..d46d981 100644 --- a/client/stillbox/src/app/calls/calls.component.scss +++ b/client/stillbox/src/app/calls/calls.component.scss @@ -21,7 +21,8 @@ table, overflow: auto; } -.toolbarButtons button, .toolbarButtons form, +.toolbarButtons button, +.toolbarButtons form, .toolbarButtons form button { justify-content: flex-end; align-content: center; @@ -95,4 +96,3 @@ form { .tagSelect { flex: 1 1 250px; } - diff --git a/client/stillbox/src/app/calls/calls.component.ts b/client/stillbox/src/app/calls/calls.component.ts index b7b088b..264eab4 100644 --- a/client/stillbox/src/app/calls/calls.component.ts +++ b/client/stillbox/src/app/calls/calls.component.ts @@ -291,11 +291,13 @@ export class CallsComponent { this.currentServerPage = 0; this.setPage(this.zeroPage()); }); - this.setPage({ - pageIndex: 0, - pageSize: 25, + this.prefsSvc.get('callsPerPage').subscribe((cpp) => { + this.perPage = cpp; + this.setPage({ + pageIndex: 0, + pageSize: 25, + }); }); - this.perPage = this.prefsSvc.get('callsPerPage'); } resetFilter() { diff --git a/client/stillbox/src/app/prefs/prefs.service.ts b/client/stillbox/src/app/prefs/prefs.service.ts index 49e9188..22f3036 100644 --- a/client/stillbox/src/app/prefs/prefs.service.ts +++ b/client/stillbox/src/app/prefs/prefs.service.ts @@ -2,19 +2,27 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { BehaviorSubject, + concatMap, Observable, shareReplay, } from 'rxjs'; type Preferences = Map; +function mapToObj(map: Map): { [key: string]: any } { + const obj: { [key: string]: any } = {}; + map.forEach((value, key) => { + obj[key] = value; + }); + return obj; +} + @Injectable({ providedIn: 'root', }) export class PrefsService { constructor(private http: HttpClient) { this.prefs$ = this.fetch().pipe(shareReplay(1)); - this.fillPrefs(); } last = {}; private readonly _getPref = new Map>(); @@ -24,31 +32,26 @@ export class PrefsService { return this.http.get('/api/user/prefs/stillbox'); } - fillPrefs() { - this.prefs$.subscribe((prefs) => { - if (prefs.size > 0) { - prefs.forEach((k, v) => { - this._getPref.set(k, new BehaviorSubject(v)); - }); - } - }); - } - get(k: string): any{ - const r = this._getPref.get(k); - return r; - } + + get(k: string): Observable { + return this.prefs$.pipe( + concatMap((prefs) => { + if (prefs instanceof Map) { + const v = prefs.get(k) ?? new BehaviorSubject(null); + return v; + } + return new BehaviorSubject(null); + }) + ); + } set(pref: string, value: any) { - if (this._getPref.get(pref) != value) { - this._getPref.set(pref, value); - this.setPrefs(); - } - } - - setPrefs() { + this.prefs$.subscribe((prefs) => { + prefs.set(pref, value); this.http - .put('/api/user/prefs/stillbox', this._getPref) + .put('/api/user/prefs/stillbox', mapToObj(prefs)) .subscribe((event) => {}); + }); } } diff --git a/client/stillbox/src/app/talkgroups/talkgroup-table/talkgroup-table.component.ts b/client/stillbox/src/app/talkgroups/talkgroup-table/talkgroup-table.component.ts index 8671be8..d95f529 100644 --- a/client/stillbox/src/app/talkgroups/talkgroup-table/talkgroup-table.component.ts +++ b/client/stillbox/src/app/talkgroups/talkgroup-table/talkgroup-table.component.ts @@ -123,7 +123,9 @@ export class TalkgroupTableComponent { this.suppress = false; }); - this.perPage = this.prefsService.get('tgsPerPage'); + this.prefsService.get('tgsPerPage').subscribe((tgpp) => { + this.perPage = tgpp; + }); this.talkgroups$.subscribe((event) => { if (event != null) { this.dataSource.data = event!.talkgroups; diff --git a/client/stillbox/src/app/talkgroups/talkgroups.component.ts b/client/stillbox/src/app/talkgroups/talkgroups.component.ts index 0385aa8..52d62ca 100644 --- a/client/stillbox/src/app/talkgroups/talkgroups.component.ts +++ b/client/stillbox/src/app/talkgroups/talkgroups.component.ts @@ -73,8 +73,10 @@ export class TalkgroupsComponent { } ngOnInit() { - this.perPage = this.prefsService.get('tgsPerPage'); - this.switchPage(this.curPage); + this.prefsService.get('tgsPerPage').subscribe((tgpp) => { + this.perPage = tgpp; + this.switchPage(this.curPage); + }); } ngAfterViewInit() { diff --git a/client/stillbox/src/app/talkgroups/talkgroups.service.ts b/client/stillbox/src/app/talkgroups/talkgroups.service.ts index 655b898..b317d4f 100644 --- a/client/stillbox/src/app/talkgroups/talkgroups.service.ts +++ b/client/stillbox/src/app/talkgroups/talkgroups.service.ts @@ -1,11 +1,6 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; -import { - concatMap, - Observable, - ReplaySubject, - shareReplay, -} from 'rxjs'; +import { concatMap, Observable, ReplaySubject, shareReplay } from 'rxjs'; import { Talkgroup, TalkgroupUpdate, TGID } from '../talkgroup'; export interface Pagination { @@ -81,7 +76,9 @@ export class TalkgroupService { allTags(): Observable { if (!this.tags$) { - this.tags$ = this.http.get('/api/talkgroup/tags').pipe(shareReplay()); + this.tags$ = this.http + .get('/api/talkgroup/tags') + .pipe(shareReplay()); } return this.tags$; diff --git a/client/stillbox/src/styles.scss b/client/stillbox/src/styles.scss index f579b17..d0d02e6 100644 --- a/client/stillbox/src/styles.scss +++ b/client/stillbox/src/styles.scss @@ -109,14 +109,14 @@ html { } @font-face { - font-family: 'Material Symbols Outlined'; + font-family: "Material Symbols Outlined"; font-style: normal; font-weight: 400; src: url("./assets/MatSymOutline.ttf") format("truetype"); } .material-symbols-outlined { - font-family: 'Material Symbols Outlined'; + font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal; font-size: 24px; @@ -129,7 +129,6 @@ html { direction: ltr; } - a, a:visited { text-decoration: none; @@ -235,4 +234,4 @@ input { display: flex; margin-top: 40px; justify-content: center; -} \ No newline at end of file +}