diff --git a/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx b/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx index 34d31015c2..5b2ec67ca7 100644 --- a/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx +++ b/frontends/dashboard/src/pages/dataset/PublicPageSettings.tsx @@ -9,15 +9,20 @@ import { CopyButton } from "../../components/CopyButton"; import { FaRegularCircleQuestion } from "solid-icons/fa"; import { JsonInput, MultiStringInput, Select, Tooltip } from "shared/ui"; import { createStore } from "solid-js/store"; -import { PublicPageParameters } from "trieve-ts-sdk"; +import { Dataset, PublicPageParameters } from "trieve-ts-sdk"; import { publicPageSearchOptionsSchema } from "../../analytics/utils/schemas/autocomplete"; import { FiExternalLink } from "solid-icons/fi"; import { createQuery } from "@tanstack/solid-query"; import { HeroPatterns } from "./HeroPatterns"; -export interface PublicDatasetOptions {} - -export const defaultCrawlOptions: PublicDatasetOptions = {}; +export type DatasetWithPublicPage = Dataset & { + server_configuration: { + PUBLIC_DATASET?: { + extra_params: PublicPageParameters; + enabled: boolean; + }; + }; +}; export const PublicPageSettings = () => { const apiHost = import.meta.env.VITE_API_HOST as unknown as string; @@ -44,39 +49,27 @@ export const PublicPageSettings = () => { const trieve = useTrieve(); createEffect(() => { - const curExtraParams = { - ...extraParams, - }; - void trieve - .fetch("/api/dataset/{dataset_id}", "get", { + void ( + trieve.fetch<"eject">("/api/dataset/{dataset_id}", "get", { datasetId: datasetId(), - }) - .then((dataset) => { - // @ts-expect-error Property 'PUBLIC_DATASET' does not exist on type '{}'. [2339] - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - setisPublic(dataset.server_configuration?.PUBLIC_DATASET.enabled); - setExtraParams( - // @ts-expect-error Property 'PUBLIC_DATASET' does not exist on type '{}'. [2339] - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument - dataset.server_configuration?.PUBLIC_DATASET.extra_params, - ); - - setHeroPattern(curExtraParams.heroPattern?.heroPatternName || "Blank"); - - setForegroundColor( - curExtraParams.heroPattern?.foregroundColor || "#000000", - ); - - setForegroundOpacity( - (curExtraParams.heroPattern?.foregroundOpacity || 0.5) * 100, - ); - - setBackgroundColor( - curExtraParams.heroPattern?.backgroundColor || "#000000", - ); - - setHasLoaded(true); - }); + }) as Promise + ).then((dataset) => { + setisPublic(!!dataset.server_configuration?.PUBLIC_DATASET?.enabled); + setExtraParams( + dataset?.server_configuration?.PUBLIC_DATASET?.extra_params || {}, + ); + + const params = + dataset?.server_configuration?.PUBLIC_DATASET?.extra_params; + setHeroPattern(params?.heroPattern?.heroPatternName || "Blank"); + setForegroundColor(params?.heroPattern?.foregroundColor || "#000000"); + setForegroundOpacity( + (params?.heroPattern?.foregroundOpacity || 0.5) * 100, + ); + setBackgroundColor(params?.heroPattern?.backgroundColor || "#000000"); + + setHasLoaded(true); + }); }); const crawlSettingsQuery = createQuery(() => ({ @@ -597,53 +590,53 @@ export const PublicPageSettings = () => { options={Object.keys(HeroPatterns)} /> - -
-
+
+ +
+
+ + { + setForegroundColor(e.currentTarget.value); + }} + value={foregroundColor()} + /> +
+
+ + { + setForegroundOpacity(parseInt(e.currentTarget.value)); + }} + value={foregroundOpacity()} + /> +
+
+ { - setForegroundColor(e.currentTarget.value); - }} - value={foregroundColor()} - /> -
-
- - { - setForegroundOpacity(parseInt(e.currentTarget.value)); + setBackgroundColor(e.currentTarget.value); }} - value={foregroundOpacity()} + value={backgroundColor()} /> -
-
- - - { - setBackgroundColor(e.currentTarget.value); - }} - value={backgroundColor()} - /> - -
+
-
-
+ +
Advanced Settings diff --git a/server/src/public/page.html b/server/src/public/page.html index b28aadd1df..f62931bb1a 100644 --- a/server/src/public/page.html +++ b/server/src/public/page.html @@ -18,7 +18,73 @@ - - - {% if logged_in %} - Back To Dashboard - {% else %} + + + +
+
+
+
+
+        
 import { TrieveModalSearch } from 'trieve-search-component';
 import 'trieve-search-component/styles';
 
 const App = () => {
   return (
-    <TrieveModalSearch 
-        {% if params.apiKey -%}
-        apiKey="{{ params.apiKey }}"
-        {% endif -%}
-        {% if params.baseUrl -%}
-        baseUrl="{{ params.baseUrl }}"
-        {% endif -%}
-        {% if params.type -%}
-        type="{{ params.type }}"
-        {% endif -%}
-        {% if params.suggestedQueries -%}
-        suggestedQueries={{ params.suggestedQueries }}
-        {% endif -%}
-        {% if params.analytics -%}
-        analytics={{ params.analytics }}
-        {% endif -%}
-        {% if params.responsive -%}
-        responsive={{ params.responsive }}
-        {% endif -%}
-        {% if params.chat -%}
-        chat="{{ params.chat}}"
-        {% endif -%}
-        {% if params.theme -%}
-        theme="{{ params.theme }}"
-        {% endif -%}
-        {% if params.search_options -%}
-        search_options={{ params.searchOptions }}
-        {% endif -%}
-        {% if params.brandLogoImgSrcUrl -%}
-        brandLogoImgSrcUrl="{{ params.brandLogoImgSrcUrl }}"
-        {% endif -%}
-        {% if params.brandName -%}
-        brandName="{{ params.brandName }}"
-        {% endif -%}
-        {% if params.problemLink -%}
-        problemLink="{{ params.problemLink }}"
-        {% endif -%}
-        {% if params.brandColor -%}
-        brandColor="{{ params.brandColor }}"
-        {% endif -%}
-        {% if params.placeholder -%}
-        placeholder="{{ params.placeholder }}"
-        {% endif -%}
-        {% if params.defaultSearchQueries -%}
-        defaultSearchQueries={{ params.defaultSearchQueries }}
-        {% endif -%}
-        {% if params.defaultAiQuestions -%}
-        defaultAiQuestions={{ params.defaultAiQuestions }}
-        {% endif -%}
-        {% if params.defaultSearchMode -%}
-        defaultSearchMode="{{ params.defaultSearchMode }}"
-        {% endif -%}
-        {% if params.useGroupSearch -%}
-        useGroupSearch={{ params.useGroupSearch }}
-        {% endif -%}
-        {% if params.allowSwitchingModes -%}
-        allowSwitchingModes={{ params.allowSwitchingModes }}
-        {% endif -%}
-        {% if params.defaultCurrency -%}
-        defaultCurrency="{{ params.defaultCurrency }}"
-        {% endif -%}
-        {% if params.currencyPosition -%}
-        currencyPosition="{{ params.currencyPosition }}"
-        {% endif -%}
-        {% if params.debounceMs -%}
-        debounceMs={{ params.debounceMs }}
-        {% endif -%}
-          />
+    <TrieveModalSearch
+      {% if params.apiKey -%}
+      apiKey="{{ params.apiKey }}"
+      {% endif -%}
+      {% if params.baseUrl -%}
+      baseUrl="{{ params.baseUrl }}"
+      {% endif -%}
+      {% if params.type -%}
+      type="{{ params.type }}"
+      {% endif -%}
+      {% if params.suggestedQueries -%}
+      suggestedQueries={{ params.suggestedQueries }}
+      {% endif -%}
+      {% if params.analytics -%}
+      analytics={{ params.analytics }}
+      {% endif -%}
+      {% if params.responsive -%}
+      responsive={{ params.responsive }}
+      {% endif -%}
+      {% if params.chat -%}
+      chat="{{ params.chat}}"
+      {% endif -%}
+      {% if params.theme -%}
+      theme="{{ params.theme }}"
+      {% endif -%}
+      {% if params.search_options -%}
+      search_options={{ params.searchOptions }}
+      {% endif -%}
+      {% if params.brandLogoImgSrcUrl -%}
+      brandLogoImgSrcUrl="{{ params.brandLogoImgSrcUrl }}"
+      {% endif -%}
+      {% if params.brandName -%}
+      brandName="{{ params.brandName }}"
+      {% endif -%}
+      {% if params.problemLink -%}
+      problemLink="{{ params.problemLink }}"
+      {% endif -%}
+      {% if params.brandColor -%}
+      brandColor="{{ params.brandColor }}"
+      {% endif -%}
+      {% if params.placeholder -%}
+      placeholder="{{ params.placeholder }}"
+      {% endif -%}
+      {% if params.defaultSearchQueries -%}
+      defaultSearchQueries={{ params.defaultSearchQueries }}
+      {% endif -%}
+      {% if params.defaultAiQuestions -%}
+      defaultAiQuestions={{ params.defaultAiQuestions }}
+      {% endif -%}
+      {% if params.defaultSearchMode -%}
+      defaultSearchMode="{{ params.defaultSearchMode }}"
+      {% endif -%}
+      {% if params.useGroupSearch -%}
+      useGroupSearch={{ params.useGroupSearch }}
+      {% endif -%}
+      {% if params.allowSwitchingModes -%}
+      allowSwitchingModes={{ params.allowSwitchingModes }}
+      {% endif -%}
+      {% if params.defaultCurrency -%}
+      defaultCurrency="{{ params.defaultCurrency }}"
+      {% endif -%}
+      {% if params.currencyPosition -%}
+      currencyPosition="{{ params.currencyPosition }}"
+      {% endif -%}
+      {% if params.debounceMs -%}
+      debounceMs={{ params.debounceMs }}
+      {% endif -%}
+/>
   );
 }
-      
-    
-
+
+ + +
+ {% if logged_in %} + Back To Dashboard + {% endif %}