pond: logs window
This commit is contained in:
parent
eb97be8df4
commit
89ea5a4750
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
logging.SetLogLevel("*", "DEBUG")
|
||||
logging.SetLogLevel("*", "INFO")
|
||||
local := []*cli.Command{
|
||||
DaemonCmd,
|
||||
}
|
||||
|
15
lotuspond/front/package-lock.json
generated
15
lotuspond/front/package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -75,3 +75,12 @@
|
||||
.ChainExplorer-before {
|
||||
background: #cccc00
|
||||
}
|
||||
|
||||
.Logs {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.Logs-window :nth-child(2) {
|
||||
height: 100%;
|
||||
}
|
||||
|
31
lotuspond/front/src/Logs.js
Normal file
31
lotuspond/front/src/Logs.js
Normal file
@ -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 <Cristal className="Logs-window" onClose={this.props.onClose} initialSize={{width: 1000, height: 480}} title={`Node ${this.props.node} Logs`}>
|
||||
<div ref={this.termRef} className="Logs"/>
|
||||
</Cristal>
|
||||
}
|
||||
}
|
||||
|
||||
export default Logs
|
@ -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 = <span>{nd.peerid}</span>
|
||||
logs = <a href='#' onClick={() => this.props.mountWindow(cl => <Logs node={nd.ID} onClose={cl}/>)}>[logs]</a>
|
||||
}
|
||||
|
||||
return <div key={n}>
|
||||
{n} {type} {info}
|
||||
{n} {type} {logs} {info}
|
||||
</div>
|
||||
})}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user