diff --git a/frontend/src/pages/archive/crawl-detail.ts b/frontend/src/pages/archive/crawl-detail.ts index 22588bd5..7d611ee5 100644 --- a/frontend/src/pages/archive/crawl-detail.ts +++ b/frontend/src/pages/archive/crawl-detail.ts @@ -7,8 +7,7 @@ import { RelativeDuration } from "../../components/relative-duration"; import type { AuthState } from "../../utils/AuthService"; import LiteElement, { html } from "../../utils/LiteElement"; import { CopyButton } from "../../components/copy-button"; -import type { Crawl } from "./types"; -import { times } from "lodash"; +import type { Crawl, CrawlTemplate } from "./types"; type SectionName = "overview" | "watch" | "replay" | "files" | "logs"; @@ -42,6 +41,9 @@ export class CrawlDetail extends LiteElement { @state() private crawl?: Crawl; + @state() + private crawlTemplate?: CrawlTemplate; + @state() private sectionName: SectionName = "overview"; @@ -77,20 +79,28 @@ export class CrawlDetail extends LiteElement { return this.crawl.resources.length > 0; } - async firstUpdated() { + firstUpdated() { if (!this.crawlsBaseUrl) { throw new Error("Crawls base URL not defined"); } - this.fetchCrawl(); + this.fetchData(); } updated(changedProperties: Map) { - const prevCrawl = changedProperties.get("crawl"); + const prevId = changedProperties.get("crawlId"); - if (prevCrawl && this.crawl) { - if (prevCrawl.state === "running" && this.crawl.state !== "running") { - this.crawlDone(); + if (prevId && prevId !== this.crawlId) { + // Handle update on URL change, e.g. from re-run + this.stopPollTimer(); + this.fetchData(); + } else { + const prevCrawl = changedProperties.get("crawl"); + + if (prevCrawl && this.crawl) { + if (prevCrawl.state === "running" && this.crawl.state !== "running") { + this.crawlDone(); + } } } } @@ -302,6 +312,28 @@ export class CrawlDetail extends LiteElement { >