Skip to content

Commit

Permalink
fix #170 add ssh loading indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
zxdong262 committed Jan 2, 2018
1 parent 2544ef3 commit 8b7c994
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/client/components/terminal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React from 'react'
import fetch from '../../common/fetch'
import {generate} from 'shortid'
import _ from 'lodash'
import {Spin} from 'antd'
import './terminal.styl'

const {Terminal, getGlobal} = window
let config = getGlobal('_config')
Expand All @@ -11,7 +13,8 @@ export default class Term extends React.Component {
constructor(props) {
super()
this.state = {
id: props.id || generate()
id: props.id || generate(),
loading: false
}
}

Expand Down Expand Up @@ -51,6 +54,9 @@ export default class Term extends React.Component {
count = 0

remoteInit = async (term) => {
this.setState({
loading: true
})
let {cols, rows} = term
let {host, port} = config
let wsUrl
Expand All @@ -63,6 +69,9 @@ export default class Term extends React.Component {
...tab,
type: tab.host ? 'remote' : 'local'
})
this.setState({
loading: false
})
if (!pid) return

term.pid = pid
Expand Down Expand Up @@ -105,10 +114,12 @@ export default class Term extends React.Component {
}

render() {
let {id} = this.state
let {id, loading} = this.state
let {height} = this.props
return (
<div id={id} style={{height}} className="bg-black" />
<Spin spinning={loading} wrapperClassName="loading-wrapper">
<div id={id} style={{height}} className="bg-black" />
</Spin>
)
}

Expand Down
5 changes: 5 additions & 0 deletions src/client/components/terminal/terminal.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.loading-wrapper
.ant-spin
color #fff
.ant-spin-blur
opacity 0

0 comments on commit 8b7c994

Please sign in to comment.