mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-11 03:39:15 +00:00
terminal functionality
This commit is contained in:
parent
6b97f36d2b
commit
ebedeab8f2
@ -12,7 +12,8 @@
|
|||||||
"reflux": "0.2.7",
|
"reflux": "0.2.7",
|
||||||
"bootstrap": "3.3.4",
|
"bootstrap": "3.3.4",
|
||||||
"font-awesome": "4.3.0",
|
"font-awesome": "4.3.0",
|
||||||
"react-router": "0.13.3"
|
"react-router": "0.13.3",
|
||||||
|
"ansi_up": "1.2.1"
|
||||||
},
|
},
|
||||||
"moduleType": [
|
"moduleType": [
|
||||||
"amd"
|
"amd"
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
.terminal {
|
.terminal {
|
||||||
|
box-sizing: border-box;
|
||||||
&_code {
|
&_code {
|
||||||
/*max-height: 100px;*/
|
max-height: 200px;
|
||||||
/*overflow-y: scroll;*/
|
padding: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
overflow-y: scroll;
|
||||||
|
border: none;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
color: white;
|
||||||
|
background-color: black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.main-row
|
.main-row
|
||||||
.row
|
.row
|
||||||
.col-md-8
|
.col-md-8
|
||||||
h2 Active builds
|
h2 Last builds
|
||||||
BuildsList()
|
BuildsList()
|
||||||
|
@ -30,4 +30,6 @@ if this.state.build
|
|||||||
| Error:
|
| Error:
|
||||||
span= this.state.build.error
|
span= this.state.build.error
|
||||||
|
|
||||||
Terminal(build=this.state.build.id)
|
.row
|
||||||
|
.col-md-8
|
||||||
|
Terminal(build=this.state.build.id)
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
.terminal
|
.terminal(onScroll=this.onScroll)
|
||||||
pre.terminal_code= this.state.data
|
.terminal_code(ref="code", onScroll=this.onScroll)!= this.state.data
|
||||||
|
@ -1,20 +1,44 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
define([
|
define([
|
||||||
|
'underscore',
|
||||||
'react',
|
'react',
|
||||||
'reflux',
|
'reflux',
|
||||||
'app/stores/terminal',
|
'app/stores/terminal',
|
||||||
|
'ansi_up',
|
||||||
'templates/app/components/terminal/terminal'
|
'templates/app/components/terminal/terminal'
|
||||||
], function(React, Reflux, terminalStore, template) {
|
], function(_, React, Reflux, terminalStore, ansiUp, template) {
|
||||||
var Component = React.createClass({
|
var Component = React.createClass({
|
||||||
mixins: [Reflux.ListenerMixin],
|
mixins: [Reflux.ListenerMixin],
|
||||||
|
scrollOnData: true,
|
||||||
|
ignoreScrollEvent: false,
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this.listenTo(terminalStore, this.updateItems);
|
this.listenTo(terminalStore, this.updateItems);
|
||||||
},
|
},
|
||||||
updateItems: function(data) {
|
ensureScrollPosition: function() {
|
||||||
|
if (this.scrollOnData) {
|
||||||
|
var codeNode = this.refs.code.getDOMNode();
|
||||||
|
this.ignoreScrollEvent = true;
|
||||||
|
codeNode.scrollTop = codeNode.scrollHeight - codeNode.offsetHeight;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onScroll: function() {
|
||||||
|
if (!this.ignoreScrollEvent) {
|
||||||
|
var codeNode = this.refs.code.getDOMNode();
|
||||||
|
if (codeNode.offsetHeight + codeNode.scrollTop >= codeNode.scrollHeight) {
|
||||||
|
this.scrollOnData = true;
|
||||||
|
} else {
|
||||||
|
this.scrollOnData = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.ignoreScrollEvent = false;
|
||||||
|
},
|
||||||
|
updateItems: function(build) {
|
||||||
// listen just our console update
|
// listen just our console update
|
||||||
if (data.buildId === this.props.build) {
|
if (build.buildId === this.props.build) {
|
||||||
this.setState({data: data});
|
this.setState({data: ansiUp.ansi_to_html(build.data)});
|
||||||
|
_.defer(this.ensureScrollPosition);
|
||||||
|
this.ensureScrollPosition();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
render: template,
|
render: template,
|
||||||
|
@ -9,6 +9,7 @@ require.config({
|
|||||||
reflux: 'libs/reflux/dist/reflux',
|
reflux: 'libs/reflux/dist/reflux',
|
||||||
_dataio: '/data.io',
|
_dataio: '/data.io',
|
||||||
socketio: '/socket.io/socket.io.js',
|
socketio: '/socket.io/socket.io.js',
|
||||||
jquery: 'libs/jquery/jquery'
|
jquery: 'libs/jquery/jquery',
|
||||||
|
ansi_up: 'libs/ansi_up/ansi_up'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user