Handle split of addon and services

This commit is contained in:
Girish Ramakrishnan
2018-12-02 18:07:11 -08:00
parent 0430fb2772
commit 203b31d81f
3 changed files with 18 additions and 18 deletions

View File

@@ -627,12 +627,12 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
}
};
Client.prototype.getAddonLogs = function (addonName, follow, lines, callback) {
Client.prototype.getServiceLogs = function (serviceName, follow, lines, callback) {
if (follow) {
var eventSource = new EventSource(client.apiOrigin + '/api/v1/services/' + addonName + '/logstream?lines=' + lines + '&access_token=' + token);
var eventSource = new EventSource(client.apiOrigin + '/api/v1/services/' + serviceName + '/logstream?lines=' + lines + '&access_token=' + token);
callback(null, eventSource);
} else {
get('/api/v1/services/' + addonName + '/logs?lines=100').success(function (data, status) {
get('/api/v1/services/' + serviceName + '/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));
@@ -665,29 +665,29 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
}).error(defaultErrorHandler(callback));
};
Client.prototype.getAddons = function (callback) {
Client.prototype.getServices = function (callback) {
get('/api/v1/services').success(function (data, status) {
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
callback(null, data.addons);
callback(null, data.services);
}).error(defaultErrorHandler(callback));
};
Client.prototype.getAddon = function (addonName, callback) {
get('/api/v1/services/' + addonName).success(function (data, status) {
Client.prototype.getService = function (serviceName, callback) {
get('/api/v1/services/' + serviceName).success(function (data, status) {
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
callback(null, data.addon);
callback(null, data.service);
}).error(defaultErrorHandler(callback));
};
Client.prototype.configureAddon = function (addonName, memoryLimit, callback) {
post('/api/v1/services/' + addonName, { memory: memoryLimit }).success(function (data, status) {
Client.prototype.configureService = function (serviceName, memoryLimit, callback) {
post('/api/v1/services/' + serviceName, { memory: memoryLimit }).success(function (data, status) {
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
}).error(defaultErrorHandler(callback));
};
Client.prototype.restartAddon = function (addonName, callback) {
post('/api/v1/services/' + addonName + '/restart').success(function (data, status) {
Client.prototype.restartService = function (serviceName, callback) {
post('/api/v1/services/' + serviceName + '/restart').success(function (data, status) {
if (status !== 202) return callback(new ClientError(status, data));
callback(null);
}).error(defaultErrorHandler(callback));