{ "version": 3, "sources": ["src/app/shared/components/arrow/arrow.component.ts", "src/app/shared/components/arrow/arrow.component.html"], "sourcesContent": ["import { CommonModule } from '@angular/common';\nimport { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnChanges, SimpleChanges } from '@angular/core';\n\nexport interface ArrowStatsInterface {\n errors_count: number | null;\n errors_percent: number | null;\n errors_time: number | null;\n prev_errors_count: number | null;\n prev_errors_percent: number | null;\n prev_errors_time: number | null;\n}\n\n@Component({\n selector: 'app-arrow',\n standalone: true,\n imports: [CommonModule],\n templateUrl: './arrow.component.html',\n styleUrls: ['./arrow.component.scss'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class ArrowComponent implements OnChanges, AfterViewInit {\n @Input() stats: ArrowStatsInterface | null = null;\n @Input() title: string | undefined;\n @Input() gaugeInfo: string | undefined;\n @Input() scorePageUrl: string | undefined;\n @Input() displayEmpty = false;\n @Input() isRobotOffline = false;\n value: number | '--';\n dir: 'up' | 'down' | 'both' | 'none' = 'none';\n statsPopup = '';\n\n constructor(\n private changeDetectorRef: ChangeDetectorRef,\n ) {}\n\n ngAfterViewInit(): void {\n this.changeDetectorRef.detectChanges();\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (!('stats' in changes || 'isRobotOffline' in changes || 'displayEmpty' in changes)) {\n return;\n }\n\n if ('displayEmpty' in changes) {\n this.displayEmpty = changes.displayEmpty.currentValue;\n }\n if ('stats' in changes) {\n this.stats = this.displayEmpty ? null : changes.stats.currentValue;\n }\n if ('isRobotOffline' in changes) {\n this.isRobotOffline = changes.isRobotOffline.currentValue;\n }\n\n if (!this.stats || !Number.isFinite(this.stats.errors_count)) {\n this.value = '--';\n this.dir = 'none';\n this.statsPopup = '';\n return;\n }\n\n const stats: ArrowStatsInterface = this.stats;\n this.value = stats.errors_count as number;\n const prevValue = stats.prev_errors_count;\n this.dir = prevValue == null ? 'none' :\n this.value > prevValue ? 'up' :\n this.value < prevValue ? 'down' :\n this.value === prevValue ? 'both' : 'none'; // NaN != NaN\n\n this.statsPopup = this.dir === 'none' ? '' : (\n $localize`Current shift` + ': ' + this.formatGaugeValue(stats.errors_percent, stats.errors_count) + '\\n' +\n $localize`Previous shift` + ': ' + this.formatGaugeValue(stats.prev_errors_percent, stats.prev_errors_count)\n );\n\n this.changeDetectorRef.detectChanges();\n }\n\n protected formatGaugeValue(percent?: number | null, count?: number | null): string {\n if (percent == null && count == null) {\n return '--';\n }\n if (percent != null && count != null) {\n return `${count} (${percent.toFixed(0)}%)`;\n }\n return percent != null ? `${percent.toFixed(0)}%` : `${count}`;\n }\n}\n", "