diff --git a/package-lock.json b/package-lock.json
index e68a950..1020b78 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4247,8 +4247,7 @@
},
"node_modules/protobuf-ts": {
"version": "1.0.0",
- "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#e3d1689e1bf3842b0601cf166be9aff78ef093ff",
- "integrity": "sha512-hlkiHxih/Z+kBGMoyWI2Y/vn6afNqRElGuZ/LLGPaLZe2BLXRLKAQOHzR3a7SLfz6p2TkZISNdpmeveK7xgKSg==",
+ "resolved": "git+https://gitlab+deploy-token-50627:hv8mB4WkyvtjBpJKU1rN@gitlab.com/brandx/protobuf-ts.git#91931b1936a92bb0bc24700664adf72eb8a912dd",
"dependencies": {
"protobufjs": "^6.8.8"
}
diff --git a/src/app/UserWrapper.tsx b/src/app/UserWrapper.tsx
index 0d4055b..ec4d6b5 100644
--- a/src/app/UserWrapper.tsx
+++ b/src/app/UserWrapper.tsx
@@ -10,7 +10,7 @@ import { User } from '../models/user'
import { Team } from '../models/team'
import { makeStyles } from '@mui/styles'
import { Theme } from '@mui/material'
-import FirmwareLoader from './FirmwareLoader'
+// import FirmwareLoader from './FirmwareLoader'
const reducer = (state: GlobalState, action: GlobalStateAction): GlobalState => {
return {
@@ -99,11 +99,11 @@ export default function UserWrapper(props: Props) {
return (
-
+ {/* */}
-
+ {/* */}
)
}
\ No newline at end of file
diff --git a/src/device/DeviceActions.tsx b/src/device/DeviceActions.tsx
index 7bf6547..5892087 100644
--- a/src/device/DeviceActions.tsx
+++ b/src/device/DeviceActions.tsx
@@ -27,8 +27,8 @@ import {
Wifi as WifiIcon
} from "@mui/icons-material";
import { Skeleton } from "@mui/material";
-import Datadog from "assets/external/datadog.png";
-import { ImgIcon } from "common/ImgIcon";
+// import Datadog from "assets/external/datadog.png";
+// import { ImgIcon } from "common/ImgIcon";
import NotificationButton from "common/NotificationButton";
// import ComponentOrder from "component/ComponentOrder";
// import ComponentSettings from "component/ComponentSettings";
@@ -44,7 +44,7 @@ import { cloneDeep } from "lodash";
// import { Component, Device, deviceScope, Interaction } from "models";
import { Device, deviceScope } from "models";
// import { MatchParams } from "navigation/Routes";
-import { isShareableLink } from "pbHelpers/Device";
+// import { isShareableLink } from "pbHelpers/Device";
import { pond } from "protobuf-ts/pond";
import { useGlobalState } from "providers";
import React, { useState } from "react";
@@ -64,7 +64,7 @@ import { useNavigate } from "react-router-dom";
import DeviceSettings from "device/DeviceSettings";
import ObjectTeams from "teams/ObjectTeams";
-const useStyles = makeStyles((theme: Theme) => {
+const useStyles = makeStyles((_theme: Theme) => {
// const isMobile = useMobile()
return ({
greenIcon: {
@@ -373,7 +373,6 @@ export default function DeviceActions(props: Props) {
isJsonDataDialogOpen
} = dialogState;
- console.log(canWrite)
return (
)}
- {user.allowedTo("provision") && }
+ {user.allowedTo("provision") && }
);
};
diff --git a/src/device/DeviceTags.tsx b/src/device/DeviceTags.tsx
index 3178ed2..9b65808 100644
--- a/src/device/DeviceTags.tsx
+++ b/src/device/DeviceTags.tsx
@@ -22,6 +22,7 @@ import { filterByTag } from "pbHelpers/Tag";
import { useDeviceAPI, useSnackbar, useTagAPI } from "providers";
import React, { useEffect, useRef, useState } from "react";
import { pond } from "protobuf-ts/pond";
+import { getContextKeys, getContextTypes } from "pbHelpers/Context";
const useStyles = makeStyles((_theme: Theme) => {
return ({
@@ -128,6 +129,7 @@ function DeviceTag(props: DeviceTagProps) {
interface DeviceTagsProps {
device: Device;
disableAdd?: boolean;
+ tags: pond.Tag[];
}
export default function DeviceTags(props: DeviceTagsProps) {
@@ -155,19 +157,45 @@ export default function DeviceTags(props: DeviceTagsProps) {
}
useEffect(() => {
- console.log(tags)
- }, [tags])
+ console.log(props.tags)
+ let newTags: string[] = []
+ props.tags.forEach(tag => {
+ if (tag.settings) newTags.push(tag.settings?.key)
+ })
+ setDeviceTags(newTags)
+ }, [props.tags])
useEffect(() => {
loadTags()
}, [])
- useEffect(() => {
- if (previousDeviceRef.current !== device) {
- setDeviceTags(device.status.tagKeys);
- previousDeviceRef.current = device;
- }
- }, [device]);
+ // useEffect(() => {
+ // // if (previousDeviceRef.current !== device) {
+ // let keys = getContextKeys()
+ // keys.push(device.id().toString())
+ // let types = getContextTypes()
+ // types.push("device")
+ // setDeviceTags(device.status.tagKeys);
+ // previousDeviceRef.current = device;
+ // tagAPI.listTags(
+ // undefined,
+ // undefined,
+ // undefined,
+ // undefined,
+ // undefined,
+ // undefined,
+ // keys,
+ // types,
+ // ).then(resp => {
+ // // console.log(resp.data)
+ // let newTagKeys: string[] = []
+ // resp.data.tags.forEach((tag: any) => {
+ // newTagKeys.push(tag.settings.key)
+ // })
+ // setDeviceTags(newTagKeys)
+ // })
+ // // }
+ // }, [device]);
const addTag = (tag: Tag) => {
if (!deviceTags.some(dt => dt === tag.key())) {
@@ -195,12 +223,6 @@ export default function DeviceTags(props: DeviceTagsProps) {
return null;
}
- if (loading) {
- return (
-
- )
- }
-
return (
{deviceTags.map(key => {
diff --git a/src/pages/Device.tsx b/src/pages/Device.tsx
index 9055dfa..b18720e 100644
--- a/src/pages/Device.tsx
+++ b/src/pages/Device.tsx
@@ -24,6 +24,7 @@ export default function DevicePage() {
const [loading, setLoading] = useState(false)
const [permissions, setPermissions] = useState([])
const [preferences, setPreferences] = useState(pond.DevicePreferences.create())
+ const [tags, setTags] = useState([]);
const [cellularUsage, _setCellularUsage] = useState(0);
const [cellularStatus, _setCellularStatus] = useState("");
@@ -55,6 +56,7 @@ export default function DevicePage() {
setPermissions(newPermissions)
let u = User.any(resp.data.user);
setPreferences(u.preferences)
+ setTags(resp.data.tags)
}).catch(err => {
setDevice(Device.create());
// setComponents(new Map());
@@ -79,10 +81,6 @@ export default function DevicePage() {
.finally(() => setLoading(false));
}
- useEffect(() => {
- console.log(permissions)
- }, [permissions])
-
useEffect(() => {
loadDevice()
}, [deviceID])
@@ -138,6 +136,7 @@ export default function DevicePage() {
components={[]}
usage={getUsage()}
loading={loading}
+ tags={tags}
/>
);
diff --git a/src/pages/Devices.tsx b/src/pages/Devices.tsx
index 8403b71..482cce5 100644
--- a/src/pages/Devices.tsx
+++ b/src/pages/Devices.tsx
@@ -164,7 +164,6 @@ export default function Devices() {
const loadDevices = () => {
setDevicesLoading(true)
- console.log(getKeys())
deviceAPI.list(
limit,
page*limit,
diff --git a/src/providers/pond/tagAPI.tsx b/src/providers/pond/tagAPI.tsx
index 3995c0b..2552bd6 100644
--- a/src/providers/pond/tagAPI.tsx
+++ b/src/providers/pond/tagAPI.tsx
@@ -2,13 +2,23 @@ import { useHTTP } from "hooks";
import { pond } from "protobuf-ts/pond";
import { createContext, PropsWithChildren, useContext } from "react";
import { pondURL } from "./pond";
+import { useGlobalState } from "providers/StateContainer";
export interface ITagAPIContext {
addTag: (tag: pond.TagSettings) => Promise;
updateTag: (tagID: string, tag: pond.TagSettings) => Promise;
removeTag: (tagID: string) => Promise;
getTag: (tagID: string) => Promise;
- listTags: () => Promise;
+ listTags: (
+ limit?: number,
+ offset?: number,
+ order?: "asc" | "desc",
+ orderBy?: string,
+ search?: string,
+ asRoot?: boolean,
+ keys?: string[],
+ types?: string[]
+ ) => Promise;
}
export const TagAPIContext = createContext({} as ITagAPIContext);
@@ -18,6 +28,7 @@ interface Props {}
export default function TagProvider(props: PropsWithChildren) {
const { children } = props;
const { get, del, put, post } = useHTTP();
+ const [{ as }] = useGlobalState()
const addTag = (tag: pond.TagSettings) => {
return post(pondURL("/tags"), tag);
@@ -35,8 +46,37 @@ export default function TagProvider(props: PropsWithChildren) {
return get(pondURL("/tags/" + tagID));
};
- const listTags = () => {
- return get(pondURL("/tags"));
+ // const listTags = () => {
+
+ // return get(pondURL("/tags"));
+ // };
+
+ const listTags = (
+ limit?: number,
+ offset?: number,
+ order?: "asc" | "desc",
+ orderBy?: string,
+ search?: string,
+ asRoot?: boolean,
+ keys?: string[],
+ types?: string[]
+ ) => {
+ limit = limit ? limit : 100
+ const url = pondURL(
+ "/tags" +
+ "?limit=" +
+ limit +
+ "&offset=" +
+ offset +
+ ("&order=" + (order ? order : "asc")) +
+ ("&by=" + (orderBy ? orderBy : "deviceId")) +
+ (search ? "&search=" + search : "") +
+ (asRoot ? "&asRoot=" + asRoot.toString() : "") +
+ (as && !(types && types.length > 0 && types[0] === "team") ? "&as=" + as : "") +
+ (keys ? "&keys=" + keys.toString() : "") +
+ (types ? "&types=" + types.toString() : "")
+ );
+ return get(url);
};
return (