From f71b3aeb6e16d4b4bad2a35ad0fa60c6033ef603 Mon Sep 17 00:00:00 2001 From: Nico Jensch Date: Sun, 6 Oct 2024 13:05:09 +0200 Subject: [PATCH] feat(status): allow showing next active build log --- frontend/src/app/status/status.component.html | 9 +++++++ frontend/src/app/status/status.component.ts | 26 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/status/status.component.html b/frontend/src/app/status/status.component.html index 13f27721..a0e7a71f 100644 --- a/frontend/src/app/status/status.component.html +++ b/frontend/src/app/status/status.component.html @@ -37,6 +37,15 @@

Build Status

> {{ displayLiveLog ? "Hide" : "Show" }} live log + @if (activeBuilds > 1) { + + } } diff --git a/frontend/src/app/status/status.component.ts b/frontend/src/app/status/status.component.ts index 4a14a116..fac94a10 100644 --- a/frontend/src/app/status/status.component.ts +++ b/frontend/src/app/status/status.component.ts @@ -32,6 +32,8 @@ export class StatusComponent implements AfterViewInit { pipelines: GitLabPipeline[] = [] liveLog: undefined | string = undefined displayLiveLog: boolean = true + activeBuilds: number = 0 + currentBuild: number = 0 constructor(private cdr: ChangeDetectorRef, private router: Router) { this.displayLiveLog = localStorage.getItem("displayLiveLog") === "true" @@ -157,10 +159,11 @@ export class StatusComponent implements AfterViewInit { this.nothingGoingOn = returnQueue.findIndex((queue) => queue.status !== "idle" && queue.count > 0) === -1 if (!this.nothingGoingOn) { const activeQueue = returnQueue.find((queue) => queue.status === "active") - if (this.liveLog !== activeQueue!.liveLogUrl![0]) { - this.liveLog = undefined + if (this.liveLog !== activeQueue!.liveLogUrl![0] && this.currentBuild === 0) { this.liveLog = activeQueue!.liveLogUrl![0] + this.currentBuild = 0 } + this.activeBuilds = activeQueue!.liveLogUrl!.length } else { this.liveLog = undefined } @@ -204,10 +207,29 @@ export class StatusComponent implements AfterViewInit { window.location.href = liveLogUrl ? liveLogUrl : "" } + /** + * Toggle the display of the live log. Saves the state in localStorage. + */ toggleLiveLog() { this.displayLiveLog = !this.displayLiveLog this.cdr.detectChanges() localStorage.setItem("displayLiveLog", this.displayLiveLog.toString()) } + + /** + * Show the next live log of the active builds. + */ + toggleLogStream(): void { + const activeQueue = this.currentQueue.find((queue) => queue.status === "active") + if (!activeQueue) return + + if ((this.currentBuild + 1) <= this.activeBuilds) { + this.currentBuild++ + this.liveLog = activeQueue.liveLogUrl![this.currentBuild] + } else { + this.currentBuild = 0 + this.liveLog = activeQueue.liveLogUrl![0] + } + } }