1import { Component } from '@angular/core'; 2import { MatButtonModule } from '@angular/material/button'; 3import { MatDividerModule } from '@angular/material/divider'; 4import { MatIconModule } from '@angular/material/icon'; 5import { MatProgressBarModule } from '@angular/material/progress-bar'; 6import { MatToolbarModule } from '@angular/material/toolbar'; 7import { RouterOutlet } from '@angular/router'; 8import { finalize } from 'rxjs'; 9 10import { Golden } from './golden'; 11import { GoldensService } from './goldens.service'; 12import { TestOverviewComponent } from './test-overview/test-overview.component'; 13 14@Component({ 15 selector: 'app-root', 16 standalone: true, 17 imports: [ 18 RouterOutlet, 19 MatToolbarModule, 20 TestOverviewComponent, 21 MatIconModule, 22 MatDividerModule, 23 MatButtonModule, 24 MatProgressBarModule, 25 ], 26 templateUrl: './app.component.html', 27 styleUrl: './app.component.scss', 28}) 29export class AppComponent { 30 constructor(private goldenService: GoldensService) {} 31 32 _progressTracker = 0; 33 34 goldens: Golden[] = []; 35 36 get showProgress() { 37 return this._progressTracker > 0; 38 } 39 40 ngOnInit(): void { 41 this.fetchGoldens(); 42 } 43 44 fetchGoldens(): void { 45 this._progressTracker++; 46 this.goldenService 47 .getGoldens() 48 .pipe(finalize(() => this._progressTracker--)) 49 .subscribe((goldens) => (this.goldens = goldens)); 50 } 51 52 refreshGoldens(clear: boolean): void { 53 this._progressTracker++; 54 this.goldenService 55 .refreshGoldens(clear) 56 .pipe(finalize(() => this._progressTracker--)) 57 .subscribe((goldens) => (this.goldens = goldens)); 58 } 59} 60