diff --git a/client/admin/src/app/talkgroup.ts b/client/admin/src/app/talkgroup.ts index f9d9557..ae4e594 100644 --- a/client/admin/src/app/talkgroup.ts +++ b/client/admin/src/app/talkgroup.ts @@ -44,13 +44,16 @@ export interface Talkgroup { metadata: Metadata|null; tags: string[]; alert: boolean; + system?: System; alert_config: AlertRule[]; - system: System; weight: number; learned?: boolean; - selected?: boolean; } +export interface TalkgroupUI extends Talkgroup { + selected?: boolean; +}; + export interface TalkgroupUpdate { id: number; system_id: number; diff --git a/client/admin/src/app/talkgroups/import/import.component.html b/client/admin/src/app/talkgroups/import/import.component.html index ad79104..b738428 100644 --- a/client/admin/src/app/talkgroups/import/import.component.html +++ b/client/admin/src/app/talkgroups/import/import.component.html @@ -9,14 +9,14 @@ > - +
- + @@ -31,8 +31,8 @@ - - + + diff --git a/client/admin/src/app/talkgroups/import/import.component.ts b/client/admin/src/app/talkgroups/import/import.component.ts index 4e6efab..b7abe05 100644 --- a/client/admin/src/app/talkgroups/import/import.component.ts +++ b/client/admin/src/app/talkgroups/import/import.component.ts @@ -1,6 +1,6 @@ import { Component, inject } from '@angular/core'; import { TalkgroupService } from '../talkgroups.service'; -import { Talkgroup } from '../../talkgroup'; +import { Talkgroup, TalkgroupUI, TalkgroupUpdate } from '../../talkgroup'; import { FormGroup, FormControl, ReactiveFormsModule, FormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; import { Router, ActivatedRoute } from '@angular/router'; @@ -16,7 +16,7 @@ import { catchError, of } from 'rxjs'; export class ImportComponent { tgService: TalkgroupService = inject(TalkgroupService); form!: FormGroup; - tgs!: Talkgroup[]; + tgs!: TalkgroupUI[]; selectAll: boolean = false; constructor( @@ -46,8 +46,32 @@ export class ImportComponent { } isAllSelected() { + return this.tgs.every(_ => _.selected); + } + + selectAllTGs(ev: any) { + this.tgs.forEach(x => x.selected = ev.target.checked); } save() { + let toImport: TalkgroupUpdate[] = []; + let sysID = Number(this.form.controls['systemID'].value); + this.tgs.forEach((x) => { + if(x.selected) { + let ct: TalkgroupUpdate = x; + toImport.push(ct); + } + }); + this.tgService.putTalkgroups(sysID, toImport). + pipe( + catchError(() => { + return of(null); + }), + ) + .subscribe((event) => { + this.tgs = event!; + }); + + } } diff --git a/client/admin/src/app/talkgroups/talkgroups.component.html b/client/admin/src/app/talkgroups/talkgroups.component.html index 2784e42..915ecd7 100644 --- a/client/admin/src/app/talkgroups/talkgroups.component.html +++ b/client/admin/src/app/talkgroups/talkgroups.component.html @@ -14,13 +14,13 @@ @for (tg of talkgroups$ | async; track tg.id) { - - + + diff --git a/client/admin/src/app/talkgroups/talkgroups.service.ts b/client/admin/src/app/talkgroups/talkgroups.service.ts index 80fbdc3..d4d16cd 100644 --- a/client/admin/src/app/talkgroups/talkgroups.service.ts +++ b/client/admin/src/app/talkgroups/talkgroups.service.ts @@ -29,4 +29,11 @@ export class TalkgroupService { tu, ); } + + putTalkgroups(sysID: Number, tgs: TalkgroupUpdate[]): Observable { + return this.http.put( + `/api/talkgroup/${sysID}`, + tgs, + ); + } }
Sys Sys ID Group
{{ tg.system.name }}{{ tg.system.id }}{{ tg.system?.name }}{{ tg.system?.id }} {{ tg.tg_group }} {{ tg.alpha_tag }} {{ tg.name }}
{{ tg.system.name }}{{ tg.system.id }}{{ tg.system?.name }}{{ tg.system?.id }} {{ tg.name }} {{ tg.tgid }} {{ tg?.learned ? 'Y' : '' }} -