frontend crawl stopping improvements (#836) (#838)

* frontend crawl stopping improvements (#836)
- support new backend 'stopping' property
- for now, keep 'stopping' indicator state when crawl is running but stopping set to true
This commit is contained in:
Ilya Kreymer 2023-05-08 23:52:49 -07:00 committed by GitHub
parent 2cae065c46
commit 82b21b6813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 5 deletions

View File

@ -15,6 +15,9 @@ export class CrawlStatus extends LitElement {
@property({ type: Boolean }) @property({ type: Boolean })
hideLabel = false; hideLabel = false;
@property({ type: Boolean })
stopping = false;
static styles = [ static styles = [
animatePulse, animatePulse,
css` css`
@ -173,7 +176,8 @@ export class CrawlStatus extends LitElement {
} }
render() { render() {
const { icon, label } = CrawlStatus.getContent(this.state); const state = this.stopping && this.state === "running" ? "stopping" : this.state;
const { icon, label } = CrawlStatus.getContent(state);
if (this.hideLabel) { if (this.hideLabel) {
return html`<div class="icon-only"> return html`<div class="icon-only">
<sl-tooltip content=${label} <sl-tooltip content=${label}

View File

@ -297,6 +297,7 @@ export class WorkflowListItem extends LitElement {
state=${workflow.currCrawlState || state=${workflow.currCrawlState ||
workflow.lastCrawlState || workflow.lastCrawlState ||
msg("No Crawls Yet")} msg("No Crawls Yet")}
?stopping=${workflow.currCrawlStopping}
></btrix-crawl-status> ></btrix-crawl-status>
` `
)} )}

View File

@ -398,7 +398,7 @@ export class WorkflowDetail extends LiteElement {
@click=${() => this.stop()} @click=${() => this.stop()}
?disabled=${!this.workflow?.currCrawlId || ?disabled=${!this.workflow?.currCrawlId ||
this.isCancelingOrStoppingCrawl || this.isCancelingOrStoppingCrawl ||
this.workflow?.currCrawlState === "stopping"} this.workflow?.currCrawlStopping}
> >
<sl-icon name="dash-circle" slot="prefix"></sl-icon> <sl-icon name="dash-circle" slot="prefix"></sl-icon>
<span>${msg("Stop")}</span> <span>${msg("Stop")}</span>
@ -480,7 +480,7 @@ export class WorkflowDetail extends LiteElement {
() => html` () => html`
<sl-menu-item <sl-menu-item
@click=${() => this.stop()} @click=${() => this.stop()}
?disabled=${workflow.currCrawlState === "stopping" || ?disabled=${workflow.currCrawlStopping ||
this.isCancelingOrStoppingCrawl} this.isCancelingOrStoppingCrawl}
> >
<sl-icon name="dash-circle" slot="prefix"></sl-icon> <sl-icon name="dash-circle" slot="prefix"></sl-icon>
@ -586,6 +586,7 @@ export class WorkflowDetail extends LiteElement {
state=${this.workflow!.currCrawlState || state=${this.workflow!.currCrawlState ||
this.workflow!.lastCrawlState || this.workflow!.lastCrawlState ||
msg("No Crawls Yet")} msg("No Crawls Yet")}
?stopping=${this.workflow?.currCrawlStopping}
></btrix-crawl-status> ></btrix-crawl-status>
` `
)} )}
@ -796,7 +797,7 @@ export class WorkflowDetail extends LiteElement {
const isStarting = this.workflow.currCrawlState === "starting"; const isStarting = this.workflow.currCrawlState === "starting";
const isWaiting = this.workflow.currCrawlState === "waiting"; const isWaiting = this.workflow.currCrawlState === "waiting";
const isRunning = this.workflow.currCrawlState === "running"; const isRunning = this.workflow.currCrawlState === "running";
const isStopping = this.workflow.currCrawlState === "stopping"; const isStopping = this.workflow.currCrawlStopping;
const authToken = this.authState.headers.Authorization.split(" ")[1]; const authToken = this.authState.headers.Authorization.split(" ")[1];
return html` return html`

View File

@ -361,7 +361,7 @@ export class WorkflowsList extends LiteElement {
() => html` () => html`
<sl-menu-item <sl-menu-item
@click=${() => this.stop(workflow.currCrawlId)} @click=${() => this.stop(workflow.currCrawlId)}
?disabled=${workflow.currCrawlState === "stopping"} ?disabled=${workflow.currCrawlStopping}
> >
<sl-icon name="dash-circle" slot="prefix"></sl-icon> <sl-icon name="dash-circle" slot="prefix"></sl-icon>
${msg("Stop Crawl")} ${msg("Stop Crawl")}

View File

@ -71,6 +71,7 @@ export type Workflow = CrawlConfig & {
currCrawlState: CrawlState | null; currCrawlState: CrawlState | null;
currCrawlStartTime: string | null; currCrawlStartTime: string | null;
currCrawlSize: number | null; currCrawlSize: number | null;
currCrawlStopping: boolean | null;
totalSize: string | null; totalSize: string | null;
inactive: boolean; inactive: boolean;
firstSeed: string; firstSeed: string;
@ -119,4 +120,5 @@ export type Crawl = CrawlConfig & {
notes: string | null; notes: string | null;
firstSeed: string; firstSeed: string;
seedCount: number; seedCount: number;
stopping: boolean;
}; };