diff --git a/src/app/(dashboard)/dashboard/HomePageClient.tsx b/src/app/(dashboard)/dashboard/HomePageClient.tsx index 57ddbd2c..8936fbcc 100644 --- a/src/app/(dashboard)/dashboard/HomePageClient.tsx +++ b/src/app/(dashboard)/dashboard/HomePageClient.tsx @@ -23,6 +23,9 @@ export default function HomePageClient({ machineId }) { const [selectedProvider, setSelectedProvider] = useState(null); const [providerMetrics, setProviderMetrics] = useState({}); + const [versionInfo, setVersionInfo] = useState(null); + const [updating, setUpdating] = useState(false); + useEffect(() => { if (typeof window !== "undefined") { setBaseUrl(`${window.location.origin}/v1`); @@ -31,10 +34,11 @@ export default function HomePageClient({ machineId }) { const fetchData = useCallback(async () => { try { - const [provRes, modelsRes, metricsRes] = await Promise.all([ + const [provRes, modelsRes, metricsRes, versionRes] = await Promise.all([ fetch("/api/providers"), fetch("/api/models"), fetch("/api/provider-metrics"), + fetch("/api/system/version"), ]); if (provRes.ok) { const provData = await provRes.json(); @@ -48,6 +52,10 @@ export default function HomePageClient({ machineId }) { const metricsData = await metricsRes.json(); setProviderMetrics(metricsData.metrics || {}); } + if (versionRes.ok) { + const versionData = await versionRes.json(); + setVersionInfo(versionData); + } } catch (e) { console.log("Error fetching data:", e); } finally { @@ -123,6 +131,27 @@ export default function HomePageClient({ machineId }) { }, ]; + const handleUpdate = async () => { + const notify = useNotificationStore.getState(); + setUpdating(true); + try { + notify.info(t("updateStarted") || "Update process started..."); + const res = await fetch("/api/system/version", { method: "POST" }); + const data = await res.json(); + if (res.ok && data.success) { + notify.success( + data.message || "Update initiated successfully. The system will restart shortly." + ); + } else { + notify.error(data.error || "Failed to start update."); + setUpdating(false); + } + } catch { + notify.error("Network error while trying to update."); + setUpdating(false); + } + }; + if (loading) { return (
@@ -136,6 +165,30 @@ export default function HomePageClient({ machineId }) { return (
+ {/* Update Notification Banner */} + {versionInfo?.updateAvailable && ( +
+
+ system_update_alt +
+

Update Available: v{versionInfo.latest}

+

+ {t("updateAvailableDesc") || + `You are currently using v${versionInfo.current}. Update to access the latest features and bug fixes.`} +

+
+
+ +
+ )} + {/* Quick Start */}