wip
This commit is contained in:
parent
d99e8126dd
commit
02316cf365
2 changed files with 27 additions and 4 deletions
|
@ -75,16 +75,29 @@ export class TalkgroupsComponent {
|
|||
selectedId: number = 0;
|
||||
talkgroups$!: Observable<Talkgroup[]>;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Talkgroup[]> {
|
||||
return this.http.get<Talkgroup[]>('/api/talkgroup/');
|
||||
getTalkgroups(pagination?: Pagination): Observable<Talkgroup[]> {
|
||||
if (pagination == null) {
|
||||
return this.http.get<Talkgroup[]>('/api/talkgroup/');
|
||||
}
|
||||
|
||||
return this.http.post<Talkgroup[]>('/api/talkgroup/', pagination);
|
||||
}
|
||||
|
||||
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
|
||||
|
|
Loading…
Reference in a new issue