diff --git a/package-lock.json b/package-lock.json index 6e9ecba..064fad0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,7 @@ "mui-tel-input": "^7.0.0", "notistack": "^3.0.1", "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-beautiful-dnd": "^13.1.1", "react-color": "^2.19.3", @@ -10864,7 +10864,7 @@ }, "node_modules/protobuf-ts": { "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": { "protobufjs": "^6.8.8" } diff --git a/package.json b/package.json index c05b146..477f4c6 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "mui-tel-input": "^7.0.0", "notistack": "^3.0.1", "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-beautiful-dnd": "^13.1.1", "react-color": "^2.19.3", diff --git a/src/device/DeviceActions.tsx b/src/device/DeviceActions.tsx index 8356b6a..adb6556 100644 --- a/src/device/DeviceActions.tsx +++ b/src/device/DeviceActions.tsx @@ -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) { )} {canWrite && - user.hasAdmin() && ( //TODO: once the resync issue has been resolved remove the admin check + user.hasAdmin() && ( openDialog("isSyncDeviceDialogOpen")} dense> @@ -517,6 +520,9 @@ export default function DeviceActions(props: Props) { const buttons = () => { return ( + { + scanFunction() + }}>0 {showSupport() && navigate("support", { state: {device: device, devicePageData: devicePageData }})}> diff --git a/src/pages/Device.tsx b/src/pages/Device.tsx index a39cf99..c6598fa 100644 --- a/src/pages/Device.tsx +++ b/src/pages/Device.tsx @@ -442,6 +442,9 @@ export default function DevicePage() { { + deviceAPI.detectI2C(device.id()).then(resp => {console.log("No errors")}).catch(err => {console.log("error")}) + }} isPaused={false} isLoading={loading} permissions={permissions} diff --git a/src/providers/pond/deviceAPI.tsx b/src/providers/pond/deviceAPI.tsx index 6a940e2..512fad2 100644 --- a/src/providers/pond/deviceAPI.tsx +++ b/src/providers/pond/deviceAPI.tsx @@ -22,6 +22,7 @@ export interface IDeviceAPIContext { otherTeam?: string ) => Promise>; getMulti: (ids: number[] | string[], otherTeam?: string) => Promise>; + detectI2C: (id: number, otherTeam?: string) => Promise>; getGeoJson: (id: number | string, demo?: boolean, otherTeam?: string) => Promise; getMultiGeoJson: (ids: number[] | string[], otherTeam?: string) => Promise; list: ( @@ -946,6 +947,19 @@ export default function DeviceProvider(props: PropsWithChildren) { }) }; + 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>((resolve, reject) => { + put(pondURL(url)).then(resp => { + return resolve(resp) + }).catch(err => { + return reject(err) + }) + }) + } + return ( ) { getDataUsage, buyData, updateComponentPreferences, - listDeviceComponentPreferences + listDeviceComponentPreferences, + detectI2C }}> {children}