diff --git a/packages/console-app/package.json b/packages/console-app/package.json index fa13807..f4b5977 100644 --- a/packages/console-app/package.json +++ b/packages/console-app/package.json @@ -8,10 +8,10 @@ ], "scripts": { "analyzer": "webpack --config webpack-analyzer.config.js", - "build:babel": "babel ./src --out-dir ./dist/es --ignore \"**/*.test.js\" --source-maps inline", "build": "yarn dist", - "dist": "yarn clean && yarn build:babel && CONFIG_FILE=config-production.yml webpack", + "build:babel": "babel ./src --out-dir ./dist/es --ignore \"**/*.test.js\" --source-maps inline", "clean": "rm -rf dist", + "dist": "yarn clean && yarn build:babel && CONFIG_FILE=config-production.yml webpack", "lint": "semistandard 'src/**/*.js'", "start": "CONFIG_FILE=${CONFIG_FILE:-config-testnet.yml} VERBOSE=true webpack-dev-server --mode development", "test": "jest --rootDir ./src --passWithNoTests --no-cache" diff --git a/packages/console-app/src/containers/Main.js b/packages/console-app/src/containers/Main.js index be1fdb8..5692903 100644 --- a/packages/console-app/src/containers/Main.js +++ b/packages/console-app/src/containers/Main.js @@ -25,7 +25,7 @@ import Config from './panels/Config'; import IPFS from './panels/ipfs/IPFS'; import Metadata from './panels/Metadata'; import Signaling from './panels/signal/Signaling'; -import System from './panels/system/Status'; +import System from './panels/system/System'; import WNS from './panels/wns/WNS'; // Global error handler. diff --git a/packages/console-app/src/containers/panels/system/Info.js b/packages/console-app/src/containers/panels/system/Info.js new file mode 100644 index 0000000..eaadd21 --- /dev/null +++ b/packages/console-app/src/containers/panels/system/Info.js @@ -0,0 +1,28 @@ +// +// Copyright 2020 DXOS.org +// + +import React, { useContext } from 'react'; +import { useQuery } from '@apollo/react-hooks'; + +import Json from '../../../components/Json'; + +import SYSTEM_STATUS from '../../../gql/system_status.graphql'; + +import { ConsoleContext, useQueryStatusReducer } from '../../../hooks'; + +const Info = () => { + const { config } = useContext(ConsoleContext); + const systemResponse = useQueryStatusReducer(useQuery(SYSTEM_STATUS, { pollInterval: config.api.intervalQuery })); + if (!systemResponse) { + return null; + } + + const status = JSON.parse(systemResponse.system_status.json); + + return ( + + ); +}; + +export default Info; diff --git a/packages/console-app/src/containers/panels/system/Services.js b/packages/console-app/src/containers/panels/system/Services.js index dfe49e3..36f9eea 100644 --- a/packages/console-app/src/containers/panels/system/Services.js +++ b/packages/console-app/src/containers/panels/system/Services.js @@ -2,7 +2,8 @@ // Copyright 2020 DXOS.org // -import React from 'react'; +import React, { useContext } from 'react'; +import { useQuery } from '@apollo/react-hooks'; import TableBody from '@material-ui/core/TableBody'; import TableContainer from '@material-ui/core/TableContainer'; @@ -11,13 +12,20 @@ import TableRow from '@material-ui/core/TableRow'; import Table from '../../../components/Table'; import TableCell from '../../../components/TableCell'; -import { useSorter } from '../../../hooks'; +import { ConsoleContext, useQueryStatusReducer, useSorter } from '../../../hooks'; +import SERVICE_STATUS from '../../../gql/service_status.graphql'; const format = (value, unit, symbol = '') => Math.floor(value / unit).toLocaleString() + symbol; -const SignalServers = ({ services }) => { +const SignalServers = () => { + const { config } = useContext(ConsoleContext); const [sorter] = useSorter('name'); + const serviceResponse = useQueryStatusReducer(useQuery(SERVICE_STATUS, { pollInterval: config.api.intervalQuery })); + if (!serviceResponse) { + return null; + } + const services = JSON.parse(serviceResponse.service_status.json); const total = services.reduce((value, { memory }) => value + memory, 0); return ( diff --git a/packages/console-app/src/containers/panels/system/Status.js b/packages/console-app/src/containers/panels/system/Status.js deleted file mode 100644 index e11a8c5..0000000 --- a/packages/console-app/src/containers/panels/system/Status.js +++ /dev/null @@ -1,86 +0,0 @@ -// -// Copyright 2020 DXOS.org -// - -import React, { useContext, useState } from 'react'; -import { useQuery } from '@apollo/react-hooks'; -import { makeStyles } from '@material-ui/core'; -import Tab from '@material-ui/core/Tab'; -import Tabs from '@material-ui/core/Tabs'; -import TabContext from '@material-ui/lab/TabContext'; - -import Json from '../../../components/Json'; - -import SERVICE_STATUS from '../../../gql/service_status.graphql'; -import SYSTEM_STATUS from '../../../gql/system_status.graphql'; - -import { ConsoleContext, useQueryStatusReducer } from '../../../hooks'; - -import Panel from '../../../components/Panel'; -import Toolbar from '../../../components/Toolbar'; - -import Services from './Services'; - -const TAB_INFO = 'status'; -const TAB_SERVICES = 'services'; - -const useStyles = makeStyles(() => ({ - expand: { - flex: 1 - }, - - panel: { - display: 'flex', - overflow: 'hidden', - flex: 1 - }, - - paper: { - display: 'flex', - overflow: 'hidden', - flex: 1 - } -})); - -const Status = () => { - const classes = useStyles(); - const { config } = useContext(ConsoleContext); - const [tab, setTab] = useState(TAB_SERVICES); - const systemResponse = useQueryStatusReducer(useQuery(SYSTEM_STATUS, { pollInterval: config.api.intervalQuery })); - const serviceResponse = useQueryStatusReducer(useQuery(SERVICE_STATUS, { pollInterval: config.api.intervalQuery })); - if (!systemResponse || !serviceResponse) { - return null; - } - - const status = JSON.parse(systemResponse.system_status.json); - const services = JSON.parse(serviceResponse.service_status.json); - - return ( - - setTab(value)}> - - - - - } - > - - {tab === TAB_SERVICES && ( -
- -
- )} - - {tab === TAB_INFO && ( -
- -
- )} -
-
- ); -}; - -export default Status; diff --git a/packages/console-app/src/containers/panels/system/System.js b/packages/console-app/src/containers/panels/system/System.js new file mode 100644 index 0000000..b0e5935 --- /dev/null +++ b/packages/console-app/src/containers/panels/system/System.js @@ -0,0 +1,66 @@ +// +// Copyright 2020 DXOS.org +// + +import React, { useState } from 'react'; +import { makeStyles } from '@material-ui/core'; + +import Paper from '@material-ui/core/Paper'; +import Tab from '@material-ui/core/Tab'; +import Tabs from '@material-ui/core/Tabs'; +import TabContext from '@material-ui/lab/TabContext'; + +import Panel from '../../../components/Panel'; +import Toolbar from '../../../components/Toolbar'; + +import Info from './Info'; +import Services from './Services'; + +const TAB_INFO = 'status'; +const TAB_SERVICES = 'services'; + +const useStyles = makeStyles(() => ({ + expand: { + flex: 1 + }, + + panel: { + display: 'flex', + overflow: 'hidden', + flex: 1 + } +})); + +const System = () => { + const classes = useStyles(); + const [tab, setTab] = useState(TAB_SERVICES); + + return ( + + setTab(value)}> + + + + + } + > + + {tab === TAB_SERVICES && ( + + + + )} + + {tab === TAB_INFO && ( + + + + )} + + + ); +}; + +export default System; diff --git a/packages/console-app/src/icons/DXOS.js b/packages/console-app/src/icons/DXOS.js index 0d56482..3ea92c6 100644 --- a/packages/console-app/src/icons/DXOS.js +++ b/packages/console-app/src/icons/DXOS.js @@ -8,7 +8,7 @@ import SvgIcon from '@material-ui/core/SvgIcon'; const Icon = (props) => ( - + ); diff --git a/packages/console-app/src/modules.js b/packages/console-app/src/modules.js index 54b38ef..b057bc0 100644 --- a/packages/console-app/src/modules.js +++ b/packages/console-app/src/modules.js @@ -9,7 +9,6 @@ import RegistryIcon from '@material-ui/icons/Language'; import IPFSIcon from '@material-ui/icons/GraphicEq'; import ConfigIcon from '@material-ui/icons/Settings'; import SignalIcon from '@material-ui/icons/Traffic'; -import ServicesIcon from '@material-ui/icons/Storage'; export default { services: [ @@ -46,11 +45,6 @@ export default { ], settings: [ - { - path: '/metadata', - title: 'Metadata', - icon: ServicesIcon - }, { path: '/config', title: 'Config', diff --git a/packages/console-app/src/version.json b/packages/console-app/src/version.json index 0b1a611..bb55c95 100644 --- a/packages/console-app/src/version.json +++ b/packages/console-app/src/version.json @@ -1,7 +1,7 @@ { "build": { "name": "@dxos/console-app", - "buildDate": "2020-07-21T16:37:30.252Z", - "version": "1.0.0-beta.21" + "buildDate": "2020-07-21T20:40:54.153Z", + "version": "1.0.0-beta.22" } }