logs page: slow on huge logs - 'show last lines' option

pull/2/head
jonny64 2015-02-05 19:23:57 +00:00
parent ccd27f203d
commit aead1fcc29
2 changed files with 22 additions and 3 deletions

View File

@ -4,6 +4,7 @@ function($scope, $routeParams, $location, $anchorScroll, ContainerLogs, Containe
$scope.stdout = '';
$scope.stderr = '';
$scope.showTimestamps = false;
$scope.tailLines = 2000;
ViewSpinner.spin();
Container.get({id: $routeParams.id}, function(d) {
@ -19,7 +20,13 @@ function($scope, $routeParams, $location, $anchorScroll, ContainerLogs, Containe
});
function getLogs() {
ContainerLogs.get($routeParams.id, {stdout: 1, stderr: 0, timestamps: $scope.showTimestamps}, function(data, status, headers, config) {
console.log($scope.tailLines);
ContainerLogs.get($routeParams.id, {
stdout: 1,
stderr: 0,
timestamps: $scope.showTimestamps,
tail: $scope.tailLines
}, function(data, status, headers, config) {
// Replace carriage returns twith newlines to clean up output
$scope.stdout = data.replace(/[\r]/g, '\n');
});
@ -45,4 +52,8 @@ function($scope, $routeParams, $location, $anchorScroll, ContainerLogs, Containe
$scope.toggleTimestamps = function() {
getLogs();
};
$scope.toggleTail = function() {
getLogs();
};
}]);

View File

@ -6,8 +6,16 @@
<button class="btn btn-warning" ng-click="scrollTo('stderr')">stderr</button>
</div>
<div class="pull-right">
<input id="timestampToggle" type="checkbox" ng-model="showTimestamps"
ng-change="toggleTimestamps()"/> <label for="timestampToggle">Display Timestamps</label>
<span style="padding-right: 10px">
<label for="tailLines">Show last</label>
<input id="tailLines" type="text" size="1" maxlength="4"
ng-model="tailLines" ng-keypress="($event.which === 13)? toggleTail() : 0"/>
<label for="tailLines">lines</label>
</span>
<span>
<input id="timestampToggle" type="checkbox" ng-model="showTimestamps"
ng-change="toggleTimestamps()"/> <label for="timestampToggle">Display Timestamps</label>
</span>
</div>
</div>