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" PAGE_SPA = "page-spa"
PREFIX = "prefix" PREFIX = "prefix"
HOST = "host" HOST = "host"
DOMAIN = "domain"
ANY = "any" ANY = "any"

View File

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

View File

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

View File

@ -31,7 +31,7 @@ const sortableFieldLabels = {
}; };
function isRunning(crawl: Crawl) { 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> <div>
<div <div
class="whitespace-nowrap mb-1 capitalize${crawl.state === "running" class="whitespace-nowrap mb-1 capitalize${isRunning(crawl)
? " motion-safe:animate-pulse" ? " motion-safe:animate-pulse"
: ""}" : ""}"
> >

View File

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