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 | 136x 26x 26x 26x 26x 56x 56x 30x 30x 104x 3962x 10807x 4x 4x 1x 1x 3x 3x | import { Component, OnInit } from '@angular/core';
import { NgIf } from '@angular/common';
import { SelectModule } from 'primeng/select';
import { FormsModule } from '@angular/forms';
import { first } from 'rxjs';
import { SignalCommandComponent } from '../signal-command/signal-command.component';
import { Signal } from '../../models/signals';
import { TwinpadApiService } from '../../services/twinpad-api.service';
@Component({
selector: 'app-command-center',
imports: [SignalCommandComponent, NgIf, SelectModule, FormsModule],
templateUrl: './command-center.component.html',
styleUrl: './command-center.component.scss'
})
export class CommandCenterComponent implements OnInit {
signalIds: string[];
signalIdsToDisplay: string[];
_selectedSignalId: string;
signal: Signal | undefined;
constructor(private twinpadApiService: TwinpadApiService) {}
ngOnInit(): void {
this.twinpadApiService.getSignalsIds().subscribe({
next: signalIds => {
this.signalIds = signalIds;
this.filterSignalIds();
}
});
}
filterSignalIds() {
this.twinpadApiService.devicesBehaviorSubject$.pipe(first()).subscribe({
next: devices => {
if (devices.length === 0) {
setTimeout(() => this.filterSignalIds(), 50);
return;
}
const downDeviceIds: string[] = devices.filter(device => device.status !== "up").map(device => device.device_id);
// display only signals of devices who are not down
// can't filter on devices who are up since some signals don't come from real devices (data storage)
this.signalIdsToDisplay = this.signalIds.filter(signalId => downDeviceIds.indexOf(signalId.split(".")[0]) === -1);
}
});
}
get selectedSignalId() {
return this._selectedSignalId;
}
set selectedSignalId(newValue: string) {
this._selectedSignalId = newValue;
if (this._selectedSignalId === null) {
this.signal = undefined;
return;
}
this.twinpadApiService.getSignal(this._selectedSignalId).subscribe({
next: signal => {
this.signal = signal;
}
});
}
}
|