diff --git a/bun.lockb b/bun.lockb index edf2874..131c0d1 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 96a256b..a2eef24 100644 --- a/package.json +++ b/package.json @@ -13,68 +13,68 @@ "preview": "vite preview" }, "dependencies": { - "@hookform/resolvers": "^3.9.1", - "@radix-ui/react-alert-dialog": "^1.1.2", - "@radix-ui/react-avatar": "^1.1.1", - "@radix-ui/react-checkbox": "^1.1.2", - "@radix-ui/react-dialog": "^1.1.2", - "@radix-ui/react-dropdown-menu": "^2.1.2", - "@radix-ui/react-label": "^2.1.0", - "@radix-ui/react-navigation-menu": "^1.2.1", - "@radix-ui/react-popover": "^1.1.2", - "@radix-ui/react-scroll-area": "^1.2.1", - "@radix-ui/react-select": "^2.1.2", - "@radix-ui/react-separator": "^1.1.0", + "@hookform/resolvers": "^3.10.0", + "@radix-ui/react-alert-dialog": "^1.1.5", + "@radix-ui/react-avatar": "^1.1.2", + "@radix-ui/react-checkbox": "^1.1.3", + "@radix-ui/react-dialog": "^1.1.5", + "@radix-ui/react-dropdown-menu": "^2.1.5", + "@radix-ui/react-label": "^2.1.1", + "@radix-ui/react-navigation-menu": "^1.2.4", + "@radix-ui/react-popover": "^1.1.5", + "@radix-ui/react-scroll-area": "^1.2.2", + "@radix-ui/react-select": "^2.1.5", + "@radix-ui/react-separator": "^1.1.1", "@radix-ui/react-slot": "^1.1.1", - "@radix-ui/react-tabs": "^1.1.1", - "@tanstack/react-table": "^8.20.5", - "@trivago/prettier-plugin-sort-imports": "^5.2.0", + "@radix-ui/react-tabs": "^1.1.2", + "@tanstack/react-table": "^8.20.6", + "@trivago/prettier-plugin-sort-imports": "^5.2.2", "@types/luxon": "^3.4.2", "@xterm/addon-attach": "^0.11.0", "@xterm/addon-fit": "^0.10.0", "@xterm/xterm": "^5.5.0", - "class-variance-authority": "^0.7.0", + "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", - "cmdk": "^1.0.0", + "cmdk": "^1.0.4", "copy-to-clipboard": "^3.3.3", - "framer-motion": "^11.14.1", - "i18next": "^24.0.2", - "i18next-browser-languagedetector": "^8.0.0", + "framer-motion": "^11.18.2", + "i18next": "^24.2.2", + "i18next-browser-languagedetector": "^8.0.2", "jotai-zustand": "^0.6.0", "lucide-react": "^0.454.0", "luxon": "^3.5.0", "next-themes": "^0.3.0", - "prettier-plugin-tailwindcss": "^0.6.9", - "react": "^18.3.1", - "react-dom": "^18.3.1", - "react-hook-form": "^7.53.1", - "react-i18next": "^15.1.2", - "react-router-dom": "^6.27.0", - "react-virtuoso": "^4.12.0", - "sonner": "^1.6.1", - "swr": "^2.2.5", - "tailwind-merge": "^2.5.4", + "prettier-plugin-tailwindcss": "^0.6.11", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "react-hook-form": "^7.54.2", + "react-i18next": "^15.4.0", + "react-router-dom": "^7.1.5", + "react-virtuoso": "^4.12.3", + "sonner": "^1.7.4", + "swr": "^2.3.0", + "tailwind-merge": "^2.6.0", "tailwindcss-animate": "^1.0.7", - "vaul": "^1.1.1", - "zod": "^3.23.8", - "zustand": "^5.0.1" + "vaul": "^1.1.2", + "zod": "^3.24.1", + "zustand": "^5.0.3" }, "devDependencies": { - "@eslint/js": "^9.13.0", - "@types/node": "^22.8.6", - "@types/react": "^18.3.12", - "@types/react-dom": "^18.3.1", - "@vitejs/plugin-react": "^4.3.3", + "@eslint/js": "^9.19.0", + "@types/node": "^22.13.0", + "@types/react": "^18.3.18", + "@types/react-dom": "^18.3.5", + "@vitejs/plugin-react": "^4.3.4", "autoprefixer": "^10.4.20", - "eslint": "^9.13.0", - "eslint-plugin-react-hooks": "^5.0.0", - "eslint-plugin-react-refresh": "^0.4.14", - "globals": "^15.11.0", - "postcss": "^8.4.47", - "swagger-typescript-api": "^13.0.22", - "tailwindcss": "^3.4.14", - "typescript": "~5.6.2", - "typescript-eslint": "^8.11.0", - "vite": "^5.4.10" + "eslint": "^9.19.0", + "eslint-plugin-react-hooks": "^5.1.0", + "eslint-plugin-react-refresh": "^0.4.18", + "globals": "^15.14.0", + "postcss": "^8.5.1", + "swagger-typescript-api": "^13.0.23", + "tailwindcss": "^3.4.17", + "typescript": "~5.6.3", + "typescript-eslint": "^8.22.0", + "vite": "^6.0.11" } } diff --git a/src/api/server.ts b/src/api/server.ts index 0ff1ec2..fe35fc6 100644 --- a/src/api/server.ts +++ b/src/api/server.ts @@ -1,4 +1,9 @@ -import { ModelForceUpdateResponse, ModelServer, ModelServerForm } from "@/types" +import { + ModelServer, + ModelServerConfigForm, + ModelServerForm, + ModelServerTaskResponse, +} from "@/types" import { FetcherMethod, fetcher } from "./api" @@ -10,8 +15,8 @@ export const deleteServer = async (id: number[]): Promise => { return fetcher(FetcherMethod.POST, "/api/v1/batch-delete/server", id) } -export const forceUpdateServer = async (id: number[]): Promise => { - return fetcher(FetcherMethod.POST, "/api/v1/force-update/server", id) +export const forceUpdateServer = async (id: number[]): Promise => { + return fetcher(FetcherMethod.POST, "/api/v1/force-update/server", id) } export const getServers = async (): Promise => { @@ -19,9 +24,11 @@ export const getServers = async (): Promise => { } export const getServerConfig = async (id: number): Promise => { - return fetcher(FetcherMethod.GET, `/api/v1/server/${id}/config`, null) + return fetcher(FetcherMethod.GET, `/api/v1/server/config/${id}`, null) } -export const setServerConfig = async (id: number, data: string): Promise => { - return fetcher(FetcherMethod.POST, `/api/v1/server/${id}/config`, data) +export const setServerConfig = async ( + data: ModelServerConfigForm, +): Promise => { + return fetcher(FetcherMethod.POST, `/api/v1/server/config`, data) } diff --git a/src/components/server-config-batch.tsx b/src/components/server-config-batch.tsx new file mode 100644 index 0000000..57a2ed6 --- /dev/null +++ b/src/components/server-config-batch.tsx @@ -0,0 +1,104 @@ +import { setServerConfig } from "@/api/server" +import { Button, ButtonProps } from "@/components/ui/button" +import { + Dialog, + DialogClose, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" +import { Input } from "@/components/ui/input" +import { Label } from "@/components/ui/label" +import { ScrollArea } from "@/components/ui/scroll-area" +import { Textarea } from "@/components/ui/textarea" +import { IconButton } from "@/components/xui/icon-button" +import { ModelServerTaskResponse } from "@/types" +import { useState } from "react" +import { useTranslation } from "react-i18next" +import { toast } from "sonner" + +import { Pusher } from "./xui/pusher" + +interface ServerConfigCardBatchProps extends ButtonProps { + sid: number[] +} + +export const ServerConfigCardBatch: React.FC = ({ sid, ...props }) => { + const { t } = useTranslation() + const [data, setData] = useState>({}) + const [open, setOpen] = useState(false) + const [currentKey, setCurrentKey] = useState("") + const [currentVal, setCurrentVal] = useState("") + + const onSubmit = async () => { + let resp: ModelServerTaskResponse = {} + try { + resp = await setServerConfig({ config: JSON.stringify(data), servers: sid }) + } catch (e) { + console.error(e) + toast(t("Error"), { + description: t("Results.UnExpectedError"), + }) + return + } + toast(t("Done"), { + description: + t("Results.ForceUpdate") + + (resp.success?.length ? t(`Success`) + ` [${resp.success.join(",")}]` : "") + + (resp.failure?.length ? t(`Failure`) + ` [${resp.failure.join(",")}]` : "") + + (resp.offline?.length ? t(`Offline`) + ` [${resp.offline.join(",")}]` : ""), + }) + setOpen(false) + } + + return ( + + + + + + +
+ + {t("EditServerConfig")} + + +
+ + { + setCurrentKey(e.target.value) + }} + /> + +