From 6044486190c2e142bebb093fd3c44e40f32e6885 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Tue, 15 Aug 2023 21:14:32 -0700 Subject: [PATCH] Add button to download error logs (#1080) * add button to download logs * render if logs are present * add icon --- frontend/src/pages/org/crawl-detail.ts | 43 +++++++++++++++++++++----- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/org/crawl-detail.ts b/frontend/src/pages/org/crawl-detail.ts index 1180b853..7bb56105 100644 --- a/frontend/src/pages/org/crawl-detail.ts +++ b/frontend/src/pages/org/crawl-detail.ts @@ -157,6 +157,7 @@ export class CrawlDetail extends LiteElement { } render() { + const authToken = this.authState!.headers.Authorization.split(" ")[1]; let sectionContent: string | TemplateResult = ""; switch (this.sectionName) { @@ -174,7 +175,25 @@ export class CrawlDetail extends LiteElement { ); break; case "logs": - sectionContent = this.renderPanel(msg("Error Logs"), this.renderLogs()); + sectionContent = this.renderPanel( + html` + ${this.renderTitle(msg("Error Logs"))} + ${when( + this.logs?.total, + () => + html` + + ${msg("Download Logs")}` + )} + `, + this.renderLogs() + ); break; case "config": sectionContent = this.renderPanel( @@ -200,7 +219,7 @@ export class CrawlDetail extends LiteElement {
${this.renderPanel( html` - ${msg("Metadata")} + ${this.renderTitle(msg("Metadata"))} ${when( this.isCrawler, () => html` @@ -510,14 +529,22 @@ export class CrawlDetail extends LiteElement { `; } - private renderPanel(title: any, content: any, classes: any = {}) { + private renderTitle(title: string) { + return html`

${title}

`; + } + + private renderPanel( + heading: string | TemplateResult, + content: any, + classes: any = {} + ) { + const headingIsTitle = typeof heading === "string"; return html` -

- ${title} -

+ ${headingIsTitle ? this.renderTitle(heading) : heading} +