diff --git a/webadmin/src/js/client.js b/webadmin/src/js/client.js index 4db7b50fb..344c12e8a 100644 --- a/webadmin/src/js/client.js +++ b/webadmin/src/js/client.js @@ -1,6 +1,7 @@ 'use strict'; /* global angular */ +/* global EventSource */ angular.module('Application').service('Client', ['$http', 'md5', 'Notification', function ($http, md5, Notification) { var client = null; @@ -571,9 +572,9 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification', }).error(defaultErrorHandler(callback)); }; - Client.prototype.getPlatformLogs = function (units, follow, callback) { + Client.prototype.getPlatformLogs = function (units, follow, lines, callback) { if (follow) { - var eventSource = new EventSource(client.apiOrigin + '/api/v1/cloudron/logstream?lines=10&access_token=' + token + '&units=' + units); + var eventSource = new EventSource(client.apiOrigin + '/api/v1/cloudron/logstream?lines=' + lines + '&access_token=' + token + '&units=' + units); callback(null, eventSource); } else { get('/api/v1/cloudron/logs?lines=100&units=' + units).success(function (data, status) { @@ -590,9 +591,9 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification', }).error(defaultErrorHandler(callback)); }; - Client.prototype.getAppLogs = function (appId, follow, callback) { + Client.prototype.getAppLogs = function (appId, follow, lines, callback) { if (follow) { - var eventSource = new EventSource(client.apiOrigin + '/api/v1/apps/' + appId + '/logstream?lines=10&access_token=' + token); + var eventSource = new EventSource(client.apiOrigin + '/api/v1/apps/' + appId + '/logstream?lines=' + lines + '&access_token=' + token); callback(null, eventSource); } else { get('/api/v1/apps/' + appId + '/logs').success(function (data, status) { diff --git a/webadmin/src/views/logs.js b/webadmin/src/views/logs.js index 7c17f58fc..206971e50 100644 --- a/webadmin/src/views/logs.js +++ b/webadmin/src/views/logs.js @@ -9,6 +9,7 @@ angular.module('Application').controller('LogsController', ['$scope', '$location $scope.logs = []; $scope.selected = ''; $scope.activeEventSource = null; + $scope.lines = 10; function ab2str(buf) { return String.fromCharCode.apply(null, new Uint16Array(buf)); @@ -36,7 +37,7 @@ angular.module('Application').controller('LogsController', ['$scope', '$location } var func = newVal.type === 'platform' ? Client.getPlatformLogs : Client.getAppLogs; - func(newVal.value, true, function handleLogs(error, result) { + func(newVal.value, true, $scope.lines, function handleLogs(error, result) { if (error) return console.error(error); var logViewer = $('.log-line-container');