fix task logs

This commit is contained in:
Girish Ramakrishnan
2018-12-08 21:45:49 -08:00
parent a8d0e25866
commit 6fb7555f01
5 changed files with 73 additions and 42 deletions

View File

@@ -579,6 +579,18 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
}).error(defaultErrorHandler(callback));
};
Client.prototype.getTaskLogs = function (taskId, follow, lines, callback) {
if (follow) {
var eventSource = new EventSource(client.apiOrigin + '/api/v1/tasks/' + taskId + '/logstream?lines=' + lines + '&access_token=' + token);
callback(null, eventSource);
} else {
get('/api/v1/services/' + taskId + '/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.startBackup = function (callback) {
post('/api/v1/backups').success(function(data, status) {
if (status !== 202 || typeof data !== 'object') return callback(new ClientError(status, data));