Use addon log routes in logviewer
This commit is contained in:
@@ -653,6 +653,18 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Client.prototype.getAddonLogs = function (addonName, follow, lines, callback) {
|
||||||
|
if (follow) {
|
||||||
|
var eventSource = new EventSource(client.apiOrigin + '/api/v1/addons/' + addonName + '/logstream?lines=' + lines + '&access_token=' + token);
|
||||||
|
callback(null, eventSource);
|
||||||
|
} else {
|
||||||
|
get('/api/v1/addons/' + addonName + '/logs?lines=100').success(function (data, status) {
|
||||||
|
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
|
||||||
|
callback(null, data);
|
||||||
|
}).error(defaultErrorHandler(callback));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Client.prototype.getApps = function (callback) {
|
Client.prototype.getApps = function (callback) {
|
||||||
get('/api/v1/apps').success(function (data, status) {
|
get('/api/v1/apps').success(function (data, status) {
|
||||||
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
|
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ app.controller('LogsController', ['$scope', '$timeout', '$location', 'Client', f
|
|||||||
function showLogs() {
|
function showLogs() {
|
||||||
if (!$scope.selected) return;
|
if (!$scope.selected) return;
|
||||||
|
|
||||||
var func = $scope.selected.type === 'platform' ? Client.getPlatformLogs : Client.getAppLogs;
|
var func;
|
||||||
|
if ($scope.selected.type === 'platform') func = Client.getPlatformLogs;
|
||||||
|
else if ($scope.selected.type === 'addon') func = Client.getAddonLogs;
|
||||||
|
else func = Client.getAppLogs;
|
||||||
|
|
||||||
func($scope.selected.value, true, $scope.lines, function handleLogs(error, result) {
|
func($scope.selected.value, true, $scope.lines, function handleLogs(error, result) {
|
||||||
if (error) return console.error(error);
|
if (error) return console.error(error);
|
||||||
|
|
||||||
@@ -66,11 +70,11 @@ app.controller('LogsController', ['$scope', '$timeout', '$location', 'Client', f
|
|||||||
{ name: 'Box', type: 'platform', value: 'box', url: Client.makeURL('/api/v1/cloudron/logs/box') },
|
{ name: 'Box', type: 'platform', value: 'box', url: Client.makeURL('/api/v1/cloudron/logs/box') },
|
||||||
{ name: 'Mail', type: 'platform', value: 'mail', url: Client.makeURL('/api/v1/cloudron/logs/mail') },
|
{ name: 'Mail', type: 'platform', value: 'mail', url: Client.makeURL('/api/v1/cloudron/logs/mail') },
|
||||||
{ name: 'Backup', type: 'platform', value: 'backup', url: Client.makeURL('/api/v1/cloudron/logs/backup') },
|
{ name: 'Backup', type: 'platform', value: 'backup', url: Client.makeURL('/api/v1/cloudron/logs/backup') },
|
||||||
{ name: 'MongoDB', type: 'platform', value: 'mongodb', url: Client.makeURL('/api/v1/addons/mongodb/logs') },
|
{ name: 'MongoDB', type: 'addon', value: 'mongodb', url: Client.makeURL('/api/v1/addons/mongodb/logs') },
|
||||||
{ name: 'MySQL', type: 'platform', value: 'mysql', url: Client.makeURL('/api/v1/addons/mysql/logs') },
|
{ name: 'MySQL', type: 'addon', value: 'mysql', url: Client.makeURL('/api/v1/addons/mysql/logs') },
|
||||||
{ name: 'PostgreSQL', type: 'platform', value: 'postgresql', url: Client.makeURL('/api/v1/addons/postgresql/logs') },
|
{ name: 'PostgreSQL', type: 'addon', value: 'postgresql', url: Client.makeURL('/api/v1/addons/postgresql/logs') },
|
||||||
{ name: 'Email', type: 'platform', value: 'email', url: Client.makeURL('/api/v1/addons/email/logs') },
|
{ name: 'Email', type: 'addon', value: 'email', url: Client.makeURL('/api/v1/addons/email/logs') },
|
||||||
{ name: 'Docker', type: 'platform', value: 'docker', url: Client.makeURL('/api/v1/addons/docker/logs') }
|
{ name: 'Docker', type: 'addon', value: 'docker', url: Client.makeURL('/api/v1/addons/docker/logs') }
|
||||||
];
|
];
|
||||||
|
|
||||||
$scope.selected = BUILT_IN_LOGS.find(function (e) { return e.value === id; });
|
$scope.selected = BUILT_IN_LOGS.find(function (e) { return e.value === id; });
|
||||||
|
|||||||
Reference in New Issue
Block a user