From d32428134a52a54623c9d9a18a411916cbe07865 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Mon, 16 Jan 2023 19:19:42 -0800 Subject: [PATCH] Crawl config frontend fixes (#482) * fix current time limit (#480) * fix browser profile name not shown (#474) * fix finish setup button label (#473) * fix paginated exclusion, border and page size (#475) --- .../src/components/queue-exclusion-table.ts | 24 ++++++++++++++----- .../src/pages/archive/crawl-config-editor.ts | 24 ++++++++++++++----- frontend/src/pages/archive/types.ts | 4 ++-- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/queue-exclusion-table.ts b/frontend/src/components/queue-exclusion-table.ts index 9c48c69e..e323829d 100644 --- a/frontend/src/components/queue-exclusion-table.ts +++ b/frontend/src/components/queue-exclusion-table.ts @@ -75,9 +75,15 @@ export class QueueExclusionTable extends LiteElement { } willUpdate(changedProperties: Map) { - if (changedProperties.has("exclusions") && this.exclusions) { + if (changedProperties.get("exclusions") && this.exclusions) { + if ( + changedProperties.get("exclusions").toString() === + this.exclusions.toString() + ) { + // Check list equality + return; + } this.exclusionToRemove = undefined; - const prevVal = changedProperties.get("exclusions"); if (prevVal) { const prevTotal = prevVal.length; @@ -88,9 +94,14 @@ export class QueueExclusionTable extends LiteElement { this.page = lastPage; } } - this.updatePageResults(); - } else if (changedProperties.has("page")) { + } else if (changedProperties.get("page") && this.page) { + this.updatePageResults(); + } + } + + firstUpdated() { + if (this.exclusions) { this.updatePageResults(); } } @@ -167,11 +178,12 @@ export class QueueExclusionTable extends LiteElement { private renderItem = ( exclusion: Exclusion, - index: number, + pageIndex: number, arr: Exclusion[] ) => { + const index = (this.page - 1) * this.pageSize + pageIndex; const [typeColClass, valueColClass, actionColClass] = - this.getColumnClassNames(index + 1, arr.length); + this.getColumnClassNames(pageIndex + 1, arr.length); return html` - ${this.formState.runNow + ${this.formState.scheduleType === "now" || + this.formState.runNow ? msg("Save & Run Crawl") : msg("Save & Schedule Crawl")} ` @@ -743,7 +747,7 @@ https://example.com/path`} ${this.renderFormCol(html` @@ -1062,7 +1067,7 @@ https://example.net`} type="number" label=${msg("Page Time Limit")} placeholder=${msg("Unlimited")} - value=${ifDefined(this.formState.pageTimeoutMinutes || undefined)} + value=${ifDefined(this.formState.pageTimeoutMinutes ?? undefined)} > ${msg("minutes")} @@ -1278,11 +1283,18 @@ https://example.net`} } private renderConfirmSettings = () => { - const crawlConfig = this.parseConfig(); return html`
- - + ${when(this.progressState.activeTab === "confirmSettings", () => { + // Prevent parsing and rendering tab when not visible + const crawlConfig = this.parseConfig(); + const profileName = this.formState.browserProfile?.name; + + return html` + `; + })}
${when(this.formHasError, () => diff --git a/frontend/src/pages/archive/types.ts b/frontend/src/pages/archive/types.ts index a4c7e020..461b8e2d 100644 --- a/frontend/src/pages/archive/types.ts +++ b/frontend/src/pages/archive/types.ts @@ -60,13 +60,13 @@ export type CrawlConfigParams = { scale: number; profileid: string | null; config: SeedConfig; - crawlTimeout: number | null; + crawlTimeout?: number | null; tags?: string[]; }; export type InitialCrawlConfig = Pick< CrawlConfigParams, - "name" | "profileid" | "schedule" | "tags" + "name" | "profileid" | "schedule" | "tags" | "crawlTimeout" > & { jobType?: JobType; config: Pick<