Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Docker-compose log output during intial start of services #54
Browse files Browse the repository at this point in the history
  • Loading branch information
francescou committed Nov 1, 2016
1 parent d86b9d4 commit c13332c
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions static/scripts/directives/actions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

angular.module('composeUiApp')
.directive('actions', function ($resource, projectService, logService) {
.directive('actions', function ($resource, projectService, logService, $interval) {

return {
restrict: 'E',
Expand Down Expand Up @@ -73,19 +73,45 @@ angular.module('composeUiApp')
updateProjectStatus(Project.stop, 'project stopped');
};

var Logz = $resource('api/v1/logs-since/:id/:since');

function updateProjectStatus(fn, msg) {
$scope.working = true;
var id = $scope.projectId;

var now = Math.floor(new Date().getTime() / 1000);

var refreshLogs = $interval(function () {

Logz.get({id: $scope.projectId, since: now}, function (data) {
var logs = logService.formatLogs(data.logs);

var lines = _.map(logs, function (item) {
return item.container + '<br>' + item.text;
});

_.each(lines, function (msg) {
alertify.message(msg);
});

});

now = Math.floor(new Date().getTime() / 1000);

}, 1500);

fn({id: id}, function () {
alertify.success(msg);
$scope.working = false;
Project.get({id: id}, function (data) {
$scope.services = projectService.groupByService(data);
});
$scope.$parent.$parent.reload(false);
$interval.cancel(refreshLogs);
}, function (err) {
$scope.working = false;
alertify.alert(err.data);
$interval.cancel(refreshLogs);
});

}
Expand All @@ -106,7 +132,6 @@ angular.module('composeUiApp')

$scope.lineLimit = 80;
$scope.combinedLogs = function () {

Logs.get({id: $scope.projectId, limit: $scope.lineLimit}, function (data) {
$scope.logs = logService.formatLogs(data.logs);
$scope.showCombinedLogsDialog = true;
Expand Down

0 comments on commit c13332c

Please sign in to comment.