2015-04-10 20:17:03 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-04-12 22:41:09 +00:00
|
|
|
define([
|
2015-04-30 15:15:23 +00:00
|
|
|
'underscore', 'react', 'socketio', 'dataio', 'jquery'
|
2015-04-12 22:41:09 +00:00
|
|
|
], function(
|
2015-04-30 15:15:23 +00:00
|
|
|
_, React, socketio, dataio, $
|
2015-04-12 22:41:09 +00:00
|
|
|
) {
|
|
|
|
var connect = dataio(socketio.connect());
|
|
|
|
|
2015-05-04 09:14:37 +00:00
|
|
|
var projects = connect.resource('projects'),
|
|
|
|
projectsTemplate = _($('#projects-template').html()).template();
|
2015-05-01 11:11:29 +00:00
|
|
|
|
2015-05-04 09:14:37 +00:00
|
|
|
$('#projects').on('click', '.js-projects .js-run', function() {
|
2015-05-01 11:11:29 +00:00
|
|
|
var projectName = $(this).parent('.js-project').data('name');
|
|
|
|
projects.sync('run', {projectName: projectName}, function(err, result) {
|
2015-05-04 09:14:37 +00:00
|
|
|
$('#content').append(err && err.message);
|
2015-05-01 11:11:29 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-04-12 22:41:09 +00:00
|
|
|
projects.sync('read', function(err, projects) {
|
2015-05-04 09:14:37 +00:00
|
|
|
$('#projects').html(
|
2015-04-12 22:56:47 +00:00
|
|
|
(err && err.message) ||
|
2015-05-01 11:11:29 +00:00
|
|
|
projectsTemplate({projects: projects})
|
2015-04-12 22:56:47 +00:00
|
|
|
);
|
2015-04-12 22:41:09 +00:00
|
|
|
});
|
2015-05-03 15:23:01 +00:00
|
|
|
|
2015-05-04 09:14:37 +00:00
|
|
|
|
|
|
|
var builds = connect.resource('builds'),
|
|
|
|
buildsTemplate = _($('#builds-template').html()).template(),
|
|
|
|
buildsHash = {};
|
|
|
|
|
|
|
|
$('#builds').on('click', '.js-builds .js-show-console', function() {
|
|
|
|
var buildId = $(this).parent('.js-build').data('id'),
|
|
|
|
resourceName = 'build' + buildId;;
|
|
|
|
|
|
|
|
$('#build-console').prev('h2').html('Build #' + buildId + ' console');
|
|
|
|
$('#build-console').html('');
|
|
|
|
|
|
|
|
connect.resource(resourceName).subscribe(function(data) {
|
|
|
|
$('#build-console').append('<div>' + data + '</div>');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
builds.subscribe(function(build, action) {
|
|
|
|
buildsHash[build.id] = build;
|
|
|
|
$('#builds').html(buildsTemplate({
|
|
|
|
builds: _(buildsHash).values().reverse()
|
|
|
|
}));
|
2015-05-03 15:23:01 +00:00
|
|
|
});
|
2015-04-10 20:17:03 +00:00
|
|
|
});
|