diff --git a/src/js/client.js b/src/js/client.js index 52a831372..27a26a31b 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -1477,6 +1477,15 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout }); }; + Client.prototype.getAppLimits = function (appId, callback) { + get('/api/v1/apps/' + appId + '/limits', null, function (error, data, status) { + if (error) return callback(error); + if (status !== 200) return callback(new ClientError(status, data)); + + callback(null, data.limits); + }); + }; + Client.prototype.getAppWithTask = function (appId, callback) { var that = this; diff --git a/src/views/app.js b/src/views/app.js index 6a62e9714..7ca77377f 100644 --- a/src/views/app.js +++ b/src/views/app.js @@ -544,13 +544,13 @@ angular.module('Application').controller('AppController', ['$scope', '$location' $scope.resources.memoryLimit = $scope.resources.currentMemoryLimit; $scope.resources.currentCpuShares = $scope.resources.cpuShares = app.cpuShares; - Client.memory(function (error, memory) { + Client.getAppLimits(app.id, function (error, limits) { if (error) return console.error(error); // create ticks starting from manifest memory limit. the memory limit here is currently split into ram+swap (and thus *2 below) // TODO: the *2 will overallocate since 4GB is max swap that cloudron itself allocates $scope.resources.memoryTicks = []; - var npow2 = Math.pow(2, Math.ceil(Math.log(memory.memory)/Math.log(2))); + var npow2 = Math.pow(2, Math.ceil(Math.log(limits.memory.memory)/Math.log(2))); for (var i = 256; i <= (npow2*2/1024/1024); i *= 2) { if (i >= (app.manifest.memoryLimit/1024/1024 || 0)) $scope.resources.memoryTicks.push(i * 1024 * 1024); }