Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionConfig inputs #1

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
useReducer,
useEffect,
useLayoutEffect,
ChangeEvent,
} from 'react';
import Topbar from './Topbar';
import Editor from './editor/Editor';
Expand Down Expand Up @@ -79,6 +80,12 @@
[-1, -1],
);

// for the ConnectionConfigModal
const [IPAddress, setIPAddress] = useState('192.168.0.100');
const [SSHAddress, setSSHAddress] = useState('192.168.0.100');
const [FieldIPAddress, setFieldIPAddress] = useState('localhost');
const [FieldStationNum, setFieldStationNum] = useState('4');

// Update windowSize:
useLayoutEffect(() => {
const onResize = () =>
Expand Down Expand Up @@ -229,6 +236,19 @@
};
const closeModal = () => changeActiveModal('');

const handleConnectionChange = (event: ChangeEvent<HTMLInputElement>) => {
const { id, value } = event.target;
if (id == 'IPAddress') {

Check failure on line 241 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='

Check failure on line 241 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='
setIPAddress(value);
} else if (id == 'SSHAddress') {

Check failure on line 243 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='

Check failure on line 243 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='
setSSHAddress(value);
} else if (id == 'FieldIPAddress') {

Check failure on line 245 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='

Check failure on line 245 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='
setFieldIPAddress(value);
} else if (id == 'FieldStationNum') {

Check failure on line 247 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='

Check failure on line 247 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Expected '===' and instead saw '=='
setFieldStationNum(value);
}
};

return (
<StrictMode>
<div className="App">
Expand Down Expand Up @@ -268,6 +288,11 @@
<ConnectionConfigModal
isActive={activeModal === 'ConnectionConfig'}
onClose={closeModal}
onChange={handleConnectionChange}
IPAddress={IPAddress}
SSHAddress={SSHAddress}
FieldIPAddress={FieldIPAddress}
FieldStationNum={FieldStationNum}
/>
<GamepadInfoModal
isActive={activeModal === 'GamepadInfo'}
Expand Down
31 changes: 30 additions & 1 deletion src/renderer/modals/ConnectionConfigModal.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,47 @@
import Modal from './Modal';
import { useState, ChangeEvent } from 'react';

Check failure on line 2 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

`react` import should occur before import of `./Modal`

Check failure on line 2 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

'useState' is defined but never used

Check failure on line 2 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

`react` import should occur before import of `./Modal`

Check failure on line 2 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

'useState' is defined but never used

/**
* Modal component exposing info about the connection to the robot (IP address, port, etc.)
*/
export default function ConnectionInfoModal({
onClose,
isActive,
onChange,
IPAddress,
SSHAddress,
FieldIPAddress,
FieldStationNum

Check failure on line 14 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Insert `,`

Check failure on line 14 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Insert `,`
}: {
onClose: () => void;
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
isActive: boolean;
IPAddress: string;
SSHAddress: string;
FieldIPAddress: string;
FieldStationNum: string;
}) {
return (
<Modal modalTitle="Connection info" onClose={onClose} isActive={isActive}>
Test
<div>
IP Address:

Check failure on line 27 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Delete `·`

Check failure on line 27 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Delete `·`
<input id="IPAddress" onChange={onChange} value={IPAddress} />
</div>
<div>
SSH Address:

Check failure on line 31 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Delete `·`

Check failure on line 31 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Delete `·`
<input id="SSHAddress" onChange={onChange} value={SSHAddress} />
</div>
<div>
Field Control Settings
<div>
Field Control IP Address:

Check failure on line 37 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Delete `·`

Check failure on line 37 in src/renderer/modals/ConnectionConfigModal.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Delete `·`
<input id="FieldIPAddress" onChange={onChange} value={FieldIPAddress} />
</div>
<div>
Field Control Station Number:
<input id="FieldStationNum" onChange={onChange} value={FieldStationNum} />
</div>
</div>
</Modal>
);
}
Loading