Add button to download error logs (#1080)
* add button to download logs * render if logs are present * add icon
This commit is contained in:
parent
270e134359
commit
6044486190
@ -157,6 +157,7 @@ export class CrawlDetail extends LiteElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const authToken = this.authState!.headers.Authorization.split(" ")[1];
|
||||||
let sectionContent: string | TemplateResult = "";
|
let sectionContent: string | TemplateResult = "";
|
||||||
|
|
||||||
switch (this.sectionName) {
|
switch (this.sectionName) {
|
||||||
@ -174,7 +175,25 @@ export class CrawlDetail extends LiteElement {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "logs":
|
case "logs":
|
||||||
sectionContent = this.renderPanel(msg("Error Logs"), this.renderLogs());
|
sectionContent = this.renderPanel(
|
||||||
|
html`
|
||||||
|
${this.renderTitle(msg("Error Logs"))}
|
||||||
|
${when(
|
||||||
|
this.logs?.total,
|
||||||
|
() =>
|
||||||
|
html`<sl-button
|
||||||
|
href=${`/api/orgs/${this.orgId}/crawls/${this.crawlId}/logs?auth_bearer=${authToken}`}
|
||||||
|
download=${`btrix-${this.crawlId}-logs.txt`}
|
||||||
|
size="small"
|
||||||
|
variant="primary"
|
||||||
|
>
|
||||||
|
<sl-icon slot="prefix" name="download"></sl-icon>
|
||||||
|
${msg("Download Logs")}</sl-button
|
||||||
|
>`
|
||||||
|
)}
|
||||||
|
`,
|
||||||
|
this.renderLogs()
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case "config":
|
case "config":
|
||||||
sectionContent = this.renderPanel(
|
sectionContent = this.renderPanel(
|
||||||
@ -200,7 +219,7 @@ export class CrawlDetail extends LiteElement {
|
|||||||
<div class="col-span-1 flex flex-col">
|
<div class="col-span-1 flex flex-col">
|
||||||
${this.renderPanel(
|
${this.renderPanel(
|
||||||
html`
|
html`
|
||||||
${msg("Metadata")}
|
${this.renderTitle(msg("Metadata"))}
|
||||||
${when(
|
${when(
|
||||||
this.isCrawler,
|
this.isCrawler,
|
||||||
() => html`
|
() => html`
|
||||||
@ -510,14 +529,22 @@ export class CrawlDetail extends LiteElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderPanel(title: any, content: any, classes: any = {}) {
|
private renderTitle(title: string) {
|
||||||
|
return html`<h2 class="text-lg font-semibold">${title}</h2>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private renderPanel(
|
||||||
|
heading: string | TemplateResult,
|
||||||
|
content: any,
|
||||||
|
classes: any = {}
|
||||||
|
) {
|
||||||
|
const headingIsTitle = typeof heading === "string";
|
||||||
return html`
|
return html`
|
||||||
<h2
|
<header
|
||||||
id="exclusions"
|
class="flex-0 flex items-center justify-between leading-none h-8 min-h-fit mb-2"
|
||||||
class="flex-0 flex items-center justify-between text-lg font-semibold leading-none h-8 min-h-fit mb-2"
|
|
||||||
>
|
>
|
||||||
${title}
|
${headingIsTitle ? this.renderTitle(heading) : heading}
|
||||||
</h2>
|
</header>
|
||||||
<div
|
<div
|
||||||
class=${classMap({
|
class=${classMap({
|
||||||
"flex-1": true,
|
"flex-1": true,
|
||||||
|
Loading…
Reference in New Issue
Block a user