forked from cerc-io/laconic-console
Fix status page.
This commit is contained in:
parent
c0efe66ec4
commit
eabd69c953
@ -26,19 +26,22 @@ const useStyles = makeStyles(theme => ({
|
|||||||
const VersionCheck = () => {
|
const VersionCheck = () => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const [{ current, latest }, setUpgrade] = useState({});
|
const [{ current, latest }, setUpgrade] = useState({});
|
||||||
const status = useQueryStatusReducer(useQuery(SYSTEM_STATUS));
|
const statusRespone = useQueryStatusReducer(useQuery(SYSTEM_STATUS));
|
||||||
const wnsResponse = useQueryStatusReducer(useQuery(WNS_RECORDS, {
|
const wnsResponse = useQueryStatusReducer(useQuery(WNS_RECORDS, {
|
||||||
pollInterval: CHECK_INTERVAL,
|
pollInterval: CHECK_INTERVAL,
|
||||||
variables: { type: 'wrn:resource' }
|
variables: { attributes: { type: 'wrn:resource' } }
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Check version.
|
// Check version.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status && wnsResponse) {
|
if (statusRespone && wnsResponse) {
|
||||||
const { dxos: { image: current } } = status.system_status;
|
const statusData = JSON.parse(statusRespone.system_status.json);
|
||||||
|
const wnsData = JSON.parse(wnsResponse.wns_records.json);
|
||||||
|
|
||||||
|
const { dxos: { image: current = '0.0.0' } = {} } = statusData;
|
||||||
|
|
||||||
let latest = current;
|
let latest = current;
|
||||||
const data = JSON.parse(wnsResponse.wns_records.json);
|
wnsData.forEach(({ attributes: { name, version } }) => {
|
||||||
data.forEach(({ attributes: { name, version } }) => {
|
|
||||||
// TODO(burdon): Filter by type (WRN?)
|
// TODO(burdon): Filter by type (WRN?)
|
||||||
if (name.startsWith('dxos/xbox:')) {
|
if (name.startsWith('dxos/xbox:')) {
|
||||||
if (compareVersions(version, latest) > 0) {
|
if (compareVersions(version, latest) > 0) {
|
||||||
|
@ -16,18 +16,20 @@ import Toolbar from '../../components/Toolbar';
|
|||||||
|
|
||||||
const Status = () => {
|
const Status = () => {
|
||||||
const { config } = useContext(ConsoleContext);
|
const { config } = useContext(ConsoleContext);
|
||||||
const data = useQueryStatusReducer(useQuery(SYSTEM_STATUS, { pollInterval: config.api.intervalQuery }));
|
const systemResponse = useQueryStatusReducer(useQuery(SYSTEM_STATUS, { pollInterval: config.api.intervalQuery }));
|
||||||
if (!data) {
|
if (!systemResponse) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const data = JSON.parse(systemResponse.system_status.json);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Panel
|
<Panel
|
||||||
toolbar={
|
toolbar={
|
||||||
<Toolbar />
|
<Toolbar />
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Json data={data.system_status} />
|
<Json data={data} />
|
||||||
</Panel>
|
</Panel>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -4,18 +4,7 @@
|
|||||||
|
|
||||||
query {
|
query {
|
||||||
system_status {
|
system_status {
|
||||||
timestamp
|
timestamp,
|
||||||
dxos {
|
json
|
||||||
image
|
|
||||||
}
|
|
||||||
system {
|
|
||||||
network {
|
|
||||||
address
|
|
||||||
}
|
|
||||||
nodejs {
|
|
||||||
version
|
|
||||||
environment
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"name": "@dxos/console-app",
|
"name": "@dxos/console-app",
|
||||||
"buildDate": "2020-06-08T23:14:00.921Z",
|
"buildDate": "2020-06-09T03:18:46.229Z",
|
||||||
"version": "1.0.0-beta.0"
|
"version": "1.0.0-beta.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,26 +2,7 @@
|
|||||||
# Copyright 2020 DxOS.org
|
# Copyright 2020 DxOS.org
|
||||||
#
|
#
|
||||||
|
|
||||||
type DXOSInfo {
|
|
||||||
image: String
|
|
||||||
}
|
|
||||||
|
|
||||||
type NetworkInfo {
|
|
||||||
address: [String]
|
|
||||||
}
|
|
||||||
|
|
||||||
type NodeInfo {
|
|
||||||
version: String
|
|
||||||
environment: String
|
|
||||||
}
|
|
||||||
|
|
||||||
type SystemInfo {
|
|
||||||
network: NetworkInfo
|
|
||||||
nodejs: NodeInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
type SystemStatus {
|
type SystemStatus {
|
||||||
timestamp: String!
|
timestamp: String!
|
||||||
dxos: DXOSInfo
|
json: String!
|
||||||
system: SystemInfo
|
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@ const getSystemInfo = async () => {
|
|||||||
const ifaces = os.networkInterfaces();
|
const ifaces = os.networkInterfaces();
|
||||||
const addresses = Object.entries(ifaces).reduce((result, [, values]) => {
|
const addresses = Object.entries(ifaces).reduce((result, [, values]) => {
|
||||||
values.forEach(({ family, address }) => {
|
values.forEach(({ family, address }) => {
|
||||||
if (family === 'IPv4' && address !== '127.0.0.1') {
|
address = address.toLowerCase();
|
||||||
|
//TODO(telackey): Include link-local IPv6?
|
||||||
|
if (!address.startsWith('127.') && !address.startsWith('fe80::') && !address.startsWith('::1')) {
|
||||||
result.push(address);
|
result.push(address);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -42,7 +44,7 @@ const getSystemInfo = async () => {
|
|||||||
const device = await si.system();
|
const device = await si.system();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cpu: pick(cpu, 'brand', 'cores', 'manufacturer', 'vendor'),
|
cpu: pick(cpu, 'brand', 'cores', 'manufacturer', 'vendor', 'speed'),
|
||||||
|
|
||||||
memory: {
|
memory: {
|
||||||
total: size(memory.total, 'M'),
|
total: size(memory.total, 'M'),
|
||||||
@ -54,21 +56,23 @@ const getSystemInfo = async () => {
|
|||||||
device: pick(device, 'model', 'serial', 'version'),
|
device: pick(device, 'model', 'serial', 'version'),
|
||||||
|
|
||||||
network: {
|
network: {
|
||||||
address: addresses
|
addresses
|
||||||
},
|
},
|
||||||
|
|
||||||
// https://nodejs.org/api/os.html
|
// https://nodejs.org/api/os.html
|
||||||
os: {
|
os: {
|
||||||
arch: os.arch(),
|
arch: os.arch(),
|
||||||
type: os.type(),
|
|
||||||
platform: os.platform(),
|
platform: os.platform(),
|
||||||
version: os.version ? os.version() : undefined, // Node > 13
|
version: os.version ? os.version() : undefined, // Node > 13
|
||||||
uptime: moment().subtract(os.uptime(), 'seconds').fromNow()
|
},
|
||||||
|
|
||||||
|
time: {
|
||||||
|
now: moment(),
|
||||||
|
up: moment().subtract(os.uptime(), 'seconds'),
|
||||||
},
|
},
|
||||||
|
|
||||||
nodejs: {
|
nodejs: {
|
||||||
version: process.version,
|
version: process.version
|
||||||
environment: process.env.NODE_ENV
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -80,11 +84,7 @@ export const systemResolvers = {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
timestamp: new Date().toUTCString(),
|
timestamp: new Date().toUTCString(),
|
||||||
dxos: {
|
json: JSON.stringify(system)
|
||||||
// TODO(burdon): ???
|
|
||||||
image: '0.0.1'
|
|
||||||
},
|
|
||||||
system
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user