Merge branch 'i2c_detect' into dev_environment

This commit is contained in:
csawatzky 2025-06-19 12:02:12 -06:00
commit 7630b67bc7
5 changed files with 80 additions and 4 deletions

53
package-lock.json generated
View file

@ -43,6 +43,7 @@
"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#dev", "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#dev",
"query-string": "^9.2.1",
"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",
@ -7618,6 +7619,15 @@
"resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz", "resolved": "https://registry.npmjs.org/decimal.js-light/-/decimal.js-light-2.5.1.tgz",
"integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg==" "integrity": "sha512-qIMFpTMZmny+MMIitAB6D7iVPEorVw6YQRWkvarTkT4tBeSLLiHzcwj6q0MmYSFCiVpiqPJTJEYIrpcPzVEIvg=="
}, },
"node_modules/decode-uri-component": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.4.1.tgz",
"integrity": "sha512-+8VxcR21HhTy8nOt6jf20w0c9CADrw1O8d+VZ/YzzCt4bJ3uBjw+D1q2osAB8RnpwwaeYBxy0HyKQxD5JBMuuQ==",
"license": "MIT",
"engines": {
"node": ">=14.16"
}
},
"node_modules/decompress-response": { "node_modules/decompress-response": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
@ -8405,6 +8415,18 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/filter-obj": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/filter-obj/-/filter-obj-5.1.0.tgz",
"integrity": "sha512-qWeTREPoT7I0bifpPUXtxkZJ1XJzxWtfoWWkdVGqa+eCr3SHW/Ocp89o8vLvbUuQnadybJpjOKu4V+RwO6sGng==",
"license": "MIT",
"engines": {
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/find-root": { "node_modules/find-root": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz",
@ -10867,7 +10889,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#8650e48a44dffc4510ab1fb1e869fd73e242db69", "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#bb403eef199a68f470fc025ae97fed2185682504",
"dependencies": { "dependencies": {
"protobufjs": "^6.8.8" "protobufjs": "^6.8.8"
} }
@ -10926,6 +10948,23 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/query-string": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/query-string/-/query-string-9.2.1.tgz",
"integrity": "sha512-3jTGGLRzlhu/1ws2zlr4Q+GVMLCQTLFOj8CMX5x44cdZG9FQE07x2mQhaNxaKVPNmIDu0mvJ/cEwtY7Pim7hqA==",
"license": "MIT",
"dependencies": {
"decode-uri-component": "^0.4.1",
"filter-obj": "^5.1.0",
"split-on-first": "^3.0.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/queue": { "node_modules/queue": {
"version": "6.0.2", "version": "6.0.2",
"resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz", "resolved": "https://registry.npmjs.org/queue/-/queue-6.0.2.tgz",
@ -12303,6 +12342,18 @@
"resolved": "https://registry.npmjs.org/splaytree-ts/-/splaytree-ts-1.0.2.tgz", "resolved": "https://registry.npmjs.org/splaytree-ts/-/splaytree-ts-1.0.2.tgz",
"integrity": "sha512-0kGecIZNIReCSiznK3uheYB8sbstLjCZLiwcQwbmLhgHJj2gz6OnSPkVzJQCMnmEz1BQ4gPK59ylhBoEWOhGNA==" "integrity": "sha512-0kGecIZNIReCSiznK3uheYB8sbstLjCZLiwcQwbmLhgHJj2gz6OnSPkVzJQCMnmEz1BQ4gPK59ylhBoEWOhGNA=="
}, },
"node_modules/split-on-first": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-3.0.0.tgz",
"integrity": "sha512-qxQJTx2ryR0Dw0ITYyekNQWpz6f8dGd7vffGNflQQ3Iqj9NJ6qiZ7ELpZsJ/QBhIVAiDfXdag3+Gp8RvWa62AA==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/split-string": { "node_modules/split-string": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",

View file

@ -55,6 +55,7 @@
"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#dev", "protobuf-ts": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#dev",
"query-string": "^9.2.1",
"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",

View file

@ -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 />

View file

@ -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}

View file

@ -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>