From 89ea5a47509db950cd50a88d01b744aa7afd826a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 19 Aug 2019 23:30:46 +0200 Subject: [PATCH] pond: logs window --- cmd/lotus/main.go | 2 +- lotuspond/front/package-lock.json | 15 +++++++++++++++ lotuspond/front/package.json | 5 ++++- lotuspond/front/src/App.css | 9 +++++++++ lotuspond/front/src/Logs.js | 31 +++++++++++++++++++++++++++++++ lotuspond/front/src/NodeList.js | 5 ++++- 6 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 lotuspond/front/src/Logs.js diff --git a/cmd/lotus/main.go b/cmd/lotus/main.go index 6dd7afa14..3b6c194d8 100644 --- a/cmd/lotus/main.go +++ b/cmd/lotus/main.go @@ -15,7 +15,7 @@ import ( ) func main() { - logging.SetLogLevel("*", "DEBUG") + logging.SetLogLevel("*", "INFO") local := []*cli.Command{ DaemonCmd, } diff --git a/lotuspond/front/package-lock.json b/lotuspond/front/package-lock.json index 65a233010..10b714fb5 100644 --- a/lotuspond/front/package-lock.json +++ b/lotuspond/front/package-lock.json @@ -13075,6 +13075,21 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, + "xterm": { + "version": "3.14.5", + "resolved": "https://registry.npmjs.org/xterm/-/xterm-3.14.5.tgz", + "integrity": "sha512-DVmQ8jlEtL+WbBKUZuMxHMBgK/yeIZwkXB81bH+MGaKKnJGYwA+770hzhXPfwEIokK9On9YIFPRleVp/5G7z9g==" + }, + "xterm-addon-attach": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/xterm-addon-attach/-/xterm-addon-attach-0.1.0.tgz", + "integrity": "sha512-vImYAP+AVoW/gnr4CIESrOr2MplzNxnrPX4YEkdk0EEkBOg3Pwnndu1xy7HnY0XZsfGRz7rfn71sAXfJDGLvUQ==" + }, + "xterm-addon-fit": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/xterm-addon-fit/-/xterm-addon-fit-0.1.0.tgz", + "integrity": "sha512-DzYThnR5rXYX7JrOZ8rHGMU36BiTwYNFUOhhNwrDSFvoUR2MgwQrfA/JrqLE62KRj0D8bkRR7+xe7qGBp1O4Rw==" + }, "y18n": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", diff --git a/lotuspond/front/package.json b/lotuspond/front/package.json index 6ae824cf2..e1adde73a 100644 --- a/lotuspond/front/package.json +++ b/lotuspond/front/package.json @@ -13,7 +13,10 @@ "react-dom": "^16.8.6", "react-scripts": "3.0.1", "rpc-websockets": "^4.5.1", - "styled-components": "^3.3.3" + "styled-components": "^3.3.3", + "xterm": "^3.14.5", + "xterm-addon-attach": "^0.1.0", + "xterm-addon-fit": "^0.1.0" }, "scripts": { "start": "react-scripts start", diff --git a/lotuspond/front/src/App.css b/lotuspond/front/src/App.css index c3649e13e..349b75f8f 100644 --- a/lotuspond/front/src/App.css +++ b/lotuspond/front/src/App.css @@ -75,3 +75,12 @@ .ChainExplorer-before { background: #cccc00 } + +.Logs { + width: 100%; + height: 100%; +} + +.Logs-window :nth-child(2) { + height: 100%; +} diff --git a/lotuspond/front/src/Logs.js b/lotuspond/front/src/Logs.js new file mode 100644 index 000000000..ec98feb79 --- /dev/null +++ b/lotuspond/front/src/Logs.js @@ -0,0 +1,31 @@ +import React from 'react' +import {Cristal} from "react-cristal"; +import { Terminal } from 'xterm'; +import { AttachAddon } from "xterm-addon-attach"; +import 'xterm/dist/xterm.css'; +import * as fit from 'xterm/lib/addons/fit/fit'; + +class Logs extends React.Component { + constructor(props) { + super(props); + this.termRef = React.createRef() + this.winRef = React.createRef() + } + + async componentDidMount() { + Terminal.applyAddon(fit); + + this.terminal = new Terminal({convertEol: true, fontSize: 11}); + this.terminal.loadAddon(new AttachAddon(new WebSocket(`ws://127.0.0.1:2222/logs/${this.props.node}`), {bidirectional: false, inputUtf8: true})) + this.terminal.open(this.termRef.current) + setInterval(() => this.terminal.fit(), 200) + } + + render() { + return +
+ + } +} + +export default Logs diff --git a/lotuspond/front/src/NodeList.js b/lotuspond/front/src/NodeList.js index 2e6d59fe8..46f84aefa 100644 --- a/lotuspond/front/src/NodeList.js +++ b/lotuspond/front/src/NodeList.js @@ -6,6 +6,7 @@ import {Cristal} from "react-cristal"; import StorageNode from "./StorageNode"; import {Client} from "rpc-websockets"; import pushMessage from "./chain/send"; +import Logs from "./Logs"; class NodeList extends React.Component { constructor(props) { @@ -130,13 +131,15 @@ class NodeList extends React.Component { type = "STOR" } + let logs = "[logs]" let info = "[CONNECTING..]" if (nd.conn) { info = {nd.peerid} + logs = this.props.mountWindow(cl => )}>[logs] } return
- {n} {type} {info} + {n} {type} {logs} {info}
})}