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}
` )}
`; } }