Semaphore/public/js/controllers/projects/taskRunner.js

31 lines
941 B
JavaScript
Raw Normal View History

2016-04-17 02:20:23 +02:00
define(function () {
app.registerController('CreateTaskCtrl', ['$scope', '$http', 'Template', 'Project', function ($scope, $http, Template, Project) {
console.log(Template);
$scope.task = {};
$scope.run = function (task) {
task.template_id = Template.id;
$http.post(Project.getURL() + '/tasks', task).success(function (t) {
}).error(function (_, status) {
swal('Error', 'error launching task: HTTP ' + status, 'error');
});
}
}]);
app.registerController('TaskCtrl', ['$scope', '$http', function ($scope, $http) {
2016-05-01 13:24:09 +02:00
$scope.$on('remote.log', function (evt, data) {
$scope.output_formatted.splice(0, 0, data);
});
$http.get($scope.project.getURL() + '/tasks/' + $scope.task.id + '/output')
.success(function (output) {
var out = [];
output.forEach(function (o) {
out.push(moment(o.time).format('HH:mm:ss') + ': ' + o.output);
});
$scope.output_formatted = out.join('\n');
});
2016-04-17 02:20:23 +02:00
}]);
});