import {Component, OnDestroy, OnInit} from '@angular/core'; import {ApiService} from "../../services/api.service"; import {Subject} from "rxjs"; import {takeUntil} from "rxjs/operators"; import {EventService} from "../../services/event.service"; import {TestingApiService} from "../../services/testing-api.service"; @Component({ selector: 'app-admin-testing', templateUrl: './admin-testing.component.html', styleUrls: ['./admin-testing.component.scss'] }) export class AdminTestingComponent implements OnInit, OnDestroy { prodMode = false; destroyed$ = new Subject(); constructor( private apiService: ApiService, private eventService: EventService, private testingApiService: TestingApiService) { } ngOnInit(): void { this.getFFState(); this.eventService.featureFlagChanged.pipe(takeUntil(this.destroyed$)).subscribe((r) => this.getFFState()); } private getFFState() { this.apiService.getFeatureFlagState("ProdMode").pipe(takeUntil(this.destroyed$)).subscribe((res) => { this.prodMode = res.state; }); } ngOnDestroy() { this.destroyed$.complete(); } simulateVersus() { this.testingApiService.simulateVersus().pipe(takeUntil(this.destroyed$)).subscribe((r) => console.log(r)); } resetAllVersusTasksAsIncompleted() { this.testingApiService.resetAllVersusTasksAsIncompleted().pipe(takeUntil(this.destroyed$)).subscribe((r) => console.log(r)); } resetAllPlayersScore() { this.testingApiService.resetAllPlayersScore().pipe(takeUntil(this.destroyed$)).subscribe(r => console.log(r)); } clearGameQueue() { this.testingApiService.clearGameQueue().pipe(takeUntil(this.destroyed$)).subscribe((r => console.log(r))); } simulateEndGamePoints() { this.testingApiService.simulateEndGamePoints().pipe(takeUntil(this.destroyed$)).subscribe(r => console.log(r)); } simulateValidAnswer() { this.testingApiService.simulateValidAnswer().pipe(takeUntil(this.destroyed$)).subscribe(r => console.log(r)); } }