mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-25 18:36:19 +00:00
separate projects, builds, build console blocks at the client
This commit is contained in:
parent
4c6f55b445
commit
5cfebe1aa1
@ -7,8 +7,10 @@
|
||||
},
|
||||
"steps": [
|
||||
{"type": "shell", "cmd": "echo \"hello, cur dir is `pwd`\""},
|
||||
{"type": "shell", "cmd": "sleep 3"},
|
||||
{"type": "shell", "cmd": "sleep 4"},
|
||||
{"type": "shell", "cmd": "echo 1 > 1.txt"},
|
||||
{"type": "shell", "cmd": "echo 2 > 2.txt"}
|
||||
{"type": "shell", "cmd": "sleep 4"},
|
||||
{"type": "shell", "cmd": "echo 2 > 2.txt"},
|
||||
{"type": "shell", "cmd": "cat 1.txt 2.txt"}
|
||||
]
|
||||
}
|
@ -7,6 +7,8 @@
|
||||
},
|
||||
"steps": [
|
||||
{"type": "shell", "cmd": "echo 11 > 11.txt"},
|
||||
{"type": "shell", "cmd": "echo 22 > 22.txt"}
|
||||
{"type": "shell", "cmd": "sleep 4"},
|
||||
{"type": "shell", "cmd": "echo 22 > 22.txt"},
|
||||
{"type": "shell", "cmd": "cat 11.txt 22.txt"}
|
||||
]
|
||||
}
|
@ -7,37 +7,44 @@ define([
|
||||
) {
|
||||
var connect = dataio(socketio.connect());
|
||||
|
||||
var projects = connect.resource('projects');
|
||||
var builds = connect.resource('builds');
|
||||
var projects = connect.resource('projects'),
|
||||
projectsTemplate = _($('#projects-template').html()).template();
|
||||
|
||||
var projectsTemplate = _($('#projects-template').html()).template();
|
||||
$('#content').on('click', '.js-projects .js-run', function() {
|
||||
$('#projects').on('click', '.js-projects .js-run', function() {
|
||||
var projectName = $(this).parent('.js-project').data('name');
|
||||
projects.sync('run', {projectName: projectName}, function(err, result) {
|
||||
$('#content').append(
|
||||
(err && err.message)
|
||||
);
|
||||
$('#content').append(err && err.message);
|
||||
});
|
||||
});
|
||||
|
||||
projects.sync('read', function(err, projects) {
|
||||
$('#content').html(
|
||||
$('#projects').html(
|
||||
(err && err.message) ||
|
||||
projectsTemplate({projects: projects})
|
||||
);
|
||||
});
|
||||
|
||||
builds.subscribe(function(data, action) {
|
||||
$('#content').append(
|
||||
action.action + ': ' + JSON.stringify(data) + '<br>'
|
||||
);
|
||||
if (action.action === 'create') {
|
||||
var name = 'build' + data.id;
|
||||
connect.resource(name).subscribe(function(data, action) {
|
||||
$('#content').append(
|
||||
'<br>' + name + ': ' + data + '<br>'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
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()
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@ -7,8 +7,6 @@ html
|
||||
require(['app/app']);
|
||||
|
||||
body
|
||||
h1 hello world
|
||||
|
||||
|
||||
script#projects-template(type="text/template")
|
||||
| <div class="js-projects">
|
||||
@ -20,5 +18,25 @@ html
|
||||
| <% }); %>
|
||||
| </div>
|
||||
|
||||
script#builds-template(type="text/template")
|
||||
| <div class="js-builds">
|
||||
| <% _(builds).each(function(build) { %>
|
||||
| <div class="js-build" data-id="<%= build.id %>">
|
||||
| <span>#<%= build.id %></span>
|
||||
| <span><%= build.project.name %></span>
|
||||
| <span><%= build.status %></span>
|
||||
| <span class="js-show-console">→</span>
|
||||
| </div>
|
||||
| <% }); %>
|
||||
| </div>
|
||||
|
||||
h2 Projects
|
||||
#projects
|
||||
|
||||
h2 Builds
|
||||
#builds
|
||||
|
||||
h2 Build console
|
||||
#build-console
|
||||
|
||||
#content
|
||||
|
Loading…
Reference in New Issue
Block a user