|
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 a59e17b..6f6a68c 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
@@ -2,8 +2,10 @@ import {
Component,
inject,
Pipe,
+ Input,
PipeTransform,
output,
+ ViewChild,
input,
} from '@angular/core';
import { toObservable } from '@angular/core/rxjs-interop';
@@ -14,13 +16,17 @@ import { RouterModule, RouterLink } from '@angular/router';
import { CommonModule } from '@angular/common';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
-import { MatPaginatorModule, PageEvent } from '@angular/material/paginator';
+import {
+ MatPaginator,
+ MatPaginatorModule,
+ PageEvent,
+} from '@angular/material/paginator';
import { PrefsService } from '../../prefs/prefs.service';
import { MatIconModule } from '@angular/material/icon';
-import {
- MatChipSelectionChange,
- MatChipsModule,
-} from '@angular/material/chips';
+import { MatChipsModule } from '@angular/material/chips';
+import { SelectionModel } from '@angular/cdk/collections';
+import { MatCheckboxModule } from '@angular/material/checkbox';
+import { Observable, Subscription } from 'rxjs';
@Pipe({
standalone: true,
@@ -60,6 +66,7 @@ export class SanitizeHtmlPipe implements PipeTransform {
IconifyPipe,
MatTableModule,
MatPaginatorModule,
+ MatCheckboxModule,
MatChipsModule,
],
templateUrl: './talkgroup-table.component.html',
@@ -81,6 +88,7 @@ export class TalkgroupTableComponent {
perPage: number = 25;
count = 0;
columns = [
+ 'select',
'icon',
'sysID',
'sysName',
@@ -92,14 +100,30 @@ export class TalkgroupTableComponent {
'learned',
'edit',
];
+ selection = new SelectionModel(true, []);
+ private resetPageSub!: Subscription;
+ @Input() resetPage!: Observable;
+ @ViewChild('paginator') paginator!: MatPaginator;
+ suppress = false;
constructor(private route: ActivatedRoute) {}
setPage(p: PageEvent) {
- this.switchPage.emit(p);
+ // don't needlessly request page 0 if we were asked merely to reset the state of the control
+ this.selection.clear();
+ if (!this.suppress) {
+ this.switchPage.emit(p);
+ }
}
ngOnInit() {
+ this.resetPageSub = this.resetPage.subscribe(() => {
+ this.suppress = true;
+ this.paginator.firstPage();
+ this.selection.clear();
+ this.suppress = false;
+ });
+
this.perPage = this.prefsService.last.tgsPerPage;
this.talkgroups$.subscribe((event) => {
if (event != null) {
@@ -109,10 +133,26 @@ export class TalkgroupTableComponent {
});
}
+ ngOnDestroy() {
+ this.resetPageSub.unsubscribe();
+ }
+
searchChip(event: MouseEvent) {
// not a fan of how this looks, but it works...
this.changeFilter.emit(
(event.target as Element).childNodes[0].textContent ?? '',
);
}
+
+ isAllSelected() {
+ const numSelected = this.selection.selected.length;
+ const numRows = this.dataSource.data.length;
+ return numSelected === numRows;
+ }
+
+ masterToggle() {
+ this.isAllSelected()
+ ? this.selection.clear()
+ : this.dataSource.data.forEach((row) => this.selection.select(row));
+ }
}
diff --git a/client/stillbox/src/app/talkgroups/talkgroups.component.html b/client/stillbox/src/app/talkgroups/talkgroups.component.html
index ac3654a..adbffc2 100644
--- a/client/stillbox/src/app/talkgroups/talkgroups.component.html
+++ b/client/stillbox/src/app/talkgroups/talkgroups.component.html
@@ -1,16 +1,33 @@
diff --git a/client/stillbox/src/app/talkgroups/talkgroups.component.scss b/client/stillbox/src/app/talkgroups/talkgroups.component.scss
index be14df6..fb24c88 100644
--- a/client/stillbox/src/app/talkgroups/talkgroups.component.scss
+++ b/client/stillbox/src/app/talkgroups/talkgroups.component.scss
@@ -3,6 +3,10 @@ talkgroup-table {
height: 100%;
}
+.filterBox {
+ width: 300px;
+}
+
talkgroups {
display: flex;
flex-direction: column;
@@ -10,6 +14,11 @@ talkgroups {
height: 90%;
}
+.clearBtn {
+ border: 0;
+ background-color: transparent;
+}
+
.tgTools {
display: flex;
}
diff --git a/client/stillbox/src/app/talkgroups/talkgroups.component.ts b/client/stillbox/src/app/talkgroups/talkgroups.component.ts
index aa8891a..f29bfc8 100644
--- a/client/stillbox/src/app/talkgroups/talkgroups.component.ts
+++ b/client/stillbox/src/app/talkgroups/talkgroups.component.ts
@@ -8,10 +8,12 @@ import { TalkgroupTableComponent } from './talkgroup-table/talkgroup-table.compo
import { PageEvent } from '@angular/material/paginator';
import { MatToolbarModule } from '@angular/material/toolbar';
import { PrefsService } from '../prefs/prefs.service';
+import { Subject } from 'rxjs';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatInputModule, MatInput } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';
import { FormsModule, ReactiveFormsModule, FormControl } from '@angular/forms';
+import { MatIconModule } from '@angular/material/icon';
@Component({
selector: 'talkgroups',
@@ -27,6 +29,7 @@ import { FormsModule, ReactiveFormsModule, FormControl } from '@angular/forms';
ReactiveFormsModule,
FormsModule,
MatProgressSpinnerModule,
+ MatIconModule,
],
templateUrl: './talkgroups.component.html',
styleUrl: './talkgroups.component.scss',
@@ -43,6 +46,12 @@ export class TalkgroupsComponent {
curPage = { pageIndex: 0, pageSize: this.perPage };
constructor(private route: ActivatedRoute) {}
+ pageReset: Subject = new Subject();
+
+ resetPage() {
+ this.pageReset.next();
+ }
+
switchPage(p: PageEvent) {
this.curPage = p;
this.route.paramMap
@@ -84,6 +93,8 @@ export class TalkgroupsComponent {
this.filter.setValue(f);
}
filterChange() {
+ this.curPage.pageIndex = 0;
+ this.resetPage();
this.switchPage(this.curPage);
}
}
diff --git a/client/stillbox/src/app/talkgroups/talkgroups.service.ts b/client/stillbox/src/app/talkgroups/talkgroups.service.ts
index b38a887..c8b9c85 100644
--- a/client/stillbox/src/app/talkgroups/talkgroups.service.ts
+++ b/client/stillbox/src/app/talkgroups/talkgroups.service.ts
@@ -40,6 +40,10 @@ export class TalkgroupService {
});
}
+ allTags(): Observable {
+ return this.http.get('/api/talkgroup/tags');
+ }
+
exportTGs(
type: string,
sysID: number,
diff --git a/client/stillbox/src/styles.scss b/client/stillbox/src/styles.scss
index 926843a..98e15aa 100644
--- a/client/stillbox/src/styles.scss
+++ b/client/stillbox/src/styles.scss
@@ -167,7 +167,7 @@ button.ybtn {
text-shadow: 2px 2px 2px rgb(156, 156, 156);
}
-button {
+button.sbButton {
border-radius: 3px;
padding: 10px;
border: none;
@@ -199,3 +199,7 @@ body {
.navItems {
width: 100px;
}
+
+input {
+ caret-color: var(--color-dark-fg) !important;
+}
|