Show last crawl state in UI (#192)

* update crawl list status

* show on detail page
This commit is contained in:
sua yoo 2022-03-10 23:25:42 -08:00 committed by GitHub
parent 9c99d67b1d
commit 4190e40964
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 17 deletions

View File

@ -792,13 +792,21 @@ export class CrawlTemplatesDetail extends LiteElement {
class="flex items-center justify-between border border-zinc-100 rounded p-1 mt-1" class="flex items-center justify-between border border-zinc-100 rounded p-1 mt-1"
> >
${this.crawlTemplate?.lastCrawlId ${this.crawlTemplate?.lastCrawlId
? html`<a ? html`
class="text-primary font-medium hover:underline text-sm p-1" <span>
href=${`/archives/${this.archiveId}/crawls/crawl/${this.crawlTemplate.lastCrawlId}#watch`} <sl-icon
@click=${this.navLink} class="inline-block align-middle mr-1"
>${msg("View crawl")}</a name=${this.crawlTemplate.lastCrawlState === "complete"
> ? "check-circle-fill"
: this.crawlTemplate.lastCrawlState === "failed"
? "x-circle-fill"
: "exclamation-circle-fill"}
></sl-icon>
<span class="inline-block align-middle capitalize">
${this.crawlTemplate.lastCrawlState.replace(/_/g, " ")}
</span>
<sl-format-date <sl-format-date
class="inline-block align-middle text-sm text-neutral-500"
date=${ date=${
`${this.crawlTemplate.lastCrawlTime}Z` /** Z for UTC */ `${this.crawlTemplate.lastCrawlTime}Z` /** Z for UTC */
} }
@ -808,7 +816,15 @@ export class CrawlTemplatesDetail extends LiteElement {
hour="numeric" hour="numeric"
minute="numeric" minute="numeric"
time-zone-name="short" time-zone-name="short"
></sl-format-date>` ></sl-format-date>
</span>
<a
class="text-primary font-medium hover:underline text-sm p-1"
href=${`/archives/${this.archiveId}/crawls/crawl/${this.crawlTemplate.lastCrawlId}#watch`}
@click=${this.navLink}
>${msg("View crawl")}</a
>
`
: html`<span class="text-0-400 text-sm p-1" : html`<span class="text-0-400 text-sm p-1"
>${msg("None")}</span >${msg("None")}</span
>`} >`}

View File

@ -147,7 +147,15 @@ export class CrawlTemplatesList extends LiteElement {
</div> </div>
<div> <div>
${t.crawlCount ${t.crawlCount
? html`<sl-tooltip content=${msg("Last complete crawl")}> ? html`<sl-tooltip>
<span slot="content" class="capitalize">
${msg(
str`Last Crawl: ${t.lastCrawlState.replace(
/_/g,
" "
)}`
)}
</span>
<a <a
class="font-medium hover:underline" class="font-medium hover:underline"
href=${`/archives/${this.archiveId}/crawls/crawl/${t.lastCrawlId}`} href=${`/archives/${this.archiveId}/crawls/crawl/${t.lastCrawlId}`}
@ -157,11 +165,18 @@ export class CrawlTemplatesList extends LiteElement {
}} }}
> >
<sl-icon <sl-icon
class="inline-block align-middle mr-1 text-purple-400" class="inline-block align-middle mr-1 ${t.lastCrawlState ===
name="check-circle-fill" "failed"
? "text-neutral-400"
: "text-purple-400"}"
name=${t.lastCrawlState === "complete"
? "check-circle-fill"
: t.lastCrawlState === "failed"
? "x-circle-fill"
: "exclamation-circle-fill"}
></sl-icon ></sl-icon
><sl-format-date ><sl-format-date
class="inline-block align-middle text-0-600" class="inline-block align-middle text-neutral-600"
date=${`${t.lastCrawlTime}Z` /** Z for UTC */} date=${`${t.lastCrawlTime}Z` /** Z for UTC */}
month="2-digit" month="2-digit"
day="2-digit" day="2-digit"

View File

@ -1,3 +1,10 @@
type CrawlState =
| "running"
| "complete"
| "failed"
| "partial_complete"
| "timed_out";
export type Crawl = { export type Crawl = {
id: string; id: string;
userid: string; userid: string;
@ -8,7 +15,7 @@ export type Crawl = {
manual: boolean; manual: boolean;
started: string; // UTC ISO date started: string; // UTC ISO date
finished?: string; // UTC ISO date finished?: string; // UTC ISO date
state: string; // "running" | "complete" | "failed" | "partial_complete" state: CrawlState;
scale: number; scale: number;
stats: { done: string; found: string } | null; stats: { done: string; found: string } | null;
resources?: { name: string; path: string; hash: string; size: number }[]; resources?: { name: string; path: string; hash: string; size: number }[];
@ -38,6 +45,7 @@ export type CrawlTemplate = {
crawlCount: number; crawlCount: number;
lastCrawlId: string; lastCrawlId: string;
lastCrawlTime: string; lastCrawlTime: string;
lastCrawlState: CrawlState;
currCrawlId: string; currCrawlId: string;
newId: string | null; newId: string | null;
oldId: string | null; oldId: string | null;