minor frontend-tweaks: (#196)

* frontend-tweaks:
- treat 'starting' state same as 'running'
- default to no schedule instead of weekly for default
- add 'Domain' scopeType

* backend: also allow 'domain' as a scopeType
This commit is contained in:
Ilya Kreymer 2022-03-15 21:19:23 -07:00 committed by GitHub
parent 8863776c54
commit 9e45dc35d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 9 deletions

View File

@ -27,6 +27,7 @@ class ScopeType(str, Enum):
PAGE_SPA = "page-spa"
PREFIX = "prefix"
HOST = "host"
DOMAIN = "domain"
ANY = "any"

View File

@ -60,7 +60,7 @@ export class CrawlDetail extends LiteElement {
private get isRunning(): boolean | null {
if (!this.crawl) return null;
return this.crawl.state === "running";
return this.crawl.state === "running" || this.crawl.state === "starting";
}
async firstUpdated() {
@ -87,7 +87,7 @@ export class CrawlDetail extends LiteElement {
switch (this.sectionName) {
case "watch": {
if (this.crawl) {
if (this.crawl.state === "running") {
if (this.isRunning) {
sectionContent = this.renderWatch();
} else {
sectionContent = this.renderReplay();
@ -408,8 +408,7 @@ export class CrawlDetail extends LiteElement {
</header>
${this.crawl
? html`
<div id="screencast-crawl">
? html` <div id="screencast-crawl">
<btrix-screencast
authToken=${authToken}
archiveId=${this.archiveId!}
@ -422,7 +421,7 @@ export class CrawlDetail extends LiteElement {
}
private renderReplay() {
const isRunning = this.crawl?.state === "running";
const isRunning = this.isRunning;
const bearer = this.authState?.headers?.Authorization?.split(" ", 2)[1];
@ -652,7 +651,7 @@ export class CrawlDetail extends LiteElement {
try {
this.crawl = await this.getCrawl();
if (this.crawl.state === "running") {
if (this.isRunning) {
// Start timer for next poll
this.timerId = window.setTimeout(() => {
this.fetchCrawl();

View File

@ -963,6 +963,7 @@ export class CrawlTemplatesDetail extends LiteElement {
<sl-menu-item value="page-spa">Page SPA</sl-menu-item>
<sl-menu-item value="prefix">Prefix</sl-menu-item>
<sl-menu-item value="host">Host</sl-menu-item>
<sl-menu-item value="domain">Domain</sl-menu-item>
<sl-menu-item value="any">Any</sl-menu-item>
</sl-select>
<sl-checkbox

View File

@ -61,7 +61,7 @@ export class CrawlTemplatesNew extends LiteElement {
private isRunNow: boolean = initialValues.runNow;
@state()
private scheduleInterval: "" | "daily" | "weekly" | "monthly" = "weekly";
private scheduleInterval: "" | "daily" | "weekly" | "monthly" = "";
/** Schedule local time */
@state()
@ -408,6 +408,7 @@ export class CrawlTemplatesNew extends LiteElement {
<sl-menu-item value="page-spa">Page SPA</sl-menu-item>
<sl-menu-item value="prefix">Prefix</sl-menu-item>
<sl-menu-item value="host">Host</sl-menu-item>
<sl-menu-item value="domain">Domain</sl-menu-item>
<sl-menu-item value="any">Any</sl-menu-item>
</sl-select>

View File

@ -31,7 +31,7 @@ const sortableFieldLabels = {
};
function isRunning(crawl: Crawl) {
return crawl.state === "running";
return crawl.state === "running" || crawl.state === "starting";
}
/**
@ -284,7 +284,7 @@ export class CrawlsList extends LiteElement {
</div>
<div>
<div
class="whitespace-nowrap mb-1 capitalize${crawl.state === "running"
class="whitespace-nowrap mb-1 capitalize${isRunning(crawl)
? " motion-safe:animate-pulse"
: ""}"
>

View File

@ -1,4 +1,5 @@
type CrawlState =
| "starting"
| "running"
| "complete"
| "failed"