From 02316cf3659aa84c91f750c5ec6faf430622f2ba Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Mon, 25 Nov 2024 16:36:15 -0500 Subject: [PATCH] wip --- .../src/app/talkgroups/talkgroups.component.ts | 17 +++++++++++++++-- .../src/app/talkgroups/talkgroups.service.ts | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/client/admin/src/app/talkgroups/talkgroups.component.ts b/client/admin/src/app/talkgroups/talkgroups.component.ts index eeb5705..739826b 100644 --- a/client/admin/src/app/talkgroups/talkgroups.component.ts +++ b/client/admin/src/app/talkgroups/talkgroups.component.ts @@ -75,16 +75,29 @@ export class TalkgroupsComponent { selectedId: number = 0; talkgroups$!: Observable; tgService: TalkgroupService = inject(TalkgroupService); + page: number = 1; + perPage: number = 20; constructor(private route: ActivatedRoute) {} - ngOnInit() { + prevPage() { + if (this.page > 1) { + this.page--; + } + this.fetchTGs(); + } + + fetchTGs() { this.talkgroups$ = this.route.paramMap.pipe( switchMap((params) => { this.selectedSys = Number(params.get('sys')); this.selectedId = Number(params.get('tg')); - return this.tgService.getTalkgroups(); + return this.tgService.getTalkgroups({page: this.page, perPage: perPage}); }), ); } + + ngOnInit() { + this.fetchTGs(); + } } diff --git a/client/admin/src/app/talkgroups/talkgroups.service.ts b/client/admin/src/app/talkgroups/talkgroups.service.ts index 00f02fd..31fe385 100644 --- a/client/admin/src/app/talkgroups/talkgroups.service.ts +++ b/client/admin/src/app/talkgroups/talkgroups.service.ts @@ -6,12 +6,22 @@ import { Talkgroup, TalkgroupUpdate } from '../talkgroup'; @Injectable({ providedIn: 'root', }) + +export interface Pagination { + page: number; + perPage: number; +} + export class TalkgroupService { loggedIn: boolean = false; constructor(private http: HttpClient) {} - getTalkgroups(): Observable { - return this.http.get('/api/talkgroup/'); + getTalkgroups(pagination?: Pagination): Observable { + if (pagination == null) { + return this.http.get('/api/talkgroup/'); + } + + return this.http.post('/api/talkgroup/', pagination); } getTalkgroup(sys: number, tg: number): Observable {