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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | 87x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 16x 24x 24x 24x 24x 14x 24x 14x 23x 23x 10x 9x 1x 13x 24x 24x 19x 24x 3x 3x 3x 3x 3x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 26x 26x 26x 15x 18x 11x 11x 18x 18x 18x 9x | import { AfterViewInit, Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core';
import { DisplayModeOption, DurationOption } from '../../models/signals';
import { FormsModule } from '@angular/forms';
import { LoaderComponent } from '../loader/loader.component';
import { NgIf } from '@angular/common';
import { SignalsGraphComponent } from '../signals-graph/signals-graph.component';
import { MultiSelectModule } from 'primeng/multiselect';
import { Select } from 'primeng/select';
import { FloatLabelModule } from 'primeng/floatlabel';
import { ToolbarModule } from 'primeng/toolbar';
import { ButtonModule } from 'primeng/button';
import { DatePicker } from 'primeng/datepicker';
import { SplitButtonModule } from 'primeng/splitbutton';
import { MenuItem } from 'primeng/api';
import { ActivatedRoute } from '@angular/router';
import { MultiSelectSignalsComponent } from '../multi-select-signals/multi-select-signals.component';
import { RefreshRateSelectorComponent } from '../refresh-rate-selector/refresh-rate-selector.component';
@Component({
selector: 'app-signals-graphs',
imports: [LoaderComponent, NgIf, FormsModule, SignalsGraphComponent, MultiSelectModule,
Select, FloatLabelModule, ToolbarModule, ButtonModule,
DatePicker, SplitButtonModule, MultiSelectSignalsComponent, RefreshRateSelectorComponent],
templateUrl: './signals-graphs.component.html',
styleUrl: './signals-graphs.component.scss'
})
export class SignalsGraphsComponent implements OnInit, OnChanges, AfterViewInit {
isLoading: boolean;
@Input() inputSignalIdsToPlot: string[] = [];
@Input() showSignals: boolean = true;
@Input() showLegend: boolean = true;
@Input() inputZoomTime: number;
@Input() inputIsLive: boolean = true;
@Input() graphId: string = "";
@Input() inputWindowLength: DurationOption;
replayWindowLengths: DurationOption[];
windowLengths: DurationOption[];
windowLength: DurationOption;
refreshTime: DurationOption;
replayWindowLength: DurationOption;
isResponseSlowerThanRefresh: boolean = false;
zoomTime: Date;
isLive: boolean;
displayModes: DisplayModeOption[];
displayMode: DisplayModeOption;
refreshModes: string[];
refreshMode: string;
dataDateMin: Date;
dataDateMax: Date;
windowMinTs: number;
windowMaxTs: number;
signalsSelectionLimit: number = 10;
querySignalId: string = "signal_id";
exports: MenuItem[] = [{ "label": "CSV", command: () => { this.downloadSignalsZip("csv"); } },
{ "label": "PrestoPlot", command: () => { this.downloadSignalsZip("prestoplot"); } }];
@ViewChild(SignalsGraphComponent) graphComponent!: SignalsGraphComponent;
@ViewChild(MultiSelectSignalsComponent) multiSelectSignals: MultiSelectSignalsComponent;
constructor(private route: ActivatedRoute) { }
applyInputs() {
// Checks if current graph is standalone graph or graph of single signal
let isStandaloneGraph: boolean = false;
this.route.url.subscribe(urlSegments => {
const segment = urlSegments[0].path;
if (segment !== "signals" && segment !== "events") {
isStandaloneGraph = true;
}
});
// If it's a standalone graph, only get signal ids to plot from query
// If query doesn't give any signals to graph, graph is empty
if (isStandaloneGraph) {
this.route.queryParams.subscribe(params => {
const signalIds = params[this.querySignalId];
if (signalIds) {
if (signalIds instanceof Array) {
this.inputSignalIdsToPlot = signalIds;
}
else {
this.inputSignalIdsToPlot = [signalIds];
}
}
else {
this.inputSignalIdsToPlot = [];
}
});
}
this.isLive = this.inputIsLive;
if (this.inputZoomTime !== undefined) {
this.zoomTime = new Date(this.inputZoomTime);
}
if (!this.isLive && this.inputWindowLength !== undefined && this.replayWindowLengths !== undefined) {
const insertIndex = this.replayWindowLengths.findIndex(existingDuration => existingDuration.duration > this.inputWindowLength.duration);
this.replayWindowLength = this.inputWindowLength;
Eif (insertIndex !== -1) {
this.replayWindowLengths.splice(insertIndex, 0, this.replayWindowLength);
}
else {
this.replayWindowLengths.push(this.replayWindowLength);
}
this.onDateChange();
}
}
ngAfterViewInit(): void {
this.applyInputs();
}
ngOnInit() {
this.isLoading = true;
this.querySignalId = `signal_id${this.graphId}`;
this.displayModes = [{ label: "Live mode", isLive: true }, { label: "Replay mode", isLive: false }];
this.displayMode = this.displayModes[0];
this.replayWindowLengths = [
{ label: "10s", duration: 10 },
{ label: "1mn", duration: 60 },
{ label: "5mn", duration: 300 },
{ label: "15mn", duration: 900 },
{ label: "1hr", duration: 3600 },
{ label: "4hr", duration: 3600 * 4 },
{ label: "12hr", duration: 3600 * 12 },
{ label: "24hr", duration: 3600 * 24 }
];
this.replayWindowLength = this.replayWindowLengths[1];
this.windowLengths = [
{ label: "10s", duration: 10 },
{ label: "30s", duration: 30 },
{ label: "1mn", duration: 60 },
{ label: "3mn", duration: 180 },
{ label: "5mn", duration: 300 },
{ label: "10mn", duration: 600 },
{ label: "1hr", duration: 3600 }
];
this.windowLength = this.windowLengths[2];
this.refreshModes = ["Single-point", "Full window", "Latest points"];
this.refreshMode = this.refreshModes[0];
this.isLoading = false;
this.onDateChange();
}
handleDataDateMin(date: Date) {
this.dataDateMin = date;
}
handleDataDateMax(date: Date) {
this.dataDateMax = date;
}
handleWindowMiddleDate(date: Date) {
this.zoomTime = date;
}
handleResponseSlowerThanRefresh(bool: boolean) {
this.isResponseSlowerThanRefresh = bool;
}
handleRefreshRateChange(value: DurationOption) {
this.refreshTime = value;
}
onDateChange() {
if (this.zoomTime === undefined) {
this.zoomTime = new Date(Date.now() - 500 * this.replayWindowLength.duration);
this.inputZoomTime = this.zoomTime.valueOf() / 1000;
}
const timestamp = this.zoomTime.valueOf() / 1000;
this.windowMinTs = timestamp - 0.5 * this.replayWindowLength.duration;
this.windowMaxTs = timestamp + 0.5 * this.replayWindowLength.duration;
}
ngOnChanges() {
this.applyInputs();
}
toggleLive() {
this.isLive = !this.isLive;
this.inputIsLive = !this.isLive;
}
downloadSignalsZip(format: string) {
this.graphComponent.downloadSignalsZip(format);
}
}
|