From 71eec4d915e714529e03f44a88b6862acb6cf6b9 Mon Sep 17 00:00:00 2001 From: sua yoo Date: Mon, 18 Apr 2022 10:36:28 -0700 Subject: [PATCH] Create crawl template with browser profile (#215) --- .../pages/archive/browser-profiles-list.ts | 2 +- .../pages/archive/crawl-templates-detail.ts | 23 ++++ .../src/pages/archive/crawl-templates-new.ts | 130 +++++++++++++++++- frontend/src/pages/archive/types.ts | 2 + 4 files changed, 154 insertions(+), 3 deletions(-) diff --git a/frontend/src/pages/archive/browser-profiles-list.ts b/frontend/src/pages/archive/browser-profiles-list.ts index 448a3fdb..c4f84200 100644 --- a/frontend/src/pages/archive/browser-profiles-list.ts +++ b/frontend/src/pages/archive/browser-profiles-list.ts @@ -3,7 +3,7 @@ import { msg, localized, str } from "@lit/localize"; import type { AuthState } from "../../utils/AuthService"; import LiteElement, { html } from "../../utils/LiteElement"; -import { Profile } from "./types"; +import type { Profile } from "./types"; /** * Usage: diff --git a/frontend/src/pages/archive/crawl-templates-detail.ts b/frontend/src/pages/archive/crawl-templates-detail.ts index 6c39235d..f0564d4d 100644 --- a/frontend/src/pages/archive/crawl-templates-detail.ts +++ b/frontend/src/pages/archive/crawl-templates-detail.ts @@ -587,6 +587,29 @@ export class CrawlTemplatesDetail extends LiteElement { ${this.crawlTemplate?.config.extraHops ? msg("Yes") : msg("No")} +
+
${msg("Browser Profile")}
+ ${this.crawlTemplate + ? html` + ${this.crawlTemplate.profileid + ? html` + + ${this.crawlTemplate.profileName} + ` + : html`${msg("None")}`} + ` + : ""} +
+ ${msg("Advanced Configuration")} diff --git a/frontend/src/pages/archive/crawl-templates-new.ts b/frontend/src/pages/archive/crawl-templates-new.ts index 6a36cbbe..984ab2a9 100644 --- a/frontend/src/pages/archive/crawl-templates-new.ts +++ b/frontend/src/pages/archive/crawl-templates-new.ts @@ -3,11 +3,12 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { msg, localized, str } from "@lit/localize"; import cronParser from "cron-parser"; import { parse as yamlToJson, stringify as jsonToYaml } from "yaml"; +import orderBy from "lodash/fp/orderBy"; import type { AuthState } from "../../utils/AuthService"; import LiteElement, { html } from "../../utils/LiteElement"; import { getLocaleTimeZone } from "../../utils/localization"; -import type { CrawlConfig } from "./types"; +import type { CrawlConfig, Profile } from "./types"; import { getUTCSchedule } from "./utils"; export type NewCrawlTemplate = { @@ -18,6 +19,7 @@ export type NewCrawlTemplate = { crawlTimeout?: number; scale: number; config: CrawlConfig; + profileid: string; }; const initialValues = { @@ -86,6 +88,12 @@ export class CrawlTemplatesNew extends LiteElement { @state() private serverError?: string; + @state() + browserProfiles?: Profile[]; + + @state() + selectedProfile?: Profile; + private get timeZone() { return Intl.DateTimeFormat().resolvedOptions().timeZone; } @@ -138,6 +146,10 @@ export class CrawlTemplatesNew extends LiteElement { super.connectedCallback(); } + protected firstUpdated() { + this.fetchBrowserProfiles(); + } + render() { return html`