- 修改接入资产时窗口标题为资产名称

- 增加用户属性表
This commit is contained in:
dushixiang
2021-01-31 20:20:40 +08:00
parent 48b978b2c2
commit 86ef89ff21
6 changed files with 89 additions and 46 deletions

View File

@ -436,7 +436,7 @@ class Access extends Component {
this.showMessage(result['message']);
return null;
}
document.title = result['data']['ip'] + ':' + result['data']['port'];
document.title = result['data']['name'];
return result['data']['id'];
}

View File

@ -4,9 +4,10 @@ import {Terminal} from "xterm";
import qs from "qs";
import {wsServer} from "../../common/constants";
import "./Console.css"
import {getToken} from "../../utils/utils";
import {getToken, isEmpty} from "../../utils/utils";
import {FitAddon} from 'xterm-addon-fit';
import "./Access.css"
import request from "../../common/request";
class AccessSSH extends Component {
@ -18,15 +19,20 @@ class AccessSSH extends Component {
fitAddon: undefined
};
componentDidMount() {
componentDidMount = async () => {
let urlParams = new URLSearchParams(this.props.location.search);
let assetId = urlParams.get('assetId');
let sessionId = await this.createSession(assetId);
if (isEmpty(sessionId)) {
return;
}
let params = {
'width': this.state.width,
'height': this.state.height,
'assetId': assetId
'sessionId': sessionId
};
let paramStr = qs.stringify(params);
@ -104,6 +110,7 @@ class AccessSSH extends Component {
let msg = JSON.parse(e.data);
switch (msg['type']) {
case 'connected':
term.clear();
console.log(msg['content'])
this.onWindowResize();
break;
@ -135,6 +142,16 @@ class AccessSSH extends Component {
}
}
async createSession(assetsId) {
let result = await request.post(`/sessions?assetId=${assetsId}`);
if (result['code'] !== 1) {
this.showMessage(result['message']);
return null;
}
document.title = result['data']['name'];
return result['data']['id'];
}
terminalSize() {
return {
cols: Math.floor(this.state.width / 7.5),
@ -169,8 +186,9 @@ class AccessSSH extends Component {
<div ref='terminal' id='terminal' style={{
height: this.state.height,
width: this.state.width,
backgroundColor: 'black',
overflowX: 'hidden',
overflowY: 'hidden'
overflowY: 'hidden',
}}/>
</div>
);