blob support
This commit is contained in:
@@ -40,9 +40,13 @@ const theme = deepMerge(grommet, {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
tab: {
|
tab: {
|
||||||
|
active: {
|
||||||
|
weight: "bold",
|
||||||
|
},
|
||||||
margin: {
|
margin: {
|
||||||
vertical: "xsmall",
|
vertical: "xsmall",
|
||||||
},
|
},
|
||||||
|
border: undefined,
|
||||||
},
|
},
|
||||||
layer: {
|
layer: {
|
||||||
background: "#00000000",
|
background: "#00000000",
|
||||||
|
|||||||
+3
-5
@@ -55,7 +55,7 @@ const client = new ApolloClient({
|
|||||||
]),
|
]),
|
||||||
cache: new InMemoryCache({
|
cache: new InMemoryCache({
|
||||||
possibleTypes: {
|
possibleTypes: {
|
||||||
IndiVector: ["NumberVector", "SwitchVector", "TextVector", "LightVector"],
|
IndiVector: ["NumberVector", "SwitchVector", "TextVector", "LightVector", "BLOBVector"],
|
||||||
},
|
},
|
||||||
typePolicies: {
|
typePolicies: {
|
||||||
Query: {
|
Query: {
|
||||||
@@ -116,6 +116,8 @@ client
|
|||||||
query: NEW_PROPERTY,
|
query: NEW_PROPERTY,
|
||||||
})
|
})
|
||||||
.subscribe(({ data }) => {
|
.subscribe(({ data }) => {
|
||||||
|
console.log(data.newIndiProp.id);
|
||||||
|
console.log(data.newIndiProp.vector)
|
||||||
const res = client.readQuery({
|
const res = client.readQuery({
|
||||||
query: GETDEVICE,
|
query: GETDEVICE,
|
||||||
variables: { id: data.newIndiProp.device.id },
|
variables: { id: data.newIndiProp.device.id },
|
||||||
@@ -126,10 +128,6 @@ client
|
|||||||
data: {
|
data: {
|
||||||
device: {
|
device: {
|
||||||
...res.device,
|
...res.device,
|
||||||
/*drivers:
|
|
||||||
data.newProperty.name === "DRIVER_INFO"
|
|
||||||
? data.newProperty.vector.values[3].text
|
|
||||||
: res.device.drivers,*/
|
|
||||||
connected:
|
connected:
|
||||||
data.newIndiProp.name === "CONNECTION"
|
data.newIndiProp.name === "CONNECTION"
|
||||||
? data.newIndiProp.vector.values[0].switch
|
? data.newIndiProp.vector.values[0].switch
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { Box, Text } from "grommet";
|
||||||
|
import { Camera } from "grommet-icons";
|
||||||
|
|
||||||
|
import { stateToColor } from "../../utils/indi";
|
||||||
|
|
||||||
|
const BLOBVector = ({ vector }) => {
|
||||||
|
return (
|
||||||
|
<Box gap="xsmall">
|
||||||
|
{vector.values.map((v) => (
|
||||||
|
<Box key={v.name} direction="row" align="center" gap="small">
|
||||||
|
<Box width="small"><Text>{v.label ? `${v.label} (${v.name})` : v.name}</Text></Box>
|
||||||
|
<Box width="medium" direction="row" gap="small"><Camera /><Text>Binary data</Text></Box>
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default BLOBVector;
|
||||||
@@ -36,6 +36,7 @@ const Device = ({ device, messages, onMessagesClosed }) => {
|
|||||||
setCurrentTab(selectedTabs[device.id] || 0);
|
setCurrentTab(selectedTabs[device.id] || 0);
|
||||||
}, [device, selectedTabs]);
|
}, [device, selectedTabs]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Tabs
|
<Tabs
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
|
import { useQuery } from "@apollo/client";
|
||||||
|
import gql from "graphql-tag";
|
||||||
|
import { deviceInfoFragment, propertyVectorFragment } from "../../graphql/fragment";
|
||||||
|
import Device from "./device";
|
||||||
|
import { Box, Button, Tabs, Tab } from "grommet";
|
||||||
|
import { Contact, StatusGood, StatusCritical } from "grommet-icons";
|
||||||
|
|
||||||
|
const GETDEVICES = gql`
|
||||||
|
query devices {
|
||||||
|
devices {
|
||||||
|
id
|
||||||
|
...DeviceInfo
|
||||||
|
messages @client
|
||||||
|
properties {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
...PropertyVector
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
${propertyVectorFragment}
|
||||||
|
${deviceInfoFragment}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const IndiPanel = () => {
|
||||||
|
const { data } = useQuery(GETDEVICES);
|
||||||
|
const [openMsg, setOpenMsg] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box overflow="auto">
|
||||||
|
{data ? (
|
||||||
|
<Tabs justify="start">
|
||||||
|
{data && data.devices ? (
|
||||||
|
data.devices.map((d) => (
|
||||||
|
<Tab
|
||||||
|
icon={d.connected ? <StatusGood /> : <StatusCritical />}
|
||||||
|
title={d.name}
|
||||||
|
key={d.id}
|
||||||
|
>
|
||||||
|
<Device
|
||||||
|
device={d}
|
||||||
|
messages={openMsg}
|
||||||
|
onMessagesClosed={() => setOpenMsg(false)}
|
||||||
|
/>
|
||||||
|
</Tab>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<div>no devices</div>
|
||||||
|
)}
|
||||||
|
</Tabs>
|
||||||
|
) : null}
|
||||||
|
<Button icon={<Contact />} onClick={() => setOpenMsg(true)} />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -7,6 +7,7 @@ import LightVector from "./light";
|
|||||||
import NumberVector from "./number";
|
import NumberVector from "./number";
|
||||||
import SwitchVector from "./switch";
|
import SwitchVector from "./switch";
|
||||||
import TextVector from "./text";
|
import TextVector from "./text";
|
||||||
|
import BLOBVector from "./blob";
|
||||||
|
|
||||||
const Property = ({ property }) => {
|
const Property = ({ property }) => {
|
||||||
return (
|
return (
|
||||||
@@ -30,6 +31,9 @@ const Property = ({ property }) => {
|
|||||||
{property.vector.__typename === "LightVector" && (
|
{property.vector.__typename === "LightVector" && (
|
||||||
<LightVector vector={property.vector} />
|
<LightVector vector={property.vector} />
|
||||||
)}
|
)}
|
||||||
|
{property.vector.__typename === "BLOBVector" && (
|
||||||
|
<BLOBVector vector={property.vector} />
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-29
@@ -3,11 +3,10 @@ import React, { useEffect, useState } from "react";
|
|||||||
import { useQuery, useMutation } from "@apollo/client";
|
import { useQuery, useMutation } from "@apollo/client";
|
||||||
import gql from "graphql-tag";
|
import gql from "graphql-tag";
|
||||||
import { deviceInfoFragment, propertyVectorFragment } from "./graphql/fragment";
|
import { deviceInfoFragment, propertyVectorFragment } from "./graphql/fragment";
|
||||||
import Device from "./components/indi/device";
|
import { Box, Button, Header, Heading, Layer } from "grommet";
|
||||||
import { Box, Tabs, Tab, Button, Header, Heading, Layer } from "grommet";
|
|
||||||
import { Contact } from "grommet-icons";
|
import { Contact } from "grommet-icons";
|
||||||
import { isConnectedQuery } from "./graphql/query";
|
import { isConnectedQuery } from "./graphql/query";
|
||||||
import { StatusGood, StatusDisabled } from "grommet-icons";
|
import { IndiPanel } from "./components/indi/panel";
|
||||||
|
|
||||||
const GETDEVICES = gql`
|
const GETDEVICES = gql`
|
||||||
query devices {
|
query devices {
|
||||||
@@ -55,7 +54,6 @@ const Devices = () => {
|
|||||||
const { data } = useQuery(GETDEVICES);
|
const { data } = useQuery(GETDEVICES);
|
||||||
const [connect] = useMutation(CONNECT);
|
const [connect] = useMutation(CONNECT);
|
||||||
const [disconnect] = useMutation(DISCONNECT);
|
const [disconnect] = useMutation(DISCONNECT);
|
||||||
const [openMsg, setOpenMsg] = useState(false);
|
|
||||||
|
|
||||||
if (!data || !data.devices) {
|
if (!data || !data.devices) {
|
||||||
return <div>No data</div>;
|
return <div>No data</div>;
|
||||||
@@ -74,7 +72,7 @@ const Devices = () => {
|
|||||||
<Button label="INDI panel" onClick={() => {}} />
|
<Button label="INDI panel" onClick={() => {}} />
|
||||||
{true ? (
|
{true ? (
|
||||||
<Button
|
<Button
|
||||||
label="Connect"
|
label="Start"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
connect();
|
connect();
|
||||||
}}
|
}}
|
||||||
@@ -87,7 +85,6 @@ const Devices = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Button icon={<Contact />} onClick={() => setOpenMsg(true)} />
|
|
||||||
</Box>
|
</Box>
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
@@ -99,29 +96,7 @@ const Devices = () => {
|
|||||||
</Layer>
|
</Layer>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Box overflow="auto">
|
<IndiPanel />
|
||||||
{data ? (
|
|
||||||
<Tabs justify="start">
|
|
||||||
{data && data.devices ? (
|
|
||||||
data.devices.map((d) => (
|
|
||||||
<Tab
|
|
||||||
icon={d.connected ? <StatusGood /> : <StatusDisabled />}
|
|
||||||
title={d.name}
|
|
||||||
key={d.id}
|
|
||||||
>
|
|
||||||
<Device
|
|
||||||
device={d}
|
|
||||||
messages={openMsg}
|
|
||||||
onMessagesClosed={() => setOpenMsg(false)}
|
|
||||||
/>
|
|
||||||
</Tab>
|
|
||||||
))
|
|
||||||
) : (
|
|
||||||
<div>no devices</div>
|
|
||||||
)}
|
|
||||||
</Tabs>
|
|
||||||
) : null}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ const vectorFragment = gql`
|
|||||||
light:value
|
light:value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
... on BLOBVector {
|
||||||
|
values {
|
||||||
|
name
|
||||||
|
label
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user