updating the proto and adding a button on the device page to test the scan i2c command
This commit is contained in:
parent
10b9cb951d
commit
2c3ba2c1f5
5 changed files with 30 additions and 6 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -42,7 +42,7 @@
|
||||||
"mui-tel-input": "^7.0.0",
|
"mui-tel-input": "^7.0.0",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"openweathermap-ts": "^1.2.10",
|
"openweathermap-ts": "^1.2.10",
|
||||||
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging",
|
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#i2c_detect",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-beautiful-dnd": "^13.1.1",
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
"react-color": "^2.19.3",
|
"react-color": "^2.19.3",
|
||||||
|
|
@ -10864,7 +10864,7 @@
|
||||||
},
|
},
|
||||||
"node_modules/protobuf-ts": {
|
"node_modules/protobuf-ts": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#070bf9e4e348afeaf5a0d2f5dcb5dc517c3e500e",
|
"resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#b7bf189d71066fd840b9a34e06c29134fdd7f00b",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"protobufjs": "^6.8.8"
|
"protobufjs": "^6.8.8"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
"mui-tel-input": "^7.0.0",
|
"mui-tel-input": "^7.0.0",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"openweathermap-ts": "^1.2.10",
|
"openweathermap-ts": "^1.2.10",
|
||||||
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#staging",
|
"protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#i2c_detect",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-beautiful-dnd": "^13.1.1",
|
"react-beautiful-dnd": "^13.1.1",
|
||||||
"react-color": "^2.19.3",
|
"react-color": "^2.19.3",
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ import ComponentOrder from "component/ComponentOrder";
|
||||||
import ArcGISDeviceData from "./ArcGISDeviceData";
|
import ArcGISDeviceData from "./ArcGISDeviceData";
|
||||||
import UpgradeDevice from "./UpgradeDevice";
|
import UpgradeDevice from "./UpgradeDevice";
|
||||||
import { DevicePageData } from "pages/Device";
|
import { DevicePageData } from "pages/Device";
|
||||||
|
import { quack } from "protobuf-ts/quack";
|
||||||
|
|
||||||
const useStyles = makeStyles((_theme: Theme) => {
|
const useStyles = makeStyles((_theme: Theme) => {
|
||||||
// const isMobile = useMobile()
|
// const isMobile = useMobile()
|
||||||
|
|
@ -113,6 +114,7 @@ interface Props {
|
||||||
preferences: pond.DevicePreferences;
|
preferences: pond.DevicePreferences;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
toggleNotificationPreference: Function;
|
toggleNotificationPreference: Function;
|
||||||
|
scanFunction: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DialogState {
|
interface DialogState {
|
||||||
|
|
@ -145,7 +147,8 @@ export default function DeviceActions(props: Props) {
|
||||||
permissions,
|
permissions,
|
||||||
preferences,
|
preferences,
|
||||||
isLoading,
|
isLoading,
|
||||||
toggleNotificationPreference
|
toggleNotificationPreference,
|
||||||
|
scanFunction
|
||||||
} = props;
|
} = props;
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const [{ user }] = useGlobalState();
|
const [{ user }] = useGlobalState();
|
||||||
|
|
@ -251,7 +254,7 @@ export default function DeviceActions(props: Props) {
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
{canWrite &&
|
{canWrite &&
|
||||||
user.hasAdmin() && ( //TODO: once the resync issue has been resolved remove the admin check
|
user.hasAdmin() && (
|
||||||
<MenuItem onClick={() => openDialog("isSyncDeviceDialogOpen")} dense>
|
<MenuItem onClick={() => openDialog("isSyncDeviceDialogOpen")} dense>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<SyncDeviceIcon className={classes.amberIcon} />
|
<SyncDeviceIcon className={classes.amberIcon} />
|
||||||
|
|
@ -517,6 +520,9 @@ export default function DeviceActions(props: Props) {
|
||||||
const buttons = () => {
|
const buttons = () => {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
<IconButton onClick={() => {
|
||||||
|
scanFunction()
|
||||||
|
}}>0</IconButton>
|
||||||
{showSupport() && <Tooltip title="Support">
|
{showSupport() && <Tooltip title="Support">
|
||||||
<IconButton onClick={() => navigate("support", { state: {device: device, devicePageData: devicePageData }})}>
|
<IconButton onClick={() => navigate("support", { state: {device: device, devicePageData: devicePageData }})}>
|
||||||
<Visibility />
|
<Visibility />
|
||||||
|
|
|
||||||
|
|
@ -442,6 +442,9 @@ export default function DevicePage() {
|
||||||
<Grid>
|
<Grid>
|
||||||
<DeviceActions
|
<DeviceActions
|
||||||
device={device}
|
device={device}
|
||||||
|
scanFunction={() => {
|
||||||
|
deviceAPI.detectI2C(device.id()).then(resp => {console.log("No errors")}).catch(err => {console.log("error")})
|
||||||
|
}}
|
||||||
isPaused={false}
|
isPaused={false}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
permissions={permissions}
|
permissions={permissions}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export interface IDeviceAPIContext {
|
||||||
otherTeam?: string
|
otherTeam?: string
|
||||||
) => Promise<AxiosResponse<pond.GetDevicePageDataResponse>>;
|
) => Promise<AxiosResponse<pond.GetDevicePageDataResponse>>;
|
||||||
getMulti: (ids: number[] | string[], otherTeam?: string) => Promise<AxiosResponse<pond.GetMultiDeviceResponse>>;
|
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>;
|
getGeoJson: (id: number | string, demo?: boolean, otherTeam?: string) => Promise<any>;
|
||||||
getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise<any>;
|
getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise<any>;
|
||||||
list: (
|
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 (
|
return (
|
||||||
<DeviceAPIContext.Provider
|
<DeviceAPIContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
|
@ -991,7 +1005,8 @@ export default function DeviceProvider(props: PropsWithChildren<Props>) {
|
||||||
getDataUsage,
|
getDataUsage,
|
||||||
buyData,
|
buyData,
|
||||||
updateComponentPreferences,
|
updateComponentPreferences,
|
||||||
listDeviceComponentPreferences
|
listDeviceComponentPreferences,
|
||||||
|
detectI2C
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</DeviceAPIContext.Provider>
|
</DeviceAPIContext.Provider>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue