From 82114d9662d082ab107dd75e02103b71d6dbb796 Mon Sep 17 00:00:00 2001 From: jLynx Date: Fri, 6 Dec 2024 21:00:06 +1300 Subject: [PATCH] REFACTOR: Reorganize types and interfaces, remove unused models (#78) * refactor: reorganize types and interfaces, remove unused models * refactor: update import for DataPacket to IDataPacket in serialUtils * refactor: update interface names for consistency and clarity * refactor: update import paths for consistency and clarity --- src/app/models.tsx | 9 - src/components/Console/Console.tsx | 88 ++++ src/components/Controller/Controller.tsx | 492 +++--------------- .../DeviceButtons/DeviceButtons.tsx | 2 +- .../DeviceControls/DeviceControls.tsx | 121 +++++ src/components/FileInputs/FileInputs.tsx | 88 ++++ .../FirmwareManager/FirmwareManager.tsx | 86 +++ src/components/Modal/Modal.tsx | 10 +- src/components/Screen/Screen.tsx | 31 ++ src/components/SerialLoader/SerialLoader.tsx | 25 +- .../SerialProvider/SerialProvider.tsx | 57 +- src/components/ToggleSwitch/ToggleSwitch.tsx | 7 +- src/hooks/useDeviceSetup.ts | 104 ++++ src/hooks/useScreenFrame.ts | 34 ++ src/types/index.ts | 31 ++ src/utils/fileUtils.tsx | 2 +- src/utils/serialUtils.tsx | 10 +- src/utils/versionUtils.tsx | 8 + 18 files changed, 713 insertions(+), 492 deletions(-) delete mode 100644 src/app/models.tsx create mode 100644 src/components/Console/Console.tsx create mode 100644 src/components/DeviceControls/DeviceControls.tsx create mode 100644 src/components/FileInputs/FileInputs.tsx create mode 100644 src/components/FirmwareManager/FirmwareManager.tsx create mode 100644 src/components/Screen/Screen.tsx create mode 100644 src/hooks/useDeviceSetup.ts create mode 100644 src/hooks/useScreenFrame.ts create mode 100644 src/types/index.ts diff --git a/src/app/models.tsx b/src/app/models.tsx deleted file mode 100644 index 4e9423a..0000000 --- a/src/app/models.tsx +++ /dev/null @@ -1,9 +0,0 @@ -export interface LatestVersions { - stable: VersionDetails; - nightly: VersionDetails; -} - -export interface VersionDetails { - version: string; - published_at: string; -} diff --git a/src/components/Console/Console.tsx b/src/components/Console/Console.tsx new file mode 100644 index 0000000..7d8f443 --- /dev/null +++ b/src/components/Console/Console.tsx @@ -0,0 +1,88 @@ +import { + faPaperPlane, + faCircleXmark, + faCode, +} from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +interface IConsole { + consoleMessageList: string; + command: string; + setCommand: (value: string) => void; + setConsoleMessageList: (value: string) => void; + sendCommand: () => Promise; + scriptStatus: string; + scriptRunning: boolean; + scriptFileInputRef: React.RefObject; +} + +export const Console: React.FC = ({ + consoleMessageList, + command, + setCommand, + setConsoleMessageList, + sendCommand, + scriptStatus, + scriptRunning, + scriptFileInputRef, +}) => { + return ( +
+