From 4429c9ddc93098e5188d099b3be1f3f5d87bb37c Mon Sep 17 00:00:00 2001 From: web Date: Tue, 28 Oct 2025 02:10:12 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Add=20server=20installation?= =?UTF-8?q?=20dialog=20and=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 15 ++- apps/admin/app/dashboard/servers/page.tsx | 2 + .../app/dashboard/servers/server-install.tsx | 119 ++++++++++++++++++ apps/admin/locales/cs-CZ/servers.json | 5 + apps/admin/locales/de-DE/servers.json | 5 + apps/admin/locales/en-US/servers.json | 5 + apps/admin/locales/es-ES/servers.json | 5 + apps/admin/locales/es-MX/servers.json | 5 + apps/admin/locales/fa-IR/servers.json | 5 + apps/admin/locales/fi-FI/servers.json | 5 + apps/admin/locales/fr-FR/servers.json | 5 + apps/admin/locales/hi-IN/servers.json | 5 + apps/admin/locales/hu-HU/servers.json | 5 + apps/admin/locales/ja-JP/servers.json | 5 + apps/admin/locales/ko-KR/servers.json | 5 + apps/admin/locales/no-NO/servers.json | 5 + apps/admin/locales/pl-PL/servers.json | 5 + apps/admin/locales/pt-BR/servers.json | 5 + apps/admin/locales/ro-RO/servers.json | 5 + apps/admin/locales/ru-RU/servers.json | 5 + apps/admin/locales/th-TH/servers.json | 5 + apps/admin/locales/tr-TR/servers.json | 5 + apps/admin/locales/uk-UA/servers.json | 5 + apps/admin/locales/vi-VN/servers.json | 5 + apps/admin/locales/zh-CN/servers.json | 8 ++ apps/admin/locales/zh-HK/servers.json | 5 + 26 files changed, 246 insertions(+), 8 deletions(-) create mode 100644 apps/admin/app/dashboard/servers/server-install.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 0519a1e..12eeeec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,22 @@ + # Changelog ## [1.5.4](https://github.com/perfect-panel/ppanel-web/compare/v1.5.3...v1.5.4) (2025-10-26) - ### 🐛 Bug Fixes -* Update generateRealityKeyPair to use async key generation ([e60e369](https://github.com/perfect-panel/ppanel-web/commit/e60e369)) -* Update the wallet localization file and add new fields such as automatic reset and recharge ([88aa965](https://github.com/perfect-panel/ppanel-web/commit/88aa965)) +- Update generateRealityKeyPair to use async key generation ([e60e369](https://github.com/perfect-panel/ppanel-web/commit/e60e369)) +- Update the wallet localization file and add new fields such as automatic reset and recharge ([88aa965](https://github.com/perfect-panel/ppanel-web/commit/88aa965)) ## [1.5.3](https://github.com/perfect-panel/ppanel-web/compare/v1.5.2...v1.5.3) (2025-10-21) - ### 🐛 Bug Fixes -* Fix bugs ([a46657d](https://github.com/perfect-panel/ppanel-web/commit/a46657d)) -* Fix dependencies ([8bd25d6](https://github.com/perfect-panel/ppanel-web/commit/8bd25d6)) -* Remove unnecessary migration function code and add device configuration options ([521a7a9](https://github.com/perfect-panel/ppanel-web/commit/521a7a9)) -* Update bun.lockb to reflect dependency changes ([ca892dd](https://github.com/perfect-panel/ppanel-web/commit/ca892dd)) +- Fix bugs ([a46657d](https://github.com/perfect-panel/ppanel-web/commit/a46657d)) +- Fix dependencies ([8bd25d6](https://github.com/perfect-panel/ppanel-web/commit/8bd25d6)) +- Remove unnecessary migration function code and add device configuration options ([521a7a9](https://github.com/perfect-panel/ppanel-web/commit/521a7a9)) +- Update bun.lockb to reflect dependency changes ([ca892dd](https://github.com/perfect-panel/ppanel-web/commit/ca892dd)) diff --git a/apps/admin/app/dashboard/servers/page.tsx b/apps/admin/app/dashboard/servers/page.tsx index bfd0b63..6a06bfd 100644 --- a/apps/admin/app/dashboard/servers/page.tsx +++ b/apps/admin/app/dashboard/servers/page.tsx @@ -21,6 +21,7 @@ import DynamicMultiplier from './dynamic-multiplier'; import OnlineUsersCell from './online-users-cell'; import ServerConfig from './server-config'; import ServerForm from './server-form'; +import ServerInstall from './server-install'; function PctBar({ value }: { value: number }) { const v = value.toFixed(2); @@ -224,6 +225,7 @@ export default function ServersPage() { } }} />, + , { + const { data } = await getNodeConfig(); + return data.data as API.NodeConfig | undefined; + }, + enabled: open, + }); + + useEffect(() => { + if (open) { + const host = localStorage.getItem('API_HOST') ?? window.location.origin; + setDomain(host); + } + }, [open]); + + const installCommand = useMemo(() => { + const secret = cfgResp?.node_secret ?? ''; + return `wget -N https://raw.githubusercontent.com/perfect-panel/ppanel-node/master/scripts/install.sh && bash install.sh --api-host ${domain} --server-id ${server.id} --secret-key ${secret}`; + }, [domain, server.id, cfgResp?.node_secret]); + + async function handleCopy() { + try { + if (navigator?.clipboard?.writeText) { + await navigator.clipboard.writeText(installCommand); + } else { + // fallback for environments without clipboard API + const el = document.createElement('textarea'); + el.value = installCommand; + document.body.appendChild(el); + el.select(); + document.execCommand('copy'); + document.body.removeChild(el); + } + toast.success(t('copied')); + setOpen(false); + } catch (error) { + toast.error(t('copyFailed')); + } + } + + const onDomainChange = useCallback((e: React.ChangeEvent) => { + setDomain(e.target.value); + localStorage.setItem('API_HOST', e.target.value); + }, []); + return ( + + + + + + + + {t('oneClickInstall')} + + +
+
+ +
+ +
+
+ +
+ +
+