added to the device settings and the chip for if a device needs the I2C bus component to power the I2C Line
This commit is contained in:
parent
989ca20a31
commit
a2c68e0089
4 changed files with 40 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { Chip, Grid2 as Grid, Theme, Tooltip, Skeleton } from "@mui/material";
|
||||
import { DataUsage, SimCard, Launch } from "@mui/icons-material";
|
||||
import { DataUsage, SimCard, Launch, DeviceHub } from "@mui/icons-material";
|
||||
import StatusChip from "common/StatusChip";
|
||||
import DeviceTags from "device/DeviceTags";
|
||||
import VersionChip from "device/VersionChip";
|
||||
|
|
@ -233,6 +233,17 @@ export default function DeviceOverview(props: Props) {
|
|||
<StatusChip status="pending" />
|
||||
</Grid>
|
||||
)}
|
||||
{device.settings.needsBusControl && (
|
||||
<Grid>
|
||||
<Tooltip title="Device needs the Bus Control component to power the I2C port">
|
||||
<Chip
|
||||
variant="outlined"
|
||||
label={"I2C Bus"}
|
||||
icon={<DeviceHub />}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Grid>
|
||||
)}
|
||||
{<DeviceTags device={device} disableAdd={disableAddTag} />}
|
||||
</Grid>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -235,6 +235,12 @@ export default function DeviceSettings(props: Props) {
|
|||
setDeviceForm(updatedForm);
|
||||
};
|
||||
|
||||
const toggleBusRequired = (event: any) => {
|
||||
let updatedForm = Device.clone(deviceForm);
|
||||
updatedForm.settings.needsBusControl = event.target.checked;
|
||||
setDeviceForm(updatedForm);
|
||||
};
|
||||
|
||||
const toggleSleeps = (event: any) => {
|
||||
let updatedForm = Device.clone(deviceForm);
|
||||
let updatedSleeps = event.target.checked;
|
||||
|
|
@ -500,7 +506,8 @@ export default function DeviceSettings(props: Props) {
|
|||
</Grid>
|
||||
)}
|
||||
{user.hasAdmin() && (
|
||||
<Grid size={{ xs: 12, sm: 12 }}>
|
||||
<React.Fragment>
|
||||
<Grid size={{ xs: 12, sm: 6 }}>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Switch
|
||||
|
|
@ -516,6 +523,23 @@ export default function DeviceSettings(props: Props) {
|
|||
labelPlacement="end"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid size={{ xs: 12, sm: 6 }}>
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Switch
|
||||
checked={deviceForm.settings.needsBusControl}
|
||||
onChange={toggleBusRequired}
|
||||
name="needsI2CBus"
|
||||
aria-label="needsI2CBus"
|
||||
color="secondary"
|
||||
/>
|
||||
}
|
||||
disabled={!canEdit}
|
||||
label="I2C Bus Required"
|
||||
labelPlacement="end"
|
||||
/>
|
||||
</Grid>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</Grid>
|
||||
</React.Fragment>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue