// // Copyright 2020 DxOS // import React, { useContext, useState } from 'react'; import { useQuery } from '@apollo/react-hooks'; import { Mutation } from '@apollo/react-components'; import { makeStyles } from '@material-ui/core'; import Button from '@material-ui/core/Button'; import ButtonGroup from '@material-ui/core/ButtonGroup'; import Tab from '@material-ui/core/Tab'; import Tabs from '@material-ui/core/Tabs'; import TabContext from '@material-ui/lab/TabContext'; import TabPanel from '@material-ui/lab/TabPanel'; import ControlButtons from '../../components/ControlButtons'; import Json from '../../components/Json'; import Log from '../../components/Log'; import Panel from '../../components/Panel'; import Toolbar from '../../components/Toolbar'; import { ConsoleContext, useQueryStatusReducer } from '../../hooks'; import WNS_STATUS from '../../../gql/wns_status.graphql'; import WNS_ACTION from '../../../gql/wns_action.graphql'; const types = [ { key: null, label: 'ALL' }, { key: 'wrn:xbox', label: 'XBox' }, { key: 'wrn:resource', label: 'Resource' }, { key: 'wrn:app', label: 'App' }, { key: 'wrn:bot', label: 'Bot' }, { key: 'wrn:type', label: 'Type' }, ]; const TAB_RECORDS = 'records'; const TAB_LOG = 'log'; const TAB_EXPLORER = 'explorer'; const useStyles = makeStyles(() => ({ expand: { flex: 1 } })); const WNS = () => { const classes = useStyles(); const { config } = useContext(ConsoleContext); const [type, setType] = useState(types[0].key); const [tab, setTab] = useState(TAB_RECORDS); const data = useQueryStatusReducer(useQuery(WNS_STATUS, { pollInterval: config.api.pollInterval })); if (!data) { return null; } return ( setTab(value)}> {tab === TAB_RECORDS && ( {types.map(t => ( ))} )}
{(action, { data }) => (
{ action({ variables: { command: 'start' } }); }} onStop={() => { action({ variables: { command: 'stop' } }); }} />
)}
} > ); }; export default WNS;