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', controller: 'LogViewerController',
bindings: { bindings: {
data: '=', data: '=',
displayTimestamps: '=',
logCollectionChange: '<' logCollectionChange: '<'
} }
}); });

View File

@ -15,6 +15,16 @@
</label> </label>
</div> </div>
</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"> <div class="form-group">
<label for="logs_search" class="col-sm-1 control-label text-left"> <label for="logs_search" class="col-sm-1 control-label text-left">
Search Search

View File

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

View File

@ -6,5 +6,5 @@
</rd-header> </rd-header>
<log-viewer <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> ></log-viewer>

View File

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

View File

@ -6,5 +6,5 @@
</rd-header> </rd-header>
<log-viewer <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> ></log-viewer>

View File

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

View File

@ -6,5 +6,5 @@
</rd-header> </rd-header>
<log-viewer <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> ></log-viewer>