From b9a24fa5e2597454c5a5e3041320cd855a878894 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Fri, 17 Mar 2023 21:04:08 -0700 Subject: [PATCH] Combine watch crawl with crawl queue (#710) - crawl queue and watch page are now part of single view - exclusions can be edited via 'Edit Exclusions' popup --- .../components/crawl-pending-exclusions.ts | 29 +-- frontend/src/components/crawl-queue.ts | 2 +- frontend/src/components/exclusion-editor.ts | 26 +-- frontend/src/components/numbered-list.ts | 5 +- frontend/src/components/screencast.ts | 56 ++--- frontend/src/pages/org/crawl-detail.ts | 209 +++++++++++------- 6 files changed, 165 insertions(+), 162 deletions(-) diff --git a/frontend/src/components/crawl-pending-exclusions.ts b/frontend/src/components/crawl-pending-exclusions.ts index b41d448f..39763d5c 100644 --- a/frontend/src/components/crawl-pending-exclusions.ts +++ b/frontend/src/components/crawl-pending-exclusions.ts @@ -24,10 +24,7 @@ export class CrawlPendingExclusions extends LiteElement { private page: number = 1; @state() - private pageSize: number = 20; - - @state() - private isOpen: boolean = false; + private pageSize: number = 10; private get total(): number { return this.matchedURLs?.length || 0; @@ -44,22 +41,10 @@ export class CrawlPendingExclusions extends LiteElement { render() { return html` - (this.isOpen = e.detail.open)} - > - - ${msg("Pending Exclusions")} ${this.renderBadge()} - -
{ - // Prevent toggle when clicking pagination - e.stopPropagation(); - e.preventDefault(); - }} - > - ${this.isOpen && this.total && this.total > this.pageSize + +
+
${msg("Pending Exclusions")} ${this.renderBadge()}
+ ${this.total && this.total > this.pageSize ? html`` : ""}
- ${this.renderContent()} - +
+ ${this.renderContent()} `; } diff --git a/frontend/src/components/crawl-queue.ts b/frontend/src/components/crawl-queue.ts index 359b669c..c65659b9 100644 --- a/frontend/src/components/crawl-queue.ts +++ b/frontend/src/components/crawl-queue.ts @@ -77,7 +77,7 @@ export class CrawlQueue extends LiteElement { render() { return html` ${msg("Crawl Queue")} ${this.renderBadge()}${msg("Queued URLs")} ${this.renderBadge()} ${this.renderContent()} `; diff --git a/frontend/src/components/exclusion-editor.ts b/frontend/src/components/exclusion-editor.ts index fb3d45a6..f014743a 100644 --- a/frontend/src/components/exclusion-editor.ts +++ b/frontend/src/components/exclusion-editor.ts @@ -79,13 +79,17 @@ export class ExclusionEditor extends LiteElement { render() { return html` - ${this.renderTable()} - ${this.isActiveCrawl && this.regex - ? html`
${this.renderPending()}
` - : ""} - ${this.isActiveCrawl - ? html`
${this.renderQueue()}
` - : ""} +
+
${this.renderTable()}
+
+ ${this.isActiveCrawl && this.regex + ? html`
${this.renderPending()}
` + : ""} + ${this.isActiveCrawl + ? html`
${this.renderQueue()}
` + : ""} +
+
`; } @@ -164,9 +168,7 @@ export class ExclusionEditor extends LiteElement { icon: "check2-circle", }); - this.dispatchEvent( - new CustomEvent("on-success") - ); + this.dispatchEvent(new CustomEvent("on-success")); } else { throw data; } @@ -239,9 +241,7 @@ export class ExclusionEditor extends LiteElement { await this.updateComplete; onSuccess(); - this.dispatchEvent( - new CustomEvent("on-success") - ); + this.dispatchEvent(new CustomEvent("on-success")); } else { throw data; } diff --git a/frontend/src/components/numbered-list.ts b/frontend/src/components/numbered-list.ts index 0aeaf782..ee1922e3 100644 --- a/frontend/src/components/numbered-list.ts +++ b/frontend/src/components/numbered-list.ts @@ -48,7 +48,7 @@ export class NumberedList extends LitElement { .item-content { --item-height: 1.5rem; - contain: strict; + contain: paint; contain-intrinsic-height: auto var(--item-height); content-visibility: auto; border-left: var(--sl-panel-border-width) solid @@ -56,7 +56,8 @@ export class NumberedList extends LitElement { border-right: var(--sl-panel-border-width) solid var(--sl-panel-border-color); padding: var(--sl-spacing-2x-small) var(--sl-spacing-x-small); - height: var(--item-height); + line-height: 1; + min-height: var(--item-height); box-sizing: border-box; } diff --git a/frontend/src/components/screencast.ts b/frontend/src/components/screencast.ts index 49629402..68c8e4da 100644 --- a/frontend/src/components/screencast.ts +++ b/frontend/src/components/screencast.ts @@ -53,35 +53,22 @@ export class Screencast extends LitElement { .container { display: grid; - gap: 0.5rem; - } - - .screen-count { - color: var(--sl-color-neutral-400); - font-size: var(--sl-font-size-small); - margin-bottom: var(--sl-spacing-x-small); - } - - .screen-count span, - .screen-count sl-icon { - display: inline-block; - vertical-align: middle; + gap: 1rem; } .screen { - border: 1px solid var(--sl-panel-border-color); - border-radius: var(--sl-border-radius-medium); + border: 1px solid var(--sl-color-neutral-300); + border-radius: var(--sl-border-radius-large); overflow: hidden; } .screen[role="button"] { cursor: pointer; - transition: opacity 0.1s border-color 0.1s; + transition: var(--sl-transition-fast) box-shadow; } .screen[role="button"]:hover { - opacity: 0.8; - border-color: var(--sl-color-neutral-300); + box-shadow: var(--sl-shadow-medium); } figure { @@ -111,7 +98,10 @@ export class Screencast extends LitElement { } .frame { - background-color: var(--sl-color-neutral-50); + display: flex; + align-items: center; + justify-content: center; + background-color: var(--sl-color-sky-50); overflow: hidden; } @@ -123,6 +113,10 @@ export class Screencast extends LitElement { outline: 0; border: 0; } + + sl-spinner { + font-size: 1.75rem; + } `; @property({ type: String }) @@ -190,30 +184,8 @@ export class Screencast extends LitElement { } render() { - const browserWindows = this.browsersCount * this.scale; - return html`
- ${!this.dataList.length - ? html`
- -
` - : html` -
- ${browserWindows > 1 - ? msg(str`Running in ${browserWindows} browser windows`) - : msg(str`Running in 1 browser window`)} - -
- `} -
` - : ""} + : html``}
` )} diff --git a/frontend/src/pages/org/crawl-detail.ts b/frontend/src/pages/org/crawl-detail.ts index a12b9073..4ff78986 100644 --- a/frontend/src/pages/org/crawl-detail.ts +++ b/frontend/src/pages/org/crawl-detail.ts @@ -19,7 +19,7 @@ const SECTIONS = [ "config", "exclusions", ] as const; -type SectionName = typeof SECTIONS[number]; +type SectionName = (typeof SECTIONS)[number]; const POLL_INTERVAL_SECONDS = 10; @@ -61,7 +61,7 @@ export class CrawlDetail extends LiteElement { private isSubmittingUpdate: boolean = false; @state() - private openDialogName?: "scale" | "metadata"; + private openDialogName?: "scale" | "metadata" | "exclusions"; @state() private isDialogVisible: boolean = false; @@ -135,10 +135,23 @@ export class CrawlDetail extends LiteElement { let sectionContent: string | TemplateResult = ""; switch (this.sectionName) { + case "exclusions": case "watch": { if (this.crawl) { + const isRunning = this.crawl.state === "running"; sectionContent = this.renderPanel( - msg("Watch Crawl"), + html`${msg("Watch Crawl")} + { + this.openDialogName = "scale"; + this.isDialogVisible = true; + }} + > + + ${msg("Crawler Instances")} + `, this.renderWatch() ); } else { @@ -163,13 +176,6 @@ export class CrawlDetail extends LiteElement { case "logs": sectionContent = this.renderPanel(msg("Logs"), this.renderLogs()); break; - case "exclusions": - sectionContent = this.renderPanel( - msg("Crawl Exclusions"), - this.renderExclusions() - ); - break; - case "config": sectionContent = this.renderPanel(msg("Config"), this.renderConfig()); break; @@ -182,30 +188,28 @@ export class CrawlDetail extends LiteElement {
${this.renderPanel( html` -
- ${msg("Metadata")} - ${when( - this.isCrawler, - () => html` - - - - ` - )} -
+ ${msg("Metadata")} + ${when( + this.isCrawler, + () => html` + + + + ` + )} `, this.renderMetadata() )} @@ -245,16 +249,6 @@ export class CrawlDetail extends LiteElement { - (this.openDialogName = undefined)} - @sl-show=${() => (this.isDialogVisible = true)} - @sl-after-hide=${() => (this.isDialogVisible = false)} - > - ${this.isDialogVisible ? this.renderEditScale() : ""} - - - { - this.openDialogName = "scale"; - this.isDialogVisible = true; - }} - > - - ${msg("Crawler Instances")} - ${msg("Stop")} @@ -551,7 +529,12 @@ export class CrawlDetail extends LiteElement { private renderPanel(title: any, content: any) { return html` -

${title}

+

+ ${title} +

${content}
`; } @@ -652,33 +635,95 @@ export class CrawlDetail extends LiteElement {
` : ""} - -
- -
` : this.renderInactiveCrawlMessage()} + ${when( + isRunning, + () => html` +
+ +
+ +
${this.renderExclusions()}
+ + (this.openDialogName = undefined)} + @sl-show=${() => (this.isDialogVisible = true)} + @sl-after-hide=${() => (this.isDialogVisible = false)} + > + ${this.isDialogVisible ? this.renderEditScale() : ""} + + ` + )} `; } private renderExclusions() { return html` - +
+

+ ${msg("Crawl URLs")} +

+ { + this.openDialogName = "exclusions"; + this.isDialogVisible = true; + }} + > + + ${msg("Edit Exclusions")} + +
+ + ${when( + this.crawl, + () => html` + + ` + )} + + (this.openDialogName = undefined)} + @sl-show=${() => (this.isDialogVisible = true)} + @sl-after-hide=${() => (this.isDialogVisible = false)} + > + ${this.isDialogVisible + ? html`` + : ""} +
+ (this.openDialogName = undefined)} + >${msg("Done Editing")} +
+
`; }