Skip to content

Commit

Permalink
REFACTOR: Reorganize types and interfaces, remove unused models (#78)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jLynx authored Dec 6, 2024
1 parent e080b78 commit 82114d9
Show file tree
Hide file tree
Showing 18 changed files with 713 additions and 492 deletions.
9 changes: 0 additions & 9 deletions src/app/models.tsx

This file was deleted.

88 changes: 88 additions & 0 deletions src/components/Console/Console.tsx
Original file line number Diff line number Diff line change
@@ -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<void>;
scriptStatus: string;
scriptRunning: boolean;
scriptFileInputRef: React.RefObject<HTMLInputElement>;
}

export const Console: React.FC<IConsole> = ({
consoleMessageList,
command,
setCommand,
setConsoleMessageList,
sendCommand,
scriptStatus,
scriptRunning,
scriptFileInputRef,
}) => {
return (
<div className="flex h-full w-full flex-col items-center justify-center gap-1">
<textarea
className="h-full w-full rounded bg-gray-600 p-2 font-mono text-white"
readOnly
value={consoleMessageList}
id="serial_console"
/>
{scriptRunning && (
<div className="flex w-full flex-row items-center justify-center gap-1">
<p className="w-full rounded-md bg-blue-700 p-2 font-mono text-white">
{scriptStatus}
</p>
</div>
)}
<div className="flex w-full flex-row items-center justify-center gap-1">
<input
type="text"
value={command}
onChange={(e) => setCommand(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
sendCommand();
}
}}
placeholder="Enter command"
className="w-full rounded-md bg-gray-600 p-2 font-mono text-white"
/>
<button
type="submit"
className="btn btn-success btn-sm size-10 text-white"
onClick={() => {
sendCommand();
}}
>
<FontAwesomeIcon icon={faPaperPlane} />
</button>
<button
type="submit"
className="btn btn-error btn-sm size-10 text-white"
onClick={() => {
setConsoleMessageList("");
}}
>
<FontAwesomeIcon icon={faCircleXmark} />
</button>
<button
type="button"
className="btn btn-info btn-sm size-10 text-white"
onClick={() => {
scriptFileInputRef.current?.click();
}}
>
<FontAwesomeIcon icon={faCode} />
</button>
</div>
</div>
);
};
Loading

0 comments on commit 82114d9

Please sign in to comment.