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;
|
selectedId: number = 0;
|
||||||
talkgroups$!: Observable<Talkgroup[]>;
|
talkgroups$!: Observable<Talkgroup[]>;
|
||||||
tgService: TalkgroupService = inject(TalkgroupService);
|
tgService: TalkgroupService = inject(TalkgroupService);
|
||||||
|
page: number = 1;
|
||||||
|
perPage: number = 20;
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute) {}
|
constructor(private route: ActivatedRoute) {}
|
||||||
|
|
||||||
ngOnInit() {
|
prevPage() {
|
||||||
|
if (this.page > 1) {
|
||||||
|
this.page--;
|
||||||
|
}
|
||||||
|
this.fetchTGs();
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchTGs() {
|
||||||
this.talkgroups$ = this.route.paramMap.pipe(
|
this.talkgroups$ = this.route.paramMap.pipe(
|
||||||
switchMap((params) => {
|
switchMap((params) => {
|
||||||
this.selectedSys = Number(params.get('sys'));
|
this.selectedSys = Number(params.get('sys'));
|
||||||
this.selectedId = Number(params.get('tg'));
|
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({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export interface Pagination {
|
||||||
|
page: number;
|
||||||
|
perPage: number;
|
||||||
|
}
|
||||||
|
|
||||||
export class TalkgroupService {
|
export class TalkgroupService {
|
||||||
loggedIn: boolean = false;
|
loggedIn: boolean = false;
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
getTalkgroups(): Observable<Talkgroup[]> {
|
getTalkgroups(pagination?: Pagination): Observable<Talkgroup[]> {
|
||||||
return this.http.get<Talkgroup[]>('/api/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> {
|
getTalkgroup(sys: number, tg: number): Observable<Talkgroup> {
|
||||||
|
|
Loading…
Reference in a new issue