nci/static/js/app/stores/terminal.js

40 lines
762 B
JavaScript
Raw Normal View History

2015-05-07 21:55:40 +00:00
'use strict';
define([
'underscore',
'reflux', 'app/actions/build', 'app/connect'
], function(_, Reflux, BuildActions, connect) {
var Store = Reflux.createStore({
listenables: BuildActions,
output: '',
init: function() {
console.log('init builds console output');
},
2015-05-10 16:53:33 +00:00
onReadTerminalOutput: function(buildId) {
var self = this;
2015-05-07 21:55:40 +00:00
self.output = '';
var resourceName = 'build' + buildId;
2015-05-07 21:55:40 +00:00
connect.resource(resourceName).unsubscribeAll();
connect.resource(resourceName).subscribe(function(data) {
self.output += data;
if (!/\n$/.test(self.output)) self.output += '\n';
2015-05-07 21:55:40 +00:00
self.trigger({
2015-05-10 16:53:33 +00:00
buildId: buildId,
2015-05-07 21:55:40 +00:00
name: 'Console for build #' + buildId,
data: self.output
2015-05-07 21:55:40 +00:00
});
});
}
});
return Store;
});