From 85c96de88354af863d6a40d2887db8d698261027 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Fri, 5 May 2023 11:30:38 -0700 Subject: [PATCH] Show critical errors in Crawl detail logs (#811) --- frontend/src/components/crawl-logs.ts | 118 +++++++++++ .../components/crawl-pending-exclusions.ts | 32 +-- frontend/src/components/crawl-queue.ts | 43 ++-- frontend/src/components/index.ts | 13 +- frontend/src/components/numbered-list.ts | 191 +++++++++++------- frontend/src/components/pagination.ts | 1 + frontend/src/pages/org/crawl-detail.ts | 148 +++++++++++--- frontend/src/utils/css.ts | 3 +- 8 files changed, 400 insertions(+), 149 deletions(-) create mode 100644 frontend/src/components/crawl-logs.ts diff --git a/frontend/src/components/crawl-logs.ts b/frontend/src/components/crawl-logs.ts new file mode 100644 index 00000000..bfa21899 --- /dev/null +++ b/frontend/src/components/crawl-logs.ts @@ -0,0 +1,118 @@ +import { LitElement, html, css } from "lit"; +import { property, state } from "lit/decorators.js"; +import { when } from "lit/directives/when.js"; +import { msg, localized, str } from "@lit/localize"; + +import { truncate } from "../utils/css"; +import type { APIPaginatedList } from "../types/api"; + +type CrawlLog = { + timestamp: string; + logLevel: "error"; + details: Record; + context: string; + message: string; +}; + +@localized() +export class CrawlLogs extends LitElement { + static styles = [ + truncate, + css` + btrix-numbered-list { + font-size: var(--sl-font-size-x-small); + } + + .row { + display: grid; + grid-template-columns: 9rem 4rem 14rem 1fr; + line-height: 1.3; + max-width: 800px; + } + + .cell { + padding-left: var(--sl-spacing-x-small); + padding-right: var(--sl-spacing-x-small); + } + + .tag { + display: inline-block; + border-radius: var(--sl-border-radius-small); + padding: var(--sl-spacing-3x-small) var(--sl-spacing-2x-small); + text-transform: capitalize; + /* TODO handle non-errors */ + background-color: var(--danger); + color: var(--sl-color-neutral-0); + } + + footer { + display: flex; + justify-content: center; + margin-top: var(--sl-spacing-large); + margin-bottom: var(--sl-spacing-x-large); + } + + .message { + white-space: pre-wrap; + } + + .url { + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + } + + `, + ]; + + @property({ type: Object }) + logs?: APIPaginatedList; + + render() { + if (!this.logs) return; + return html` + +
+
${msg("Date")}
+
${msg("Level")}
+
${msg("Error Message")}
+
${msg("Page URL")}
+
+
+ ${this.logs.items.map( + (log: CrawlLog, idx) => html` + +
+
+ + +
+
+ ${log.logLevel} +
+
${log.message}
+ +
+
+ ` + )} +
+
+ + +
`; + } +} diff --git a/frontend/src/components/crawl-pending-exclusions.ts b/frontend/src/components/crawl-pending-exclusions.ts index f215ca7a..aee6a976 100644 --- a/frontend/src/components/crawl-pending-exclusions.ts +++ b/frontend/src/components/crawl-pending-exclusions.ts @@ -87,20 +87,24 @@ export class CrawlPendingExclusions extends LiteElement { } return html` - ({ - order: idx + 1 + (this.page - 1) * this.pageSize, - content: html`${url}`, - }))} - aria-live="polite" - style="--link-color: var(--sl-color-danger-600); --link-hover-color: var(--sl-color-danger-400);" - > + + ${this.pageResults.map( + (url, idx) => html` + + ${idx + 1 + (this.page - 1) * this.pageSize}. + ${url} + + ` + )} + `; } } diff --git a/frontend/src/components/crawl-queue.ts b/frontend/src/components/crawl-queue.ts index c65659b9..5d04271a 100644 --- a/frontend/src/components/crawl-queue.ts +++ b/frontend/src/components/crawl-queue.ts @@ -100,29 +100,28 @@ export class CrawlQueue extends LiteElement { if (!this.queue) return; - const excludedURLStyles = [ - "--marker-color: var(--sl-color-danger-500)", - "--link-color: var(--sl-color-danger-500)", - "--link-hover-color: var(--sl-color-danger-400)", - ].join(";"); - return html` - ({ - order: idx + 1, - style: this.queue!.matched.some((v) => v === url) - ? excludedURLStyles - : "", - content: html`${url}`, - }))} - aria-live="polite" - > + + ${this.queue.results.map((url, idx) => { + const isMatch = this.queue!.matched.some((v) => v === url); + return html` + + ${idx + 1}. + ${url} + + `; + })} +