- Add copy button to the build logs
- Add support for timestamps in the build logs - Other small UI improvements to the build view
This commit is contained in:
parent
e227d7e526
commit
ed46d37ea7
12 changed files with 189 additions and 18 deletions
|
@ -10,18 +10,35 @@ angular.module('quay').directive('buildLogsView', function () {
|
|||
restrict: 'C',
|
||||
scope: {
|
||||
'build': '=build',
|
||||
'useTimestamps': '=useTimestamps',
|
||||
'buildUpdated': '&buildUpdated'
|
||||
},
|
||||
controller: function($scope, $element, $interval, $sanitize, ansi2html, AngularViewArray,
|
||||
AngularPollChannel, ApiService, Restangular) {
|
||||
|
||||
var result = $element.find('#copyButton').clipboardCopy();
|
||||
if (!result) {
|
||||
$element.find('#copyButton').hide();
|
||||
}
|
||||
|
||||
$scope.logEntries = null;
|
||||
$scope.currentParentEntry = null;
|
||||
$scope.logStartIndex = 0;
|
||||
$scope.buildLogsText = '';
|
||||
|
||||
var pollChannel = null;
|
||||
var currentBuild = null;
|
||||
|
||||
var appendToTextLog = function(type, message) {
|
||||
if (type == 'phase') {
|
||||
text = 'Starting phase: ' + message + '\n';
|
||||
} else {
|
||||
text = message + '\n';
|
||||
}
|
||||
|
||||
$scope.buildLogsText += text.replace(new RegExp("\\033\\[[^m]+m"), '');
|
||||
};
|
||||
|
||||
var processLogs = function(logs, startIndex, endIndex) {
|
||||
if (!$scope.logEntries) { $scope.logEntries = []; }
|
||||
|
||||
|
@ -43,6 +60,8 @@ angular.module('quay').directive('buildLogsView', function () {
|
|||
} else if ($scope.currentParentEntry) {
|
||||
$scope.currentParentEntry['logs'].push(entry);
|
||||
}
|
||||
|
||||
appendToTextLog(type, entry['message']);
|
||||
}
|
||||
|
||||
return endIndex;
|
||||
|
@ -112,6 +131,11 @@ angular.module('quay').directive('buildLogsView', function () {
|
|||
}
|
||||
};
|
||||
|
||||
$scope.$watch('useTimestamps', function() {
|
||||
if (!$scope.logEntries) { return; }
|
||||
$scope.logEntries = $scope.logEntries.slice();
|
||||
});
|
||||
|
||||
$scope.$watch('build', function(build) {
|
||||
if (build) {
|
||||
startWatching(build);
|
||||
|
@ -124,6 +148,11 @@ angular.module('quay').directive('buildLogsView', function () {
|
|||
return container.logs.hasEntries;
|
||||
};
|
||||
|
||||
$scope.formatDatetime = function(datetimeString) {
|
||||
var dt = new Date(datetimeString);
|
||||
return dt.toLocaleString();
|
||||
}
|
||||
|
||||
$scope.processANSI = function(message, container) {
|
||||
var filter = container.logs._filter = (container.logs._filter || ansi2html.create());
|
||||
|
||||
|
|
Reference in a new issue