Merge branch 'i2c_detect' into dev_environment
This commit is contained in:
commit
7630b67bc7
5 changed files with 80 additions and 4 deletions
|
|
@ -73,6 +73,7 @@ import ComponentOrder from "component/ComponentOrder";
|
|||
import ArcGISDeviceData from "./ArcGISDeviceData";
|
||||
import UpgradeDevice from "./UpgradeDevice";
|
||||
import { DevicePageData } from "pages/Device";
|
||||
import { quack } from "protobuf-ts/quack";
|
||||
|
||||
const useStyles = makeStyles((_theme: Theme) => {
|
||||
// const isMobile = useMobile()
|
||||
|
|
@ -113,6 +114,7 @@ interface Props {
|
|||
preferences: pond.DevicePreferences;
|
||||
isLoading: boolean;
|
||||
toggleNotificationPreference: Function;
|
||||
scanFunction: () => void
|
||||
}
|
||||
|
||||
interface DialogState {
|
||||
|
|
@ -145,7 +147,8 @@ export default function DeviceActions(props: Props) {
|
|||
permissions,
|
||||
preferences,
|
||||
isLoading,
|
||||
toggleNotificationPreference
|
||||
toggleNotificationPreference,
|
||||
scanFunction
|
||||
} = props;
|
||||
const classes = useStyles();
|
||||
const [{ user }] = useGlobalState();
|
||||
|
|
@ -251,7 +254,7 @@ export default function DeviceActions(props: Props) {
|
|||
</MenuItem>
|
||||
)}
|
||||
{canWrite &&
|
||||
user.hasAdmin() && ( //TODO: once the resync issue has been resolved remove the admin check
|
||||
user.hasAdmin() && (
|
||||
<MenuItem onClick={() => openDialog("isSyncDeviceDialogOpen")} dense>
|
||||
<ListItemIcon>
|
||||
<SyncDeviceIcon className={classes.amberIcon} />
|
||||
|
|
@ -517,6 +520,9 @@ export default function DeviceActions(props: Props) {
|
|||
const buttons = () => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<IconButton onClick={() => {
|
||||
scanFunction()
|
||||
}}>0</IconButton>
|
||||
{showSupport() && <Tooltip title="Support">
|
||||
<IconButton onClick={() => navigate("support", { state: {device: device, devicePageData: devicePageData }})}>
|
||||
<Visibility />
|
||||
|
|
|
|||
|
|
@ -442,6 +442,9 @@ export default function DevicePage() {
|
|||
<Grid>
|
||||
<DeviceActions
|
||||
device={device}
|
||||
scanFunction={() => {
|
||||
deviceAPI.detectI2C(device.id()).then(resp => {console.log("No errors")}).catch(err => {console.log("error")})
|
||||
}}
|
||||
isPaused={false}
|
||||
isLoading={loading}
|
||||
permissions={permissions}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export interface IDeviceAPIContext {
|
|||
otherTeam?: string
|
||||
) => Promise<AxiosResponse<pond.GetDevicePageDataResponse>>;
|
||||
getMulti: (ids: number[] | string[], otherTeam?: string) => Promise<AxiosResponse<pond.GetMultiDeviceResponse>>;
|
||||
detectI2C: (id: number, otherTeam?: string) => Promise<AxiosResponse<pond.DetectI2CResponse>>;
|
||||
getGeoJson: (id: number | string, demo?: boolean, otherTeam?: string) => Promise<any>;
|
||||
getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise<any>;
|
||||
list: (
|
||||
|
|
@ -946,6 +947,19 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
})
|
||||
};
|
||||
|
||||
const detectI2C = (id: number, otherTeam?: string) => {
|
||||
let url = "/devices/" + id + "/detectI2C";
|
||||
const view = otherTeam ? otherTeam : as
|
||||
if(view) url = url + "?as=" + view
|
||||
return new Promise<AxiosResponse<pond.DetectI2CResponse>>((resolve, reject) => {
|
||||
put<pond.DetectI2CResponse>(pondURL(url)).then(resp => {
|
||||
return resolve(resp)
|
||||
}).catch(err => {
|
||||
return reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<DeviceAPIContext.Provider
|
||||
value={{
|
||||
|
|
@ -991,7 +1005,8 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
|||
getDataUsage,
|
||||
buyData,
|
||||
updateComponentPreferences,
|
||||
listDeviceComponentPreferences
|
||||
listDeviceComponentPreferences,
|
||||
detectI2C
|
||||
}}>
|
||||
{children}
|
||||
</DeviceAPIContext.Provider>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue