diff --git a/kinode/packages/app_store/app_store/src/http_api.rs b/kinode/packages/app_store/app_store/src/http_api.rs index 5747f60a..9a9c6d08 100644 --- a/kinode/packages/app_store/app_store/src/http_api.rs +++ b/kinode/packages/app_store/app_store/src/http_api.rs @@ -588,7 +588,7 @@ fn serve_paths( } // start auto-updating a downloaded app: PUT // stop auto-updating a downloaded app: DELETE - "/downloads/:id/auto-update" => { + "/apps/:id/auto-update" => { let package_id = get_package_id(url_params)?; let chain_request = match method { diff --git a/kinode/packages/app_store/app_store/src/lib.rs b/kinode/packages/app_store/app_store/src/lib.rs index 282e0124..328d9c29 100644 --- a/kinode/packages/app_store/app_store/src/lib.rs +++ b/kinode/packages/app_store/app_store/src/lib.rs @@ -225,9 +225,21 @@ fn handle_local_request( None, ), LocalRequest::Uninstall(package_id) => ( - match utils::uninstall(state, &package_id.to_process_lib()) { - Ok(()) => LocalResponse::UninstallResponse(UninstallResponse::Success), - Err(_) => LocalResponse::UninstallResponse(UninstallResponse::Failure), + match utils::uninstall(state, &package_id.clone().to_process_lib()) { + Ok(()) => { + println!( + "successfully uninstalled package: {:?}", + &package_id.to_process_lib() + ); + LocalResponse::UninstallResponse(UninstallResponse::Success) + } + Err(e) => { + println!( + "error uninstalling package: {:?}: {e}", + &package_id.to_process_lib() + ); + LocalResponse::UninstallResponse(UninstallResponse::Failure) + } }, None, ), diff --git a/kinode/packages/app_store/app_store/src/utils.rs b/kinode/packages/app_store/app_store/src/utils.rs index 615d0331..13150706 100644 --- a/kinode/packages/app_store/app_store/src/utils.rs +++ b/kinode/packages/app_store/app_store/src/utils.rs @@ -113,7 +113,6 @@ pub fn new_package( .send_and_await_response(5)??; let download_resp = serde_json::from_slice::(&resp.body())?; - println!("got download resp: {:?}", download_resp); match download_resp { DownloadResponses::Error(e) => { diff --git a/kinode/packages/app_store/ui/src/index.css b/kinode/packages/app_store/ui/src/index.css index c3d71bb6..2ca0b343 100644 --- a/kinode/packages/app_store/ui/src/index.css +++ b/kinode/packages/app_store/ui/src/index.css @@ -413,4 +413,18 @@ td { .progress-text { min-width: 50px; text-align: right; +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } +} + +.fa-spin { + animation: spin 1s linear infinite; } \ No newline at end of file diff --git a/kinode/packages/app_store/ui/src/pages/AppPage.tsx b/kinode/packages/app_store/ui/src/pages/AppPage.tsx index 58f0d708..b6700d9d 100644 --- a/kinode/packages/app_store/ui/src/pages/AppPage.tsx +++ b/kinode/packages/app_store/ui/src/pages/AppPage.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, useCallback } from "react"; import { useNavigate, useParams } from "react-router-dom"; -import { FaDownload, FaCheck, FaTimes, FaPlay, FaSpinner, FaTrash } from "react-icons/fa"; +import { FaDownload, FaCheck, FaTimes, FaPlay, FaSpinner, FaTrash, FaSync } from "react-icons/fa"; import useAppsStore from "../store"; import { AppListing, PackageState } from "../types/Apps"; import { compareVersions } from "../utils/compareVersions"; @@ -8,7 +8,7 @@ import { compareVersions } from "../utils/compareVersions"; export default function AppPage() { const { id } = useParams(); const navigate = useNavigate(); - const { fetchListing, fetchInstalledApp, uninstallApp } = useAppsStore(); + const { fetchListing, fetchInstalledApp, uninstallApp, setAutoUpdate } = useAppsStore(); const [app, setApp] = useState(null); const [installedApp, setInstalledApp] = useState(null); const [currentVersion, setCurrentVersion] = useState(null); @@ -16,6 +16,7 @@ export default function AppPage() { const [isLoading, setIsLoading] = useState(true); const [error, setError] = useState(null); const [isUninstalling, setIsUninstalling] = useState(false); + const [isTogglingAutoUpdate, setIsTogglingAutoUpdate] = useState(false); const loadData = useCallback(async () => { @@ -70,6 +71,21 @@ export default function AppPage() { } }; + const handleToggleAutoUpdate = async () => { + if (!app || !latestVersion) return; + setIsTogglingAutoUpdate(true); + try { + const newAutoUpdateState = !app.auto_update; + await setAutoUpdate(`${app.package_id.package_name}:${app.package_id.publisher_node}`, latestVersion, newAutoUpdateState); + await loadData(); + } catch (error) { + console.error('Failed to toggle auto-update:', error); + setError(`Failed to toggle auto-update: ${error instanceof Error ? error.message : String(error)}`); + } finally { + setIsTogglingAutoUpdate(false); + } + }; + useEffect(() => { loadData(); }, [loadData]); @@ -122,6 +138,12 @@ export default function AppPage() { )}
  • Publisher: {app.package_id.publisher_node}
  • License: {app.metadata?.properties?.license || "Not specified"}
  • +
  • + Auto Update: + + {app.auto_update ? : } + +
  • @@ -134,6 +156,10 @@ export default function AppPage() { + )}