forked from cerc-io/laconic-console
Decode json.
This commit is contained in:
parent
99f87336c6
commit
a36c6cfee8
@ -21,7 +21,7 @@ const getLogBuffer = (name) => {
|
||||
_logBuffers.set(name, buffer);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
};
|
||||
|
||||
const LogPoller = ({ service }) => {
|
||||
const { config } = useContext(ConsoleContext);
|
||||
@ -47,7 +47,7 @@ const LogPoller = ({ service }) => {
|
||||
}
|
||||
|
||||
return (
|
||||
<Log log={logBuffer.slice(0)}/>
|
||||
<Log log={logBuffer.slice(0)} />
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -11,6 +11,7 @@ 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';
|
||||
@ -44,19 +45,21 @@ const Status = () => {
|
||||
const { config } = useContext(ConsoleContext);
|
||||
const [tab, setTab] = useState(TAB_SYSTEM);
|
||||
const systemResponse = useQueryStatusReducer(useQuery(SYSTEM_STATUS, { pollInterval: config.api.intervalQuery }));
|
||||
if (!systemResponse) {
|
||||
const serviceResponse = useQueryStatusReducer(useQuery(SERVICE_STATUS, { pollInterval: config.api.intervalQuery }));
|
||||
if (!systemResponse || !serviceResponse) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const data = JSON.parse(systemResponse.system_status.json);
|
||||
const systemData = JSON.parse(systemResponse.system_status.json);
|
||||
const serviceData = JSON.parse(serviceResponse.service_status.json);
|
||||
|
||||
return (
|
||||
<Panel
|
||||
toolbar={
|
||||
<Toolbar>
|
||||
<Tabs value={tab} onChange={(_, value) => setTab(value)}>
|
||||
<Tab value={TAB_SYSTEM} label='System'/>
|
||||
<Tab value={TAB_SERVICES} label='Services'/>
|
||||
<Tab value={TAB_SYSTEM} label='System' />
|
||||
<Tab value={TAB_SERVICES} label='Services' />
|
||||
</Tabs>
|
||||
</Toolbar>
|
||||
}
|
||||
@ -64,12 +67,13 @@ const Status = () => {
|
||||
<TabContext value={tab}>
|
||||
{tab === TAB_SYSTEM && (
|
||||
<div className={classes.panel}>
|
||||
<Json data={data}/>
|
||||
<Json data={systemData} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{tab === TAB_SERVICES && (
|
||||
<div className={classes.panel}>
|
||||
<Json data={serviceData} />
|
||||
</div>
|
||||
)}
|
||||
</TabContext>
|
||||
|
@ -11,7 +11,7 @@ import Panel from '../../../components/Panel';
|
||||
import Toolbar from '../../../components/Toolbar';
|
||||
|
||||
import AppRecords from './AppRecords';
|
||||
import LogPoller from "../../../components/LogPoller";
|
||||
import LogPoller from '../../../components/LogPoller';
|
||||
|
||||
const TAB_RECORDS = 'records';
|
||||
const TAB_LOG = 'log';
|
||||
|
@ -2,13 +2,11 @@
|
||||
// Copyright 2020 DxOS.org
|
||||
//
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
import get from 'lodash.get';
|
||||
|
||||
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 TableBody from '@material-ui/core/TableBody';
|
||||
import TableHead from '@material-ui/core/TableHead';
|
||||
import TableRow from '@material-ui/core/TableRow';
|
||||
@ -22,7 +20,6 @@ import Json from '../../../components/Json';
|
||||
import Panel from '../../../components/Panel';
|
||||
import Table from '../../../components/Table';
|
||||
import TableCell from '../../../components/TableCell';
|
||||
import Toolbar from '../../../components/Toolbar';
|
||||
import { BooleanIcon } from '../../../components/BooleanIcon';
|
||||
|
||||
const RECORD_TYPE = 'wrn:service';
|
||||
@ -70,13 +67,8 @@ const useStyles = makeStyles((theme) => ({
|
||||
}
|
||||
}));
|
||||
|
||||
const TAB_STATUS = 'status';
|
||||
const TAB_LOG_IPFS = 'log';
|
||||
const TAB_LOG_SWARM = 'connect log';
|
||||
|
||||
const IPFSStatus = () => {
|
||||
const classes = useStyles();
|
||||
const [tab, setTab] = useState(TAB_STATUS);
|
||||
|
||||
const ipfsResponse = useQueryStatusReducer(useQuery(IPFS_STATUS));
|
||||
const wnsResponse = useQueryStatusReducer(useQuery(WNS_RECORDS, {
|
||||
@ -138,7 +130,7 @@ const IPFSStatus = () => {
|
||||
<TableCell>{name}</TableCell>
|
||||
<TableCell>{description}</TableCell>
|
||||
<TableCell>
|
||||
<BooleanIcon yes={connected}/>
|
||||
<BooleanIcon yes={connected} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{ipfs.addresses}
|
||||
|
@ -13,7 +13,7 @@ import Panel from '../../../components/Panel';
|
||||
import Toolbar from '../../../components/Toolbar';
|
||||
|
||||
import SignalStatus from './SignalStatus';
|
||||
import LogPoller from "../../../components/LogPoller";
|
||||
import LogPoller from '../../../components/LogPoller';
|
||||
|
||||
const TAB_STATUS = 'status';
|
||||
const TAB_LOG = 'log';
|
||||
|
@ -9,7 +9,7 @@ import Tab from '@material-ui/core/Tab';
|
||||
import Tabs from '@material-ui/core/Tabs';
|
||||
import TabContext from '@material-ui/lab/TabContext';
|
||||
|
||||
import LogPoller from "../../../components/LogPoller";
|
||||
import LogPoller from '../../../components/LogPoller';
|
||||
import Panel from '../../../components/Panel';
|
||||
import Toolbar from '../../../components/Toolbar';
|
||||
|
||||
|
10
packages/console-app/src/gql/service_status.graphql
Normal file
10
packages/console-app/src/gql/service_status.graphql
Normal file
@ -0,0 +1,10 @@
|
||||
#
|
||||
# Copyright 2020 DxOS.org
|
||||
#
|
||||
|
||||
query {
|
||||
service_status {
|
||||
timestamp,
|
||||
json
|
||||
}
|
||||
}
|
@ -8,10 +8,3 @@ query {
|
||||
json
|
||||
}
|
||||
}
|
||||
|
||||
query {
|
||||
service_status {
|
||||
timestamp,
|
||||
json
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"build": {
|
||||
"name": "@dxos/console-app",
|
||||
"buildDate": "2020-06-11T05:01:31.306Z",
|
||||
"buildDate": "2020-06-11T06:21:53.153Z",
|
||||
"version": "1.0.0-beta.0"
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ const getServiceInfo = async () => {
|
||||
const args = ['service', '--json'];
|
||||
|
||||
const child = spawnSync(command, args, { encoding: 'utf8' });
|
||||
return child.stdout;
|
||||
return JSON.parse(child.stdout);
|
||||
}
|
||||
|
||||
export const systemResolvers = {
|
||||
|
Loading…
Reference in New Issue
Block a user