terminal output

This commit is contained in:
Vladimir Polyakov 2015-05-10 19:53:33 +03:00
parent ed8b86567b
commit 58fa1ef6e9
11 changed files with 44 additions and 22 deletions

View File

@ -29,4 +29,7 @@
font-size: inherit; font-size: inherit;
} }
} }
&_terminal {
margin-top: 10px;
}
} }

View File

@ -2,7 +2,7 @@
define(['reflux'], function(Reflux) { define(['reflux'], function(Reflux) {
var Actions = Reflux.createActions([ var Actions = Reflux.createActions([
'readConsoleOutput', 'readTerminalOutput',
'readAll' 'readAll'
]); ]);

View File

@ -21,7 +21,6 @@ define([
); );
Router.run(routes, Router.HistoryLocation, function(Handler) { Router.run(routes, Router.HistoryLocation, function(Handler) {
console.log(Handler);
React.render(template({ React.render(template({
Component: Handler Component: Handler
}), document.getElementById('content')); }), document.getElementById('content'));

View File

@ -4,15 +4,14 @@ define([
'react', 'react',
'app/components/projects/index', 'app/components/projects/index',
'app/components/builds/index', 'app/components/builds/index',
'app/components/console/index', 'app/components/terminal/index',
'templates/app/components/app' 'templates/app/components/app'
], function(React, Projects, Builds, Console, template) { ], function(React, Projects, Builds, Console, template) {
var Component = React.createClass({ var Component = React.createClass({
render: function() { render: function() {
return template({ return template({
ProjectsList: Projects.List, ProjectsList: Projects.List,
BuildsList: Builds.List, BuildsList: Builds.List
Console: Console.Console
}); });
} }
}); });

View File

@ -13,7 +13,10 @@ mixin statusText(build)
.build(class="build__#{build.status}") .build(class="build__#{build.status}")
.build_controls.pull-right .build_controls.pull-right
a(href="javascript:void(0);", onClick=this.onBuildSelect(build.id)) a(href="javascript:void(0);", onClick=this.onBuildSelect(build.id))
i.fa.fa-2x.fa-repeat(title="Rebuild", style={marginTop: '5px'}, onClick=this.onRebuildProject(build.project.name)) i.fa.fa-2x.fa-repeat(title="Rebuild", style={marginRight: '15px'}, onClick=this.onRebuildProject(build.project.name))
a(href="javascript:void(0);", onClick=this.onShowTerminal)
i.fa.fa-2x.fa-terminal(title="Rebuild")
.build_header .build_header
span # span #
span= build.id span= build.id
@ -34,7 +37,7 @@ mixin statusText(build)
span.build_info span.build_info
i.fa.fa-fw.fa-clock-o i.fa.fa-fw.fa-clock-o
| builded at | builded at
DateTime(date=new Date(build.createDate)) DateTime(date=new Date(build.endDate))
else else
if build.startDate if build.startDate
span.build_info span.build_info
@ -45,4 +48,8 @@ mixin statusText(build)
span.build_info span.build_info
i.fa.fa-fw.fa-clock-o i.fa.fa-fw.fa-clock-o
| queued at | queued at
DateTime(date=new Date(build.endDate)) DateTime(date=new Date(build.createDate))
if this.state.showTerminal
.build_terminal
Terminal(build=build)

View File

@ -3,20 +3,32 @@
define([ define([
'react', 'app/actions/project', 'react', 'app/actions/project',
'app/actions/build', 'templates/app/components/builds/item', 'app/actions/build', 'templates/app/components/builds/item',
'app/components/terminal/terminal',
'app/components/common/index' 'app/components/common/index'
], function(React, ProjectActions, BuildActions, template, CommonComponents) { ], function(
React, ProjectActions, BuildActions, template,
TerminalComponent, CommonComponents
) {
template = template.locals({ template = template.locals({
DateTime: CommonComponents.DateTime DateTime: CommonComponents.DateTime,
Terminal: TerminalComponent
}); });
console.log(CommonComponents.DateTime);
var Component = React.createClass({ var Component = React.createClass({
getInitialState: function() {
return {
showTerminal: false
};
},
onRebuildProject: function(projectName) { onRebuildProject: function(projectName) {
ProjectActions.run(projectName) ProjectActions.run(projectName)
}, },
onShowTerminal: function(build) {
this.setState({showTerminal: !this.state.showTerminal});
BuildActions.readTerminalOutput(this.props.build.id);
},
onBuildSelect: function(buildId) { onBuildSelect: function(buildId) {
console.log('on build select'); console.log('on build select');
BuildActions.readConsoleOutput(buildId);
}, },
render: template render: template
}); });

View File

@ -1,3 +0,0 @@
if name
h2= name
pre= data

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
define([ define([
'app/components/console/console', 'app/components/terminal/terminal',
], function(Console) { ], function(Console) {
return { return {
Console: Console Console: Console

View File

@ -0,0 +1 @@
pre= data

View File

@ -3,16 +3,19 @@
define([ define([
'react', 'react',
'reflux', 'reflux',
'app/stores/console', 'app/stores/terminal',
'templates/app/components/console/console' 'templates/app/components/terminal/terminal'
], function(React, Reflux, consoleStore, template) { ], function(React, Reflux, terminalStore, template) {
var Component = React.createClass({ var Component = React.createClass({
mixins: [Reflux.ListenerMixin], mixins: [Reflux.ListenerMixin],
componentDidMount: function() { componentDidMount: function() {
this.listenTo(consoleStore, this.updateItems); this.listenTo(terminalStore, this.updateItems);
}, },
updateItems: function(data) { updateItems: function(data) {
this.setState({data: data}); // listen just our console update
if (data.buildId === this.props.build.id) {
this.setState({data: data});
}
}, },
render: function() { render: function() {
return template(this.state.data); return template(this.state.data);

View File

@ -13,7 +13,7 @@ define([
console.log('init builds console output'); console.log('init builds console output');
}, },
onReadConsoleOutput: function(buildId) { onReadTerminalOutput: function(buildId) {
var self = this; var self = this;
self.output = ''; self.output = '';
@ -27,6 +27,7 @@ define([
if (!/\n$/.test(self.output)) self.output += '\n'; if (!/\n$/.test(self.output)) self.output += '\n';
self.trigger({ self.trigger({
buildId: buildId,
name: 'Console for build #' + buildId, name: 'Console for build #' + buildId,
data: self.output data: self.output
}); });