diff --git a/main/http_server/axe-os/src/app/components/home/home.component.html b/main/http_server/axe-os/src/app/components/home/home.component.html index 7d6841ff..9ac4e9fa 100644 --- a/main/http_server/axe-os/src/app/components/home/home.component.html +++ b/main/http_server/axe-os/src/app/components/home/home.component.html @@ -125,8 +125,8 @@

Results

-

Realtime Logs

diff --git a/main/http_server/axe-os/src/app/components/home/home.component.ts b/main/http_server/axe-os/src/app/components/home/home.component.ts index 35f51bb3..9f8afbf2 100644 --- a/main/http_server/axe-os/src/app/components/home/home.component.ts +++ b/main/http_server/axe-os/src/app/components/home/home.component.ts @@ -18,7 +18,7 @@ export class HomeComponent implements AfterViewChecked, OnDestroy { public logs: string[] = []; - private websocketSubscription: Subscription; + private websocketSubscription?: Subscription; public showLogs = false; @@ -47,19 +47,11 @@ export class HomeComponent implements AfterViewChecked, OnDestroy { }) ) - this.websocketSubscription = this.websocketService.ws$.subscribe({ - next: (val) => { - this.logs.push(val); - if (this.logs.length > 100) { - this.logs.shift(); - } - } - }) } ngOnDestroy(): void { - this.websocketSubscription.unsubscribe(); + this.websocketSubscription?.unsubscribe(); } ngAfterViewChecked(): void { if (this.scrollContainer?.nativeElement != null) { @@ -67,6 +59,23 @@ export class HomeComponent implements AfterViewChecked, OnDestroy { } } + public toggleLogs() { + this.showLogs = !this.showLogs; + + if (this.showLogs) { + this.websocketSubscription = this.websocketService.ws$.subscribe({ + next: (val) => { + this.logs.push(val); + if (this.logs.length > 100) { + this.logs.shift(); + } + } + }) + } else { + this.websocketSubscription?.unsubscribe(); + } + } + }