mirror of
https://github.com/luckfox-eng29/kvm.git
synced 2026-01-19 09:52:32 +01:00
* feat(ui): Add other session handling route and modal * feat(ui): Add dedicated update route and refactor update dialog state management * feat(ui): Add local authentication route * refactor(ui): Remove LocalAuthPasswordDialog component and clean up related code * refactor(ui): Remove OtherSessionConnectedModal component * feat(ui): Add dedicated mount route and refactor mount media dialog * refactor(ui): Simplify Escape key navigation in device route * refactor(ui): Add TODO comments for future URL-based state migration * refactor(ui): Migrate settings and update routes to dedicated routes This commit introduces a comprehensive refactoring of the UI routing and state management: - Removed sidebar-based settings view - Replaced global modal state with URL-based routing - Added dedicated routes for settings, including general, security, and update sections - Simplified modal and sidebar interactions - Improved animation and transition handling using motion library - Removed deprecated components and simplified route structure * fix(ui): Add TODO comment for modal session interaction * refactor(ui): Move USB configuration to new settings setup This commit introduces several improvements to the USB configuration workflow: - Refactored USB configuration dialog component - Simplified USB config state management - Moved USB configuration to hardware settings route - Updated JSON-RPC type definitions - Cleaned up unused imports and components - Improved error handling and notifications * refactor(ui): Replace react-router-dom navigation with custom navigation hook This commit introduces a new custom navigation hook `useDeviceUiNavigation` to replace direct usage of `useNavigate` across multiple components: - Removed direct `useNavigate` imports in various components - Added `navigateTo` method from new navigation hook - Updated navigation calls in ActionBar, MountPopover, UpdateInProgressStatusCard, and other routes - Simplified navigation logic and prepared for potential future navigation enhancements - Removed console logs and unnecessary comments * refactor(ui): Remove unused react-router-dom import Clean up unnecessary import of `useNavigate` from react-router-dom in device settings route * feat(ui): Improve mobile navigation and scrolling in device settings * refactor(ui): Reorganize device access and security settings This commit introduces several changes to the device access and security settings: - Renamed "Security" section to "Access" in settings navigation - Moved local authentication routes from security to access - Removed deprecated security settings route - Added new route for device access settings with cloud and local authentication management - Updated cloud URL and adoption logic to be part of the access settings - Simplified routing and component structure for better user experience * fix(ui): Update logout button hover state color * fix(ui): Adjust device de-registration button size to small * fix(ui): Update appearance settings section header and description * refactor(ui): Replace SectionHeader with new SettingsPageHeader and SettingsSectionHeader components This commit introduces two new header components for settings pages: - Created SettingsPageHeader for main page headers - Created SettingsSectionHeader for subsection headers - Replaced all existing SectionHeader imports with new components - Updated styling and type definitions to support more flexible header rendering * feat(ui): Add dev channel toggle to advanced settings Move dev channel update option from general settings to advanced settings - Introduced new state and handler for dev channel toggle - Removed dev channel option from general settings route - Added dev channel toggle in advanced settings with error handling
134 lines
4.8 KiB
TypeScript
134 lines
4.8 KiB
TypeScript
import { SettingsPageHeader } from "@components/SettingsPageheader";
|
|
import { SettingsItem } from "./devices.$id.settings";
|
|
import { Checkbox } from "@/components/Checkbox";
|
|
import { GridCard } from "@/components/Card";
|
|
import PointingFinger from "@/assets/pointing-finger.svg";
|
|
import { CheckCircleIcon } from "@heroicons/react/16/solid";
|
|
import { useSettingsStore } from "@/hooks/stores";
|
|
import notifications from "@/notifications";
|
|
import { useEffect, useState } from "react";
|
|
import { useJsonRpc } from "@/hooks/useJsonRpc";
|
|
import { cx } from "../cva.config";
|
|
|
|
export default function SettingsKeyboardMouseRoute() {
|
|
const hideCursor = useSettingsStore(state => state.isCursorHidden);
|
|
const setHideCursor = useSettingsStore(state => state.setCursorVisibility);
|
|
|
|
const [jiggler, setJiggler] = useState(false);
|
|
|
|
const [send] = useJsonRpc();
|
|
|
|
useEffect(() => {
|
|
send("getJigglerState", {}, resp => {
|
|
if ("error" in resp) return;
|
|
setJiggler(resp.result as boolean);
|
|
});
|
|
}, [send]);
|
|
|
|
const handleJigglerChange = (enabled: boolean) => {
|
|
send("setJigglerState", { enabled }, resp => {
|
|
if ("error" in resp) {
|
|
notifications.error(
|
|
`Failed to set jiggler state: ${resp.error.data || "Unknown error"}`,
|
|
);
|
|
return;
|
|
}
|
|
setJiggler(enabled);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<SettingsPageHeader
|
|
title="Mouse"
|
|
description="Configure cursor behavior and interaction settings for your device"
|
|
/>
|
|
|
|
<div className="space-y-4">
|
|
<SettingsItem
|
|
title="Hide Cursor"
|
|
description="Hide the cursor when sending mouse movements"
|
|
>
|
|
<Checkbox
|
|
checked={hideCursor}
|
|
onChange={e => setHideCursor(e.target.checked)}
|
|
/>
|
|
</SettingsItem>
|
|
<SettingsItem
|
|
title="Jiggler"
|
|
description="Simulate movement of a computer mouse. Prevents sleep mode, standby mode or the screensaver from activating"
|
|
>
|
|
<Checkbox
|
|
checked={jiggler}
|
|
onChange={e => handleJigglerChange(e.target.checked)}
|
|
/>
|
|
</SettingsItem>
|
|
<div className="space-y-4">
|
|
<SettingsItem title="Modes" description="Choose the mouse input mode" />
|
|
<div className="flex flex-col items-center gap-4 md:flex-row">
|
|
<button
|
|
className="group block w-full grow"
|
|
onClick={() => console.log("Absolute mouse mode clicked")}
|
|
>
|
|
<GridCard>
|
|
<div className="group flex items-center gap-x-4 px-4 py-3">
|
|
<img
|
|
className="w-6 shrink-0 dark:invert"
|
|
src={PointingFinger}
|
|
alt="Finger touching a screen"
|
|
/>
|
|
<div className="flex grow items-center justify-between">
|
|
<div className="text-left">
|
|
<h3 className="text-sm font-semibold text-black dark:text-white">
|
|
Absolute
|
|
</h3>
|
|
<p className="text-xs leading-none text-slate-800 dark:text-slate-300">
|
|
Most convenient
|
|
</p>
|
|
</div>
|
|
<CheckCircleIcon
|
|
className={cx(
|
|
"h-4 w-4 text-blue-700 transition-opacity duration-300 dark:text-blue-500",
|
|
)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</GridCard>
|
|
</button>
|
|
<button
|
|
className="group block w-full grow cursor-not-allowed opacity-50"
|
|
disabled
|
|
>
|
|
<GridCard>
|
|
<div className="group flex items-center gap-x-4 px-4 py-3">
|
|
<img
|
|
className="w-6 shrink-0 dark:invert"
|
|
src={PointingFinger}
|
|
alt="Finger touching a screen"
|
|
/>
|
|
<div className="flex grow items-center justify-between">
|
|
<div className="text-left">
|
|
<h3 className="text-sm font-semibold text-black dark:text-white">
|
|
Relative
|
|
</h3>
|
|
<p className="text-xs leading-none text-slate-800 dark:text-slate-300">
|
|
Most Compatible
|
|
</p>
|
|
</div>
|
|
<CheckCircleIcon
|
|
className={cx(
|
|
"hidden",
|
|
"h-4 w-4 text-blue-700 transition-opacity duration-300 dark:text-blue-500",
|
|
)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</GridCard>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|