feat(log-viewer): add the ability to display timestamps (#1697)

pull/1770/head
Rahul Ruikar 2018-03-25 10:36:13 +10:00 committed by Anthony Lapenna
parent 30dfd3d616
commit 80a23b5351
8 changed files with 26 additions and 12 deletions

View File

@ -3,6 +3,7 @@ angular.module('portainer.docker').component('logViewer', {
controller: 'LogViewerController',
bindings: {
data: '=',
displayTimestamps: '=',
logCollectionChange: '<'
}
});

View File

@ -15,6 +15,16 @@
</label>
</div>
</div>
<div class="form-group">
<div class="col-sm-12">
<label for="tls" class="control-label text-left">
Display timestamps
</label>
<label class="switch" style="margin-left: 20px;">
<input type="checkbox" ng-model="$ctrl.displayTimestamps"><i></i>
</label>
</div>
</div>
<div class="form-group">
<label for="logs_search" class="col-sm-1 control-label text-left">
Search

View File

@ -3,7 +3,8 @@ angular.module('portainer.docker')
function ($scope, $transition$, $interval, ContainerService, Notifications) {
$scope.state = {
refreshRate: 3,
lineCount: 2000
lineCount: 2000,
displayTimestamps: false
};
$scope.changeLogCollection = function(logCollectionStatus) {
@ -33,7 +34,7 @@ function ($scope, $transition$, $interval, ContainerService, Notifications) {
function setUpdateRepeater() {
var refreshRate = $scope.state.refreshRate;
$scope.repeater = $interval(function() {
ContainerService.logs($transition$.params().id, 1, 1, 0, $scope.state.lineCount)
ContainerService.logs($transition$.params().id, 1, 1, $scope.state.displayTimestamps ? 1 : 0, $scope.state.lineCount)
.then(function success(data) {
$scope.logs = data;
})
@ -45,7 +46,7 @@ function ($scope, $transition$, $interval, ContainerService, Notifications) {
}
function startLogPolling() {
ContainerService.logs($transition$.params().id, 1, 1, 0, $scope.state.lineCount)
ContainerService.logs($transition$.params().id, 1, 1, $scope.state.displayTimestamps ? 1 : 0, $scope.state.lineCount)
.then(function success(data) {
$scope.logs = data;
setUpdateRepeater();

View File

@ -6,5 +6,5 @@
</rd-header>
<log-viewer
data="logs" ng-if="logs" log-collection-change="changeLogCollection"
data="logs" ng-if="logs" log-collection-change="changeLogCollection" display-timestamps="state.displayTimestamps"
></log-viewer>

View File

@ -3,7 +3,8 @@ angular.module('portainer.docker')
function ($scope, $transition$, $interval, ServiceService, Notifications) {
$scope.state = {
refreshRate: 3,
lineCount: 2000
lineCount: 2000,
displayTimestamps: false
};
$scope.changeLogCollection = function(logCollectionStatus) {
@ -29,7 +30,7 @@ function ($scope, $transition$, $interval, ServiceService, Notifications) {
function setUpdateRepeater() {
var refreshRate = $scope.state.refreshRate;
$scope.repeater = $interval(function() {
ServiceService.logs($transition$.params().id, 1, 1, 0, $scope.state.lineCount)
ServiceService.logs($transition$.params().id, 1, 1, $scope.state.displayTimestamps ? 1 : 0, $scope.state.lineCount)
.then(function success(data) {
$scope.logs = data;
})
@ -41,7 +42,7 @@ function ($scope, $transition$, $interval, ServiceService, Notifications) {
}
function startLogPolling() {
ServiceService.logs($transition$.params().id, 1, 1, 0, $scope.state.lineCount)
ServiceService.logs($transition$.params().id, 1, 1, $scope.state.displayTimestamps ? 1 : 0, $scope.state.lineCount)
.then(function success(data) {
$scope.logs = data;
setUpdateRepeater();

View File

@ -6,5 +6,5 @@
</rd-header>
<log-viewer
data="logs" ng-if="logs" log-collection-change="changeLogCollection"
data="logs" ng-if="logs" log-collection-change="changeLogCollection" display-timestamps="state.displayTimestamps"
></log-viewer>

View File

@ -3,7 +3,8 @@ angular.module('portainer.docker')
function ($scope, $transition$, $interval, TaskService, ServiceService, Notifications) {
$scope.state = {
refreshRate: 3,
lineCount: 2000
lineCount: 2000,
displayTimestamps: false
};
$scope.changeLogCollection = function(logCollectionStatus) {
@ -29,7 +30,7 @@ function ($scope, $transition$, $interval, TaskService, ServiceService, Notifica
function setUpdateRepeater() {
var refreshRate = $scope.state.refreshRate;
$scope.repeater = $interval(function() {
TaskService.logs($transition$.params().id, 1, 1, 0, $scope.state.lineCount)
TaskService.logs($transition$.params().id, 1, 1, $scope.state.displayTimestamps ? 1 : 0, $scope.state.lineCount)
.then(function success(data) {
$scope.logs = data;
})
@ -41,7 +42,7 @@ function ($scope, $transition$, $interval, TaskService, ServiceService, Notifica
}
function startLogPolling() {
TaskService.logs($transition$.params().id, 1, 1, 0, $scope.state.lineCount)
TaskService.logs($transition$.params().id, 1, 1, $scope.state.displayTimestamps ? 1 : 0, $scope.state.lineCount)
.then(function success(data) {
$scope.logs = data;
setUpdateRepeater();

View File

@ -6,5 +6,5 @@
</rd-header>
<log-viewer
data="logs" ng-if="logs" log-collection-change="changeLogCollection"
data="logs" ng-if="logs" log-collection-change="changeLogCollection" display-timestamps="state.displayTimestamps"
></log-viewer>