From f740e7f7aa33d5ceff3caafc01b168b31a045904 Mon Sep 17 00:00:00 2001 From: Nico Jensch Date: Sat, 5 Oct 2024 19:29:43 +0200 Subject: [PATCH] feat(status): support linking to source folder --- .../deploy-log-full.component.html | 20 +++++----- .../deploy-log-full.component.ts | 16 ++++++-- .../app/deploy-log/deploy-log.component.html | 12 +++--- .../app/deploy-log/deploy-log.component.ts | 6 ++- shared-lib/src/lib/functions.ts | 39 +++++++++++++------ 5 files changed, 63 insertions(+), 30 deletions(-) diff --git a/frontend/src/app/deploy-log-full/deploy-log-full.component.html b/frontend/src/app/deploy-log-full/deploy-log-full.component.html index 69c2b85a..7f4594b0 100644 --- a/frontend/src/app/deploy-log-full/deploy-log-full.component.html +++ b/frontend/src/app/deploy-log-full/deploy-log-full.component.html @@ -2,10 +2,11 @@

Deployment log

Shows the last deployed packages and allows searching the entire history.

Shows the last deployed packages and allows searching the entire history. + Click the package name to be redirected to the PKGBUILDs used.

Disclaimer: the data shown here corresponds to our in-progress + >Disclaimer: the data shown here corresponds to our in-progress infra 4.0, NOT the live Chaotic-AUR repo.

@@ -26,7 +27,7 @@

Deployment log

value="0" /> All 🌍
@@ -43,7 +44,7 @@

Deployment log

Success 📣 @@ -58,7 +59,7 @@

Deployment log

value="2" /> Failed 🚫 @@ -75,7 +76,7 @@

Deployment log

Timed out ⏳ @@ -109,7 +110,7 @@

Deployment log

@if (requestedTooMany) {

You requested more logs than we currently have. Showing the max amount of + >You requested more logs than we currently have. Showing the max amount of {{ latestDeployments.length }}.

} @@ -122,10 +123,11 @@

Deployment log

class="items-center justify-between rounded-lg border border-mauve bg-surface0 p-4 shadow-sm sm:flex" >
{{ deployment.string }} {{ deployment.name }} from + >{{ deployment.string }} {{ deployment.name }} from {{ deployment.node }} to {{ deployment.repo }} @if (deployment.log) { diff --git a/frontend/src/app/deploy-log-full/deploy-log-full.component.ts b/frontend/src/app/deploy-log-full/deploy-log-full.component.ts index c565c50f..1826ba5d 100644 --- a/frontend/src/app/deploy-log-full/deploy-log-full.component.ts +++ b/frontend/src/app/deploy-log-full/deploy-log-full.component.ts @@ -2,11 +2,12 @@ import { CACHE_TELEGRAM_TTL, type DeploymentList, DeploymentType, + generateRepoUrl, getDeployments, parseDeployments, - startShortPolling, + startShortPolling } from "@./shared-lib" -import { type AfterViewInit, Component } from "@angular/core" +import { type AfterViewInit, ChangeDetectorRef, Component } from "@angular/core" import { FormsModule } from "@angular/forms" import { RouterLink } from "@angular/router" @@ -15,7 +16,7 @@ import { RouterLink } from "@angular/router" standalone: true, imports: [FormsModule, RouterLink], templateUrl: "./deploy-log-full.component.html", - styleUrl: "./deploy-log-full.component.css", + styleUrl: "./deploy-log-full.component.css" }) export class DeployLogFullComponent implements AfterViewInit { latestDeployments: DeploymentList = [] @@ -26,6 +27,9 @@ export class DeployLogFullComponent implements AfterViewInit { searchterm: string | undefined isFiltered = false + constructor(private cdr: ChangeDetectorRef) { + } + async ngAfterViewInit(): Promise { await this.updateLogAmount(50) void this.showDeployments() @@ -44,12 +48,13 @@ export class DeployLogFullComponent implements AfterViewInit { async updateLogAmount(amount: number): Promise { this.latestDeployments = parseDeployments( await getDeployments(amount, this.currentType), - this.currentType, + this.currentType ) this.requestedTooMany = this.latestDeployments.length < amount // Parse the strings for the UI and write them to the list this.constructStrings() + this.cdr.detectChanges() } /** @@ -93,6 +98,9 @@ export class DeployLogFullComponent implements AfterViewInit { this.latestDeployments[index].string = `Unknown status for` break } + + // Add source URL + this.latestDeployments[index].sourceUrl = generateRepoUrl(this.latestDeployments[index]) } } diff --git a/frontend/src/app/deploy-log/deploy-log.component.html b/frontend/src/app/deploy-log/deploy-log.component.html index 1394f2ca..4f23d4b3 100644 --- a/frontend/src/app/deploy-log/deploy-log.component.html +++ b/frontend/src/app/deploy-log/deploy-log.component.html @@ -1,5 +1,6 @@
    +> +
    1. @for (deployment of latestDeployments; track deployment) {
    2. @@ -7,13 +8,14 @@ class="items-center justify-between rounded-lg border border-mauve bg-surface0 p-4 shadow-sm sm:flex" >
      Deployed {{ deployment.name }} from + >Deployed {{ deployment.name }} from {{ deployment.node }} to - {{ deployment.repo }}
      + {{ deployment.repo }} +
} diff --git a/frontend/src/app/deploy-log/deploy-log.component.ts b/frontend/src/app/deploy-log/deploy-log.component.ts index 0b76fada..c4b89285 100644 --- a/frontend/src/app/deploy-log/deploy-log.component.ts +++ b/frontend/src/app/deploy-log/deploy-log.component.ts @@ -2,9 +2,10 @@ import { CACHE_TELEGRAM_TTL, type DeploymentList, DeploymentType, + generateRepoUrl, getDeployments, parseDeployments, - startShortPolling, + startShortPolling } from "@./shared-lib" import { type AfterViewInit, Component } from "@angular/core" import { FormsModule } from "@angular/forms" @@ -41,6 +42,9 @@ export class DeployLogComponent implements AfterViewInit { DeploymentType.SUCCESS, ) if (newList[0].date !== this.latestDeployments[0].date) { + for (const deployment of newList) { + deployment.sourceUrl = generateRepoUrl(deployment) + } this.latestDeployments = newList } } diff --git a/shared-lib/src/lib/functions.ts b/shared-lib/src/lib/functions.ts index 848f142a..d32f9c91 100644 --- a/shared-lib/src/lib/functions.ts +++ b/shared-lib/src/lib/functions.ts @@ -3,12 +3,15 @@ import { type CatppuccinFlavor, flavors } from "@catppuccin/palette" import { Axios } from "axios" import TimeAgo from "javascript-time-ago" import { + CAUR_REPO_URL, + CAUR_REPO_URL_GARUDA, CAUR_TG_API_URL, type CountNameObject, + Deployment, type DeploymentList, DeploymentType, type TgMessageList, - type UserAgentList, + type UserAgentList } from "./types" /** @@ -25,7 +28,7 @@ export function parseOutput(input: string): any[] { if (!isNaN(count)) { returningArray.push({ name: name ?? "Unknown", - count, + count }) } } @@ -46,7 +49,7 @@ export function getNow(): string { */ export function checkIfMobile() { return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( - navigator.userAgent, + navigator.userAgent ) } @@ -58,7 +61,7 @@ export function checkIfMobile() { */ export function parseDeployments( messages: TgMessageList, - type: DeploymentType, + type: DeploymentType ): DeploymentList { const timeAgo = new TimeAgo("en-US") const deploymentList: DeploymentList = [] @@ -78,7 +81,7 @@ export function parseDeployments( const date = timeAgo.format( Number.parseInt(message.date) * 1000, - "round", + "round" ) if ( @@ -86,7 +89,7 @@ export function parseDeployments( String(message.content).includes("deployment to") ) { const buildRepo = String( - String(message.content).split("deployment to ")[1], + String(message.content).split("deployment to ")[1] ) node = buildRepo.match(/from\s(.*)/) ? buildRepo.match(/from\s([\w-]*)/)![1] @@ -106,7 +109,7 @@ export function parseDeployments( String(message.content).includes("Failed") ) { const buildRepo = String( - String(message.content).split("Failed deploying to ")[1], + String(message.content).split("Failed deploying to ")[1] ) node = buildRepo.match(/on\s(.*)/) ? buildRepo.match(/on\s([\w-]*)/)![1] @@ -131,7 +134,7 @@ export function parseDeployments( repo: repo, type: deploymentType, log: log ? log.split(":")[1] : undefined, - node: node, + node: node }) } return deploymentList @@ -143,11 +146,11 @@ export function parseDeployments( */ export async function getDeployments( amount: number, - type: DeploymentType, + type: DeploymentType ): Promise { const axios = new Axios({ baseURL: CAUR_TG_API_URL, - timeout: 1000, + timeout: 1000 }) let requestString @@ -212,7 +215,21 @@ export function loadTheme(theme: string, renderer: Renderer2, el: ElementRef) { renderer.setStyle( el.nativeElement.ownerDocument.body, "backgroundColor", - flavorColor, + flavorColor ) return theme } + +/** + * Generate the URL for the repository. + * @param deployment The deployment to generate the URL for. + * @returns The URL for the repository, in which the PKGBUILD is located. + */ +export function generateRepoUrl(deployment: Deployment): string | undefined { + if (deployment.repo === "chaotic-aur") { + return deployment.sourceUrl = `${CAUR_REPO_URL}${deployment.name}` + } else if (deployment.repo === "garuda") { + return deployment.sourceUrl = `${CAUR_REPO_URL_GARUDA}${deployment.name}` + } + return undefined +}