8 changed files with 100 additions and 34 deletions
@ -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; |
||||||
@ -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> |
||||||
|
); |
||||||
|
}; |
||||||
Loading…
Reference in new issue