diff --git a/frontend/src/index.ts b/frontend/src/index.ts index d81963d8..15f7a92a 100644 --- a/frontend/src/index.ts +++ b/frontend/src/index.ts @@ -6,12 +6,12 @@ import type { SlDialog } from "@shoelace-style/shoelace"; import "tailwindcss/tailwind.css"; import type { ArchiveTab } from "./pages/archive"; -import type { NotifyEvent } from "./utils/LiteElement"; +import type { NotifyEvent, NavigateEvent } from "./utils/LiteElement"; import LiteElement, { html } from "./utils/LiteElement"; import APIRouter from "./utils/APIRouter"; import AuthService from "./utils/AuthService"; import type { LoggedInEvent } from "./utils/AuthService"; -import type { ViewState, NavigateEvent } from "./utils/APIRouter"; +import type { ViewState } from "./utils/APIRouter"; import type { CurrentUser } from "./types/user"; import type { AuthState } from "./utils/AuthService"; import theme from "./theme"; @@ -145,7 +145,7 @@ export class App extends LiteElement { } } - navigate(newViewPath: string) { + navigate(newViewPath: string, state?: object) { if (newViewPath.startsWith("http")) { const url = new URL(newViewPath); newViewPath = `${url.pathname}${url.search}`; @@ -158,6 +158,8 @@ export class App extends LiteElement { this.viewState = this.router.match(newViewPath); } + this.viewState.data = state; + window.history.pushState(this.viewState, "", this.viewState.pathname); } @@ -377,6 +379,7 @@ export class App extends LiteElement { @notify="${this.onNotify}" .authState=${this.authService.authState} .userInfo=${this.userInfo} + .viewStateData=${this.viewState.data} archiveId=${this.viewState.params.id} archiveTab=${this.viewState.params.crawlConfigId ? "crawl-templates" @@ -472,7 +475,7 @@ export class App extends LiteElement { onNavigateTo(event: NavigateEvent) { event.stopPropagation(); - this.navigate(event.detail); + this.navigate(event.detail.url, event.detail.state); } onUserInfoChange(event: CustomEvent>) { diff --git a/frontend/src/pages/archive/crawl-templates-detail.ts b/frontend/src/pages/archive/crawl-templates-detail.ts index 891a9740..2f6860e2 100644 --- a/frontend/src/pages/archive/crawl-templates-detail.ts +++ b/frontend/src/pages/archive/crawl-templates-detail.ts @@ -109,24 +109,24 @@ export class CrawlTemplatesDetail extends LiteElement { ? " border-t" : ""}" role="row" - title=${seed.url} + title=${typeof seed === "string" ? seed : seed.url} >
- ${seed.url} + ${typeof seed === "string" ? seed : seed.url}
${seed.scopeType || + >${(typeof seed !== "string" && seed.scopeType) || this.crawlTemplate?.config.scopeType} ${seed.limit || + >${(typeof seed !== "string" && seed.limit) || this.crawlTemplate?.config.limit} ` @@ -290,22 +290,7 @@ export class CrawlTemplatesDetail extends LiteElement { this.authState! ); - const { config, ...template } = data; - - return { - ...template, - config: { - ...config, - // Normalize seed format - seeds: config.seeds.map((seed) => - typeof seed === "string" - ? { - url: seed, - } - : seed - ), - }, - }; + return data; } private async runNow(): Promise { diff --git a/frontend/src/pages/archive/crawl-templates-list.ts b/frontend/src/pages/archive/crawl-templates-list.ts index 3bd9d5e8..19228536 100644 --- a/frontend/src/pages/archive/crawl-templates-list.ts +++ b/frontend/src/pages/archive/crawl-templates-list.ts @@ -110,9 +110,22 @@ export class CrawlTemplatesList extends LiteElement { style="font-size: 1rem" > -