diff --git a/src/atoms/atoms.ts b/src/atoms/atoms.ts index 47e154ea..3afa59de 100644 --- a/src/atoms/atoms.ts +++ b/src/atoms/atoms.ts @@ -2,7 +2,7 @@ import { BestMoves, EngineOptions, GoMode } from "@/bindings"; import { Card, buildFromTree } from "@/components/files/opening"; import { LocalOptions } from "@/components/panels/database/DatabasePanel"; import { DatabaseInfo } from "@/utils/db"; -import { LocalEngine } from "@/utils/engines"; +import { Engine } from "@/utils/engines"; import { LichessGamesOptions, MasterGamesOptions, @@ -45,13 +45,7 @@ const fileStorage: AsyncStringStorage = { await removeFile(key, options); }, }; - -export const remoteEnabledAtom = atomWithStorage("remote-enabled", { - lichess: false, - chessdb: false, -}); - -export const enginesAtom = atomWithStorage( +export const enginesAtom = atomWithStorage( "engines/engines.json", [], createJSONStorage(() => fileStorage) diff --git a/src/components/boards/BoardGame.tsx b/src/components/boards/BoardGame.tsx index ce47a236..a61662b7 100644 --- a/src/components/boards/BoardGame.tsx +++ b/src/components/boards/BoardGame.tsx @@ -61,7 +61,9 @@ function EnginesSelect({ engine: LocalEngine | null; setEngine: (engine: LocalEngine | null) => void; }) { - const engines = useAtomValue(enginesAtom); + const engines = useAtomValue(enginesAtom).filter( + (e): e is LocalEngine => e.type === "local" + ); useEffect(() => { if (engines.length > 0 && engine === null) { diff --git a/src/components/common/ProgressButton.css.ts b/src/components/common/ProgressButton.css.ts index 3f66f085..63d24792 100644 --- a/src/components/common/ProgressButton.css.ts +++ b/src/components/common/ProgressButton.css.ts @@ -1,13 +1,6 @@ import { vars } from "@/styles/theme"; import { style } from "@vanilla-extract/css"; -export const button = style({ - position: "relative", - transition: "background-color 150ms ease", - backgroundColor: vars.colors.gray[7], - color: vars.colors.gray[5], -}); - export const finished = style({ backgroundColor: vars.colors.green[7], color: vars.colors.gray[2], @@ -15,10 +8,6 @@ export const finished = style({ export const progress = style({ position: "absolute", - bottom: -1, - right: -1, - left: -1, - top: -1, height: "auto", backgroundColor: "transparent", zIndex: 0, diff --git a/src/components/common/ProgressButton.tsx b/src/components/common/ProgressButton.tsx index f184b2a8..11dbed22 100644 --- a/src/components/common/ProgressButton.tsx +++ b/src/components/common/ProgressButton.tsx @@ -73,21 +73,30 @@ function ProgressButton({ const theme = useMantineTheme(); return ( - + <> + + ); } diff --git a/src/components/databases/AddDatabase.tsx b/src/components/databases/AddDatabase.tsx index 51d33529..1b65c41c 100644 --- a/src/components/databases/AddDatabase.tsx +++ b/src/components/databases/AddDatabase.tsx @@ -197,7 +197,7 @@ function DatabaseCard({ key={database.title} > - + DATABASE diff --git a/src/components/engines/AddEngine.tsx b/src/components/engines/AddEngine.tsx index ef05facb..693e8b1b 100644 --- a/src/components/engines/AddEngine.tsx +++ b/src/components/engines/AddEngine.tsx @@ -1,6 +1,7 @@ import { Alert, Box, + Button, Center, Group, Image, @@ -17,7 +18,7 @@ import { IconAlertCircle, IconDatabase, IconTrophy } from "@tabler/icons-react"; import { platform } from "@tauri-apps/api/os"; import { appDataDir, join, resolve } from "@tauri-apps/api/path"; import { useCallback, useState } from "react"; -import { LocalEngine, useDefaultEngines } from "@/utils/engines"; +import { LocalEngine, RemoteEngine, useDefaultEngines } from "@/utils/engines"; import { formatBytes } from "@/utils/format"; import { invoke } from "@/utils/invoke"; import ProgressButton from "../common/ProgressButton"; @@ -34,7 +35,11 @@ function AddEngine({ opened: boolean; setOpened: (opened: boolean) => void; }) { - const [engines, setEngines] = useAtom(enginesAtom); + const [allEngines, setEngines] = useAtom(enginesAtom); + const engines = allEngines.filter( + (e): e is LocalEngine => e.type === "local" + ); + const { data: os } = useSWR("os", async () => { const p = await platform(); const os = match(p) @@ -51,6 +56,7 @@ function AddEngine({ const form = useForm({ initialValues: { + type: "local", version: "", name: "", path: "", @@ -74,6 +80,7 @@ function AddEngine({ Web + Cloud Eval Local @@ -105,6 +112,24 @@ function AddEngine({ + + + + + + + + + + ENGINE + + {engine.name} + + {engine.url} + + + + + + ); +} + function EngineCard({ engine, engineId, @@ -154,6 +211,7 @@ function EngineCard({ ...(await prev), { ...engine, + type: "local", path: enginePath, }, ]); @@ -169,7 +227,7 @@ function EngineCard({ {engine.name} )} - + ENGINE diff --git a/src/components/engines/EnginesPage.tsx b/src/components/engines/EnginesPage.tsx index 92872fee..69f8ad39 100644 --- a/src/components/engines/EnginesPage.tsx +++ b/src/components/engines/EnginesPage.tsx @@ -10,9 +10,15 @@ import { Text, Title, } from "@mantine/core"; -import { IconEdit, IconPlus, IconRobot, IconX } from "@tabler/icons-react"; +import { + IconCloud, + IconEdit, + IconPlus, + IconRobot, + IconX, +} from "@tabler/icons-react"; import { useEffect, useState } from "react"; -import { LocalEngine } from "@/utils/engines"; +import { Engine } from "@/utils/engines"; import OpenFolderButton from "../common/OpenFolderButton"; import AddEngine from "./AddEngine"; import { useToggle } from "@mantine/hooks"; @@ -34,18 +40,21 @@ export default function EnginesPage() { Your Engines - + Engine Elo - Actions + + Actions + - {engines && - engines.map((item) => )} + {engines.map((item) => ( + + ))}