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 | 116x 1x 1x 1x 1x 1x 2x 1x 2x 2x |
import { Component, OnDestroy, OnInit, inject } from '@angular/core';
import { interval, Subject, takeUntil } from 'rxjs';
import { TwinpadApiService } from '../../services/twinpad-api.service';
@Component({
selector: 'app-global-error',
imports: [],
templateUrl: './global-error.component.html',
styleUrl: './global-error.component.scss'
})
export class GlobalErrorComponent implements OnInit, OnDestroy{
private twinpadApiService = inject(TwinpadApiService);
nextRequest: number;
nextPingWait: number;
image: string;
images = ['towing', 'alien-invasion', 'server-down'];
private destroy$ = new Subject<void>();
ngOnInit(){
this.image = 'assets/svg/'+ this.images[Math.floor(Math.random() * this.images.length)] + '.svg';
this.twinpadApiService.cloudStatusBehaviorSubject$?.subscribe({
next: status => {
Iif(status.services.backend !== "up"){
this.nextRequest = Date.now() + 1000*this.twinpadApiService.statusRefreshTime;
}
}
});
interval(200)
.pipe(takeUntil(this.destroy$))
.subscribe(() => {
this.nextPingWait = Math.round((this.nextRequest - Date.now() ) *0.001);
Iif (this.nextPingWait < 0){
this.nextPingWait = 0;
}
});
}
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
}
|