Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | 129x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 3x 3x 3x 14x 17x 17x 14x 14x 14x 11056x 44x 44x 3x 3x 3x 28x 86x 86x 86x 86x 25x 25x 25x 25x 25x 25x 8x 8x 8x 17x 25x 115x | import { Component, Input, OnInit, inject } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpErrorResponse } from '@angular/common/http';
import { ButtonModule } from 'primeng/button';
import { Table, TableLazyLoadEvent, TableModule, TablePageEvent } from 'primeng/table';
import { TagModule } from 'primeng/tag';
import { Signal } from '../../models/signals';
import { getSeverity } from '../../utils/utils';
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
import { IconFieldModule } from 'primeng/iconfield';
import { InputIconModule } from 'primeng/inputicon';
import { InputTextModule } from 'primeng/inputtext';
import { DialogModule } from 'primeng/dialog';
import { TwinpadApiService } from '../../services/twinpad-api.service';
import { ListResponse } from '../../models/response';
import { SignalCardComponent } from '../signal-card/signal-card.component';
import { first } from 'rxjs';
@Component({
selector: 'app-signals-table',
imports: [TableModule, ButtonModule, TagModule, RouterLink, IconFieldModule, InputIconModule, InputTextModule, FormsModule, DialogModule, SignalCardComponent],
templateUrl: './signals-table.component.html',
styleUrl: './signals-table.component.scss'
})
export class SignalsTableComponent implements OnInit {
private route = inject(ActivatedRoute);
private router = inject(Router);
private twinpadApiService = inject(TwinpadApiService);
private _deviceId!: string;
signals: ListResponse<Signal>;
isLoading: boolean;
searchValue: string | undefined;
offset: number = 0;
rows: number = 10;
filter: string;
sortField: string = "";
sortOrder: number = 1;
defaultRowOptions = [10, 20, 50];
filteredRowsPerPageOptions: number[] = [];
signalsError: HttpErrorResponse;
selectedSignal: Signal | null = null;
signalDialogVisible: boolean = false;
@Input() displaySignalDialog: boolean = false;
@Input() set deviceId(value: string) {
Eif (this._deviceId !== value) {
this._deviceId = value;
this.getData();
}
}
ngOnInit(): void {
this.route.queryParams.subscribe(params => {
this.rows = params['rows'] ? +params['rows'] : 10;
this.offset = params['offset'] ? +params['offset'] : 0;
});
this.updateRowsPerPageOptions();
Eif (this.signals === undefined) {
this.getData();
}
}
getSeverity(status: string) {
return getSeverity(status);
}
clear(table: Table) {
table.clear();
}
clearFilter() {
this.searchValue = this.filter = "";
this.getData();
}
applyFilterGlobal($event: Event) {
this.filter = ($event.target as HTMLInputElement).value;
this.getData();
}
onTableEvent(event: TablePageEvent) {
this.offset = event.first;
this.rows = event.rows;
this.router.navigate([], {
queryParams: { offset: this.offset, rows: this.rows },
queryParamsHandling: 'merge'
});
}
updateRowsPerPageOptions() {
this.filteredRowsPerPageOptions = [...new Set([...this.defaultRowOptions, this.rows])].sort((a, b) => a - b);
}
getData() {
this.isLoading = true;
this.twinpadApiService.getSignals(this.rows, this.offset, this.filter, this._deviceId, null, this.sortField !== "" ? this.sortField + ":" + this.sortOrder.toString() : null)
.subscribe({
next: (value) => {
this.signals = value;
this.isLoading = false;
},
error: (error) => {
this.signalsError = error;
}
});
}
loadEvents(event: TableLazyLoadEvent) {
this.isLoading = true;
Eif (event.first !== null && event.first !== undefined) {
this.offset = event.first;
}
Eif (event.rows !== null && event.rows !== undefined) {
this.rows = event.rows;
}
if (event.sortField !== null && event.sortField !== undefined) {
Iif (Array.isArray(event.sortField)) {
this.sortField = event.sortField[0];
}
else {
this.sortField = event.sortField;
}
this.sortOrder = event.sortOrder ?? 1;
}
else {
this.sortField = "";
}
this.getData();
}
showSignal(signal: Signal) {
this.selectedSignal = signal;
this.signalDialogVisible = true;
this.router.navigate([], {
fragment: signal.signal_id,
queryParamsHandling: 'preserve'
});
}
hideSignal() {
this.selectedSignal = null;
this.route.fragment.pipe(first()).subscribe(fragment => {
if (fragment) {
const el = document.getElementById(fragment);
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
}
this.router.navigate([]);
});
}
}
|